10
10
import sys
11
11
import re
12
12
import subprocess
13
+ import shutil
13
14
14
15
# https://github.com/me-no-dev/EspExceptionDecoder/blob/349d17e4c9896306e2c00b4932be3ba510cad208/src/EspExceptionDecoder.java#L59-L90
15
16
EXCEPTION_CODES = (
@@ -104,7 +105,10 @@ def decode_lines(format_addresses, elf, lines):
104
105
105
106
STACK_LINE_RE = re .compile (r"^[0-9a-f]{8}:\s\s+" )
106
107
108
+ IGNORE_FIRMWARE_RE = re .compile (r"^(epc1=0x........, |Fatal exception )" )
109
+
107
110
CUT_HERE_STRING = "CUT HERE FOR EXCEPTION DECODER"
111
+ DECODE_IT = "DECODE IT"
108
112
EXCEPTION_STRING = "Exception ("
109
113
EPC_STRING = "epc1="
110
114
@@ -132,6 +136,8 @@ def format_address(address):
132
136
stack_addresses = print_all_addresses (stack_addresses )
133
137
last_stack = line .strip ()
134
138
# 3fffffb0: feefeffe feefeffe 3ffe85d8 401004ed
139
+ elif IGNORE_FIRMWARE_RE .match (line ):
140
+ continue
135
141
elif in_stack and STACK_LINE_RE .match (line ):
136
142
_ , addrs = line .split (":" )
137
143
addrs = ANY_ADDR_RE .findall (addrs )
@@ -163,8 +169,10 @@ def format_address(address):
163
169
in_stack = True
164
170
# ignore
165
171
elif "<<<stack<<<" in line :
172
+ in_stack = False
173
+ stack_addresses = print_all_addresses (stack_addresses )
166
174
continue
167
- elif CUT_HERE_STRING in line :
175
+ elif CUT_HERE_STRING in line or DECODE_IT in line :
168
176
continue
169
177
else :
170
178
line = line .strip ()
@@ -181,6 +189,9 @@ def select_tool(toolchain_path, tool, func):
181
189
path = f"xtensa-lx106-elf-{ tool } "
182
190
if toolchain_path :
183
191
path = os .path .join (toolchain_path , path )
192
+
193
+ if not shutil .which (path ):
194
+ raise FileNotFoundError (path )
184
195
185
196
def formatter (func , path ):
186
197
def wrapper (elf , addresses ):
0 commit comments