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 b0353d2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 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,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 ");
Expand Down

0 comments on commit b0353d2

Please sign in to comment.