Skip to content

Instantly share code, notes, and snippets.

@ayourtch
Created January 1, 2011 19:07
Show Gist options
  • Save ayourtch/761926 to your computer and use it in GitHub Desktop.
Save ayourtch/761926 to your computer and use it in GitHub Desktop.
Print stack trace with hex addresses
void bt() {
enum { BT_SIZE = 10 }; // Whatever big enough.
int i;
void *btbuf[BT_SIZE];
int btsize = backtrace(btbuf, BT_SIZE);
printf("Backtrace entries: %d\n", btsize);
for(i=0; i<btsize; i++) {
printf("%d: %p\n", i, btbuf[i]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment