Index: lldb/trunk/source/Commands/CommandObjectProcess.cpp =================================================================== --- lldb/trunk/source/Commands/CommandObjectProcess.cpp +++ lldb/trunk/source/Commands/CommandObjectProcess.cpp @@ -1729,8 +1729,8 @@ void PrintSignalHeader (Stream &str) { - str.Printf ("NAME PASS STOP NOTIFY\n"); - str.Printf ("========== ===== ===== ======\n"); + str.Printf ("NAME PASS STOP NOTIFY\n"); + str.Printf ("=========== ===== ===== ======\n"); } void @@ -1740,7 +1740,7 @@ bool suppress; bool notify; - str.Printf ("%-10s ", sig_name); + str.Printf ("%-11s ", sig_name); if (signals.GetSignalInfo (signo, suppress, stop, notify)) { bool pass = !suppress; Index: lldb/trunk/source/Plugins/Process/Utility/LinuxSignals.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Utility/LinuxSignals.cpp +++ lldb/trunk/source/Plugins/Process/Utility/LinuxSignals.cpp @@ -25,38 +25,71 @@ { m_signals.clear(); - AddSignal (1, "SIGHUP", "HUP", false, true , true , "hangup"); - AddSignal (2, "SIGINT", "INT", true , true , true , "interrupt"); - AddSignal (3, "SIGQUIT", "QUIT", false, true , true , "quit"); - AddSignal (4, "SIGILL", "ILL", false, true , true , "illegal instruction"); - AddSignal (5, "SIGTRAP", "TRAP", true , true , true , "trace trap (not reset when caught)"); - AddSignal (6, "SIGABRT", "ABRT", false, true , true , "abort()"); - AddSignal (6, "SIGIOT", "IOT", false, true , true , "IOT trap"); - AddSignal (7, "SIGBUS", "BUS", false, true , true , "bus error"); - AddSignal (8, "SIGFPE", "FPE", false, true , true , "floating point exception"); - AddSignal (9, "SIGKILL", "KILL", false, true , true , "kill"); - AddSignal (10, "SIGUSR1", "USR1", false, true , true , "user defined signal 1"); - AddSignal (11, "SIGSEGV", "SEGV", false, true , true , "segmentation violation"); - AddSignal (12, "SIGUSR2", "USR2", false, true , true , "user defined signal 2"); - AddSignal (13, "SIGPIPE", "PIPE", false, true , true , "write to pipe with reading end closed"); - AddSignal (14, "SIGALRM", "ALRM", false, false, false, "alarm"); - AddSignal (15, "SIGTERM", "TERM", false, true , true , "termination requested"); - AddSignal (16, "SIGSTKFLT", "STKFLT", false, true , true , "stack fault"); - AddSignal (16, "SIGCLD", "CLD", false, false, true , "same as SIGCHLD"); - AddSignal (17, "SIGCHLD", "CHLD", false, false, true , "child status has changed"); - AddSignal (18, "SIGCONT", "CONT", false, true , true , "process continue"); - AddSignal (19, "SIGSTOP", "STOP", true , true , true , "process stop"); - AddSignal (20, "SIGTSTP", "TSTP", false, true , true , "tty stop"); - AddSignal (21, "SIGTTIN", "TTIN", false, true , true , "background tty read"); - AddSignal (22, "SIGTTOU", "TTOU", false, true , true , "background tty write"); - AddSignal (23, "SIGURG", "URG", false, true , true , "urgent data on socket"); - AddSignal (24, "SIGXCPU", "XCPU", false, true , true , "CPU resource exceeded"); - AddSignal (25, "SIGXFSZ", "XFSZ", false, true , true , "file size limit exceeded"); - AddSignal (26, "SIGVTALRM", "VTALRM", false, true , true , "virtual time alarm"); - AddSignal (27, "SIGPROF", "PROF", false, false, false, "profiling time alarm"); - AddSignal (28, "SIGWINCH", "WINCH", false, true , true , "window size changes"); - AddSignal (29, "SIGPOLL", "POLL", false, true , true , "pollable event"); - AddSignal (29, "SIGIO", "IO", false, true , true , "input/output ready"); - AddSignal (30, "SIGPWR", "PWR", false, true , true , "power failure"); - AddSignal (31, "SIGSYS", "SYS", false, true , true , "invalid system call"); + AddSignal (1, "SIGHUP", "HUP", false, true , true , "hangup"); + AddSignal (2, "SIGINT", "INT", true , true , true , "interrupt"); + AddSignal (3, "SIGQUIT", "QUIT", false, true , true , "quit"); + AddSignal (4, "SIGILL", "ILL", false, true , true , "illegal instruction"); + AddSignal (5, "SIGTRAP", "TRAP", true , true , true , "trace trap (not reset when caught)"); + AddSignal (6, "SIGABRT", "ABRT", false, true , true , "abort()"); + AddSignal (6, "SIGIOT", "IOT", false, true , true , "IOT trap"); + AddSignal (7, "SIGBUS", "BUS", false, true , true , "bus error"); + AddSignal (8, "SIGFPE", "FPE", false, true , true , "floating point exception"); + AddSignal (9, "SIGKILL", "KILL", false, true , true , "kill"); + AddSignal (10, "SIGUSR1", "USR1", false, true , true , "user defined signal 1"); + AddSignal (11, "SIGSEGV", "SEGV", false, true , true , "segmentation violation"); + AddSignal (12, "SIGUSR2", "USR2", false, true , true , "user defined signal 2"); + AddSignal (13, "SIGPIPE", "PIPE", false, true , true , "write to pipe with reading end closed"); + AddSignal (14, "SIGALRM", "ALRM", false, false, false, "alarm"); + AddSignal (15, "SIGTERM", "TERM", false, true , true , "termination requested"); + AddSignal (16, "SIGSTKFLT", "STKFLT", false, true , true , "stack fault"); + AddSignal (16, "SIGCLD", "CLD", false, false, true , "same as SIGCHLD"); + AddSignal (17, "SIGCHLD", "CHLD", false, false, true , "child status has changed"); + AddSignal (18, "SIGCONT", "CONT", false, true , true , "process continue"); + AddSignal (19, "SIGSTOP", "STOP", true , true , true , "process stop"); + AddSignal (20, "SIGTSTP", "TSTP", false, true , true , "tty stop"); + AddSignal (21, "SIGTTIN", "TTIN", false, true , true , "background tty read"); + AddSignal (22, "SIGTTOU", "TTOU", false, true , true , "background tty write"); + AddSignal (23, "SIGURG", "URG", false, true , true , "urgent data on socket"); + AddSignal (24, "SIGXCPU", "XCPU", false, true , true , "CPU resource exceeded"); + AddSignal (25, "SIGXFSZ", "XFSZ", false, true , true , "file size limit exceeded"); + AddSignal (26, "SIGVTALRM", "VTALRM", false, true , true , "virtual time alarm"); + AddSignal (27, "SIGPROF", "PROF", false, false, false, "profiling time alarm"); + AddSignal (28, "SIGWINCH", "WINCH", false, true , true , "window size changes"); + AddSignal (29, "SIGPOLL", "POLL", false, true , true , "pollable event"); + AddSignal (29, "SIGIO", "IO", false, true , true , "input/output ready"); + AddSignal (30, "SIGPWR", "PWR", false, true , true , "power failure"); + AddSignal (31, "SIGSYS", "SYS", false, true , true , "invalid system call"); + AddSignal (32, "SIG32", "SIG32", false, true , true , "threading library internal signal 1"); + AddSignal (33, "SIG33", "SIG33", false, true , true , "threading library internal signal 2"); + AddSignal (34, "SIGRTMIN", "RTMIN", false, true , true , "real time signal 0"); + AddSignal (35, "SIGRTMIN+1", "RTMIN+1", false, true , true , "real time signal 1"); + AddSignal (36, "SIGRTMIN+2", "RTMIN+2", false, true , true , "real time signal 2"); + AddSignal (37, "SIGRTMIN+3", "RTMIN+3", false, true , true , "real time signal 3"); + AddSignal (38, "SIGRTMIN+4", "RTMIN+4", false, true , true , "real time signal 4"); + AddSignal (39, "SIGRTMIN+5", "RTMIN+5", false, true , true , "real time signal 5"); + AddSignal (40, "SIGRTMIN+6", "RTMIN+6", false, true , true , "real time signal 6"); + AddSignal (41, "SIGRTMIN+7", "RTMIN+7", false, true , true , "real time signal 7"); + AddSignal (42, "SIGRTMIN+8", "RTMIN+8", false, true , true , "real time signal 8"); + AddSignal (43, "SIGRTMIN+9", "RTMIN+9", false, true , true , "real time signal 9"); + AddSignal (44, "SIGRTMIN+10", "RTMIN+10", false, true , true , "real time signal 10"); + AddSignal (45, "SIGRTMIN+11", "RTMIN+11", false, true , true , "real time signal 11"); + AddSignal (46, "SIGRTMIN+12", "RTMIN+12", false, true , true , "real time signal 12"); + AddSignal (47, "SIGRTMIN+13", "RTMIN+13", false, true , true , "real time signal 13"); + AddSignal (48, "SIGRTMIN+14", "RTMIN+14", false, true , true , "real time signal 14"); + AddSignal (49, "SIGRTMIN+15", "RTMIN+15", false, true , true , "real time signal 15"); + AddSignal (50, "SIGRTMAX-14", "RTMAX-14", false, true , true , "real time signal 16"); // switching to SIGRTMAX-xxx to match "kill -l" output + AddSignal (51, "SIGRTMAX-13", "RTMAX-13", false, true , true , "real time signal 17"); + AddSignal (52, "SIGRTMAX-12", "RTMAX-12", false, true , true , "real time signal 18"); + AddSignal (53, "SIGRTMAX-11", "RTMAX-11", false, true , true , "real time signal 19"); + AddSignal (54, "SIGRTMAX-10", "RTMAX-10", false, true , true , "real time signal 20"); + AddSignal (55, "SIGRTMAX-9", "RTMAX-9", false, true , true , "real time signal 21"); + AddSignal (56, "SIGRTMAX-8", "RTMAX-8", false, true , true , "real time signal 22"); + AddSignal (57, "SIGRTMAX-7", "RTMAX-7", false, true , true , "real time signal 23"); + AddSignal (58, "SIGRTMAX-6", "RTMAX-6", false, true , true , "real time signal 24"); + AddSignal (59, "SIGRTMAX-5", "RTMAX-5", false, true , true , "real time signal 25"); + AddSignal (60, "SIGRTMAX-4", "RTMAX-4", false, true , true , "real time signal 26"); + AddSignal (61, "SIGRTMAX-3", "RTMAX-3", false, true , true , "real time signal 27"); + AddSignal (62, "SIGRTMAX-2", "RTMAX-2", false, true , true , "real time signal 28"); + AddSignal (63, "SIGRTMAX-1", "RTMAX-1", false, true , true , "real time signal 29"); + AddSignal (64, "SIGRTMAX", "RTMAX", false, true , true , "real time signal 30"); } Index: lldb/trunk/source/Plugins/Process/Utility/MipsLinuxSignals.cpp =================================================================== --- lldb/trunk/source/Plugins/Process/Utility/MipsLinuxSignals.cpp +++ lldb/trunk/source/Plugins/Process/Utility/MipsLinuxSignals.cpp @@ -25,38 +25,71 @@ { m_signals.clear(); - AddSignal (1, "SIGHUP", "HUP", false, true , true , "hangup"); - AddSignal (2, "SIGINT", "INT", true , true , true , "interrupt"); - AddSignal (3, "SIGQUIT", "QUIT", false, true , true , "quit"); - AddSignal (4, "SIGILL", "ILL", false, true , true , "illegal instruction"); - AddSignal (5, "SIGTRAP", "TRAP", true , true , true , "trace trap (not reset when caught)"); - AddSignal (6, "SIGABRT", "ABRT", false, true , true , "abort()"); - AddSignal (6, "SIGIOT", "IOT", false, true , true , "IOT trap"); - AddSignal (7, "SIGEMT", "EMT", false, true , true , "terminate process with core dump"); - AddSignal (8, "SIGFPE", "FPE", false, true , true , "floating point exception"); - AddSignal (9, "SIGKILL", "KILL", false, true , true , "kill"); - AddSignal (10, "SIGBUS", "BUS", false, true , true , "bus error"); - AddSignal (11, "SIGSEGV", "SEGV", false, true , true , "segmentation violation"); - AddSignal (12, "SIGSYS", "SYS", false, true , true , "invalid system call"); - AddSignal (13, "SIGPIPE", "PIPE", false, true , true , "write to pipe with reading end closed"); - AddSignal (14, "SIGALRM", "ALRM", false, false, false, "alarm"); - AddSignal (15, "SIGTERM", "TERM", false, true , true , "termination requested"); - AddSignal (16, "SIGUSR1", "USR1", false, true , true , "user defined signal 1"); - AddSignal (17, "SIGUSR2", "USR2", false, true , true , "user defined signal 2"); - AddSignal (18, "SIGCLD", "CLD", false, false, true , "same as SIGCHLD"); - AddSignal (18, "SIGCHLD", "CHLD", false, false, true , "child status has changed"); - AddSignal (19, "SIGPWR", "PWR", false, true , true , "power failure"); - AddSignal (20, "SIGWINCH", "WINCH", false, true , true , "window size changes"); - AddSignal (21, "SIGURG", "URG", false, true , true , "urgent data on socket"); - AddSignal (22, "SIGIO", "IO", false, true , true , "input/output ready"); - AddSignal (22, "SIGPOLL", "POLL", false, true , true , "pollable event"); - AddSignal (23, "SIGSTOP", "STOP", true , true , true , "process stop"); - AddSignal (24, "SIGTSTP", "TSTP", false, true , true , "tty stop"); - AddSignal (25, "SIGCONT", "CONT", false, true , true , "process continue"); - AddSignal (26, "SIGTTIN", "TTIN", false, true , true , "background tty read"); - AddSignal (27, "SIGTTOU", "TTOU", false, true , true , "background tty write"); - AddSignal (28, "SIGVTALRM", "VTALRM", false, true , true , "virtual time alarm"); - AddSignal (29, "SIGPROF", "PROF", false, false, false, "profiling time alarm"); - AddSignal (30, "SIGXCPU", "XCPU", false, true , true , "CPU resource exceeded"); - AddSignal (31, "SIGXFSZ", "XFSZ", false, true , true , "file size limit exceeded"); + AddSignal (1, "SIGHUP", "HUP", false, true , true , "hangup"); + AddSignal (2, "SIGINT", "INT", true , true , true , "interrupt"); + AddSignal (3, "SIGQUIT", "QUIT", false, true , true , "quit"); + AddSignal (4, "SIGILL", "ILL", false, true , true , "illegal instruction"); + AddSignal (5, "SIGTRAP", "TRAP", true , true , true , "trace trap (not reset when caught)"); + AddSignal (6, "SIGABRT", "ABRT", false, true , true , "abort()"); + AddSignal (6, "SIGIOT", "IOT", false, true , true , "IOT trap"); + AddSignal (7, "SIGEMT", "EMT", false, true , true , "terminate process with core dump"); + AddSignal (8, "SIGFPE", "FPE", false, true , true , "floating point exception"); + AddSignal (9, "SIGKILL", "KILL", false, true , true , "kill"); + AddSignal (10, "SIGBUS", "BUS", false, true , true , "bus error"); + AddSignal (11, "SIGSEGV", "SEGV", false, true , true , "segmentation violation"); + AddSignal (12, "SIGSYS", "SYS", false, true , true , "invalid system call"); + AddSignal (13, "SIGPIPE", "PIPE", false, true , true , "write to pipe with reading end closed"); + AddSignal (14, "SIGALRM", "ALRM", false, false, false, "alarm"); + AddSignal (15, "SIGTERM", "TERM", false, true , true , "termination requested"); + AddSignal (16, "SIGUSR1", "USR1", false, true , true , "user defined signal 1"); + AddSignal (17, "SIGUSR2", "USR2", false, true , true , "user defined signal 2"); + AddSignal (18, "SIGCLD", "CLD", false, false, true , "same as SIGCHLD"); + AddSignal (18, "SIGCHLD", "CHLD", false, false, true , "child status has changed"); + AddSignal (19, "SIGPWR", "PWR", false, true , true , "power failure"); + AddSignal (20, "SIGWINCH", "WINCH", false, true , true , "window size changes"); + AddSignal (21, "SIGURG", "URG", false, true , true , "urgent data on socket"); + AddSignal (22, "SIGIO", "IO", false, true , true , "input/output ready"); + AddSignal (22, "SIGPOLL", "POLL", false, true , true , "pollable event"); + AddSignal (23, "SIGSTOP", "STOP", true , true , true , "process stop"); + AddSignal (24, "SIGTSTP", "TSTP", false, true , true , "tty stop"); + AddSignal (25, "SIGCONT", "CONT", false, true , true , "process continue"); + AddSignal (26, "SIGTTIN", "TTIN", false, true , true , "background tty read"); + AddSignal (27, "SIGTTOU", "TTOU", false, true , true , "background tty write"); + AddSignal (28, "SIGVTALRM", "VTALRM", false, true , true , "virtual time alarm"); + AddSignal (29, "SIGPROF", "PROF", false, false, false, "profiling time alarm"); + AddSignal (30, "SIGXCPU", "XCPU", false, true , true , "CPU resource exceeded"); + AddSignal (31, "SIGXFSZ", "XFSZ", false, true , true , "file size limit exceeded"); + AddSignal (32, "SIG32", "SIG32", false, true , true , "threading library internal signal 1"); + AddSignal (33, "SIG33", "SIG33", false, true , true , "threading library internal signal 2"); + AddSignal (34, "SIGRTMIN", "RTMIN", false, true , true , "real time signal 0"); + AddSignal (35, "SIGRTMIN+1", "RTMIN+1", false, true , true , "real time signal 1"); + AddSignal (36, "SIGRTMIN+2", "RTMIN+2", false, true , true , "real time signal 2"); + AddSignal (37, "SIGRTMIN+3", "RTMIN+3", false, true , true , "real time signal 3"); + AddSignal (38, "SIGRTMIN+4", "RTMIN+4", false, true , true , "real time signal 4"); + AddSignal (39, "SIGRTMIN+5", "RTMIN+5", false, true , true , "real time signal 5"); + AddSignal (40, "SIGRTMIN+6", "RTMIN+6", false, true , true , "real time signal 6"); + AddSignal (41, "SIGRTMIN+7", "RTMIN+7", false, true , true , "real time signal 7"); + AddSignal (42, "SIGRTMIN+8", "RTMIN+8", false, true , true , "real time signal 8"); + AddSignal (43, "SIGRTMIN+9", "RTMIN+9", false, true , true , "real time signal 9"); + AddSignal (44, "SIGRTMIN+10", "RTMIN+10", false, true , true , "real time signal 10"); + AddSignal (45, "SIGRTMIN+11", "RTMIN+11", false, true , true , "real time signal 11"); + AddSignal (46, "SIGRTMIN+12", "RTMIN+12", false, true , true , "real time signal 12"); + AddSignal (47, "SIGRTMIN+13", "RTMIN+13", false, true , true , "real time signal 13"); + AddSignal (48, "SIGRTMIN+14", "RTMIN+14", false, true , true , "real time signal 14"); + AddSignal (49, "SIGRTMIN+15", "RTMIN+15", false, true , true , "real time signal 15"); + AddSignal (50, "SIGRTMAX-14", "RTMAX-14", false, true , true , "real time signal 16"); // switching to SIGRTMAX-xxx to match "kill -l" output + AddSignal (51, "SIGRTMAX-13", "RTMAX-13", false, true , true , "real time signal 17"); + AddSignal (52, "SIGRTMAX-12", "RTMAX-12", false, true , true , "real time signal 18"); + AddSignal (53, "SIGRTMAX-11", "RTMAX-11", false, true , true , "real time signal 19"); + AddSignal (54, "SIGRTMAX-10", "RTMAX-10", false, true , true , "real time signal 20"); + AddSignal (55, "SIGRTMAX-9", "RTMAX-9", false, true , true , "real time signal 21"); + AddSignal (56, "SIGRTMAX-8", "RTMAX-8", false, true , true , "real time signal 22"); + AddSignal (57, "SIGRTMAX-7", "RTMAX-7", false, true , true , "real time signal 23"); + AddSignal (58, "SIGRTMAX-6", "RTMAX-6", false, true , true , "real time signal 24"); + AddSignal (59, "SIGRTMAX-5", "RTMAX-5", false, true , true , "real time signal 25"); + AddSignal (60, "SIGRTMAX-4", "RTMAX-4", false, true , true , "real time signal 26"); + AddSignal (61, "SIGRTMAX-3", "RTMAX-3", false, true , true , "real time signal 27"); + AddSignal (62, "SIGRTMAX-2", "RTMAX-2", false, true , true , "real time signal 28"); + AddSignal (63, "SIGRTMAX-1", "RTMAX-1", false, true , true , "real time signal 29"); + AddSignal (64, "SIGRTMAX", "RTMAX", false, true , true , "real time signal 30"); } Index: lldb/trunk/test/functionalities/signal/raise/TestRaise.py =================================================================== --- lldb/trunk/test/functionalities/signal/raise/TestRaise.py +++ lldb/trunk/test/functionalities/signal/raise/TestRaise.py @@ -5,6 +5,7 @@ import lldb from lldbtest import * import lldbutil +import re class RaiseTestCase(TestBase): @@ -17,34 +18,43 @@ @expectedFailureDarwin("llvm.org/pr23610") # process doesn't stop at a breakpoint on the third launch def test_sigstop_with_dsym(self): self.buildDsym() - self.sigstop() + self.signal_test('SIGSTOP', False) + # passing of SIGSTOP is not correctly handled, so not testing that scenario: https://llvm.org/bugs/show_bug.cgi?id=23574 @skipIfWindows # signals do not exist on Windows @dwarf_test @expectedFailureDarwin("llvm.org/pr23610") # process doesn't stop at a breakpoint on the third launch def test_sigstop_with_dwarf(self): self.buildDwarf() - self.sigstop() + self.signal_test('SIGSTOP', False) + # passing of SIGSTOP is not correctly handled, so not testing that scenario: https://llvm.org/bugs/show_bug.cgi?id=23574 - def launch(self, target): + @skipIfWindows # signals do not exist on Windows + @dwarf_test + @skipIfDarwin # darwin does not support real time signals + def test_sigsigrtmin_with_dwarf(self): + self.buildDwarf() + self.signal_test('SIGRTMIN', True) + + def launch(self, target, signal): # launch the process, do not stop at entry point. - process = target.LaunchSimple(['SIGSTOP'], None, self.get_process_working_directory()) + process = target.LaunchSimple([signal], None, self.get_process_working_directory()) self.assertTrue(process, PROCESS_IS_VALID) self.assertEqual(process.GetState(), lldb.eStateStopped) thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) self.assertTrue(thread.IsValid(), "Thread should be stopped due to a breakpoint") return process - def set_handle(self, signal, stop_at_signal, pass_signal, notify_signal): + def set_handle(self, signal, pass_signal, stop_at_signal, notify_signal): return_obj = lldb.SBCommandReturnObject() self.dbg.GetCommandInterpreter().HandleCommand( - "process handle %s -s %d -p %d -n %d" % (signal, stop_at_signal, pass_signal, notify_signal), + "process handle %s -p %s -s %s -n %s" % (signal, pass_signal, stop_at_signal, notify_signal), return_obj) self.assertTrue (return_obj.Succeeded() == True, "Setting signal handling failed") - def sigstop(self): - """Test that we handle inferior raising SIGSTOP""" + def signal_test(self, signal, test_passing): + """Test that we handle inferior raising signals""" exe = os.path.join(os.getcwd(), "a.out") # Create a target by the debugger. @@ -53,42 +63,99 @@ lldbutil.run_break_set_by_symbol(self, "main") # launch - process = self.launch(target) + process = self.launch(target, signal) + signo = process.GetUnixSignals().GetSignalNumberFromName(signal) + + # retrieve default signal disposition + return_obj = lldb.SBCommandReturnObject() + self.dbg.GetCommandInterpreter().HandleCommand("process handle %s " % signal, return_obj) + match = re.match('NAME *PASS *STOP *NOTIFY.*(false|true) *(false|true) *(false|true)', + return_obj.GetOutput(), re.IGNORECASE | re.DOTALL) + if not match: + self.fail('Unable to retrieve default signal disposition.') + default_pass = match.group(1) + default_stop = match.group(2) + default_notify = match.group(3) # Make sure we stop at the signal - self.set_handle("SIGSTOP", 1, 0, 1) + self.set_handle(signal, "false", "true", "true") process.Continue() + self.assertEqual(process.GetState(), lldb.eStateStopped) thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonSignal) self.assertTrue(thread.IsValid(), "Thread should be stopped due to a signal") self.assertTrue(thread.GetStopReasonDataCount() >= 1, "There was data in the event.") - self.assertEqual(thread.GetStopReasonDataAtIndex(0), - process.GetUnixSignals().GetSignalNumberFromName('SIGSTOP'), - "The stop signal was SIGSTOP") + self.assertEqual(thread.GetStopReasonDataAtIndex(0), signo, + "The stop signal was %s" % signal) # Continue until we exit. process.Continue() self.assertEqual(process.GetState(), lldb.eStateExited) + self.assertEqual(process.GetExitStatus(), 0) # launch again - process = self.launch(target) + process = self.launch(target, signal) # Make sure we do not stop at the signal. We should still get the notification. - self.set_handle("SIGSTOP", 0, 0, 1) - self.expect("process continue", substrs=["stopped and restarted", "SIGSTOP"]) + self.set_handle(signal, "false", "false", "true") + self.expect("process continue", substrs=["stopped and restarted", signal]) self.assertEqual(process.GetState(), lldb.eStateExited) + self.assertEqual(process.GetExitStatus(), 0) # launch again - process = self.launch(target) + process = self.launch(target, signal) # Make sure we do not stop at the signal, and we do not get the notification. - self.set_handle("SIGSTOP", 0, 0, 0) + self.set_handle(signal, "false", "false", "false") self.expect("process continue", substrs=["stopped and restarted"], matching=False) self.assertEqual(process.GetState(), lldb.eStateExited) + self.assertEqual(process.GetExitStatus(), 0) - # passing of SIGSTOP is not correctly handled, so not testing that scenario: https://llvm.org/bugs/show_bug.cgi?id=23574 + if not test_passing: + # reset signal handling to default + self.set_handle(signal, default_pass, default_stop, default_notify) + return + + # launch again + process = self.launch(target, signal) + + # Make sure we stop at the signal + self.set_handle(signal, "true", "true", "true") + process.Continue() + self.assertEqual(process.GetState(), lldb.eStateStopped) + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonSignal) + self.assertTrue(thread.IsValid(), "Thread should be stopped due to a signal") + self.assertTrue(thread.GetStopReasonDataCount() >= 1, "There was data in the event.") + self.assertEqual(thread.GetStopReasonDataAtIndex(0), + process.GetUnixSignals().GetSignalNumberFromName(signal), + "The stop signal was %s" % signal) + + # Continue until we exit. The process should receive the signal. + process.Continue() + self.assertEqual(process.GetState(), lldb.eStateExited) + self.assertEqual(process.GetExitStatus(), signo) + + # launch again + process = self.launch(target, signal) + + # Make sure we do not stop at the signal. We should still get the notification. Process + # should receive the signal. + self.set_handle(signal, "true", "false", "true") + self.expect("process continue", substrs=["stopped and restarted", signal]) + self.assertEqual(process.GetState(), lldb.eStateExited) + self.assertEqual(process.GetExitStatus(), signo) + + # launch again + process = self.launch(target, signal) + + # Make sure we do not stop at the signal, and we do not get the notification. Process + # should receive the signal. + self.set_handle(signal, "true", "false", "false") + self.expect("process continue", substrs=["stopped and restarted"], matching=False) + self.assertEqual(process.GetState(), lldb.eStateExited) + self.assertEqual(process.GetExitStatus(), signo) # reset signal handling to default - self.set_handle("SIGSTOP", 1, 0, 1) + self.set_handle(signal, default_pass, default_stop, default_notify) if __name__ == '__main__': import atexit Index: lldb/trunk/test/functionalities/signal/raise/main.c =================================================================== --- lldb/trunk/test/functionalities/signal/raise/main.c +++ lldb/trunk/test/functionalities/signal/raise/main.c @@ -1,9 +1,24 @@ #include #include #include +#include + +void handler(int signo) +{ + _exit(signo); +} int main (int argc, char *argv[]) { +#ifndef __APPLE__ + // Real time signals not supported on apple platforms. + if (signal(SIGRTMIN, handler) == SIG_ERR) + { + perror("signal(SIGRTMIN)"); + return 1; + } +#endif + if (argc < 2) { puts("Please specify a signal to raise"); @@ -12,10 +27,14 @@ if (strcmp(argv[1], "SIGSTOP") == 0) raise(SIGSTOP); +#ifndef __APPLE__ + else if (strcmp(argv[1], "SIGRTMIN") == 0) + raise(SIGRTMIN); +#endif else { printf("Unknown signal: %s\n", argv[1]); - return 2; + return 1; } return 0;