[Lldb-commits] [lldb] e637602 - [lldb] [Process/FreeBSDRemote] Fix handling user-generated SIGTRAP

Michał Górny via lldb-commits lldb-commits at lists.llvm.org
Tue Nov 10 05:18:17 PST 2020


Author: Michał Górny
Date: 2020-11-10T14:18:03+01:00
New Revision: e637602e7ac9bb5721dbe079fa783cee891139b4

URL: https://github.com/llvm/llvm-project/commit/e637602e7ac9bb5721dbe079fa783cee891139b4
DIFF: https://github.com/llvm/llvm-project/commit/e637602e7ac9bb5721dbe079fa783cee891139b4.diff

LOG: [lldb] [Process/FreeBSDRemote] Fix handling user-generated SIGTRAP

Update the SIGTRAP handler to account for the possibility of SIGTRAP
being generated by the user, i.e. not having any specific debugging
event associated with it, as well as receiving unknown SIGTRAPs.  These
instances of SIGTRAP are passed to the regular signal handler.

Differential Revision: https://reviews.llvm.org/D91007

Added: 
    

Modified: 
    lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
    lldb/test/API/functionalities/signal/raise/TestRaise.py

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp b/lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
index 5c10c9c8cd07..8f0936c169b9 100644
--- a/lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
+++ b/lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
@@ -192,7 +192,8 @@ void NativeProcessFreeBSD::MonitorSIGTRAP(lldb::pid_t pid) {
   }
   assert(info.pl_event == PL_EVENT_SIGNAL);
 
-  LLDB_LOG(log, "got SIGTRAP, pid = {0}, lwpid = {1}", pid, info.pl_lwpid);
+  LLDB_LOG(log, "got SIGTRAP, pid = {0}, lwpid = {1}, flags = {2:x}", pid,
+           info.pl_lwpid, info.pl_flags);
   NativeThreadFreeBSD *thread = nullptr;
 
   if (info.pl_flags & (PL_FLAG_BORN | PL_FLAG_EXITED)) {
@@ -240,6 +241,8 @@ void NativeProcessFreeBSD::MonitorSIGTRAP(lldb::pid_t pid) {
 
   if (info.pl_flags & PL_FLAG_SI) {
     assert(info.pl_siginfo.si_signo == SIGTRAP);
+    LLDB_LOG(log, "SIGTRAP siginfo: si_code = {0}, pid = {1}",
+             info.pl_siginfo.si_code, info.pl_siginfo.si_pid);
 
     switch (info.pl_siginfo.si_code) {
     case TRAP_BRKPT:
@@ -248,7 +251,7 @@ void NativeProcessFreeBSD::MonitorSIGTRAP(lldb::pid_t pid) {
         FixupBreakpointPCAsNeeded(*thread);
       }
       SetState(StateType::eStateStopped, true);
-      break;
+      return;
     case TRAP_TRACE:
       if (thread) {
         auto &regctx = static_cast<NativeRegisterContextFreeBSD &>(
@@ -272,9 +275,14 @@ void NativeProcessFreeBSD::MonitorSIGTRAP(lldb::pid_t pid) {
       }
 
       SetState(StateType::eStateStopped, true);
-      break;
+      return;
     }
   }
+
+  // Either user-generated SIGTRAP or an unknown event that would
+  // otherwise leave the debugger hanging.
+  LLDB_LOG(log, "unknown SIGTRAP, passing to generic handler");
+  MonitorSignal(pid, SIGTRAP);
 }
 
 void NativeProcessFreeBSD::MonitorSignal(lldb::pid_t pid, int signal) {

diff  --git a/lldb/test/API/functionalities/signal/raise/TestRaise.py b/lldb/test/API/functionalities/signal/raise/TestRaise.py
index 93df3b1f93a9..70271e43cff5 100644
--- a/lldb/test/API/functionalities/signal/raise/TestRaise.py
+++ b/lldb/test/API/functionalities/signal/raise/TestRaise.py
@@ -30,7 +30,6 @@ def test_sigsigrtmin(self):
         self.signal_test('SIGRTMIN', True)
 
     @skipIfNetBSD  # Hangs on NetBSD
-    @skipIfFreeBSD  # hangs
     def test_sigtrap(self):
         self.build()
         self.signal_test('SIGTRAP', True)


        


More information about the lldb-commits mailing list