Skip to content

Commit e747925

Browse files
committed
[lldb-dap] Improve the process & initialized event check
1 parent 79f5452 commit e747925

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,17 @@ def wait_for_event(self, filter=None, timeout=None):
380380
)
381381
return None
382382

383+
def wait_for_events(self, events, timeout=None):
384+
"""Wait for a list of events in `events` in any order.
385+
Return the events not hit before the timeout expired"""
386+
events = events[:] # Make a copy to avoid modifying the input
387+
while events:
388+
event_dict = self.wait_for_event(filter=events, timeout=timeout)
389+
if event_dict is None:
390+
break
391+
events.remove(event_dict["event"])
392+
return events
393+
383394
def wait_for_stopped(self, timeout=None):
384395
stopped_events = []
385396
stopped_event = self.wait_for_event(
@@ -621,9 +632,7 @@ def request_attach(
621632
response = self.send_recv(command_dict)
622633

623634
if response["success"]:
624-
# Wait for a 'process' and 'initialized' event in any order
625-
self.wait_for_event(filter=["process", "initialized"])
626-
self.wait_for_event(filter=["process", "initialized"])
635+
self.wait_for_events(["process", "initialized"])
627636
return response
628637

629638
def request_breakpointLocations(
@@ -878,9 +887,7 @@ def request_launch(
878887
response = self.send_recv(command_dict)
879888

880889
if response["success"]:
881-
# Wait for a 'process' and 'initialized' event in any order
882-
self.wait_for_event(filter=["process", "initialized"])
883-
self.wait_for_event(filter=["process", "initialized"])
890+
self.wait_for_events(["process", "initialized"])
884891
return response
885892

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

0 commit comments

Comments
 (0)