Created
June 23, 2014 07:22
-
-
Save kbinani/c2a3396a61b5fe4d1798 to your computer and use it in GitHub Desktop.
print backtrace at runtime
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// #include <execinfo.h> | |
void * trace[128]; | |
int const num_trace = backtrace(trace, 128); | |
char ** trace_symbols = backtrace_symbols(trace, num_trace); | |
for (int i = 0; i < num_trace; ++i) { | |
std::cout << trace_symbols[i] << std::endl; | |
} | |
free(trace_symbols); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment