@@ -105,6 +105,7 @@ def decode_lines(format_addresses, elf, lines):
105
105
STACK_LINE_RE = re .compile (r"^[0-9a-f]{8}:\s\s+" )
106
106
107
107
CUT_HERE_STRING = "CUT HERE FOR EXCEPTION DECODER"
108
+ DECODE_IT = "DECODE IT"
108
109
EXCEPTION_STRING = "Exception ("
109
110
EPC_STRING = "epc1="
110
111
@@ -125,6 +126,7 @@ def print_all_addresses(addresses):
125
126
def format_address (address ):
126
127
return "\n " .join (format_addresses (elf , [address ]))
127
128
129
+ lastepc = 0
128
130
for line in lines :
129
131
# ctx could happen multiple times. for the 2nd one, reset list
130
132
# ctx: bearssl *or* ctx: cont *or* ctx: sys *or* ctx: whatever
@@ -143,9 +145,13 @@ def format_address(address):
143
145
for pair in pairs :
144
146
name , addr = pair .split ("=" )
145
147
if name in ["epc1" , "excvaddr" ]:
146
- output = format_address (addr )
147
- if output :
148
- print (f"{ name } ={ output } " )
148
+ addr = addr .rstrip (',' )
149
+ if lastepc != addr :
150
+ if addr != '0x00000000' :
151
+ lastepc = addr
152
+ output = format_address (addr )
153
+ if output :
154
+ print (f"{ name } ={ output } " )
149
155
# Exception (123):
150
156
# Other reasons coming before the guard shown as-is
151
157
elif EXCEPTION_STRING in line :
@@ -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
+ if not os .path .isfile (path ):
193
+ print (f"error: not existing tool (path -- tool): '{ path } '" , file = sys .stderr )
194
+ sys .exit (1 )
184
195
185
196
def formatter (func , path ):
186
197
def wrapper (elf , addresses ):
0 commit comments