SHARE
TWEET

Untitled

a guest Jan 22nd, 2013 29 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <unwind.h> // GCC's internal unwinder, part of libgcc
  2. _Unwind_Reason_Code trace_fcn(struct _Unwind_Context *ctx, void *d)
  3. {
  4.   int *depth = (int*)d;
  5.   printf("\t#%d: program counter at %08x\n", *depth, _Unwind_GetIP(ctx));
  6.   (*depth)++;
  7.   return _URC_NO_REASON;
  8. }
  9.  
  10. void print_backtrace_here()
  11. {
  12.   int depth = 0;
  13.   _Unwind_Backtrace(&trace_fcn, &depth);
  14. }
  15.  
  16. int func3() { print_backtrace_here(); return 0; }
  17. int func2() { return func3(); }
  18. int func1() { return func2(); }
  19. int main()  { return func1(); }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top