mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
decoder.py: allowing to use it live (#9108)
- avoid ctx repetition and hide some useless fw debug lines - hide "DECODE IT" - immediately print stack at closing marker - check for tool executable at startup live command line example > pyserial-miniterm /dev/ttyUSB0 115200 | \ path/to/esp8266/Arduino/tools/decoder.py \ --tool addr2line \ --toolchain-path path/to/esp8266/Arduino/tools/xtensa-lx106-elf/bin \ path/to/build.elf
This commit is contained in:
parent
75cd58f647
commit
685f2c97ff
@ -10,6 +10,7 @@ import argparse
|
|||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import shutil
|
||||||
|
|
||||||
# https://github.com/me-no-dev/EspExceptionDecoder/blob/349d17e4c9896306e2c00b4932be3ba510cad208/src/EspExceptionDecoder.java#L59-L90
|
# https://github.com/me-no-dev/EspExceptionDecoder/blob/349d17e4c9896306e2c00b4932be3ba510cad208/src/EspExceptionDecoder.java#L59-L90
|
||||||
EXCEPTION_CODES = (
|
EXCEPTION_CODES = (
|
||||||
@ -104,7 +105,10 @@ def decode_lines(format_addresses, elf, lines):
|
|||||||
|
|
||||||
STACK_LINE_RE = re.compile(r"^[0-9a-f]{8}:\s\s+")
|
STACK_LINE_RE = re.compile(r"^[0-9a-f]{8}:\s\s+")
|
||||||
|
|
||||||
|
IGNORE_FIRMWARE_RE = re.compile(r"^(epc1=0x........, |Fatal exception )")
|
||||||
|
|
||||||
CUT_HERE_STRING = "CUT HERE FOR EXCEPTION DECODER"
|
CUT_HERE_STRING = "CUT HERE FOR EXCEPTION DECODER"
|
||||||
|
DECODE_IT = "DECODE IT"
|
||||||
EXCEPTION_STRING = "Exception ("
|
EXCEPTION_STRING = "Exception ("
|
||||||
EPC_STRING = "epc1="
|
EPC_STRING = "epc1="
|
||||||
|
|
||||||
@ -132,6 +136,8 @@ def decode_lines(format_addresses, elf, lines):
|
|||||||
stack_addresses = print_all_addresses(stack_addresses)
|
stack_addresses = print_all_addresses(stack_addresses)
|
||||||
last_stack = line.strip()
|
last_stack = line.strip()
|
||||||
# 3fffffb0: feefeffe feefeffe 3ffe85d8 401004ed
|
# 3fffffb0: feefeffe feefeffe 3ffe85d8 401004ed
|
||||||
|
elif IGNORE_FIRMWARE_RE.match(line):
|
||||||
|
continue
|
||||||
elif in_stack and STACK_LINE_RE.match(line):
|
elif in_stack and STACK_LINE_RE.match(line):
|
||||||
_, addrs = line.split(":")
|
_, addrs = line.split(":")
|
||||||
addrs = ANY_ADDR_RE.findall(addrs)
|
addrs = ANY_ADDR_RE.findall(addrs)
|
||||||
@ -163,8 +169,10 @@ def decode_lines(format_addresses, elf, lines):
|
|||||||
in_stack = True
|
in_stack = True
|
||||||
# ignore
|
# ignore
|
||||||
elif "<<<stack<<<" in line:
|
elif "<<<stack<<<" in line:
|
||||||
|
in_stack = False
|
||||||
|
stack_addresses = print_all_addresses(stack_addresses)
|
||||||
continue
|
continue
|
||||||
elif CUT_HERE_STRING in line:
|
elif CUT_HERE_STRING in line or DECODE_IT in line:
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
@ -181,6 +189,9 @@ def select_tool(toolchain_path, tool, func):
|
|||||||
path = f"xtensa-lx106-elf-{tool}"
|
path = f"xtensa-lx106-elf-{tool}"
|
||||||
if toolchain_path:
|
if toolchain_path:
|
||||||
path = os.path.join(toolchain_path, path)
|
path = os.path.join(toolchain_path, path)
|
||||||
|
|
||||||
|
if not shutil.which(path):
|
||||||
|
raise FileNotFoundError(path)
|
||||||
|
|
||||||
def formatter(func, path):
|
def formatter(func, path):
|
||||||
def wrapper(elf, addresses):
|
def wrapper(elf, addresses):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user