https://github.com/kusmour created https://github.com/llvm/llvm-project/pull/137278
This patch makes the `request_attach` wait for events `process` and `initialized` just like `request_launch`. This ensure the DAP session can move forward somewhat correctly. Recently `TestDap_attach.test_terminate_commands` became flaky. It's hitting: ``` lldbsuite/test/tools/lldb-dap/dap_server.py", line 350, in send_recv raise ValueError(desc) ValueError: no response for "disconnect" ``` I took a look at the DAP msg from that test case and noticed: - It's not using the regular attaching, instead it's using the attachCommands to launch debug the binary and it will stop at entry. - The initialized event returned after the disconnect request. Which means lldb-dap didn't really get ready yet. NOTE: The `dap_server.py` is doing things to mimic the VSCode (or other dap clients) but it had some assumptions. For example, it's still missing the `configurationDone` request and response because it relies on a continue action to trigger the `configurationDone` request. >From 810c3ed54b2d567e90a8fa007a4eee9fd9c3f8a2 Mon Sep 17 00:00:00 2001 From: Wanyi Ye <wa...@meta.com> Date: Thu, 24 Apr 2025 13:30:26 -0700 Subject: [PATCH] [lldb-dap] Fix TestDap_attach.py flakiness --- .../Python/lldbsuite/test/tools/lldb-dap/dap_server.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py index dadf6b1f8774c..20f5286da3203 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py @@ -612,7 +612,13 @@ def request_attach( if gdbRemoteHostname is not None: args_dict["gdb-remote-hostname"] = gdbRemoteHostname command_dict = {"command": "attach", "type": "request", "arguments": args_dict} - return self.send_recv(command_dict) + response = self.send_recv(command_dict) + + if response["success"]: + # Wait for a 'process' and 'initialized' event in any order + self.wait_for_event(filter=["process", "initialized"]) + self.wait_for_event(filter=["process", "initialized"]) + return response def request_breakpointLocations( self, file_path, line, end_line=None, column=None, end_column=None _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits