Skip to content

Commit

Permalink
Debug|Unix|libdeng2: Added a backtrace print macro
Browse files Browse the repository at this point in the history
Perhaps the Best Thing Ever for non-invasive debugging.
  • Loading branch information
skyjake committed Mar 16, 2014
1 parent 9189210 commit 564a567
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions doomsday/libdeng2/include/de/libdeng2.h
Expand Up @@ -137,6 +137,19 @@
# define DENG2_DEBUG
# ifdef DENG2_USE_QT
# define DENG2_ASSERT(x) Q_ASSERT(x)
# ifdef UNIX
# include <execinfo.h>
/**
* @macro DENG2_PRINT_BACKTRACE
* Debug utility for dumping the current backtrace using qDebug.
*/
# define DENG2_PRINT_BACKTRACE() { \
void *callstack[128]; \
int i, frames = backtrace(callstack, 128); \
char** strs = backtrace_symbols(callstack, frames); \
for(i = 0; i < frames; ++i) qDebug("%s", strs[i]); \
free(strs); }
# endif
# else
# define DENG2_ASSERT(x) assert(x)
# endif
Expand Down

0 comments on commit 564a567

Please sign in to comment.