Skip to content
Snippets Groups Projects
unc.c 446 B
Newer Older
Jason Hiser's avatar
Jason Hiser committed
#include <stdio.h>

Jason Hiser's avatar
Jason Hiser committed
#define UNW_LOCAL_ONLY
#include <libunwind.h>

void show_backtrace (void) {
  unw_cursor_t cursor; unw_context_t uc;
  unw_word_t ip, sp;

  unw_getcontext(&uc);
  unw_init_local(&cursor, &uc);
  while (unw_step(&cursor) > 0) {
    unw_get_reg(&cursor, UNW_REG_IP, &ip);
    unw_get_reg(&cursor, UNW_REG_SP, &sp);
    printf ("ip = %lx, sp = %lx\n", (long) ip, (long) sp);
  }
}


int main()
{
	show_backtrace();
	return 0;
}