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 99fcc423894b6..6d9ab770684f1 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 @@ -380,6 +380,17 @@ def wait_for_event(self, filter=None, timeout=None): ) return None + def wait_for_events(self, events, timeout=None): + """Wait for a list of events in `events` in any order. + Return the events not hit before the timeout expired""" + events = events[:] # Make a copy to avoid modifying the input + while events: + event_dict = self.wait_for_event(filter=events, timeout=timeout) + if event_dict is None: + break + events.remove(event_dict["event"]) + return events + def wait_for_stopped(self, timeout=None): stopped_events = [] stopped_event = self.wait_for_event( @@ -618,7 +629,11 @@ 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"]: + self.wait_for_events(["process", "initialized"]) + return response def request_breakpointLocations( self, file_path, line, end_line=None, column=None, end_column=None @@ -872,9 +887,7 @@ def request_launch( 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"]) + self.wait_for_events(["process", "initialized"]) return response def request_next(self, threadId, granularity="statement"): diff --git a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py index b9fbf2c8d14f9..dcdfada2ff4c2 100644 --- a/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py +++ b/lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py @@ -93,7 +93,6 @@ def cleanup(): self.set_and_hit_breakpoint(continueToExit=True) @skipUnlessDarwin - @skipIfDarwin @skipIfNetBSD # Hangs on NetBSD as well def test_by_name_waitFor(self): """ @@ -114,7 +113,6 @@ def test_by_name_waitFor(self): self.attach(program=program, waitFor=True) self.set_and_hit_breakpoint(continueToExit=True) - @skipIfDarwin @skipIfNetBSD # Hangs on NetBSD as well def test_commands(self): """ @@ -201,7 +199,6 @@ def test_commands(self): self.verify_commands("exitCommands", output, exitCommands) self.verify_commands("terminateCommands", output, terminateCommands) - @skipIfDarwin @skipIfNetBSD # Hangs on NetBSD as well @skipIf( archs=["arm", "aarch64"]