Skip to content

Commit 93eca83

Browse files
committed
Improve info line{,s}
1 parent dca1196 commit 93eca83

File tree

1 file changed

+8
-19
lines changed
  • trepan/processor/command/info_subcmd

1 file changed

+8
-19
lines changed

trepan/processor/command/info_subcmd/lines.py

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
# Our local modules
2222
from trepan.processor.command.base_subcmd import DebuggerSubcommand
2323
from trepan.misc import pretty_modfunc_name
24-
# from pyficache import get_linecache_info
25-
from pyficache import cache_code_lines
24+
from pyficache import get_linecache_info
2625

2726

2827
class InfoOffsets(DebuggerSubcommand):
@@ -98,29 +97,19 @@ def run(self, args):
9897

9998
# No line number. Use current frame line number
10099
filename = self.core.canonic_filename(self.proc.curframe)
101-
file_info = cache_code_lines(
102-
filename, toplevel_only=False, include_offsets=True
103-
)
104-
if file_info:
100+
linecache_info = get_linecache_info(filename)
101+
if linecache_info:
105102
self.section(f"Line: fn, offset for table for {filename}")
106103
lines = []
107-
# linecache_info = get_linecache_info(filename)
108-
# line_info = linecache_info.line_info
109-
110-
for line_number, line_info in file_info.line_numbers.items():
111-
if not name or any(li.name == name for li in line_info):
104+
linecache_info = get_linecache_info(filename)
105+
line_info = linecache_info.line_info
106+
for line_number, code_offset_pair in line_info.items():
107+
for code, offset in code_offset_pair:
112108
lines.append(
113109
"%4d: %s"
114110
% (
115111
line_number,
116-
", ".join(
117-
[
118-
"%s *%d"
119-
% (pretty_modfunc_name(li.name), li.offsets[0])
120-
for li in line_info
121-
if not name or li.name == name
122-
]
123-
),
112+
"%s *%d"% (pretty_modfunc_name(code), offset)
124113
)
125114
)
126115
m = self.columnize_commands(list(sorted(lines)))

0 commit comments

Comments
 (0)