MCPcopy Create free account
hub / github.com/FastLED/FastLED / extract_addresses_from_crash_log

Function extract_addresses_from_crash_log

ci/decode_esp32_backtrace.py:173–201  ·  view source on GitHub ↗

Extract addresses from ESP32 crash log.

(log: str)

Source from the content-addressed store, hash-verified

171
172
173def extract_addresses_from_crash_log(log: str) -> list[str]:
174 """Extract addresses from ESP32 crash log."""
175 addresses: list[str] = []
176
177 # Extract MEPC (RISC-V program counter)
178 mepc_match = re.search(r"MEPC\s*:\s*(0x[0-9a-fA-F]+)", log)
179 if mepc_match:
180 addresses.append(mepc_match.group(1))
181
182 # Extract RA (return address)
183 ra_match = re.search(r"RA\s*:\s*(0x[0-9a-fA-F]+)", log)
184 if ra_match:
185 addresses.append(ra_match.group(1))
186
187 # Extract backtrace addresses from ESP32 memory regions:
188 # 0x3C - Flash DROM, 0x3F - DRAM, 0x40 - IRAM, 0x42 - Flash IROM, 0x50 - RTC
189 backtrace_pattern = r"0x(?:3[CF]|4[02]|50)[0-9a-fA-F]{6}"
190 backtrace_addrs: list[str] = re.findall(backtrace_pattern, log)
191 addresses.extend(backtrace_addrs[:10]) # Limit to first 10 addresses
192
193 # Remove duplicates while preserving order
194 seen: set[str] = set()
195 unique_addresses: list[str] = []
196 for addr in addresses:
197 if addr not in seen:
198 seen.add(addr)
199 unique_addresses.append(addr)
200
201 return unique_addresses
202
203
204def main():

Callers 2

_decodeMethod · 0.90
mainFunction · 0.85

Calls 3

setClass · 0.50
appendMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected