NeoMutt  2024-04-25-89-g194907
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
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
40{
41 unw_cursor_t cursor = { 0 };
42 unw_context_t uc = { 0 };
43 unw_word_t ip = 0;
44 unw_word_t sp = 0;
45 char buf[256] = { 0 };
46
47 printf("\n%s\n", mutt_make_version());
48 printf("Backtrace\n");
49 mutt_debug(LL_DEBUG1, "\nBacktrace\n");
50 unw_getcontext(&uc);
51 unw_init_local(&cursor, &uc);
52 while (unw_step(&cursor) > 0)
53 {
54 unw_get_reg(&cursor, UNW_REG_IP, &ip);
55 unw_get_reg(&cursor, UNW_REG_SP, &sp);
56 unw_get_proc_name(&cursor, buf, sizeof(buf), &ip);
57 if (buf[0] == '_')
58 continue;
59 printf(" %s() ip = %lx, sp = %lx\n", buf, (long) ip, (long) sp);
60 mutt_debug(LL_DEBUG1, " %s() ip = %lx, sp = %lx\n", buf, (long) ip, (long) sp);
61 }
62 printf("\n");
63}
void show_backtrace(void)
Log the program's call stack.
Definition: backtrace.c:39
#define mutt_debug(LEVEL,...)
Definition: logging2.h:89
@ LL_DEBUG1
Log at debug level 1.
Definition: logging2.h:43
Convenience wrapper for the library headers.
const char * mutt_make_version(void)
Generate the NeoMutt version string.
Definition: muttlib.c:858
Some miscellaneous functions.
Key value store.