Skip to content

Commit 685f2c9

Browse files
authored
decoder.py: allowing to use it live (#9108)
- avoid ctx repetition and hide some useless fw debug lines - hide "DECODE IT" - immediately print stack at closing marker - check for tool executable at startup live command line example > pyserial-miniterm /dev/ttyUSB0 115200 | \ path/to/esp8266/Arduino/tools/decoder.py \ --tool addr2line \ --toolchain-path path/to/esp8266/Arduino/tools/xtensa-lx106-elf/bin \ path/to/build.elf
1 parent 75cd58f commit 685f2c9

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tools/decoder.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import sys
1111
import re
1212
import subprocess
13+
import shutil
1314

1415
# https://github.com/me-no-dev/EspExceptionDecoder/blob/349d17e4c9896306e2c00b4932be3ba510cad208/src/EspExceptionDecoder.java#L59-L90
1516
EXCEPTION_CODES = (
@@ -104,7 +105,10 @@ def decode_lines(format_addresses, elf, lines):
104105

105106
STACK_LINE_RE = re.compile(r"^[0-9a-f]{8}:\s\s+")
106107

108+
IGNORE_FIRMWARE_RE = re.compile(r"^(epc1=0x........, |Fatal exception )")
109+
107110
CUT_HERE_STRING = "CUT HERE FOR EXCEPTION DECODER"
111+
DECODE_IT = "DECODE IT"
108112
EXCEPTION_STRING = "Exception ("
109113
EPC_STRING = "epc1="
110114

@@ -132,6 +136,8 @@ def format_address(address):
132136
stack_addresses = print_all_addresses(stack_addresses)
133137
last_stack = line.strip()
134138
# 3fffffb0: feefeffe feefeffe 3ffe85d8 401004ed
139+
elif IGNORE_FIRMWARE_RE.match(line):
140+
continue
135141
elif in_stack and STACK_LINE_RE.match(line):
136142
_, addrs = line.split(":")
137143
addrs = ANY_ADDR_RE.findall(addrs)
@@ -163,8 +169,10 @@ def format_address(address):
163169
in_stack = True
164170
# ignore
165171
elif "<<<stack<<<" in line:
172+
in_stack = False
173+
stack_addresses = print_all_addresses(stack_addresses)
166174
continue
167-
elif CUT_HERE_STRING in line:
175+
elif CUT_HERE_STRING in line or DECODE_IT in line:
168176
continue
169177
else:
170178
line = line.strip()
@@ -181,6 +189,9 @@ def select_tool(toolchain_path, tool, func):
181189
path = f"xtensa-lx106-elf-{tool}"
182190
if toolchain_path:
183191
path = os.path.join(toolchain_path, path)
192+
193+
if not shutil.which(path):
194+
raise FileNotFoundError(path)
184195

185196
def formatter(func, path):
186197
def wrapper(elf, addresses):

0 commit comments

Comments
 (0)