* build dbug manual and unit tests
* document safemalloc
This commit is contained in:
parent
2005689700
commit
55d13e8dc7
@ -20,3 +20,47 @@ INCLUDE_DIRECTORIES(
|
||||
SET(DBUG_SOURCES dbug.c)
|
||||
ADD_CONVENIENCE_LIBRARY(dbug ${DBUG_SOURCES})
|
||||
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)
|
||||
|
||||
|
22
dbug/user.r
22
dbug/user.r
@ -881,6 +881,20 @@ Modifying
|
||||
.I initial
|
||||
value does not affect threads that are already running. Obviously,
|
||||
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
|
||||
|
||||
.SK
|
||||
@ -989,9 +1003,11 @@ Most useful with
|
||||
macros used to temporarily alter the
|
||||
debugger state.
|
||||
.LI S
|
||||
When compiled with
|
||||
.I safemalloc
|
||||
this flag invokes "sanity" memory checks (for overwrites/underwrites)
|
||||
Check the memory allocated with
|
||||
.B DBUG_MALLOC
|
||||
and
|
||||
.B DBUG_REALLOC
|
||||
for overwrites/underwrites
|
||||
on each
|
||||
.B DBUG_ENTER
|
||||
and
|
||||
|
Loading…
x
Reference in New Issue
Block a user