Skip to content

Instantly share code, notes, and snippets.

@CocoaBeans
Created April 30, 2013 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CocoaBeans/5491683 to your computer and use it in GitHub Desktop.
Save CocoaBeans/5491683 to your computer and use it in GitHub Desktop.
Print a symbolicated stack trace
#import <execinfo.h>
#import <stdio.h>
void PrintStackTrace(void)
{
void* callstack[128];
int i, frames = backtrace(callstack, 128);
char** strs = backtrace_symbols(callstack, frames);
for (i = 0; i < frames; ++i) {
printf("%s\n", strs[i]);
}
free(strs);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment