@@ -37,7 +37,7 @@ class Breakpoint:
3737 how many times the breakpoint was hit,
3838 whether it is disabled, or has a condition associated with the breakpoint.
3939
40- If is_code_offset is True, position is a code offset. Otherwise, it
40+ If attribute is_code_offset is True, position is a code offset. Otherwise, it
4141 is a 0-origin column offset.
4242
4343 The code offset for start of a method, module, or function is always 0.
@@ -50,6 +50,12 @@ class Breakpoint:
5050
5151 To do this, we need deep undertanding of Python code objects, which we get
5252 from pyficache.
53+
54+ Attribute offset is the code offset, when is_code_offset is true, it is ignored and
55+ should be the same value as position. However when is_code_offset is False, then
56+ we have a line or line/column position. Here offset can be the code offset when there
57+ is a unique value, but since line or line/column might have many offsets associated with them,
58+ the sentinal value -1 is used to indicate any possible offset.
5359 """
5460
5561 def __init__ (
@@ -62,7 +68,8 @@ def __init__(
6268 code : Optional [CodeType ] = None ,
6369 position : Optional [int ] = None ,
6470 is_code_offset : bool = True ,
65- is_breakpoint_call : bool = False
71+ is_breakpoint_call : bool = False ,
72+ offset : int = - 1 # default is any possible code offset
6673 ):
6774 # FIXME: split out this top part into a part that fills out information
6875 if code is not None :
@@ -101,8 +108,7 @@ def __init__(
101108 pass
102109 else :
103110 self .column = position
104- # TODO: Figure out code offset.
105- self .offset = None
111+ self .offset = offset
106112
107113 self .condition = condition
108114 self .enabled = True
@@ -251,6 +257,7 @@ def add_breakpoint(
251257 condition : Optional [str ] = None ,
252258 func_or_code = None ,
253259 is_breakpoint_call : bool = False ,
260+ offset : int = - 1 # default is any possible code offset
254261 ):
255262 """
256263 Add a breakpoint in ``filename`` at line number ``line_number``.
@@ -313,6 +320,7 @@ def add_breakpoint(
313320 position ,
314321 is_code_offset ,
315322 is_breakpoint_call ,
323+ offset ,
316324 )
317325
318326 # Build the internal lists of breakpoints
@@ -498,8 +506,13 @@ def needs_no_tracing(self) -> bool:
498506 support, i.e. they are handled either by explicit breakpoint() calls
499507 or the newer debug protocal handles the breakpoints
500508 """
501- # return len(self.bplist) == 0
502- return all (not getattr (item , 'is_breakpoint_call' , False ) for item in self .bplist )
509+ for bp_list in self .bplist .values ():
510+ for bp in bp_list :
511+ if hasattr (bp , "is_breakpoint_call" ) and not bp .is_breakpoint_call :
512+ # print(f"XXX0 {bp} needs tracing")
513+ return False
514+ # print(f"XXX does not need tracing")
515+ return True
503516
504517 def last (self ):
505518 return len (self .bpbynumber ) - 1
0 commit comments