Commit 55d13e8d authored by Sergei Golubchik's avatar Sergei Golubchik

* build dbug manual and unit tests

* document safemalloc
parent 20056897
...@@ -20,3 +20,47 @@ INCLUDE_DIRECTORIES( ...@@ -20,3 +20,47 @@ INCLUDE_DIRECTORIES(
SET(DBUG_SOURCES dbug.c) SET(DBUG_SOURCES dbug.c)
ADD_CONVENIENCE_LIBRARY(dbug ${DBUG_SOURCES}) ADD_CONVENIENCE_LIBRARY(dbug ${DBUG_SOURCES})
TARGET_LINK_LIBRARIES(dbug mysys) TARGET_LINK_LIBRARIES(dbug mysys)
ADD_EXECUTABLE(tests tests.c)
TARGET_LINK_LIBRARIES(tests dbug)
ADD_EXECUTABLE(factorial my_main.c factorial.c)
TARGET_LINK_LIBRARIES(factorial dbug)
IF(NOT WIN32)
FIND_PROGRAM(GROFF groff)
FIND_PROGRAM(NROFF nroff)
SET(OUTPUT_INC output1.r output2.r output3.r output4.r output5.r)
SET(SOURCE_INC factorial.r main.r example1.r example2.r example3.r)
ADD_CUSTOM_COMMAND(OUTPUT ${OUTPUT_INC}
DEPENDS factorial
COMMAND ./factorial 1 2 3 4 5 > output1.r
COMMAND ./factorial -\#t:o 2 3 > output2.r
COMMAND ./factorial -\#d:t:o 3 > output3.r
COMMAND ./factorial -\#d,result:o 4 > output4.r
COMMAND ./factorial -\#d:f,factorial:F:L:o 3 > output5.r)
FOREACH(file ${SOURCE_INC})
STRING(REGEX REPLACE "\\.r" ".c" srcfile ${file})
ADD_CUSTOM_COMMAND(OUTPUT ${file} DEPENDS ${srcfile}
COMMAND sed -e 's!\\\\!\\\\\\\\!g'
<${CMAKE_CURRENT_SOURCE_DIR}/${srcfile} >${file})
ENDFOREACH(file)
ADD_CUSTOM_COMMAND(OUTPUT tests-t DEPENDS tests-t.pl
COMMAND cp -f ${CMAKE_CURRENT_SOURCE_DIR}/tests-t.pl tests-t)
ADD_CUSTOM_TARGET(unit ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/tests-t)
IF(GROFF)
ADD_CUSTOM_COMMAND(OUTPUT user.ps
DEPENDS user.r ${OUTPUT_INC} ${SOURCE_INC}
COMMAND ${GROFF} -mm ${CMAKE_CURRENT_SOURCE_DIR}/user.r > user.ps)
ADD_CUSTOM_TARGET(ps ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/user.ps)
ENDIF(GROFF)
IF(NROFF)
ADD_CUSTOM_COMMAND(OUTPUT user.t
DEPENDS user.r ${OUTPUT_INC} ${SOURCE_INC}
COMMAND ${NROFF} -mm ${CMAKE_CURRENT_SOURCE_DIR}/user.r > user.t)
ADD_CUSTOM_TARGET(t ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/user.t)
ENDIF(NROFF)
ENDIF(NOT WIN32)
...@@ -881,6 +881,20 @@ Modifying ...@@ -881,6 +881,20 @@ Modifying
.I initial .I initial
value does not affect threads that are already running. Obviously, value does not affect threads that are already running. Obviously,
these macros are only useful in the multi-threaded environment. these macros are only useful in the multi-threaded environment.
.SP 1
.LI DBUG_MALLOC\
.LI DBUG_REALLOC\
.LI DBUG_FREE\
When these macros are used instead of system malloc(), realloc(), and free(),
.I dbug
built-in memory debugger performs checks for memory overwrites, underwrites,
memory leaks, and accesses to uninitialized or freed memory. Memory leaks are
found as memory not deallocated at shutdown. Memory overwrites and underwrites
are detected when this memory is about to be freed (by
.B DBUG_FREE
macro), unless
.B S
flag is present in the debug control string (see below).
.LE .LE
.SK .SK
...@@ -989,9 +1003,11 @@ Most useful with ...@@ -989,9 +1003,11 @@ Most useful with
macros used to temporarily alter the macros used to temporarily alter the
debugger state. debugger state.
.LI S .LI S
When compiled with Check the memory allocated with
.I safemalloc .B DBUG_MALLOC
this flag invokes "sanity" memory checks (for overwrites/underwrites) and
.B DBUG_REALLOC
for overwrites/underwrites
on each on each
.B DBUG_ENTER .B DBUG_ENTER
and and
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment