diff options
author | Jim Ingham <jingham@apple.com> | 2017-07-06 02:18:16 +0000 |
---|---|---|
committer | Jim Ingham <jingham@apple.com> | 2017-07-06 02:18:16 +0000 |
commit | a15e7f296babc33d7565dc6c224a818a9597796b (patch) | |
tree | e6c4bc1fdc59886148171e58f9bb3a522200e731 /lldb/packages/Python/lldbsuite/test/expression_command | |
parent | 35adb43950dc9be4e0efb0cc36f87e5be43cfff4 (diff) | |
download | bcm5719-llvm-a15e7f296babc33d7565dc6c224a818a9597796b.tar.gz bcm5719-llvm-a15e7f296babc33d7565dc6c224a818a9597796b.zip |
Add a lldbutils routine that gathers up the boiler-plate
to make a target, set a source regex breakpoint, run to
the breakpoint and find the thread that hit the breakpoint.
Start the process of replacing the boiler plate with this
routine.
llvm-svn: 307234
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/expression_command')
4 files changed, 9 insertions, 84 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/expression_command/call-restarts/TestCallThatRestarts.py b/lldb/packages/Python/lldbsuite/test/expression_command/call-restarts/TestCallThatRestarts.py index 0b9ad0ed632..5eb7b309c94 100644 --- a/lldb/packages/Python/lldbsuite/test/expression_command/call-restarts/TestCallThatRestarts.py +++ b/lldb/packages/Python/lldbsuite/test/expression_command/call-restarts/TestCallThatRestarts.py @@ -48,28 +48,8 @@ class ExprCommandThatRestartsTestCase(TestBase): "Restored the zeroth frame correctly") def call_function(self): - exe_name = "a.out" - exe = os.path.join(os.getcwd(), exe_name) - - target = self.dbg.CreateTarget(exe) - self.assertTrue(target, VALID_TARGET) - empty = lldb.SBFileSpec() - breakpoint = target.BreakpointCreateBySourceRegex( - 'Stop here in main.', self.main_source_spec) - self.assertTrue(breakpoint.GetNumLocations() > 0, VALID_BREAKPOINT) - - # Launch the process, and do not stop at the entry point. - process = target.LaunchSimple( - None, None, self.get_process_working_directory()) - - self.assertTrue(process, PROCESS_IS_VALID) - - # Frame #0 should be at our breakpoint. - threads = lldbutil.get_threads_stopped_at_breakpoint( - process, breakpoint) - - self.assertTrue(len(threads) == 1) - self.thread = threads[0] + (target, process, self.thread, bkpt) = lldbutil.run_to_source_breakpoint(self, + 'Stop here in main.', self.main_source_spec) # Make sure the SIGCHLD behavior is pass/no-stop/no-notify: return_obj = lldb.SBCommandReturnObject() diff --git a/lldb/packages/Python/lldbsuite/test/expression_command/call-throws/TestCallThatThrows.py b/lldb/packages/Python/lldbsuite/test/expression_command/call-throws/TestCallThatThrows.py index e5162609dfa..f2ec340ac84 100644 --- a/lldb/packages/Python/lldbsuite/test/expression_command/call-throws/TestCallThatThrows.py +++ b/lldb/packages/Python/lldbsuite/test/expression_command/call-throws/TestCallThatThrows.py @@ -37,28 +37,8 @@ class ExprCommandWithThrowTestCase(TestBase): def call_function(self): """Test calling function that throws.""" - exe_name = "a.out" - exe = os.path.join(os.getcwd(), exe_name) - - target = self.dbg.CreateTarget(exe) - self.assertTrue(target, VALID_TARGET) - - breakpoint = target.BreakpointCreateBySourceRegex( - 'I am about to throw.', self.main_source_spec) - self.assertTrue(breakpoint.GetNumLocations() > 0, VALID_BREAKPOINT) - - # Launch the process, and do not stop at the entry point. - process = target.LaunchSimple( - None, None, self.get_process_working_directory()) - - self.assertTrue(process, PROCESS_IS_VALID) - - # Frame #0 should be at our breakpoint. - threads = lldbutil.get_threads_stopped_at_breakpoint( - process, breakpoint) - - self.assertTrue(len(threads) == 1) - self.thread = threads[0] + (target, process, self.thread, bkpt) = lldbutil.run_to_source_breakpoint(self, + 'I am about to throw.', self.main_source_spec) options = lldb.SBExpressionOptions() options.SetUnwindOnError(True) diff --git a/lldb/packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py b/lldb/packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py index a771e7004c9..74991999d92 100644 --- a/lldb/packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py +++ b/lldb/packages/Python/lldbsuite/test/expression_command/char/TestExprsChar.py @@ -17,29 +17,14 @@ class ExprCharTestCase(TestBase): self.main_source = "main.cpp" self.main_source_spec = lldb.SBFileSpec(self.main_source) - self.exe = os.path.join(os.getcwd(), "a.out") def do_test(self, dictionary=None): """These basic expression commands should work as expected.""" self.build(dictionary=dictionary) - target = self.dbg.CreateTarget(self.exe) - self.assertTrue(target) - - breakpoint = target.BreakpointCreateBySourceRegex( - '// Break here', self.main_source_spec) - self.assertTrue(breakpoint) - - # Launch the process, and do not stop at the entry point. - process = target.LaunchSimple( - None, None, self.get_process_working_directory()) - self.assertTrue(process) - - threads = lldbutil.get_threads_stopped_at_breakpoint( - process, breakpoint) - self.assertEqual(len(threads), 1) - - frame = threads[0].GetFrameAtIndex(0) + (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, + '// Break here', self.main_source_spec) + frame = thread.GetFrameAtIndex(0) value = frame.EvaluateExpression("foo(c)") self.assertTrue(value.IsValid()) diff --git a/lldb/packages/Python/lldbsuite/test/expression_command/fixits/TestFixIts.py b/lldb/packages/Python/lldbsuite/test/expression_command/fixits/TestFixIts.py index 418c5325ad0..4b096149e72 100644 --- a/lldb/packages/Python/lldbsuite/test/expression_command/fixits/TestFixIts.py +++ b/lldb/packages/Python/lldbsuite/test/expression_command/fixits/TestFixIts.py @@ -37,28 +37,8 @@ class ExprCommandWithFixits(TestBase): def try_expressions(self): """Test calling expressions with errors that can be fixed by the FixIts.""" - exe_name = "a.out" - exe = os.path.join(os.getcwd(), exe_name) - - target = self.dbg.CreateTarget(exe) - self.assertTrue(target, VALID_TARGET) - - breakpoint = target.BreakpointCreateBySourceRegex( - 'Stop here to evaluate expressions', self.main_source_spec) - self.assertTrue(breakpoint.GetNumLocations() > 0, VALID_BREAKPOINT) - - # Launch the process, and do not stop at the entry point. - process = target.LaunchSimple( - None, None, self.get_process_working_directory()) - - self.assertTrue(process, PROCESS_IS_VALID) - - # Frame #0 should be at our breakpoint. - threads = lldbutil.get_threads_stopped_at_breakpoint( - process, breakpoint) - - self.assertTrue(len(threads) == 1) - self.thread = threads[0] + (target, process, self.thread, bkpt) = lldbutil.run_to_source_breakpoint(self, + 'Stop here to evaluate expressions', self.main_source_spec) options = lldb.SBExpressionOptions() options.SetAutoApplyFixIts(True) |