@@ -166,7 +166,7 @@ def __init__(
166
166
self .initialized = False
167
167
self .frame_scopes = {}
168
168
self .init_commands = init_commands
169
- self .resolved_breakpoints = set ([])
169
+ self .resolved_breakpoints = {}
170
170
171
171
@classmethod
172
172
def encode_content (cls , s : str ) -> bytes :
@@ -297,6 +297,9 @@ def _handle_recv_packet(self, packet: Optional[ProtocolMessage]) -> bool:
297
297
# and 'progressEnd' events. Keep these around in case test
298
298
# cases want to verify them.
299
299
self .progress_events .append (packet )
300
+ elif event == "breakpoint" :
301
+ # Breakpoint events are sent when a breakpoint is resolved
302
+ self ._update_verified_breakpoints ([body ["breakpoint" ]])
300
303
301
304
elif packet_type == "response" :
302
305
if packet ["command" ] == "disconnect" :
@@ -310,13 +313,11 @@ def _process_continued(self, all_threads_continued: bool):
310
313
if all_threads_continued :
311
314
self .thread_stop_reasons = {}
312
315
313
- def _update_verified_breakpoints (self , breakpoints ):
316
+ def _update_verified_breakpoints (self , breakpoints : list [ Event ] ):
314
317
for breakpoint in breakpoints :
315
- if "verified" in breakpoint :
316
- if breakpoint ["verified" ]:
317
- self .resolved_breakpoints .add (str (breakpoint ["id" ]))
318
- else :
319
- self .resolved_breakpoints .discard (str (breakpoint ["id" ]))
318
+ self .resolved_breakpoints [str (breakpoint ["id" ])] = breakpoint .get (
319
+ "verified" , False
320
+ )
320
321
321
322
def send_packet (self , command_dict : Request , set_sequence = True ):
322
323
"""Take the "command_dict" python dictionary and encode it as a JSON
@@ -462,25 +463,18 @@ def wait_for_breakpoint_events(self, timeout: Optional[float] = None):
462
463
break
463
464
breakpoint_events .append (event )
464
465
465
- self ._update_verified_breakpoints (
466
- [event ["body" ]["breakpoint" ] for event in breakpoint_events ]
467
- )
468
466
return breakpoint_events
469
467
470
468
def wait_for_breakpoints_to_be_verified (
471
469
self , breakpoint_ids : list [str ], timeout : Optional [float ] = None
472
470
):
473
471
"""Wait for all breakpoints to be verified. Return all unverified breakpoints."""
474
- unresolved_breakpoints = set (breakpoint_ids )
475
- unresolved_breakpoints -= self .resolved_breakpoints
476
- while len (unresolved_breakpoints ) > 0 :
472
+ while any (id not in self .resolved_breakpoints for id in breakpoint_ids ):
477
473
breakpoint_event = self .wait_for_event ("breakpoint" , timeout = timeout )
478
474
if breakpoint_event is None :
479
475
break
480
476
481
- self ._update_verified_breakpoints ([breakpoint_event ["body" ]["breakpoint" ]])
482
- unresolved_breakpoints -= self .resolved_breakpoints
483
- return unresolved_breakpoints
477
+ return [id for id in breakpoint_ids if id not in self .resolved_breakpoints ]
484
478
485
479
def wait_for_exited (self , timeout : Optional [float ] = None ):
486
480
event_dict = self .wait_for_event ("exited" , timeout = timeout )
@@ -1042,8 +1036,8 @@ def request_setBreakpoints(self, source: Source, line_array, data=None):
1042
1036
"arguments" : args_dict ,
1043
1037
}
1044
1038
response = self .send_recv (command_dict )
1045
- breakpoints = response ["body" ][ "breakpoints" ]
1046
- self ._update_verified_breakpoints (breakpoints )
1039
+ if response ["success" ]:
1040
+ self ._update_verified_breakpoints (response [ "body" ][ " breakpoints" ] )
1047
1041
return response
1048
1042
1049
1043
def request_setExceptionBreakpoints (self , filters ):
@@ -1071,8 +1065,8 @@ def request_setFunctionBreakpoints(self, names, condition=None, hitCondition=Non
1071
1065
"arguments" : args_dict ,
1072
1066
}
1073
1067
response = self .send_recv (command_dict )
1074
- breakpoints = response ["body" ][ "breakpoints" ]
1075
- self ._update_verified_breakpoints (breakpoints )
1068
+ if response ["success" ]:
1069
+ self ._update_verified_breakpoints (response [ "body" ][ " breakpoints" ] )
1076
1070
return response
1077
1071
1078
1072
def request_dataBreakpointInfo (
0 commit comments