summaryrefslogtreecommitdiff
path: root/dbug
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2011-07-12 13:12:07 +0200
committerSergei Golubchik <sergii@pisem.net>2011-07-12 13:12:07 +0200
commit55d13e8dc72eb10d266762f413dabf4b5b887713 (patch)
tree2cb57f61860280c54e8dd924c5d4ef27e164e0dc /dbug
parent20056897002575c3e81b7ce08b171cadc906bebc (diff)
downloadmariadb-git-55d13e8dc72eb10d266762f413dabf4b5b887713.tar.gz
* build dbug manual and unit tests
* document safemalloc
Diffstat (limited to 'dbug')
-rw-r--r--dbug/CMakeLists.txt44
-rw-r--r--dbug/user.r22
2 files changed, 63 insertions, 3 deletions
diff --git a/dbug/CMakeLists.txt b/dbug/CMakeLists.txt
index b0a6eba5d08..09b3ed928ab 100644
--- a/dbug/CMakeLists.txt
+++ b/dbug/CMakeLists.txt
@@ -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)
+
diff --git a/dbug/user.r b/dbug/user.r
index 8d8a9ce6910..1ccd46bd21e 100644
--- a/dbug/user.r
+++ b/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