Add overloads to dump_stacktrace
Using a function while debugging helps to see where various functions are called from.
This commit is contained in:
@ -15,6 +15,7 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
#ifdef HAVE_GLIBC
|
#ifdef HAVE_GLIBC
|
||||||
#include <execinfo.h>
|
#include <execinfo.h>
|
||||||
@ -119,7 +120,7 @@ static void extract_file_and_line(const char* symbols, char* cmd, size_t size)
|
|||||||
namespace maxbase
|
namespace maxbase
|
||||||
{
|
{
|
||||||
|
|
||||||
void dump_stacktrace(void (*handler)(const char* symbol, const char* command))
|
void dump_stacktrace(std::function<void(const char*, const char*)> handler)
|
||||||
{
|
{
|
||||||
void *addrs[128];
|
void *addrs[128];
|
||||||
int count = backtrace(addrs, 128);
|
int count = backtrace(addrs, 128);
|
||||||
@ -137,6 +138,11 @@ void dump_stacktrace(void (*handler)(const char* symbol, const char* command))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dump_stacktrace(void (*handler)(const char* symbol, const char* command))
|
||||||
|
{
|
||||||
|
dump_stacktrace([&](const char* symbol, const char* command){handler(symbol, command);});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|||||||
Reference in New Issue
Block a user