Skip to content

Instantly share code, notes, and snippets.

@kbinani
Created June 23, 2014 07:22
Show Gist options
  • Save kbinani/c2a3396a61b5fe4d1798 to your computer and use it in GitHub Desktop.
Save kbinani/c2a3396a61b5fe4d1798 to your computer and use it in GitHub Desktop.
print backtrace at runtime
// #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