From 137097f10ddaf8220c0d48221f194e333844f9e0 Mon Sep 17 00:00:00 2001 From: Milian Wolff Date: Mon, 15 Jun 2015 21:11:06 +0200 Subject: [PATCH] Skip one more level in backtraces in debug builds. Otherwise, the malloc function would still be shown in the backtrace and thereby breaking the aggregation we use elsewhere. --- CMakeLists.txt | 6 ++++++ config.h.cmake | 2 ++ libheaptrack.cpp | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 05270b7..3731e3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,6 +56,12 @@ include_directories( ${LIBUNWIND_INCLUDE_DIR} ) +if (CMAKE_BUILD_TYPE STREQUAL "Debug") + set(HEAPTRACK_DEBUG_BUILD 1) +else() + set(HEAPTRACK_DEBUG_BUILD 0) +endif() + configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) add_library(heaptrack_preload MODULE heaptrack_preload.cpp libheaptrack.cpp) diff --git a/config.h.cmake b/config.h.cmake index 951dab6..aacfc22 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -32,4 +32,6 @@ #define HEAPTRACK_VERSION_PATCH @HEAPTRACK_VERSION_PATCH@ #define HEAPTRACK_VERSION ((HEAPTRACK_VERSION_MAJOR<<16)|(HEAPTRACK_VERSION_MINOR<<8)|(HEAPTRACK_VERSION_PATCH)) +#define HEAPTRACK_DEBUG_BUILD @HEAPTRACK_DEBUG_BUILD@ + #endif // HEAPTRACK_CONFIG_H diff --git a/libheaptrack.cpp b/libheaptrack.cpp index 0a043e3..1e0f65b 100644 --- a/libheaptrack.cpp +++ b/libheaptrack.cpp @@ -538,7 +538,7 @@ void heaptrack_malloc(void* ptr, size_t size) debugLog("heaptrack_malloc(%p, %lu)", ptr, size); Trace trace; - trace.fill(2); + trace.fill(2 + HEAPTRACK_DEBUG_BUILD); HeapTrack heaptrack(guard); heaptrack.handleMalloc(ptr, size, trace); @@ -565,7 +565,7 @@ void heaptrack_realloc(void* ptr_in, size_t size, void* ptr_out) debugLog("heaptrack_realloc(%p, %lu, %p)", ptr_in, size, ptr_out); Trace trace; - trace.fill(2); + trace.fill(2 + HEAPTRACK_DEBUG_BUILD); HeapTrack heaptrack(guard); if (ptr_in) { -- 2.7.4