[Lldb-commits] [PATCH] D91007: [lldb] [Process/FreeBSDRemote] Fix handling user-generated SIGTRAP

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


This revision was automatically updated to reflect the committed changes.
Closed by commit rGe637602e7ac9: [lldb] [Process/FreeBSDRemote] Fix handling user-generated SIGTRAP (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91007/new/

https://reviews.llvm.org/D91007

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


Index: lldb/test/API/functionalities/signal/raise/TestRaise.py
===================================================================
--- lldb/test/API/functionalities/signal/raise/TestRaise.py
+++ lldb/test/API/functionalities/signal/raise/TestRaise.py
@@ -30,7 +30,6 @@
         self.signal_test('SIGRTMIN', True)
 
     @skipIfNetBSD  # Hangs on NetBSD
-    @skipIfFreeBSD  # hangs
     def test_sigtrap(self):
         self.build()
         self.signal_test('SIGTRAP', True)
Index: lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
===================================================================
--- lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
+++ lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
@@ -192,7 +192,8 @@
   }
   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 @@
 
   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 @@
         FixupBreakpointPCAsNeeded(*thread);
       }
       SetState(StateType::eStateStopped, true);
-      break;
+      return;
     case TRAP_TRACE:
       if (thread) {
         auto &regctx = static_cast<NativeRegisterContextFreeBSD &>(
@@ -272,9 +275,14 @@
       }
 
       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) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91007.304151.patch
Type: text/x-patch
Size: 2105 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20201110/883589d3/attachment-0001.bin>


More information about the lldb-commits mailing list