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

2020-11-10 Thread Michał Górny via Phabricator via lldb-commits
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  = static_cast(
@@ -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) {


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  = static_cast(
@@ -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) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


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

2020-11-10 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 304135.
mgorny added a comment.

clang-format


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  = static_cast(
@@ -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) {


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  = static_cast(
@@ -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) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


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

2020-11-09 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 303817.
mgorny edited the summary of this revision.
mgorny added a comment.
This revision is now accepted and ready to land.

Pass unknown SIGTRAPs to the user too.


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  = static_cast(
@@ -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) {


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  = static_cast(
@@ -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) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


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

2020-11-09 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: 
lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp:287
+// probably a unknown event-generated SIGTRAP.
+return;
   }

mgorny wrote:
> labath wrote:
> > What will happen in case this returns? Will the process auto-resume or just 
> > hang stopped? It sounds like it would still be useful to report this as 
> > "SIGTRAP" even if we are unable to give any details about it...
> Good catch. Should it be reported as an arbitrary SIGTRAP then or maybe as a 
> trace trap?
I don't have a strong opinion there. I'd probably just go with a regular 
SIGTRAP.


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

https://reviews.llvm.org/D91007

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


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

2020-11-09 Thread Michał Górny via Phabricator via lldb-commits
mgorny added inline comments.



Comment at: 
lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp:287
+// probably a unknown event-generated SIGTRAP.
+return;
   }

labath wrote:
> What will happen in case this returns? Will the process auto-resume or just 
> hang stopped? It sounds like it would still be useful to report this as 
> "SIGTRAP" even if we are unable to give any details about it...
Good catch. Should it be reported as an arbitrary SIGTRAP then or maybe as a 
trace trap?


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

https://reviews.llvm.org/D91007

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


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

2020-11-09 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: 
lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp:287
+// probably a unknown event-generated SIGTRAP.
+return;
   }

What will happen in case this returns? Will the process auto-resume or just 
hang stopped? It sounds like it would still be useful to report this as 
"SIGTRAP" even if we are unable to give any details about it...


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

https://reviews.llvm.org/D91007

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


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

2020-11-07 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 303676.
mgorny added a comment.

Updated to treat generic SIGTRAP as a fallback as requested by @krytarowski. 
This happens either if `si_code >= SI_USER`, or there is no siginfo and no 
other flag is set.


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  = static_cast(
@@ -272,9 +275,20 @@
   }
 
   SetState(StateType::eStateStopped, true);
-  break;
+  return;
 }
+
+// If this is an unknown event-generated SIGTRAP, return now.
+if (info.pl_siginfo.si_code < SI_USER)
+  return;
+  } else if (info.pl_flags != 0) {
+// If there is no siginfo but there are unknown flags, then it is
+// probably a unknown event-generated SIGTRAP.
+return;
   }
+
+  // If we did not return by now, this is a user-generated SIGTRAP.
+  MonitorSignal(pid, SIGTRAP);
 }
 
 void NativeProcessFreeBSD::MonitorSignal(lldb::pid_t pid, int signal) {


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  = static_cast(
@@ -272,9 +275,20 @@
   }
 
   SetState(StateType::eStateStopped, true);
-  break;
+  return;
 }
+
+// If this is an unknown event-generated SIGTRAP, return now.
+if (info.pl_siginfo.si_code < SI_USER)
+  return;
+  } else if (info.pl_flags != 0) {
+// If there is no siginfo but there are unknown flags, then it is
+// probably a unknown event-generated SIGTRAP.
+return;
   }
+
+  // If we did not return by now, this is a user-generated SIGTRAP.
+  MonitorSignal(pid, SIGTRAP);
 }
 
 void NativeProcessFreeBSD::MonitorSignal(lldb::pid_t pid, int signal) 

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

2020-11-07 Thread Kamil Rytarowski via Phabricator via lldb-commits
krytarowski added a comment.

I propose to filter all user induced signals at once and check `& 0x1` and 
SI_USER.

http://src.illumos.org/source/xref/freebsd-head/sys/sys/signal.h#406

This way we will avoid all future fallout and crashing the debugger on unknown 
signal.


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

https://reviews.llvm.org/D91007

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


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

2020-11-07 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, emaste, krytarowski.
mgorny requested review of this revision.

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.  These instances of SIGTRAP are passed
to the regular signal handler.


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:
@@ -273,6 +276,11 @@
 
   SetState(StateType::eStateStopped, true);
   break;
+case SI_USER:
+case SI_LWP:
+  // User-generated SIGTRAP
+  MonitorSignal(pid, SIGTRAP);
+  break;
 }
   }
 }


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:
@@ -273,6 +276,11 @@
 
   SetState(StateType::eStateStopped, true);
   break;
+case SI_USER:
+case SI_LWP:
+  // User-generated SIGTRAP
+  MonitorSignal(pid, SIGTRAP);
+  break;
 }
   }
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits