Minor improvements.
GitOrigin-RevId: f66a5294ec1026c85dc71f62bb0026dce4a09fe0
This commit is contained in:
parent
3d972da1e6
commit
a91d296f87
@ -53,10 +53,12 @@ void print_backtrace_gdb(void) {
|
|||||||
name_buf[res] = 0;
|
name_buf[res] = 0;
|
||||||
|
|
||||||
#if TD_LINUX
|
#if TD_LINUX
|
||||||
|
#if defined(PR_SET_DUMPABLE)
|
||||||
if (prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) < 0) {
|
if (prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) < 0) {
|
||||||
signal_safe_write("Can't set dumpable\n");
|
signal_safe_write("Can't set dumpable\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#if defined(PR_SET_PTRACER)
|
#if defined(PR_SET_PTRACER)
|
||||||
// We can't use event fd because we are in a signal handler
|
// We can't use event fd because we are in a signal handler
|
||||||
int fds[2];
|
int fds[2];
|
||||||
@ -108,14 +110,15 @@ void print_backtrace_gdb(void) {
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void Stacktrace::print_to_stderr(const PrintOptions &options) {
|
void Stacktrace::print_to_stderr(const PrintOptions &options) {
|
||||||
|
print_backtrace();
|
||||||
if (options.use_gdb) {
|
if (options.use_gdb) {
|
||||||
print_backtrace_gdb();
|
print_backtrace_gdb();
|
||||||
}
|
}
|
||||||
print_backtrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stacktrace::init() {
|
void Stacktrace::init() {
|
||||||
#if __GLIBC__
|
#if __GLIBC__
|
||||||
|
// backtrace needs to be called once to ensure that next calls are async-signal-safe
|
||||||
void *buffer[1];
|
void *buffer[1];
|
||||||
backtrace(buffer, 1);
|
backtrace(buffer, 1);
|
||||||
#endif
|
#endif
|
||||||
|
@ -16,7 +16,7 @@ class Stacktrace {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
static void print_to_stderr(const PrintOptions &options = PrintOptions());
|
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();
|
static void init();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user