From a91d296f87e8cd10db4d3483894d9580493a10ee Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 20 Dec 2019 20:12:52 +0300 Subject: [PATCH] Minor improvements. GitOrigin-RevId: f66a5294ec1026c85dc71f62bb0026dce4a09fe0 --- tdutils/td/utils/port/stacktrace.cpp | 5 ++++- tdutils/td/utils/port/stacktrace.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tdutils/td/utils/port/stacktrace.cpp b/tdutils/td/utils/port/stacktrace.cpp index 384b2d0f..05828dc4 100644 --- a/tdutils/td/utils/port/stacktrace.cpp +++ b/tdutils/td/utils/port/stacktrace.cpp @@ -53,10 +53,12 @@ void print_backtrace_gdb(void) { name_buf[res] = 0; #if TD_LINUX +#if defined(PR_SET_DUMPABLE) if (prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) < 0) { signal_safe_write("Can't set dumpable\n"); return; } +#endif #if defined(PR_SET_PTRACER) // We can't use event fd because we are in a signal handler int fds[2]; @@ -108,14 +110,15 @@ void print_backtrace_gdb(void) { } // namespace void Stacktrace::print_to_stderr(const PrintOptions &options) { + print_backtrace(); if (options.use_gdb) { print_backtrace_gdb(); } - print_backtrace(); } void Stacktrace::init() { #if __GLIBC__ + // backtrace needs to be called once to ensure that next calls are async-signal-safe void *buffer[1]; backtrace(buffer, 1); #endif diff --git a/tdutils/td/utils/port/stacktrace.h b/tdutils/td/utils/port/stacktrace.h index 5a16ec01..8a2cf8bc 100644 --- a/tdutils/td/utils/port/stacktrace.h +++ b/tdutils/td/utils/port/stacktrace.h @@ -16,7 +16,7 @@ class Stacktrace { } }; static void print_to_stderr(const PrintOptions &options = PrintOptions()); - // backtrace needs to be called once to ensure that next calls are async-signal-safe + static void init(); };