Support stacktrace printing on Windows.
This commit is contained in:
parent
445183e52c
commit
083d599c41
@ -27,13 +27,24 @@ namespace td {
|
||||
namespace {
|
||||
|
||||
void print_backtrace(void) {
|
||||
#if __GLIBC__
|
||||
void *buffer[128];
|
||||
#if TD_PORT_WINDOWS
|
||||
USHORT nptrs = CaptureStackBackTrace(0, 128, buffer, nullptr);
|
||||
#elif __GLIBC__
|
||||
int nptrs = backtrace(buffer, 128);
|
||||
signal_safe_write("------- Stack Backtrace -------\n", false);
|
||||
backtrace_symbols_fd(buffer, nptrs, 2);
|
||||
signal_safe_write("-------------------------------\n", false);
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
|
||||
signal_safe_write("------- Stack Backtrace -------\n", false);
|
||||
#if TD_PORT_WINDOWS
|
||||
for (USHORT i = 0; i < nptrs; i++) {
|
||||
signal_safe_write_pointer(buffer[i], false);
|
||||
}
|
||||
#elif __GLIBC__
|
||||
backtrace_symbols_fd(buffer, nptrs, 2);
|
||||
#endif
|
||||
signal_safe_write("-------------------------------\n", false);
|
||||
}
|
||||
|
||||
void print_backtrace_gdb(void) {
|
||||
|
Loading…
Reference in New Issue
Block a user