Skip to content

Commit aa7540d

Browse files
committed
[lldb-dap] Improve the process & initialized event check
1 parent 0236f67 commit aa7540d

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,15 @@ def wait_for_event(self, filter=None, timeout=None):
374374
)
375375
return None
376376

377+
def wait_for_events(self, events, timeout=None):
378+
"""Wait for a list of events in `events` in any order.
379+
Return the events not hit before the timeout expired"""
380+
events = events[:] # Make a copy to avoid modifying the input
381+
while events:
382+
event = self.wait_for_event(filter=events, timeout=timeout)
383+
events.remove(event["event"])
384+
return events
385+
377386
def wait_for_stopped(self, timeout=None):
378387
stopped_events = []
379388
stopped_event = self.wait_for_event(
@@ -615,9 +624,7 @@ def request_attach(
615624
response = self.send_recv(command_dict)
616625

617626
if response["success"]:
618-
# Wait for a 'process' and 'initialized' event in any order
619-
self.wait_for_event(filter=["process", "initialized"])
620-
self.wait_for_event(filter=["process", "initialized"])
627+
self.wait_for_events(["process", "initialized"])
621628
return response
622629

623630
def request_breakpointLocations(
@@ -872,9 +879,7 @@ def request_launch(
872879
response = self.send_recv(command_dict)
873880

874881
if response["success"]:
875-
# Wait for a 'process' and 'initialized' event in any order
876-
self.wait_for_event(filter=["process", "initialized"])
877-
self.wait_for_event(filter=["process", "initialized"])
882+
self.wait_for_events(["process", "initialized"])
878883
return response
879884

880885
def request_next(self, threadId, granularity="statement"):

0 commit comments

Comments
 (0)