[Lldb-commits] [lldb] [lldb-dap] Fix the breakpoint events test. (PR #180518)
Sergei Druzhkov via lldb-commits
lldb-commits at lists.llvm.org
Mon Feb 9 05:26:48 PST 2026
================
@@ -51,54 +43,80 @@ def test_breakpoint_events(self):
# registered and marked with a special keyword to ensure we deliver
# breakpoint events for these breakpoints but not for ones that are not
# set via the command interpreter.
- bp_command = "breakpoint set --file foo.cpp --line %u" % (foo_bp2_line)
- self.build_and_launch(program, preRunCommands=[bp_command])
- main_bp_id = 0
- foo_bp_id = 0
- # Set breakpoints and verify that they got set correctly
+
+ # Set preCommand breakpoint
+ func_unique_function_name = "unique_function_name"
+ bp_command = f"breakpoint set --name {func_unique_function_name}"
+ launch_seq = self.build_and_launch(program, preRunCommands=[bp_command])
+ self.dap_server.wait_for_event(["initialized"])
dap_breakpoint_ids = []
+
+ # We set the breakpoints after initialized event.
+ # Set and verify new line breakpoint.
response = self.dap_server.request_setBreakpoints(
Source.build(path=main_source_path), [main_bp_line]
)
self.assertTrue(response["success"])
breakpoints = response["body"]["breakpoints"]
- for breakpoint in breakpoints:
- main_bp_id = breakpoint["id"]
- dap_breakpoint_ids.append(main_bp_id)
- self.assertTrue(
- breakpoint["verified"], "expect main breakpoint to be verified"
- )
-
- response = self.dap_server.request_setBreakpoints(
- Source.build(path=foo_source_path), [foo_bp1_line]
+ self.assertEqual(len(breakpoints), 1, "Expects only one line breakpoint")
+ main_breakpoint = breakpoints[0]
+ main_bp_id = main_breakpoint["id"]
+ dap_breakpoint_ids.append(main_bp_id)
+ self.assertTrue(
+ main_breakpoint["verified"], "Expects main breakpoint to be verified"
)
+
+ # Set and verify new function breakpoint.
+ func_foo = "foo"
+ response = self.dap_server.request_setFunctionBreakpoints([func_foo])
self.assertTrue(response["success"])
breakpoints = response["body"]["breakpoints"]
- for breakpoint in breakpoints:
- foo_bp_id = breakpoint["id"]
- dap_breakpoint_ids.append(foo_bp_id)
- self.assertFalse(
- breakpoint["verified"], "expect foo breakpoint to not be verified"
- )
+ self.assertEqual(len(breakpoints), 1, "Expects only one function breakpoint")
+ func_foo_breakpoint = breakpoints[0]
+ foo_bp_id = func_foo_breakpoint["id"]
+ dap_breakpoint_ids.append(foo_bp_id)
+ self.assertFalse(
+ func_foo_breakpoint["verified"],
+ "Expects unique function breakpoint to not be verified",
+ )
- # Flush the breakpoint events.
- self.dap_server.wait_for_breakpoint_events()
+ self.dap_server.request_configurationDone()
+ launch_response = self.dap_server.receive_response(launch_seq)
+ self.assertIsNotNone(launch_response)
+ self.assertTrue(launch_response["success"])
- # Continue to the breakpoint
- self.continue_to_breakpoints(dap_breakpoint_ids)
+ # wait for the next stop (breakpoint foo).
----------------
DrSergei wrote:
nit: Start from capital letter
https://github.com/llvm/llvm-project/pull/180518
More information about the lldb-commits
mailing list