summaryrefslogtreecommitdiff
path: root/ports/esp32s2/tools/decode_backtrace.py
blob: 523677baea0deae503b4fb1aa0d0268e7f5c2528 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""Simple script that translates "Backtrace:" lines from the ESP output to files
   and line numbers.

   Run with: python3 tools/decode_backtrace.py <board>

   Enter the backtrace line at the "? " prompt. CTRL-C to exit the script.
   """

import subprocess
import sys

board = sys.argv[1]
print(board)

while True:
    addresses = input("? ")
    if addresses.startswith("Backtrace:"):
        addresses = addresses[len("Backtrace:") :]
    addresses = addresses.strip().split()
    addresses = [address.split(":")[0] for address in addresses]
    print("got", addresses)
    subprocess.run(
        ["xtensa-esp32s2-elf-addr2line", "-e", "build-{}/firmware.elf".format(board)] + addresses
    )