Skip to content

Commit bcaa341

Browse files
committed
feat: Improved addr2line output formatting
1 parent e9aa6eb commit bcaa341

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

esp_idf_monitor/base/logger.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from esp_idf_monitor.base.key_config import MENU_KEY, TOGGLE_OUTPUT_KEY
1212

13-
from .output_helpers import error_print, note_print
13+
from .output_helpers import error_print, note_print, yellow_print, green_print, red_print, normal_print
1414

1515
key_description = miniterm.key_description
1616

@@ -141,9 +141,18 @@ def output_toggle(self): # type: () -> None
141141
def handle_possible_pc_address_in_line(self, line: bytes, insert_new_line: bool = False) -> None:
142142
if not self.pc_address_decoder:
143143
return
144-
translation = self.pc_address_decoder.decode_address(line)
145-
if translation:
144+
decoded = self.pc_address_decoder.decode_addresses(line)
145+
if decoded:
146146
if insert_new_line:
147147
# insert a new line in case address translation is printed in the middle of a line
148148
self.print(b'\n')
149-
self.print(translation, console_printer=note_print)
149+
for address, entries in decoded.items():
150+
self.print(f"{address}: ", console_printer=normal_print)
151+
for idx, entry in enumerate(entries):
152+
if idx > 0:
153+
self.print(' (inlined by) ', console_printer=normal_print)
154+
self.print(entry['fn'], console_printer=lambda msg: yellow_print(msg, newline=''))
155+
self.print(' in ', console_printer=normal_print)
156+
self.print(entry['path'], console_printer=lambda msg: green_print(msg, newline=''))
157+
self.print(':', console_printer=normal_print)
158+
self.print(str(entry['line']), console_printer=red_print)

0 commit comments

Comments
 (0)