From 36194fe43517dd31f509ad9dbab93f66208c9f1b Mon Sep 17 00:00:00 2001 From: Kai Wang Date: Fri, 19 Dec 2014 22:24:54 -0800 Subject: [PATCH] Print linux TID while crashing Summary: For servers using GLOG, all thread ID are get from gettid system call. So it is very useful if we print this ID so during debugging I can find the log of crashing thread. I'm not sure who should review this diff. Just found you guys from previous diffs touched this file :) Test Plan: See the crash log. *** Aborted at 1419029404 (Unix time, try 'date -d @1419029404') *** *** Signal 11 (SIGSEGV) (0x18) received by PID 18852 (pthread TID 0x7f52a1fff700) (linux TID 27908), stack trace: *** Reviewed By: tudorb@fb.com Subscribers: seanc, folly-diffs@ FB internal diff: D1752301 Signature: t1:1752301:1419032887:e43c2ace6914e54812149a8b8e84eaffaf42a09c --- folly/experimental/symbolizer/SignalHandler.cpp | 5 ++++- folly/experimental/symbolizer/test/SignalHandlerTest.cpp | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/folly/experimental/symbolizer/SignalHandler.cpp b/folly/experimental/symbolizer/SignalHandler.cpp index 2a98872e..62b4952b 100644 --- a/folly/experimental/symbolizer/SignalHandler.cpp +++ b/folly/experimental/symbolizer/SignalHandler.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -205,8 +206,10 @@ void dumpSignalInfo(int signum, siginfo_t* siginfo) { printHex(reinterpret_cast(siginfo->si_addr)); print(") received by PID "); printDec(getpid()); - print(" (TID "); + print(" (pthread TID "); printHex((uint64_t)pthread_self()); + print(") (linux TID "); + printDec(syscall(__NR_gettid)); print("), stack trace: ***\n"); } diff --git a/folly/experimental/symbolizer/test/SignalHandlerTest.cpp b/folly/experimental/symbolizer/test/SignalHandlerTest.cpp index 62ebf1e7..d73628c7 100644 --- a/folly/experimental/symbolizer/test/SignalHandlerTest.cpp +++ b/folly/experimental/symbolizer/test/SignalHandlerTest.cpp @@ -60,7 +60,8 @@ TEST(SignalHandler, Simple) { "^\\*\\*\\* Aborted at [0-9]+ \\(Unix time, try 'date -d @[0-9]+'\\) " "\\*\\*\\*\n" "\\*\\*\\* Signal 11 \\(SIGSEGV\\) \\(0x2a\\) received by PID [0-9]+ " - "\\(TID 0x[0-9a-f]+\\), stack trace: \\*\\*\\*\n" + "\\(pthread TID 0x[0-9a-f]+\\) \\(linux TID [0-9]+\\), " + "stack trace: \\*\\*\\*\n" ".*\n" " @ [0-9a-f]+ folly::symbolizer::test::SignalHandler_Simple_Test" "::TestBody\\(\\)\n" -- 2.34.1