0bf82c4a310a7bbb72520ca8b82fe3795a9e8c5a
[openbsd] /
1 """
2 Test require hardware breakpoints.
3 """
4
5
6 import lldb
7 from lldbsuite.test.decorators import *
8 from lldbsuite.test.lldbtest import *
9 from lldbsuite.test import lldbutil
10
11
12 class BreakpointLocationsTestCase(TestBase):
13     NO_DEBUG_INFO_TESTCASE = True
14     mydir = TestBase.compute_mydir(__file__)
15
16     def test_breakpoint(self):
17         """Test regular breakpoints when hardware breakpoints are required."""
18         self.build()
19         exe = self.getBuildArtifact("a.out")
20         target = self.dbg.CreateTarget(exe)
21
22         self.runCmd("settings set target.require-hardware-breakpoint true")
23
24         breakpoint = target.BreakpointCreateByLocation("main.c", 1)
25         self.assertTrue(breakpoint.IsHardware())
26
27     @skipIfWindows
28     @expectedFailureAll(archs="aarch64", oslist="linux",
29                         bugnumber="https://bugs.llvm.org/show_bug.cgi?id=44055")
30     def test_step_range(self):
31         """Test stepping when hardware breakpoints are required."""
32         self.build()
33
34         _, _, thread, _ = lldbutil.run_to_line_breakpoint(
35             self, lldb.SBFileSpec("main.c"), 1)
36
37         self.runCmd("settings set target.require-hardware-breakpoint true")
38
39         # Ensure we fail in the interpreter.
40         self.expect("thread step-in")
41         self.expect("thread step-in", error=True)
42
43         # Ensure we fail when stepping through the API.
44         error = lldb.SBError()
45         thread.StepInto('', 4, error)
46         self.assertTrue(error.Fail())
47         self.assertTrue("Could not create hardware breakpoint for thread plan"
48                         in error.GetCString())
49
50     @skipIfWindows
51     @expectedFailureAll(archs="aarch64", oslist="linux",
52                         bugnumber="https://bugs.llvm.org/show_bug.cgi?id=44055")
53     def test_step_out(self):
54         """Test stepping out when hardware breakpoints are required."""
55         self.build()
56
57         _, _, thread, _ = lldbutil.run_to_line_breakpoint(
58             self, lldb.SBFileSpec("main.c"), 1)
59
60         self.runCmd("settings set target.require-hardware-breakpoint true")
61
62         # Ensure this fails in the command interpreter.
63         self.expect("thread step-out", error=True)
64
65         # Ensure we fail when stepping through the API.
66         error = lldb.SBError()
67         thread.StepOut(error)
68         self.assertTrue(error.Fail())
69         self.assertTrue("Could not create hardware breakpoint for thread plan"
70                         in error.GetCString())
71
72     @skipIfWindows
73     @expectedFailureAll(archs="aarch64", oslist="linux",
74                         bugnumber="https://bugs.llvm.org/show_bug.cgi?id=44055")
75     def test_step_over(self):
76         """Test stepping over when hardware breakpoints are required."""
77         self.build()
78
79         _, _, thread, _ = lldbutil.run_to_line_breakpoint(
80             self, lldb.SBFileSpec("main.c"), 7)
81
82         self.runCmd("settings set target.require-hardware-breakpoint true")
83
84         # Step over doesn't fail immediately but fails later on.
85         self.expect(
86             "thread step-over",
87             error=True,
88             substrs=[
89                 'error: Could not create hardware breakpoint for thread plan.'
90             ])
91
92     @skipIfWindows
93     @expectedFailureAll(archs="aarch64", oslist="linux",
94                         bugnumber="https://bugs.llvm.org/show_bug.cgi?id=44055")
95     def test_step_until(self):
96         """Test stepping until when hardware breakpoints are required."""
97         self.build()
98
99         _, _, thread, _ = lldbutil.run_to_line_breakpoint(
100             self, lldb.SBFileSpec("main.c"), 7)
101
102         self.runCmd("settings set target.require-hardware-breakpoint true")
103
104         self.expect("thread until 5", error=True)
105
106         # Ensure we fail when stepping through the API.
107         error = thread.StepOverUntil(lldb.SBFrame(), lldb.SBFileSpec(), 5)
108         self.assertTrue(error.Fail())
109         self.assertTrue("Could not create hardware breakpoint for thread plan"
110                         in error.GetCString())