summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt10
-rw-r--r--include/my_valgrind.h2
2 files changed, 11 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0ea8269c14c..ed76fba7d10 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -289,6 +289,16 @@ ELSEIF(WITH_SAFEMALLOC MATCHES "AUTO" AND NOT WIN32 AND NOT WITH_VALGRIND)
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC")
ENDIF()
+# Another memory debugging feature
+SET(THRASH_FREED_MEMORY "AUTO" CACHE STRING "Fill freed memory with specific byte pattern. Will result in slower execution. Options are: ON OFF AUTO.")
+MARK_AS_ADVANCED(THRASH_FREED_MEMORY)
+IF(THRASH_FREED_MEMORY MATCHES "ON")
+ ADD_DEFINITIONS( -DTHRASH_FREED_MEMORY)
+ELSEIF(THRASH_FREED_MEMORY MATCHES "AUTO" AND NOT WIN32 AND NOT WITH_VALGRIND AND NOT WITH_ASAN)
+ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DTHRASH_FREED_MEMORY")
+ SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DTHRASH_FREED_MEMORY")
+ENDIF()
+
# Set commonly used variables
IF(WIN32)
SET(DEFAULT_MYSQL_HOME "C:/Program Files/MariaDB ${MYSQL_BASE_VERSION}")
diff --git a/include/my_valgrind.h b/include/my_valgrind.h
index 575ed46a0ee..e04f1f64ef0 100644
--- a/include/my_valgrind.h
+++ b/include/my_valgrind.h
@@ -48,7 +48,7 @@ https://github.com/google/sanitizers/wiki/AddressSanitizerManualPoisoning */
# define MEM_CHECK_DEFINED(a,len) ((void) 0)
#endif /* HAVE_VALGRIND_MEMCHECK_H */
-#if !defined(DBUG_OFF) || defined(TRASH_FREED_MEMORY)
+#if defined(TRASH_FREED_MEMORY)
#define TRASH_FILL(A,B,C) do { const size_t trash_tmp= (B); MEM_UNDEFINED(A, trash_tmp); memset(A, C, trash_tmp); } while (0)
#else
#define TRASH_FILL(A,B,C) do { MEM_UNDEFINED((A), (B)); } while (0)