================
@@ -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).
+ self.verify_breakpoint_hit([foo_bp_id])
+ unique_bp_id = 1
+ # Check the breakpoints set in dap is verified
verified_breakpoint_ids = []
- unverified_breakpoint_ids = []
- for breakpoint_event in self.dap_server.wait_for_breakpoint_events():
- breakpoint = breakpoint_event["body"]["breakpoint"]
- id = breakpoint["id"]
- if breakpoint["verified"]:
- verified_breakpoint_ids.append(id)
- else:
- unverified_breakpoint_ids.append(id)
+ events = self.dap_server.wait_for_breakpoint_events()
+ for breakpoint_event in events:
+ breakpoint_event_body = breakpoint_event["body"]
+ if breakpoint_event_body["reason"] != "changed":
+ continue
+ breakpoint = breakpoint_event_body["breakpoint"]
- self.assertIn(main_bp_id, unverified_breakpoint_ids)
- self.assertIn(foo_bp_id, unverified_breakpoint_ids)
+ if "verified" in breakpoint_event_body:
+ self.assertFalse(
+ breakpoint_event_body["verified"],
+ f"Expected changed breakpoint to be verified. event:
{breakpoint_event}",
+ )
+ id = breakpoint["id"]
+ verified_breakpoint_ids.append(id)
self.assertIn(main_bp_id, verified_breakpoint_ids)
self.assertIn(foo_bp_id, verified_breakpoint_ids)
+ self.assertNotIn(unique_bp_id, verified_breakpoint_ids)
+
+ # Continue to the unique function breakpoint set from preRunCommands.
+ unique_function_stop_event = self.continue_to_next_stop()[0]
+ unique_body = unique_function_stop_event["body"]
+ self.assertEqual(unique_body["reason"], "breakpoint")
+ self.assertIn(unique_bp_id, unique_body["hitBreakpointIds"])
+
+ # Clear line and function breakpoints and exit.
+ self.dap_server.request_setFunctionBreakpoints([])
+
self.dap_server.request_setBreakpoints(Source.build(path=main_source_path), [])
----------------
DrSergei wrote:
nit: move `Source.build(path=main_source_path)` to sepatate variable and reuse
it in requests
https://github.com/llvm/llvm-project/pull/180518
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits