debug.c 455 B

12345678910111213141516171819202122232425
  1. #include <zebra.h>
  2. #include "log.h"
  3. void
  4. debug_print_trace (int signal)
  5. {
  6. #ifdef HAVE_GLIBC_BACKTRACE
  7. void *array[10];
  8. size_t size;
  9. char **strings;
  10. size_t i;
  11. size = backtrace (array, 10);
  12. strings = backtrace_symbols (array, size);
  13. printf ("Obtained %zd stack frames.\n", size);
  14. for (i = 0; i < size; i++)
  15. printf ("%s\n", strings[i]);
  16. free (strings);
  17. #endif /* HAVE_GLIBC_BACKTRACE */
  18. exit(1);
  19. }