|
2 | 2 | Test lldb-dap setBreakpoints request
|
3 | 3 | """
|
4 | 4 |
|
5 |
| - |
6 | 5 | import dap_server
|
7 | 6 | from lldbsuite.test.decorators import *
|
8 | 7 | from lldbsuite.test.lldbtest import *
|
|
12 | 11 |
|
13 | 12 |
|
14 | 13 | class TestDAP_breakpointEvents(lldbdap_testcase.DAPTestCaseBase):
|
15 |
| - @skipIfWindows |
16 | 14 | @skipUnlessDarwin
|
17 |
| - @expectedFailureAll(macos_version=[">=", "13.0"]) |
18 | 15 | def test_breakpoint_events(self):
|
19 | 16 | """
|
20 | 17 | This test sets a breakpoint in a shared library and runs and stops
|
@@ -63,70 +60,73 @@ def test_breakpoint_events(self):
|
63 | 60 | response = self.dap_server.request_setBreakpoints(
|
64 | 61 | main_source_path, [main_bp_line]
|
65 | 62 | )
|
66 |
| - if response: |
67 |
| - breakpoints = response["body"]["breakpoints"] |
68 |
| - for breakpoint in breakpoints: |
69 |
| - main_bp_id = breakpoint["id"] |
70 |
| - dap_breakpoint_ids.append("%i" % (main_bp_id)) |
71 |
| - # line = breakpoint['line'] |
72 |
| - self.assertTrue( |
73 |
| - breakpoint["verified"], "expect main breakpoint to be verified" |
74 |
| - ) |
| 63 | + self.assertTrue(response) |
| 64 | + breakpoints = response["body"]["breakpoints"] |
| 65 | + for breakpoint in breakpoints: |
| 66 | + main_bp_id = breakpoint["id"] |
| 67 | + dap_breakpoint_ids.append("%i" % (main_bp_id)) |
| 68 | + self.assertTrue( |
| 69 | + breakpoint["verified"], "expect main breakpoint to be verified" |
| 70 | + ) |
75 | 71 |
|
76 | 72 | response = self.dap_server.request_setBreakpoints(
|
77 | 73 | foo_source_path, [foo_bp1_line]
|
78 | 74 | )
|
79 |
| - if response: |
80 |
| - breakpoints = response["body"]["breakpoints"] |
81 |
| - for breakpoint in breakpoints: |
82 |
| - foo_bp_id = breakpoint["id"] |
83 |
| - dap_breakpoint_ids.append("%i" % (foo_bp_id)) |
84 |
| - self.assertFalse( |
85 |
| - breakpoint["verified"], "expect foo breakpoint to not be verified" |
86 |
| - ) |
| 75 | + self.assertTrue(response) |
| 76 | + breakpoints = response["body"]["breakpoints"] |
| 77 | + for breakpoint in breakpoints: |
| 78 | + foo_bp_id = breakpoint["id"] |
| 79 | + dap_breakpoint_ids.append("%i" % (foo_bp_id)) |
| 80 | + self.assertFalse( |
| 81 | + breakpoint["verified"], "expect foo breakpoint to not be verified" |
| 82 | + ) |
87 | 83 |
|
88 | 84 | # Get the stop at the entry point
|
89 | 85 | self.continue_to_next_stop()
|
90 | 86 |
|
91 | 87 | # We are now stopped at the entry point to the program. Shared
|
92 |
| - # libraries are not loaded yet (at least on macOS they aren't) and any |
93 |
| - # breakpoints set in foo.cpp should not be resolved. |
| 88 | + # libraries are not loaded yet (at least on macOS they aren't) and only |
| 89 | + # the breakpoint in the main executable should be resolved. |
| 90 | + self.assertEqual(len(self.dap_server.breakpoint_events), 1) |
| 91 | + event = self.dap_server.breakpoint_events[0] |
| 92 | + body = event["body"] |
94 | 93 | self.assertEqual(
|
95 |
| - len(self.dap_server.breakpoint_events), |
96 |
| - 0, |
97 |
| - "no breakpoint events when stopped at entry point", |
| 94 | + body["reason"], "changed", "breakpoint event should say changed" |
98 | 95 | )
|
| 96 | + breakpoint = body["breakpoint"] |
| 97 | + self.assertEqual(breakpoint["id"], main_bp_id) |
| 98 | + self.assertTrue(breakpoint["verified"], "main breakpoint should be resolved") |
| 99 | + |
| 100 | + # Clear the list of breakpoint events so we don't see this one again. |
| 101 | + self.dap_server.breakpoint_events.clear() |
99 | 102 |
|
100 | 103 | # Continue to the breakpoint
|
101 | 104 | self.continue_to_breakpoints(dap_breakpoint_ids)
|
102 | 105 |
|
103 |
| - # Make sure we only get an event for the breakpoint we set via a call |
104 |
| - # to self.dap_server.request_setBreakpoints(...), not the breakpoint |
105 |
| - # we set with with a LLDB command in preRunCommands. |
106 |
| - self.assertEqual( |
107 |
| - len(self.dap_server.breakpoint_events), |
108 |
| - 1, |
109 |
| - "make sure we got a breakpoint event", |
110 |
| - ) |
111 |
| - event = self.dap_server.breakpoint_events[0] |
112 |
| - # Verify the details of the breakpoint changed notification. |
113 |
| - body = event["body"] |
114 |
| - self.assertEqual( |
115 |
| - body["reason"], "changed", "breakpoint event is says breakpoint is changed" |
116 |
| - ) |
117 |
| - breakpoint = body["breakpoint"] |
118 |
| - self.assertTrue( |
119 |
| - breakpoint["verified"], "breakpoint event is says it is verified" |
120 |
| - ) |
121 |
| - self.assertEqual( |
122 |
| - breakpoint["id"], |
123 |
| - foo_bp_id, |
124 |
| - "breakpoint event is for breakpoint %i" % (foo_bp_id), |
125 |
| - ) |
126 |
| - self.assertTrue( |
127 |
| - "line" in breakpoint and breakpoint["line"] > 0, |
128 |
| - "breakpoint event is has a line number", |
129 |
| - ) |
130 |
| - self.assertNotIn( |
131 |
| - "source", breakpoint, "breakpoint event should not return a source object" |
132 |
| - ) |
| 106 | + # When the process launches, we first expect to see both the main and |
| 107 | + # foo breakpoint as unresolved. |
| 108 | + for event in self.dap_server.breakpoint_events[:2]: |
| 109 | + body = event["body"] |
| 110 | + self.assertEqual( |
| 111 | + body["reason"], "changed", "breakpoint event should say changed" |
| 112 | + ) |
| 113 | + breakpoint = body["breakpoint"] |
| 114 | + self.assertIn(str(breakpoint["id"]), dap_breakpoint_ids) |
| 115 | + self.assertFalse(breakpoint["verified"], "breakpoint should be unresolved") |
| 116 | + |
| 117 | + # Then, once the dynamic loader has given us a load address, they |
| 118 | + # should show up as resolved again. |
| 119 | + for event in self.dap_server.breakpoint_events[3:]: |
| 120 | + body = event["body"] |
| 121 | + self.assertEqual( |
| 122 | + body["reason"], "changed", "breakpoint event should say changed" |
| 123 | + ) |
| 124 | + breakpoint = body["breakpoint"] |
| 125 | + self.assertIn(str(breakpoint["id"]), dap_breakpoint_ids) |
| 126 | + self.assertTrue(breakpoint["verified"], "breakpoint should be resolved") |
| 127 | + self.assertNotIn( |
| 128 | + "source", |
| 129 | + breakpoint, |
| 130 | + "breakpoint event should not return a source object", |
| 131 | + ) |
| 132 | + self.assertIn("line", breakpoint, "breakpoint event should have line") |
0 commit comments