1010import sys
1111import re
1212import subprocess
13+ import shutil
1314
1415# https://github.com/me-no-dev/EspExceptionDecoder/blob/349d17e4c9896306e2c00b4932be3ba510cad208/src/EspExceptionDecoder.java#L59-L90
1516EXCEPTION_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