Skip to content

Commit 0b1a296

Browse files
committed
Don't stop at intermediate call event...
Sometimes call tracing is set so that we can support (line) stepping to a breakpoint. These kinds of breakpoints are not places we normally want to stop at.
1 parent 2738d07 commit 0b1a296

2 files changed

Lines changed: 18 additions & 16 deletions

File tree

test/unit/test_api.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,8 @@ def test_run_xxx():
3939
print('Issuing: run_eval("1+2")')
4040
print(run_eval("1+2", debug_opts=debug_opts))
4141
print(debugger_output.output)
42-
start_lineno = "1" if sys.version_info[:2] < (3, 11) else "0"
4342

44-
assert debugger_output.output[0:3] == [
45-
"call - <string>:%s" % start_lineno,
43+
assert debugger_output.output[0:2] == [
4644
"line - <string>:1",
4745
"return - <string>:1, 3 ",
4846
]
@@ -61,7 +59,6 @@ def test_run_xxx():
6159
call_lineno = "16"
6260
for i, (prefix, suffix) in enumerate(
6361
(
64-
("call - ", "test/unit/test_api.py:%s" % call_lineno),
6562
("line - ", "test/unit/test_api.py:17"),
6663
("return - ", "test/unit/test_api.py:17, 8 "),
6764
)

trepan/lib/core.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -430,18 +430,23 @@ def trace_dispatch(self, frame, event: str, arg):
430430
# that we don't have any breakpoint set, since we have to check
431431
# for breakpoints in a kind of slow way of checking all events.
432432

433-
if (
434-
event == "call"
435-
and self.last_frame != frame
436-
and len(self.bpmgr.bplist) == 0
437-
and self.stop_level is not None
438-
and self.stop_level < count_frames(frame)
439-
and self.current_thread == threading.current_thread()
440-
):
441-
# We are "finish"ing or "next"ing and should not be tracing into this call
442-
# or any other calls from this. Return Nont to not trace further.
443-
# print("""trace_dispatch: "finish"ing or "next"ing from call event""")
444-
return None
433+
if event == "call":
434+
if (self.last_frame != frame
435+
and len(self.bpmgr.bplist) == 0
436+
and self.stop_level is not None
437+
and self.stop_level < count_frames(frame)
438+
and self.current_thread == threading.current_thread()
439+
):
440+
# We are "finish"ing or "next"ing and should not be tracing into this call
441+
# or any other calls from this. Return None to not trace further.
442+
# print("""trace_dispatch: "finish"ing or "next"ing from call event""")
443+
return None
444+
elif not self.is_stop_here(frame, event):
445+
# We might have a stop here as a result of a breakpoint set inside
446+
# this function. In this case we need to ignore this stop, but
447+
# make sure we don't turn off breapoints inside this function which
448+
# we do by returning "self".
449+
return self
445450

446451
self.event = event
447452

0 commit comments

Comments
 (0)