Skip to content

Commit aa752ff

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

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

esp_idf_monitor/base/logger.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
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 (COMMON_PREFIX, error_print, green_print,
14+
normal_print, note_print, red_print, yellow_print)
1415

1516
key_description = miniterm.key_description
1617

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

0 commit comments

Comments
 (0)