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

Function print_stacktrace_execinfo

tests/crash_handler_execinfo.h:14–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12namespace crash_handler_execinfo {
13
14inline void print_stacktrace_execinfo() {
15 // Fallback to execinfo.h backtrace
16 void *buffer[100];
17 int nptrs;
18 char **strings;
19
20 printf("Stack trace (backtrace):\n");
21 nptrs = backtrace(buffer, 100);
22 strings = backtrace_symbols(buffer, nptrs);
23
24 if (strings == nullptr) {
25 printf("backtrace_symbols failed\n");
26 return;
27 }
28
29 for (int j = 0; j < nptrs; j++) {
30 printf("#%-2d %s\n", j, strings[j]);
31 }
32
33 free(strings);
34}
35
36inline void crash_handler(int sig) {
37 // Prevent recursion if handler crashes

Callers 2

crash_handlerFunction · 0.85
print_stacktraceFunction · 0.85

Calls 2

printfFunction · 0.85
freeFunction · 0.50

Tested by

no test coverage detected