parameterize printing of backtrace

This commit is contained in:
Tim Felgentreff 2020-11-22 09:28:37 +01:00
parent ad27752541
commit 694a8fc722

View file

@ -6,12 +6,12 @@
#ifdef __GLIBC__ #ifdef __GLIBC__
#include "execinfo.h" #include "execinfo.h"
inline void print_backtrace(void) { inline void print_backtrace(int sz = 100) {
int j, nptrs; int j, nptrs;
void *buffer[100]; void *buffer[sz];
nptrs = backtrace(buffer, 100); nptrs = backtrace(buffer, sz);
fprintf(stderr, "backtrace() returned %d addresses\n", nptrs); fprintf(stderr, "backtrace() returned %d addresses\n", nptrs);
backtrace_symbols_fd(buffer, 100, 2); backtrace_symbols_fd(buffer, sz, 2);
} }
#elif defined(USE_WIN32) #elif defined(USE_WIN32)