2 Test that we handle breakpoints on consecutive instructions correctly.
9 from lldbsuite.test.decorators import *
10 from lldbsuite.test.lldbtest import *
11 from lldbsuite.test import lldbutil
14 class ConsecutiveBreakpointsTestCase(TestBase):
16 mydir = TestBase.compute_mydir(__file__)
18 def prepare_test(self):
21 (self.target, self.process, self.thread, bkpt) = lldbutil.run_to_source_breakpoint(
22 self, "Set breakpoint here", lldb.SBFileSpec("main.cpp"))
24 # Set breakpoint to the next instruction
25 frame = self.thread.GetFrameAtIndex(0)
27 address = frame.GetPCAddress()
28 instructions = self.target.ReadInstructions(address, 2)
29 self.assertTrue(len(instructions) == 2)
30 self.bkpt_address = instructions[1].GetAddress()
31 self.breakpoint2 = self.target.BreakpointCreateByAddress(
32 self.bkpt_address.GetLoadAddress(self.target))
34 self.breakpoint2 and self.breakpoint2.GetNumLocations() == 1,
37 def finish_test(self):
38 # Run the process until termination
39 self.process.Continue()
40 self.assertEquals(self.process.GetState(), lldb.eStateExited)
43 def test_continue(self):
44 """Test that continue stops at the second breakpoint."""
47 self.process.Continue()
48 self.assertEquals(self.process.GetState(), lldb.eStateStopped)
49 # We should be stopped at the second breakpoint
50 self.thread = lldbutil.get_one_thread_stopped_at_breakpoint(
51 self.process, self.breakpoint2)
54 "Expected one thread to be stopped at breakpoint 2")
59 def test_single_step(self):
60 """Test that single step stops at the second breakpoint."""
64 self.thread.StepInstruction(step_over)
66 self.assertEquals(self.process.GetState(), lldb.eStateStopped)
68 self.thread.GetFrameAtIndex(0).GetPCAddress().GetLoadAddress(
69 self.target), self.bkpt_address.GetLoadAddress(
71 self.thread = lldbutil.get_one_thread_stopped_at_breakpoint(
72 self.process, self.breakpoint2)
75 "Expected one thread to be stopped at breakpoint 2")
80 def test_single_step_thread_specific(self):
81 """Test that single step stops, even though the second breakpoint is not valid."""
84 # Choose a thread other than the current one. A non-existing thread is
86 thread_index = self.process.GetNumThreads() + 1
87 self.assertFalse(self.process.GetThreadAtIndex(thread_index).IsValid())
88 self.breakpoint2.SetThreadIndex(thread_index)
91 self.thread.StepInstruction(step_over)
93 self.assertEquals(self.process.GetState(), lldb.eStateStopped)
95 self.thread.GetFrameAtIndex(0).GetPCAddress().GetLoadAddress(
96 self.target), self.bkpt_address.GetLoadAddress(
99 self.thread.GetStopReason(),
100 lldb.eStopReasonPlanComplete,
101 "Stop reason should be 'plan complete'")