summaryrefslogtreecommitdiff
path: root/lib/common/Box.h
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2013-02-13 00:27:54 +0000
committerChris Wilson <chris+github@qwirx.com>2013-02-13 00:27:54 +0000
commit51d63d54c9ab3a0d53760e0e8a6a5ac57963dd36 (patch)
tree1f4eb179bb8c3c1f63d178e81b301399c7a29729 /lib/common/Box.h
parent24edb39601fa14de8d8ba3308fd9ec5377c815b8 (diff)
Add ability to generate memory usage reports while running.
* ./configure CXXFLAGS=-DDEBUG_LEAKS * Build and run the binary as normal (release or debug) * Send SIGUSR1 to the process (e.g. killall -USR1 bbstored) * Check the system logs, or the console. Not safe for use on a production process, as it does illegal things in a signal handler that may result in the process hanging. Use only for debugging, and be prepared to kill any stuck processes.
Diffstat (limited to 'lib/common/Box.h')
-rw-r--r--lib/common/Box.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/common/Box.h b/lib/common/Box.h
index bbff2ccb..316f4364 100644
--- a/lib/common/Box.h
+++ b/lib/common/Box.h
@@ -40,7 +40,6 @@
#include "Logging.h"
#ifndef BOX_RELEASE_BUILD
-
extern bool AssertFailuresToSyslog;
#define ASSERT_FAILS_TO_SYSLOG_ON {AssertFailuresToSyslog = true;}
void BoxDebugAssertFailed(const char *cond, const char *file, int line);
@@ -71,7 +70,6 @@
// Exception names
#define EXCEPTION_CODENAMES_EXTENDED
-
#else
#define ASSERT_FAILS_TO_SYSLOG_ON
#define ASSERT(cond)
@@ -82,9 +80,20 @@
// Box Backup builds release get extra information for exception logging
#define EXCEPTION_CODENAMES_EXTENDED
#define EXCEPTION_CODENAMES_EXTENDED_WITH_DESCRIPTION
-
#endif
+#if defined DEBUG_LEAKS
+ #ifdef PLATFORM_DISABLE_MEM_LEAK_TESTING
+ #error Compiling with DEBUG_LEAKS enabled, but not supported on this platform
+ #else
+ #define BOX_MEMORY_LEAK_TESTING
+ #endif
+#elif defined BOX_RELEASE_BUILD
+ #ifndef PLATFORM_DISABLE_MEM_LEAK_TESTING
+ #define BOX_MEMORY_LEAK_TESTING
+ #endif
+#endif // DEBUG_LEAKS || BOX_RELEASE_BUILD
+
#ifdef BOX_MEMORY_LEAK_TESTING
// Memory leak testing
#include "MemLeakFinder.h"