2 Test breakpoint commands set before we have a target
5 from __future__ import print_function
11 from lldbsuite.test.lldbtest import *
12 import lldbsuite.test.lldbutil as lldbutil
14 class BreakpointInDummyTarget (TestBase):
16 mydir = TestBase.compute_mydir(__file__)
19 """Test breakpoint set before we have a target. """
21 self.dummy_breakpoint_test()
24 # Call super's setUp().
26 # Find the line number to break inside main().
27 self.line = line_number('main.c', 'Set a breakpoint on this line.')
28 self.line2 = line_number ('main.c', 'Set another on this line.')
30 def dummy_breakpoint_test(self):
31 """Test breakpoint set before we have a target. """
33 # This should create a breakpoint with 3 locations.
34 lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line, num_expected_locations=0)
35 lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line2, num_expected_locations=0)
37 # This is the function to remove breakpoints from the dummy target
38 # to get a clean slate for the next test case.
40 self.runCmd('breakpoint delete -D -f', check=False)
41 self.runCmd('breakpoint list', check=False)
44 # Execute the cleanup function during test case tear down.
45 self.addTearDownHook(cleanup)
47 exe = os.path.join(os.getcwd(), "a.out")
48 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
50 # The breakpoint list should show 3 locations.
51 self.expect("breakpoint list -f", "Breakpoint locations shown correctly",
52 substrs = ["1: file = 'main.c', line = %d, exact_match = 0, locations = 1" % self.line,
53 "2: file = 'main.c', line = %d, exact_match = 0, locations = 1" % self.line2])
56 self.runCmd("run", RUN_SUCCEEDED)
59 self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT,
60 substrs = ["stop reason = breakpoint 1."])
62 # Continue the program, there should be another stop.
63 self.runCmd("process continue")
66 self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT,
67 substrs = ["stop reason = breakpoint 2."])