@@ -166,7 +166,7 @@ def __init__(
166166 self .initialized = False
167167 self .frame_scopes = {}
168168 self .init_commands = init_commands
169- self .resolved_breakpoints = set ([])
169+ self .resolved_breakpoints = {}
170170
171171 @classmethod
172172 def encode_content (cls , s : str ) -> bytes :
@@ -297,6 +297,9 @@ def _handle_recv_packet(self, packet: Optional[ProtocolMessage]) -> bool:
297297 # and 'progressEnd' events. Keep these around in case test
298298 # cases want to verify them.
299299 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" ]])
300303
301304 elif packet_type == "response" :
302305 if packet ["command" ] == "disconnect" :
@@ -310,13 +313,11 @@ def _process_continued(self, all_threads_continued: bool):
310313 if all_threads_continued :
311314 self .thread_stop_reasons = {}
312315
313- def _update_verified_breakpoints (self , breakpoints ):
316+ def _update_verified_breakpoints (self , breakpoints : list [ Event ] ):
314317 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+ )
320321
321322 def send_packet (self , command_dict : Request , set_sequence = True ):
322323 """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):
462463 break
463464 breakpoint_events .append (event )
464465
465- self ._update_verified_breakpoints (
466- [event ["body" ]["breakpoint" ] for event in breakpoint_events ]
467- )
468466 return breakpoint_events
469467
470468 def wait_for_breakpoints_to_be_verified (
471469 self , breakpoint_ids : list [str ], timeout : Optional [float ] = None
472470 ):
473471 """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 ):
477473 breakpoint_event = self .wait_for_event ("breakpoint" , timeout = timeout )
478474 if breakpoint_event is None :
479475 break
480476
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 ]
484478
485479 def wait_for_exited (self , timeout : Optional [float ] = None ):
486480 event_dict = self .wait_for_event ("exited" , timeout = timeout )
@@ -1042,8 +1036,8 @@ def request_setBreakpoints(self, source: Source, line_array, data=None):
10421036 "arguments" : args_dict ,
10431037 }
10441038 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" ] )
10471041 return response
10481042
10491043 def request_setExceptionBreakpoints (self , filters ):
@@ -1071,8 +1065,8 @@ def request_setFunctionBreakpoints(self, names, condition=None, hitCondition=Non
10711065 "arguments" : args_dict ,
10721066 }
10731067 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" ] )
10761070 return response
10771071
10781072 def request_dataBreakpointInfo (
0 commit comments