2 Test that the breakpoint auto-continue flag works correctly.
8 import lldbsuite.test.lldbutil as lldbutil
9 from lldbsuite.test.lldbtest import *
12 class BreakpointAutoContinue(TestBase):
14 mydir = TestBase.compute_mydir(__file__)
16 NO_DEBUG_INFO_TESTCASE = True
18 def test_breakpoint_auto_continue(self):
19 """Make sure the auto continue continues with no other complications"""
21 self.simple_auto_continue()
23 def test_auto_continue_with_command(self):
24 """Add a command, make sure the command gets run"""
26 self.auto_continue_with_command()
28 def test_auto_continue_on_location(self):
29 """Set auto-continue on a location and make sure only that location continues"""
31 self.auto_continue_location()
33 def make_target_and_bkpt(self, additional_options=None, num_expected_loc=1,
34 pattern="Set a breakpoint here"):
35 exe = self.getBuildArtifact("a.out")
36 self.target = self.dbg.CreateTarget(exe)
37 self.assertTrue(self.target.IsValid(), "Target is not valid")
39 extra_options_txt = "--auto-continue 1 "
40 if additional_options:
41 extra_options_txt += additional_options
42 bpno = lldbutil.run_break_set_by_source_regexp(self, pattern,
43 extra_options = extra_options_txt,
44 num_expected_locations = num_expected_loc)
47 def launch_it (self, expected_state):
48 error = lldb.SBError()
49 launch_info = lldb.SBLaunchInfo(None)
50 launch_info.SetWorkingDirectory(self.get_process_working_directory())
52 process = self.target.Launch(launch_info, error)
53 self.assertTrue(error.Success(), "Launch failed.")
55 state = process.GetState()
56 self.assertEqual(state, expected_state, "Didn't get expected state")
60 def simple_auto_continue(self):
61 bpno = self.make_target_and_bkpt()
62 process = self.launch_it(lldb.eStateExited)
64 bkpt = self.target.FindBreakpointByID(bpno)
65 self.assertEqual(bkpt.GetHitCount(), 2, "Should have run through the breakpoint twice")
67 def auto_continue_with_command(self):
68 bpno = self.make_target_and_bkpt("-N BKPT -C 'break modify --auto-continue 0 BKPT'")
69 process = self.launch_it(lldb.eStateStopped)
70 state = process.GetState()
71 self.assertEqual(state, lldb.eStateStopped, "Process should be stopped")
72 bkpt = self.target.FindBreakpointByID(bpno)
73 threads = lldbutil.get_threads_stopped_at_breakpoint(process, bkpt)
74 self.assertEqual(len(threads), 1, "There was a thread stopped at our breakpoint")
75 self.assertEqual(bkpt.GetHitCount(), 2, "Should have hit the breakpoint twice")
77 def auto_continue_location(self):
78 bpno = self.make_target_and_bkpt(pattern="Set a[^ ]* breakpoint here", num_expected_loc=2)
79 bkpt = self.target.FindBreakpointByID(bpno)
80 bkpt.SetAutoContinue(False)
82 loc = lldb.SBBreakpointLocation()
84 func_name = bkpt.location[i].GetAddress().function.name
85 if func_name == "main":
86 loc = bkpt.location[i]
88 self.assertTrue(loc.IsValid(), "Didn't find a location in main")
89 loc.SetAutoContinue(True)
91 process = self.launch_it(lldb.eStateStopped)
93 threads = lldbutil.get_threads_stopped_at_breakpoint(process, bkpt)
94 self.assertEqual(len(threads), 1, "Didn't get one thread stopped at our breakpoint")
95 func_name = threads[0].frame[0].function.name
96 self.assertEqual(func_name, "call_me")