circuitpython/ports/espressif/tools/decode_backtrace.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

25 lines
683 B
Python
Raw Normal View History

"""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:"):
2021-03-15 09:57:36 -04:00
addresses = addresses[len("Backtrace:") :]
addresses = addresses.strip().split()
addresses = [address.split(":")[0] for address in addresses]
2021-03-15 09:57:36 -04:00
subprocess.run(
decode_backtrace: Show even more information addr2line can show information about how functions were inlined, including function names Typical new output: ``` 0x400dec57: mp_obj_get_type at /home/jepler/src/circuitpython/ports/espressif/../../py/obj.c:68 (inlined by) mp_obj_print_helper at /home/jepler/src/circuitpython/ports/espressif/../../py/obj.c:133 (inlined by) mp_obj_print_helper at /home/jepler/src/circuitpython/ports/espressif/../../py/obj.c:114 0x400e1a25: fun_builtin_1_call at /home/jepler/src/circuitpython/ports/espressif/../../py/objfun.c:75 0x400dd016: mp_call_function_n_kw at /home/jepler/src/circuitpython/ports/espressif/../../py/runtime.c:665 0x400eac99: mp_execute_bytecode at /home/jepler/src/circuitpython/ports/espressif/../../py/vm.c:936 0x400e1ae9: fun_bc_call at /home/jepler/src/circuitpython/ports/espressif/../../py/objfun.c:297 (discriminator 4) 0x400dd016: mp_call_function_n_kw at /home/jepler/src/circuitpython/ports/espressif/../../py/runtime.c:665 0x400dd03a: mp_call_function_0 at /home/jepler/src/circuitpython/ports/espressif/../../py/runtime.c:638 0x40117c03: parse_compile_execute at /home/jepler/src/circuitpython/ports/espressif/../../shared/runtime/pyexec.c:146 0x4011800d: pyexec_friendly_repl at /home/jepler/src/circuitpython/ports/espressif/../../shared/runtime/pyexec.c:734 0x400eeded: run_repl at /home/jepler/src/circuitpython/ports/espressif/../../main.c:823 (inlined by) main at /home/jepler/src/circuitpython/ports/espressif/../../main.c:922 0x400ef5e3: app_main at /home/jepler/src/circuitpython/ports/espressif/supervisor/port.c:410 0x401bb461: main_task at /home/jepler/src/circuitpython/ports/espressif/build-adafruit_feather_esp32_v2/esp-idf/../../esp-idf/components/freertos/port/port_common.c:141 ```
2022-07-12 17:28:33 -04:00
["xtensa-esp32s2-elf-addr2line", "-aipfe", "build-{}/firmware.elf".format(board)]
+ addresses
2021-03-15 09:57:36 -04:00
)