NeoMutt  2021-02-05-666-ge300cd
Teaching an old dog new tricks
DOXYGEN
backtrace.c
Go to the documentation of this file.
1 
29 #include "config.h"
30 #include <libunwind.h>
31 #include <stdio.h>
32 #include "mutt/lib.h"
33 #include "lib.h"
34 #include "muttlib.h"
35 
39 void show_backtrace(void)
40 {
41  unw_cursor_t cursor;
42  unw_context_t uc;
43  unw_word_t ip, sp;
44  char buf[256];
45 
46  printf("\n%s\n", mutt_make_version());
47  printf("Backtrace\n");
48  mutt_debug(LL_DEBUG1, "\nBacktrace\n");
49  unw_getcontext(&uc);
50  unw_init_local(&cursor, &uc);
51  while (unw_step(&cursor) > 0)
52  {
53  unw_get_reg(&cursor, UNW_REG_IP, &ip);
54  unw_get_reg(&cursor, UNW_REG_SP, &sp);
55  unw_get_proc_name(&cursor, buf, sizeof(buf), &ip);
56  if (buf[0] == '_')
57  break;
58  printf(" %s() ip = %lx, sp = %lx\n", buf, (long) ip, (long) sp);
59  mutt_debug(LL_DEBUG1, " %s() ip = %lx, sp = %lx\n", buf, (long) ip, (long) sp);
60  }
61  printf("\n");
62 }
Some miscellaneous functions.
#define mutt_debug(LEVEL,...)
Definition: logging.h:85
Convenience wrapper for the debug headers.
Log at debug level 1.
Definition: logging.h:40
void show_backtrace(void)
Log the program&#39;s call stack.
Definition: backtrace.c:39
Convenience wrapper for the library headers.
const char * mutt_make_version(void)
Generate the NeoMutt version string.
Definition: muttlib.c:1476