summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2016-02-02 10:40:56 +0000
committerPavel Labath <labath@google.com>2016-02-02 10:40:56 +0000
commitefd04a6c755af24e0909f42f60ea1cc671840310 (patch)
tree072900e53fc2eabf038de42d330e925f98923658 /lldb/packages/Python/lldbsuite
parentb618a985821ffcdf65b84eec5f3d50677efef776 (diff)
downloadbcm5719-llvm-efd04a6c755af24e0909f42f60ea1cc671840310.tar.gz
bcm5719-llvm-efd04a6c755af24e0909f42f60ea1cc671840310.zip
Fix single-stepping onto a breakpoint
Summary: r259344 introduced a bug, where we fail to perform a single step, when the instruction we are stepping onto contains a breakpoint which is not valid for this thread. This fixes the problem and add a test case. Reviewers: tberghammer, emaste Subscribers: abhishek.aggarwal, lldb-commits, emaste Differential Revision: http://reviews.llvm.org/D16767 llvm-svn: 259488
Diffstat (limited to 'lldb/packages/Python/lldbsuite')
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py92
1 files changed, 67 insertions, 25 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py
index 7f5e5adb9b9..d2bd9f2812d 100644
--- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py
@@ -1,5 +1,5 @@
"""
-Test continue from a breakpoint when there is a breakpoint on the next instruction also.
+Test that we handle breakpoints on consecutive instructions correctly.
"""
from __future__ import print_function
@@ -15,44 +15,86 @@ class ConsecutiveBreakpointsTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
- def test (self):
- self.build ()
- self.consecutive_breakpoints_tests()
-
- def consecutive_breakpoints_tests(self):
+ def prepare_test(self):
+ self.build()
exe = os.path.join (os.getcwd(), "a.out")
# Create a target by the debugger.
- target = self.dbg.CreateTarget(exe)
- self.assertTrue(target, VALID_TARGET)
+ self.target = self.dbg.CreateTarget(exe)
+ self.assertTrue(self.target, VALID_TARGET)
- breakpoint1 = target.BreakpointCreateBySourceRegex("Set breakpoint here", lldb.SBFileSpec("main.cpp"))
- self.assertTrue(breakpoint1 and
- breakpoint1.GetNumLocations() == 1,
- VALID_BREAKPOINT)
+ breakpoint1 = self.target.BreakpointCreateBySourceRegex("Set breakpoint here", lldb.SBFileSpec("main.cpp"))
+ self.assertTrue(breakpoint1 and breakpoint1.GetNumLocations() == 1, VALID_BREAKPOINT)
# Now launch the process, and do not stop at entry point.
- process = target.LaunchSimple (None, None, self.get_process_working_directory())
- self.assertTrue(process, PROCESS_IS_VALID)
+ self.process = self.target.LaunchSimple (None, None, self.get_process_working_directory())
+ self.assertIsNotNone(self.process, PROCESS_IS_VALID)
# We should be stopped at the first breakpoint
- thread = lldbutil.get_one_thread_stopped_at_breakpoint(process, breakpoint1)
- self.assertIsNotNone(thread, "Expected one thread to be stopped at breakpoint 1")
+ self.thread = lldbutil.get_one_thread_stopped_at_breakpoint(self.process, breakpoint1)
+ self.assertIsNotNone(self.thread, "Expected one thread to be stopped at breakpoint 1")
# Set breakpoint to the next instruction
- frame = thread.GetFrameAtIndex(0)
+ frame = self.thread.GetFrameAtIndex(0)
address = frame.GetPCAddress()
- instructions = target.ReadInstructions(address, 2)
+ instructions = self.target.ReadInstructions(address, 2)
self.assertTrue(len(instructions) == 2)
- address = instructions[1].GetAddress()
+ self.bkpt_address = instructions[1].GetAddress()
+ self.breakpoint2 = self.target.BreakpointCreateByAddress(self.bkpt_address.GetLoadAddress(self.target))
+ self.assertTrue(self.breakpoint2 and self.breakpoint2.GetNumLocations() == 1, VALID_BREAKPOINT)
+
+ def finish_test(self):
+ # Run the process until termination
+ self.process.Continue()
+ self.assertEquals(self.process.GetState(), lldb.eStateExited)
- breakpoint2 = target.BreakpointCreateByAddress(address.GetLoadAddress(target))
- process.Continue()
+ @no_debug_info_test
+ def test_continue(self):
+ """Test that continue stops at the second breakpoint."""
+ self.prepare_test()
+ self.process.Continue()
+ self.assertEquals(self.process.GetState(), lldb.eStateStopped)
# We should be stopped at the second breakpoint
- thread = lldbutil.get_one_thread_stopped_at_breakpoint(process, breakpoint2)
- self.assertIsNotNone(thread, "Expected one thread to be stopped at breakpoint 2")
+ self.thread = lldbutil.get_one_thread_stopped_at_breakpoint(self.process, self.breakpoint2)
+ self.assertIsNotNone(self.thread, "Expected one thread to be stopped at breakpoint 2")
- # Run the process until termination
- process.Continue()
+ self.finish_test()
+
+ @no_debug_info_test
+ def test_single_step(self):
+ """Test that single step stops at the second breakpoint."""
+ self.prepare_test()
+
+ step_over = False
+ self.thread.StepInstruction(step_over)
+
+ self.assertEquals(self.process.GetState(), lldb.eStateStopped)
+ self.assertEquals(self.thread.GetFrameAtIndex(0).GetPCAddress().GetLoadAddress(self.target),
+ self.bkpt_address.GetLoadAddress(self.target))
+ self.thread = lldbutil.get_one_thread_stopped_at_breakpoint(self.process, self.breakpoint2)
+ self.assertIsNotNone(self.thread, "Expected one thread to be stopped at breakpoint 2")
+
+ self.finish_test()
+
+ @no_debug_info_test
+ def test_single_step_thread_specific(self):
+ """Test that single step stops, even though the second breakpoint is not valid."""
+ self.prepare_test()
+
+ # Choose a thread other than the current one. A non-existing thread is fine.
+ thread_index = self.process.GetNumThreads()+1
+ self.assertFalse(self.process.GetThreadAtIndex(thread_index).IsValid())
+ self.breakpoint2.SetThreadIndex(thread_index)
+
+ step_over = False
+ self.thread.StepInstruction(step_over)
+
+ self.assertEquals(self.process.GetState(), lldb.eStateStopped)
+ self.assertEquals(self.thread.GetFrameAtIndex(0).GetPCAddress().GetLoadAddress(self.target),
+ self.bkpt_address.GetLoadAddress(self.target))
+ self.assertEquals(self.thread.GetStopReason(), lldb.eStopReasonPlanComplete,
+ "Stop reason should be 'plan complete'")
+
+ self.finish_test()
OpenPOWER on IntegriCloud