From 497c1196373ed40d9ed9cf045405be7df6ac55c4 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Sat, 5 Mar 2016 14:32:40 -0800 Subject: Memento: Store/display backtraces with blocks. If built with MEMENTO_DETAILS (on by default), we store the backtrace on every event that affects a block. Memento_details(address) will display the events that affected a block (typically malloc, {realloc}*, free), including the backtrace at each point. Windows and linux use different mechanisms for this. Windows loads a DLL and calls windows specific functions - no extra libraries are required. Linux also loads a shared object (libbacktrace.so). This is not present on all platforms, so on platforms where it is not available we just get addresses. These can be converted using addr2line (unless ASLR is enabled). In order for linux to be able to load libbacktrace.so we link in libdl. If this is not available, define HAVE_LIBDL=no when building the memento target. --- Makerules | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Makerules') diff --git a/Makerules b/Makerules index 013b2e20..d6041d28 100644 --- a/Makerules +++ b/Makerules @@ -5,10 +5,13 @@ OS := $(OS:MINGW%=MINGW) OS := $(OS:Windows_NT=MINGW) OS := $(OS:Darwin=MACOS) +HAVE_LIBDL ?= yes + CFLAGS += -Wall ifeq "$(build)" "debug" CFLAGS += -pipe -g -DDEBUG +LDFLAGS += -g else ifeq "$(build)" "release" CFLAGS += -pipe -O2 -DNDEBUG -fomit-frame-pointer else ifeq "$(build)" "sanitize" @@ -24,6 +27,11 @@ else ifeq "$(build)" "native" CFLAGS += -pipe -O2 -DNDEBUG -fomit-frame-pointer -march=native -mfpmath=sse else ifeq "$(build)" "memento" CFLAGS += -pipe -g -DMEMENTO -DDEBUG +LDFLAGS += -g -d -rdynamic +ifeq "$(HAVE_LIBDL)" "yes" +CFLAGS += -DHAVE_LIBDL +LDFLAGS += -ldl +endif else $(error unknown build setting: '$(build)') endif -- cgit v1.2.3