MCPcopy Create free account
hub / github.com/FastLED/FastLED / print_stacktrace_libunwind

Function print_stacktrace_libunwind

tests/crash_handler_libunwind.h:15–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13namespace crash_handler_libunwind {
14
15inline void print_stacktrace_libunwind() {
16 // Use libunwind for better stack traces
17 unw_cursor_t cursor;
18 unw_context_t context;
19
20 unw_getcontext(&context);
21 unw_init_local(&cursor, &context);
22
23 int depth = 0;
24 printf("Stack trace (libunwind):\n");
25 while (unw_step(&cursor) > 0) {
26 unw_word_t offset, pc;
27 char sym[256];
28
29 unw_get_reg(&cursor, UNW_REG_IP, &pc);
30 if (pc == 0) {
31 break;
32 }
33
34 printf("#%-2d 0x%lx:", depth++, pc);
35
36 if (unw_get_proc_name(&cursor, sym, sizeof(sym), &offset) == 0) {
37 printf(" (%s+0x%lx)\n", sym, offset);
38 } else {
39 printf(" -- symbol not found\n");
40 }
41 }
42}
43
44inline void crash_handler(int sig) {
45 // Prevent recursion if handler crashes

Callers 2

crash_handlerFunction · 0.85
print_stacktraceFunction · 0.85

Calls 1

printfFunction · 0.85

Tested by

no test coverage detected