From 21a365ba593ebeac305f1cf12fc039676697ef08 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Tue, 11 Jul 2017 10:38:40 +0000 Subject: 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. llvm-svn: 307644 --- .../lldbsuite/test/functionalities/signal/raise/TestRaise.py | 5 +++++ .../Python/lldbsuite/test/functionalities/signal/raise/main.c | 7 +++++++ 2 files changed, 12 insertions(+) (limited to 'lldb/packages/Python/lldbsuite/test/functionalities/signal/raise') diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/signal/raise/TestRaise.py b/lldb/packages/Python/lldbsuite/test/functionalities/signal/raise/TestRaise.py index efadea51f66..79175562fe7 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/signal/raise/TestRaise.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/signal/raise/TestRaise.py @@ -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( diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/signal/raise/main.c b/lldb/packages/Python/lldbsuite/test/functionalities/signal/raise/main.c index 8827174e758..4203fe5d4c8 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/signal/raise/main.c +++ b/lldb/packages/Python/lldbsuite/test/functionalities/signal/raise/main.c @@ -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); -- cgit v1.2.3