summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohnny Chen <johnny.chen@apple.com>2010-10-14 01:22:03 +0000
committerJohnny Chen <johnny.chen@apple.com>2010-10-14 01:22:03 +0000
commitc066ab43851559207f7ac83420e10bbd5fd16d8c (patch)
treeedbdf235ad4f67ec27d2736c3a65f2c38e35bc2c
parent0441c6cba0d42fdcf40ebe6b7a0c868b51351153 (diff)
downloadbcm5719-llvm-c066ab43851559207f7ac83420e10bbd5fd16d8c.tar.gz
bcm5719-llvm-c066ab43851559207f7ac83420e10bbd5fd16d8c.zip
Add an initial version of test that exercise the lldb commands: 'process signal'
and 'process handle'. The test suite would like to control the asynch/sync execution of the interpreter during the middle of the test method, so the CommandInterpreter::SetSynchronous(bool value) is modified to allow the mode to be changed more than once. In practice, it would be advisable to control the process and to set the async/sync mode from a single thread, too. llvm-svn: 116467
-rw-r--r--lldb/source/Interpreter/CommandInterpreter.cpp7
-rw-r--r--lldb/test/lldbtest.py2
-rw-r--r--lldb/test/signal/TestSendSignal.py76
3 files changed, 79 insertions, 6 deletions
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index 4a87ba0359d..0f5d85b8e76 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1107,12 +1107,7 @@ CommandInterpreter::GetSynchronous ()
void
CommandInterpreter::SetSynchronous (bool value)
{
- static bool value_set_once = false;
- if (!value_set_once)
- {
- value_set_once = true;
- m_synchronous_execution = value;
- }
+ m_synchronous_execution = value;
}
void
diff --git a/lldb/test/lldbtest.py b/lldb/test/lldbtest.py
index 97b351cdd69..373f8bfc08b 100644
--- a/lldb/test/lldbtest.py
+++ b/lldb/test/lldbtest.py
@@ -150,6 +150,8 @@ STEP_OUT_SUCCEEDED = "Thread step-out succeeded"
STOPPED_DUE_TO_BREAKPOINT = "Process state is stopped due to breakpoint"
+STOPPED_DUE_TO_SIGNAL = "Process state is stopped due to signal"
+
STOPPED_DUE_TO_STEP_IN = "Process state is stopped due to step in"
DATA_TYPES_DISPLAYED_CORRECTLY = "Data type(s) displayed correctly"
diff --git a/lldb/test/signal/TestSendSignal.py b/lldb/test/signal/TestSendSignal.py
new file mode 100644
index 00000000000..8c188d3d98c
--- /dev/null
+++ b/lldb/test/signal/TestSendSignal.py
@@ -0,0 +1,76 @@
+"""Test that lldb command 'process signal SIGUSR1' to send a signal to the inferior works."""
+
+import os, time, signal
+import unittest2
+import lldb
+from lldbtest import *
+
+class SendSignalTestCase(TestBase):
+
+ mydir = "signal"
+
+ @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
+ def test_with_dsym_and_run_command(self):
+ """Test that lldb command 'process signal SIGUSR1' sends a signal to the inferior process."""
+ self.buildDsym()
+ self.send_signal()
+
+ def test_with_dwarf_and_run_command(self):
+ """Test that lldb command 'process signal SIGUSR1' sends a signal to the inferior process."""
+ self.buildDwarf()
+ self.send_signal()
+
+ def setUp(self):
+ super(SendSignalTestCase, self).setUp()
+ # Find the line number to break inside main().
+ self.line = line_number('main.c', 'Put breakpoint here')
+
+ def send_signal(self):
+ """Test that lldb command 'process signal SIGUSR1' sends a signal to the inferior process."""
+
+ exe = os.path.join(os.getcwd(), "a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Break inside the main() function and immediately send a signal to the inferior after resuming.
+ self.expect("breakpoint set -f main.c -l %d" % self.line,
+ BREAKPOINT_CREATED,
+ startstr = "Breakpoint created: 1: file ='main.c', line = %d, locations = 1" %
+ self.line)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+ self.runCmd("thread backtrac")
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['state is Stopped',
+ 'stop reason = breakpoint'])
+
+ # The breakpoint should have a hit count of 1.
+ self.expect("breakpoint list", BREAKPOINT_HIT_ONCE,
+ substrs = [' resolved, hit count = 1'])
+
+ self.runCmd("process status")
+ output = self.res.GetOutput()
+ pid = re.match("Process (.*) Stopped", output).group(1)
+
+ # After resuming the process, immediately send a SIGUSR1 signal.
+ self.dbg.SetAsync(True)
+ self.runCmd("process continue")
+ self.runCmd("process handle -n False -p True -s True SIGUSR1")
+ #os.kill(int(pid), signal.SIGUSR1)
+ self.runCmd("process signal SIGUSR1")
+
+ time.sleep(1)
+ self.dbg.SetAsync(False)
+ self.expect("process status", STOPPED_DUE_TO_SIGNAL,
+ startstr = "Process %s Stopped" % pid,
+ substrs = ['stop reason = signal SIGUSR1'])
+ self.expect("thread backtrace", STOPPED_DUE_TO_SIGNAL,
+ substrs = ['stop reason = signal SIGUSR1'])
+
+
+if __name__ == '__main__':
+ import atexit
+ lldb.SBDebugger.Initialize()
+ atexit.register(lambda: lldb.SBDebugger.Terminate())
+ unittest2.main()
OpenPOWER on IntegriCloud