Stacktrace improvements.

GitOrigin-RevId: 99dd952cff5c9e5edce575b84e365def24a59441
This commit is contained in:
Arseny Smirnov 2019-08-14 11:31:25 +03:00
parent c093afbf68
commit 3d972da1e6
3 changed files with 10 additions and 0 deletions

View File

@ -306,6 +306,7 @@ static void block_stdin() {
}
static void default_failure_signal_handler(int sig) {
Stacktrace::init();
signal_safe_write_signal_number(sig);
Stacktrace::PrintOptions options;

View File

@ -114,4 +114,11 @@ void Stacktrace::print_to_stderr(const PrintOptions &options) {
print_backtrace();
}
void Stacktrace::init() {
#if __GLIBC__
void *buffer[1];
backtrace(buffer, 1);
#endif
}
} // namespace td

View File

@ -16,6 +16,8 @@ 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();
};
} // namespace td