[Enhancement] dump LWP when BE crash (#54089)

Signed-off-by: stdpain <drfeng08@gmail.com>
This commit is contained in:
stdpain 2024-12-20 10:08:15 +08:00 committed by GitHub
parent 67dbf3924b
commit 681be8b83f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 0 deletions

View File

@ -254,6 +254,7 @@ fi
if [ ! -f $PATCHED_MARK ] && [ $GLOG_SOURCE == "glog-0.7.1" ]; then
patch -p1 < $TP_PATCH_DIR/glog-0.7.1.patch
patch -p1 < $TP_PATCH_DIR/glog-0.7.1-add-handler-after-output-log.patch
patch -p1 < $TP_PATCH_DIR/glog-0.7.1-lwp.patch
touch $PATCHED_MARK
fi
cd -

28
thirdparty/patches/glog-0.7.1-lwp.patch vendored Normal file
View File

@ -0,0 +1,28 @@
diff --git a/src/signalhandler.cc b/src/signalhandler.cc
index c5bae59..b46b41c 100644
--- a/src/signalhandler.cc
+++ b/src/signalhandler.cc
@@ -53,6 +53,8 @@
# include <sys/ucontext.h>
#endif
#ifdef HAVE_UNISTD_H
+#include <sys/syscall.h>
+#include <sys/types.h>
# include <unistd.h>
#endif
@@ -218,6 +220,14 @@ void DumpSignalInfo(int signal_number, siginfo_t* siginfo) {
formatter.AppendString(oss.str().c_str());
formatter.AppendString(") ");
+
+#ifdef HAVE_UNISTD_H
+ pid_t tid = syscall(SYS_gettid);
+ formatter.AppendString("LWP(");
+ formatter.AppendUint64(tid, 10);
+ formatter.AppendString(") ");
+#endif
+
// Only linux has the PID of the signal sender in si_pid.
# ifdef GLOG_OS_LINUX
formatter.AppendString("from PID ");