Skip to content

Commit

Permalink
Add LWP id to dump info
Browse files Browse the repository at this point in the history
LWP can help gdb find the corresponding thread more quickly.
  • Loading branch information
stdpain committed Dec 19, 2024
1 parent 6c5c692 commit 1e7279d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/signalhandler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -218,8 +220,14 @@ void DumpSignalInfo(int signal_number, siginfo_t* siginfo) {
formatter.AppendString(oss.str().c_str());

formatter.AppendString(") ");

// Only linux has the PID of the signal sender in si_pid.
# ifdef GLOG_OS_LINUX
pid_t tid = syscall(SYS_gettid);
formatter.AppendString("(LWP ");
formatter.AppendUint64(tid, 10);
formatter.AppendString(") ");

formatter.AppendString("from PID ");
formatter.AppendUint64(static_cast<uint64>(siginfo->si_pid), 10);
formatter.AppendString("; ");
Expand Down

0 comments on commit 1e7279d

Please sign in to comment.