Skip to content

Commit 6d4b989

Browse files
committed
Go over info {lines,PC}
1 parent ea9c239 commit 6d4b989

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

trepan/processor/command/info_subcmd/line.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import re
2121

2222
import columnize
23-
from pyficache import get_linecache_info, file2file_remap
23+
from pyficache import file2file_remap, get_linecache_info
2424

2525
from trepan.clifns import search_file
2626
from trepan.lib.format import Filename, format_line_number, format_token

trepan/processor/command/info_subcmd/lines.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
from getopt import getopt, GetoptError
2020

2121
from trepan.processor.command.base_subcmd import DebuggerSubcommand
22-
from trepan.lib.format import format_line_number, format_offset
22+
from trepan.lib.format import Filename, format_line_number, format_offset, format_token
2323
from trepan.misc import pretty_modfunc_name
24-
from pyficache import get_linecache_info
24+
from pyficache import file2file_remap, get_linecache_info
2525

2626

2727
class InfoOffsets(DebuggerSubcommand):
@@ -97,12 +97,25 @@ def run(self, args):
9797

9898
# No line number. Use current frame line number
9999
filename = self.core.canonic_filename(self.proc.curframe)
100-
linecache_info = get_linecache_info(filename)
100+
101+
remapped_filename = file2file_remap.get(filename, filename)
102+
103+
style = self.settings["style"]
104+
formatted_filename = format_token(
105+
Filename,
106+
format_token(Filename, remapped_filename, style=style),
107+
style=style,
108+
)
109+
110+
if remapped_filename != filename:
111+
self.msg(f"{filename} remapped to {formatted_filename}")
112+
113+
linecache_info = get_linecache_info(remapped_filename)
101114
style = self.settings["style"]
102115
if linecache_info:
103-
self.section(f"Line: fn, offset for table for {filename}")
116+
self.section(f"Line: fn, offset for table for {formatted_filename}")
104117
lines = []
105-
linecache_info = get_linecache_info(filename)
118+
linecache_info = get_linecache_info(remapped_filename)
106119
line_info = linecache_info.line_info
107120
for line_number, code_offset_pair in line_info.items():
108121
# FIXME:
@@ -113,7 +126,8 @@ def run(self, args):
113126
"%s: %s"
114127
% (
115128
format_line_number(line_number, style, "%4d"),
116-
"%s *%s" % (pretty_modfunc_name(code), format_offset(offset, style))
129+
"%s *%s"
130+
% (pretty_modfunc_name(code), format_offset(offset, style)),
117131
)
118132
)
119133
m = self.columnize_commands(list(sorted(lines)))
@@ -122,9 +136,7 @@ def run(self, args):
122136
self.section(f"Line: offset for table for {filename}")
123137
lines = []
124138
for offset, line_number in findlinestarts(curframe.f_code):
125-
lines.append(
126-
"%4d: *%d" % (line_number, offset)
127-
)
139+
lines.append("%4d: *%d" % (line_number, offset))
128140
m = self.columnize_commands(list(sorted(lines)))
129141
self.msg(m)
130142
pass

trepan/processor/command/info_subcmd/pc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def run(self, args):
8686
msg = "is not currently running. "
8787
self.msg(wrapped_lines(part1, msg, self.settings["width"]))
8888
else:
89-
self.msg("No Python program is currently running.")
89+
self.errmsg("No Python program is currently running.")
9090
pass
9191
self.msg(self.core.execution_status)
9292
pass

0 commit comments

Comments
 (0)