11# -*- coding: utf-8 -*-
22#
3- # Copyright (C) 2008-2010, 2013-2016, 2020 2023-2025
3+ # Copyright (C) 2008-2010, 2013-2016, 2020 2023-2026
44# Rocky Bernstein <rocky@gnu.org>
55#
66# This program is free software: you can redistribute it and/or modify
4040from trepan .clifns import search_file
4141from trepan .lib .breakpoint import BreakpointManager
4242from trepan .lib .default import START_OPTS , STOP_OPTS
43- from trepan .lib .stack import ExtraFrameInfo , FrameInfo , count_frames
43+ from trepan .lib .stack import FrameInfo , count_frames
4444from trepan .misc import option_set
4545from trepan .processor .cmdproc import CommandProcessor
4646from trepan .processor .trace import PrintProcessor
@@ -422,14 +422,18 @@ def trace_dispatch(self, frame, event: str, arg):
422422 processor-specific I think it best to distribute the checks."""
423423
424424 # for debugging
425- # print("XXX+ trace dispatch:", frame.f_code.co_name, frame.f_lineno, event, arg)
425+ # print("XXX+ trace dispatch:", frame.f_code.co_name, frame.f_lineno, event, arg, frame.f_trace )
426426
427427 # Check to see if are in a call but we should be stepping over the call
428428 # using "next" of "finish". If so, then we can speed tracing by
429429 # removing further tracing. Not though that we *also* must make sure
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+ remove_frame_on_return = False
434+ # FIXME:
435+ # instead of self.bpmgr.bplist == 0, we should be counting on
436+ # per breakpoints in code object.
433437 if event == "call" :
434438 if (self .last_frame != frame
435439 and len (self .bpmgr .bplist ) == 0
@@ -439,20 +443,22 @@ def trace_dispatch(self, frame, event: str, arg):
439443 ):
440444 # We are "finish"ing or "next"ing and should not be tracing into this call
441445 # or any other calls from this. Return None to not trace further.
442- # print("""trace_dispatch: "finish"ing or "next"ing from call event""")
446+ # print("""XXX+ trace_dispatch: "finish"ing or "next"ing from call event""")
447+ frame .f_trace = None
443448 return None
444- elif not self .is_stop_here (frame , event ):
449+
450+ if frame not in FrameInfo :
451+ count_frames (frame )
452+
453+ if not self .is_stop_here (frame , event ):
445454 # We might have a stop here as a result of a breakpoint set inside
446455 # 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
456+ # make sure we don't turn off breakpoints inside this function which
448457 # we do by returning "self".
449458 return self
450- if frame not in FrameInfo :
451- FrameInfo [frame ] = ExtraFrameInfo (- 1 , frame .f_code .co_filename )
452- elif event == "return" :
453- if frame in FrameInfo :
454- print ("XXX deleting {frame}" )
455- del FrameInfo [frame ]
459+
460+ elif event == "return" and frame in FrameInfo :
461+ remove_frame_on_return = True
456462
457463 self .event = event
458464
@@ -465,10 +471,14 @@ def trace_dispatch(self, frame, event: str, arg):
465471 # f_lineno can only be set by a trace function
466472 if self .ignore_filter and self .ignore_filter .is_excluded (frame ):
467473 # print("trace_dispatch: ignore_filter", self.ignore_filter, frame, frame.f_lineno, event, arg) # for debugging
474+ if remove_frame_on_return :
475+ del FrameInfo [frame ]
468476 return self
469477
470478 if self .trace_hook_suspend :
471479 # print("XXX trace_dispatch: hook suspended")
480+ if remove_frame_on_return :
481+ del FrameInfo [frame ]
472482 return None
473483
474484 # print("XXX+ trace dispatch", frame, frame.f_lineno, event, arg) # for debugging
@@ -483,6 +493,8 @@ def trace_dispatch(self, frame, event: str, arg):
483493 if self .until_condition :
484494 if not self .matches_condition (frame ):
485495 # print(f"XXX trace until condition not met for {frame}") # for debugging
496+ if remove_frame_on_return :
497+ del FrameInfo [frame ]
486498 return self
487499 pass
488500
@@ -494,6 +506,8 @@ def trace_dispatch(self, frame, event: str, arg):
494506 trace_event_set = self .debugger .settings ["events" ]
495507 if trace_event_set is None or self .event not in trace_event_set :
496508 # print(f"trace_dispatch: self.event not in {trace_event_set}")
509+ if remove_frame_on_return :
510+ del FrameInfo [frame ]
497511 return self
498512
499513 # I think we *have* to run is_stop_here() before
@@ -514,7 +528,8 @@ def trace_dispatch(self, frame, event: str, arg):
514528 except Exception :
515529 pass
516530 pass
517-
531+ if remove_frame_on_return :
532+ del FrameInfo [frame ]
518533 pass
519534
520535
0 commit comments