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