[Lldb-commits] [lldb] r307644 - NativeProcessLinux: Fix handling of raise(SIGTRAP)
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Tue Jul 11 03:38:40 PDT 2017
Author: labath
Date: Tue Jul 11 03:38:40 2017
New Revision: 307644
URL: http://llvm.org/viewvc/llvm-project?rev=307644&view=rev
Log:
NativeProcessLinux: Fix handling of raise(SIGTRAP)
In NativeProcessLinux::MonitorSIGTRAP we were asserting that the si_code
value is one of the codes we know about. However, that list was very
incomplete -- for example, we were not handling SI_TKILL/SI_USER,
generated by raise(SIGTRAP). A cursory examination show there are at
least a dozen codes like these that an app can generate, and more can be
added at any point.
So, instead of trying to play catchup, I change the default behavior to
treat an unknown si_code like an ordinary signal. The only reason we
needed to inspect si_code in the first place is because
watchpoint/breakpoints are notified as SIGTRAP, but we already know
about those, and us starting to use a new debug event is far less likely
than somebody introducing a new non-debug event.
I add a test case to TestRaise to verify we are handling raise(SIGTRAP)
in an application properly.
Modified:
lldb/trunk/packages/Python/lldbsuite/test/functionalities/signal/raise/TestRaise.py
lldb/trunk/packages/Python/lldbsuite/test/functionalities/signal/raise/main.c
lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/signal/raise/TestRaise.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/signal/raise/TestRaise.py?rev=307644&r1=307643&r2=307644&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/signal/raise/TestRaise.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/signal/raise/TestRaise.py Tue Jul 11 03:38:40 2017
@@ -16,6 +16,7 @@ from lldbsuite.test import lldbutil
class RaiseTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
+ NO_DEBUG_INFO_TESTCASE = True
def test_sigstop(self):
self.build()
@@ -29,6 +30,10 @@ class RaiseTestCase(TestBase):
self.build()
self.signal_test('SIGRTMIN', True)
+ def test_sigtrap(self):
+ self.build()
+ self.signal_test('SIGTRAP', True)
+
def launch(self, target, signal):
# launch the process, do not stop at entry point.
process = target.LaunchSimple(
Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/signal/raise/main.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/signal/raise/main.c?rev=307644&r1=307643&r2=307644&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/signal/raise/main.c (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/signal/raise/main.c Tue Jul 11 03:38:40 2017
@@ -10,6 +10,11 @@ void handler(int signo)
int main (int argc, char *argv[])
{
+ if (signal(SIGTRAP, handler) == SIG_ERR)
+ {
+ perror("signal(SIGTRAP)");
+ return 1;
+ }
#ifndef __APPLE__
// Real time signals not supported on apple platforms.
if (signal(SIGRTMIN, handler) == SIG_ERR)
@@ -27,6 +32,8 @@ int main (int argc, char *argv[])
if (strcmp(argv[1], "SIGSTOP") == 0)
raise(SIGSTOP);
+ else if (strcmp(argv[1], "SIGTRAP") == 0)
+ raise(SIGTRAP);
#ifndef __APPLE__
else if (strcmp(argv[1], "SIGRTMIN") == 0)
raise(SIGRTMIN);
Modified: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp?rev=307644&r1=307643&r2=307644&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp Tue Jul 11 03:38:40 2017
@@ -796,11 +796,9 @@ void NativeProcessLinux::MonitorSIGTRAP(
break;
default:
- LLDB_LOG(
- log,
- "received unknown SIGTRAP stop event ({0}, pid {1} tid {2}, resuming",
- info.si_code, GetID(), thread.GetID());
- llvm_unreachable("Unexpected SIGTRAP code!");
+ LLDB_LOG(log, "received unknown SIGTRAP stop event ({0}, pid {1} tid {2}",
+ info.si_code, GetID(), thread.GetID());
+ MonitorSignal(info, thread, false);
break;
}
}
More information about the lldb-commits
mailing list