@@ -96,7 +96,7 @@ def addresses_addr2line(addr2line, elf, addresses):
96
96
97
97
98
98
def decode_lines (format_addresses , elf , lines ):
99
- STACK_RE = re .compile (r"^[0-9a-f]{8}:\s+([0-9a-f]{8} ?)+ *$ " )
99
+ STACK_RE = re .compile (r"^[0-9a-f]{8}:\s+([0-9a-f]{8} ?)+ *" )
100
100
101
101
LAST_ALLOC_RE = re .compile (
102
102
r"last failed alloc call: ([0-9a-fA-F]{8})\(([0-9]+)\).*"
@@ -106,17 +106,23 @@ def decode_lines(format_addresses, elf, lines):
106
106
CUT_HERE_STRING = "CUT HERE FOR EXCEPTION DECODER"
107
107
EXCEPTION_STRING = "Exception ("
108
108
EPC_STRING = "epc1="
109
+ DECODE_IT = "DECODE IT"
109
110
110
111
# either print everything as-is, or cache current string and dump after stack contents end
111
112
last_stack = None
112
113
stack_addresses = {}
113
114
114
115
in_stack = False
116
+ lastctx = ''
117
+ lastepc = 0
115
118
116
119
def print_all_addresses (addresses ):
120
+ nonlocal lastctx
117
121
for ctx , addrs in addresses .items ():
118
- print ()
119
- print (ctx )
122
+ if ctx != lastctx :
123
+ print ()
124
+ print (ctx )
125
+ lastctx = ctx
120
126
for formatted in format_addresses (elf , addrs ):
121
127
print (formatted )
122
128
return dict ()
@@ -138,15 +144,20 @@ def format_address(address):
138
144
stack_addresses .setdefault (last_stack , [])
139
145
for addr in addrs :
140
146
stack_addresses [last_stack ].append (addr )
147
+ stack_addresses = print_all_addresses (stack_addresses )
141
148
# epc1=0xfffefefe epc2=0xfefefefe epc3=0xefefefef excvaddr=0xfefefefe depc=0xfefefefe
142
149
elif EPC_STRING in line :
143
150
pairs = line .split ()
144
151
for pair in pairs :
145
152
name , addr = pair .split ("=" )
153
+ addr = addr .rstrip (',' )
146
154
if name in ["epc1" , "excvaddr" ]:
147
- output = format_address (addr )
148
- if output :
149
- print (f"{ name } ={ output } " )
155
+ if lastepc != addr :
156
+ if addr != '0x00000000' :
157
+ lastepc = addr
158
+ output = format_address (addr )
159
+ if output :
160
+ print (f"{ name } ={ output } " )
150
161
# Exception (123):
151
162
# Other reasons coming before the guard shown as-is
152
163
elif EXCEPTION_STRING in line :
@@ -164,8 +175,9 @@ def format_address(address):
164
175
in_stack = True
165
176
# ignore
166
177
elif "<<<stack<<<" in line :
178
+ in_stack = False
167
179
continue
168
- elif CUT_HERE_STRING in line :
180
+ elif CUT_HERE_STRING in line or DECODE_IT in line :
169
181
continue
170
182
else :
171
183
line = line .strip ()
0 commit comments