Skip to content

Commit

Permalink
Small changes...
Browse files Browse the repository at this point in the history
to "info frame" and trace_hook debugging
  • Loading branch information
rocky committed Sep 29, 2024
1 parent a2c9512 commit 0b668b7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
15 changes: 4 additions & 11 deletions trepan/lib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,21 +411,16 @@ def trace_dispatch(self, frame, event: str, arg):
different line). We could put that here, but since that seems
processor-specific I think it best to distribute the checks."""

# print("XXX+ trace dispatch", frame.f_code.co_name, frame.f_lineno, event, arg) # for debugging
# for debugging
# print("XXX+ trace dispatch:", frame.f_code.co_name, frame.f_lineno, event, arg)

# Check to see if are in a call but we should be stepping over the call
# using "next" of "finish". If so, then we can speed tracing by
# removing futher tracing. Not though that we *also* must make sure
# that we don't have any breakpoint set, since we have to check
# for breakpoints in a kind of slow way of checking all events.

# For debugging:
# if event == "call":
# print("XXX1", self.last_frame, frame, len(self.bpmgr.bplist), self.stop_level, count_frames(frame))
# print("XXX2 frames !=", self.last_frame != frame)
# print("XXX3 bplit == 0", len(self.bpmgr.bplist) == 0, self.bpmgr.bplist)
# print("XXX4 stop_level", self.stop_level is not None and self.stop_level < count_frames(frame))

# TODO: add thread check
if (
event == "call"
and self.last_frame != frame
Expand All @@ -434,9 +429,7 @@ def trace_dispatch(self, frame, event: str, arg):
and self.stop_level < count_frames(frame)
):
# We are "finish"ing or "next"ing and should not be tracing into this call
# or any other calls from this. Set to not trace further.
# print(f"XXX1 deleting further calls {frame.f_code.co_name}") # debug
del frame.f_trace
# or any other calls from this. Return Nont to not trace further.
return None

self.event = event
Expand Down
9 changes: 7 additions & 2 deletions trepan/processor/command/info_subcmd/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,14 @@ def run(self, args):
line_number = frame.f_lineno
code = frame.f_code
file_path = code.co_filename
line_text = getline(file_path, line_number, {"style": style}).strip()

self.msg(f" current line number: {frame.f_lineno}: {line_text[:40]}")
line_text = getline(file_path, line_number, {"style": style})
if line_text is None:
self.msg(f" current line number: {frame.f_lineno}")
else:
formatted_text = highlight_string(line_text.strip())
self.msg(f" current line number: {frame.f_lineno}: {formatted_text}")

self.msg(f" last instruction: {frame.f_lasti}")
self.msg(f" code: {code}")
self.msg(f" previous frame: {frame.f_back}")
Expand Down

0 comments on commit 0b668b7

Please sign in to comment.