summaryrefslogtreecommitdiff
path: root/port
diff options
context:
space:
mode:
authorHaobo Xu <haobo@fb.com>2013-04-22 10:14:54 -0700
committerHaobo Xu <haobo@fb.com>2013-04-22 20:38:02 -0700
commit06d3487b3fba1a3ed4f5041c7e6be38cc6dff4a3 (patch)
treed644f1847b16387666d79d228519c4b7f970722f /port
parent958b9c80e1d54624228bad5fd3382a84bbce6553 (diff)
[RocksDB] Print stack trace to stderr instead of stdio.
Summary: Some scripts (like regression_build_test.sh) redirect stdio to a tmp file and delete it on exit. This would miss the stack trace output on segfault. Output to stderr would hopefully show us the stack trace in the continuous build output. Test Plan: ./signal_test, make check Reviewers: dhruba Reviewed By: dhruba CC: leveldb Differential Revision: https://reviews.facebook.net/D10485
Diffstat (limited to 'port')
-rw-r--r--port/stack_trace.cc15
1 files changed, 9 insertions, 6 deletions
diff --git a/port/stack_trace.cc b/port/stack_trace.cc
index d9f41881f..039500999 100644
--- a/port/stack_trace.cc
+++ b/port/stack_trace.cc
@@ -30,7 +30,7 @@ static void StackTraceHandler(int sig) {
// reset to default handler
signal(sig, SIG_DFL);
- printf("Received signal %d (%s)\n", sig, strsignal(sig));
+ fprintf(stderr, "Received signal %d (%s)\n", sig, strsignal(sig));
const int kMaxFrames = 100;
void *frames[kMaxFrames];
@@ -44,9 +44,9 @@ static void StackTraceHandler(int sig) {
for (int i = kSkip; i < num_frames; ++i)
{
- printf("#%-2d %p ", i - kSkip, frames[i]);
+ fprintf(stderr, "#%-2d %p ", i - kSkip, frames[i]);
if (symbols) {
- printf("%s ", symbols[i]);
+ fprintf(stderr, "%s ", symbols[i]);
}
if (executable) {
// out source to addr2line, for the address translation
@@ -57,14 +57,14 @@ static void StackTraceHandler(int sig) {
if (f) {
char line[kLineMax];
while (fgets(line, sizeof(line), f)) {
- printf("%s", line);
+ fprintf(stderr, "%s", line);
}
pclose(f);
} else {
- printf("\n");
+ fprintf(stderr, "\n");
}
} else {
- printf("\n");
+ fprintf(stderr, "\n");
}
}
@@ -79,6 +79,9 @@ void InstallStackTraceHandler() {
signal(SIGSEGV, StackTraceHandler);
signal(SIGBUS, StackTraceHandler);
signal(SIGABRT, StackTraceHandler);
+
+ printf("Installed stack trace handler for SIGILL SIGSEGV SIGBUS SIGABRT\n");
+
}
} // namespace leveldb