]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/breakpoint/dummy_target_breakpoints/TestBreakpointsWithNoTargets.py
Vendor import of lldb trunk r256945:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / breakpoint / dummy_target_breakpoints / TestBreakpointsWithNoTargets.py
1 """
2 Test breakpoint commands set before we have a target
3 """
4
5 from __future__ import print_function
6
7
8
9 import os, time
10 import lldb
11 from lldbsuite.test.lldbtest import *
12 import lldbsuite.test.lldbutil as lldbutil
13
14 class BreakpointInDummyTarget (TestBase):
15
16     mydir = TestBase.compute_mydir(__file__)
17
18     def test(self):
19         """Test breakpoint set before we have a target. """
20         self.build()
21         self.dummy_breakpoint_test()
22
23     def setUp(self):
24         # Call super's setUp().
25         TestBase.setUp(self)
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.')
29
30     def dummy_breakpoint_test(self):
31         """Test breakpoint set before we have a target. """
32
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)
36         
37         # This is the function to remove breakpoints from the dummy target
38         # to get a clean slate for the next test case.
39         def cleanup():
40             self.runCmd('breakpoint delete -D -f', check=False)
41             self.runCmd('breakpoint list', check=False)
42
43
44         # Execute the cleanup function during test case tear down.
45         self.addTearDownHook(cleanup)
46         
47         exe = os.path.join(os.getcwd(), "a.out")
48         self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
49
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])
54
55         # Run the program.
56         self.runCmd("run", RUN_SUCCEEDED)
57
58         # Stopped once.
59         self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT,
60             substrs = ["stop reason = breakpoint 1."])
61
62         # Continue the program, there should be another stop.
63         self.runCmd("process continue")
64
65         # Stopped again.
66         self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT,
67             substrs = ["stop reason = breakpoint 2."])