Skip to content

Commit b2c2d4c

Browse files
committed
Improve offset coloring
1 parent f40c1eb commit b2c2d4c

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

trepan/lib/disassemble.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
Integer,
4141
Keyword,
4242
LineNumber,
43-
Number,
43+
Offset,
4444
Symbol,
4545
format_token,
4646
)
@@ -313,7 +313,7 @@ def print_instruction(
313313
msg_nocr(" ")
314314

315315
# Column: Instruction offset from start of code sequence
316-
msg_nocr(format_token(Number, repr(offset).rjust(4), style=style))
316+
msg_nocr(format_token(Offset, repr(offset).rjust(4), style=style))
317317
msg_nocr(" ")
318318

319319
# Column: Instruction bytes

trepan/processor/command/info_subcmd/pc.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# Copyright (C) 2017, 2020, 2024 Rocky Bernstein <[email protected]>
2+
# Copyright (C) 2017, 2020, 2024, 2026 Rocky Bernstein <[email protected]>
33
#
44
# This program is free software: you can redistribute it and/or modify
55
# it under the terms of the GNU General Public License as published by
@@ -19,6 +19,7 @@
1919
from xdis import findlinestarts
2020

2121
from trepan.lib.disassemble import disassemble_bytes
22+
from trepan.lib.format import format_offset
2223
from trepan.misc import wrapped_lines
2324

2425
# Our local modules
@@ -51,10 +52,11 @@ def run(self, args):
5152
mainfile = self.core.filename(None)
5253
if self.core.is_running():
5354
curframe = self.proc.curframe
55+
style = self.settings["style"]
5456
if curframe:
5557
line_no = inspect.getlineno(curframe)
5658
offset = curframe.f_lasti
57-
self.msg(f"PC offset is {offset}.")
59+
self.msg(f"PC offset is {format_offset(offset, style)}.")
5860
offset = max(offset, 0)
5961
code = curframe.f_code
6062
co_code = code.co_code

0 commit comments

Comments
 (0)