Minor improvements.

GitOrigin-RevId: f66a5294ec1026c85dc71f62bb0026dce4a09fe0
This commit is contained in:
levlam 2019-12-20 20:12:52 +03:00
parent 3d972da1e6
commit a91d296f87
2 changed files with 5 additions and 2 deletions

View File

@ -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

View File

@ -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();
};