Skip to content

Instantly share code, notes, and snippets.

@karlp
Created September 19, 2023 10:58
Show Gist options
  • Save karlp/4687ebae40fb90fcead02ffb8c33ce73 to your computer and use it in GitHub Desktop.
Save karlp/4687ebae40fb90fcead02ffb8c33ce73 to your computer and use it in GitHub Desktop.
example decoding backtraces by hand for esp32
#!/bin/sh
[ -e "$1" ] || { printf "Must provide .elf as argument\n"; exit 1; }
printf "Paste your backtrace and press ctrl-d\n";
sed -e 's/ /\n/g' | grep 0x | cut -d':' -f1 | xargs xtensa-esp32-elf-addr2line -pfiaC -e $1
# Nominally, you _could_ autoconstruct which toolchain to use from
# the CONFIG_IDF_TARGET_ARCH and CONFIG_IDF_TARGET fields in sdkconfig...
$ sh decode-backtrace.sh build/my-app.elf
Paste your backtrace and press ctrl-d
Backtrace: 0x400df932:0x3ffb58f0 0x400df9d9:0x3ffb5910 0x4010928c:0x3ffb5940 0x400e04e9:0x3ffb59c0 0x400e6277:0x3ffb59e0 0x400e640f:0x3ffb5a20 0x400e6496:0x3ffb5a40 0x400d9a8e:0x3ffb5a60 0x400df959:0x3ffb5a90 0x400dfa1d:0x3ffb5ab0 0x400862ce:0x3ffb5ad0 0x400d9b43:0x3ffb5b70 0x400df959:0x3ffb5ba0 0x400dfa1d:0x3ffb5bc0 0x400862ce:0x3ffb5be0 0x400d9b43:0x3ffb5c80 0x400df959:0x3ffb5cb0 0x4008622d:0x3ffb5cd0 0x400d9b43:0x3ffb5d70 0x400df959:0x3ffb5dd0 0x400dfa1d:0x3ffb5df0 0x400862ce:0x3ffb5e10 0x400d9b43:0x3ffb5eb0 0x400df959:0x3ffb5ee0 0x400dfa1d:0x3ffb5f00 0x400862ce:0x3ffb5f20 0x400d9b43:0x3ffb5fc0 0x400df959:0x3ffb6030 0x400dfa1d:0x3ffb6050 0x400862ce:0x3ffb6070 0x400d9b43:0x3ffb6110 0x400df959:0x3ffb6160 0x400df96e:0x3ffb6180 0x4010b58b:0x3ffb61a0 0x4010b89d:0x3ffb6230 0x4010e17c:0x3ffb6270
0x400df932: mp_call_function_n_kw at /home/somewhere/micropython/py/runtime.c:703
0x400df9d9: mp_call_function_1 at /home/somewhere/micropython/py/runtime.c:685
0x4010928c: mp_call_function_1_protected at /home/somewhere/micropython/py/runtime_utils.c:33
0x400e04e9: mp_sched_run_pending at /home/somewhere/micropython/py/scheduler.c:110
(inlined by) mp_handle_pending at /home/somewhere/micropython/py/scheduler.c:239
0x400e6277: poll_set_poll_until_ready_or_timeout at /home/somewhere/micropython/extmod/modselect.c:369
0x400e640f: poll_poll_internal at /home/somewhere/micropython/extmod/modselect.c:517
0x400e6496: poll_ipoll at /home/somewhere/micropython/extmod/modselect.c:548
0x400d9a8e: fun_builtin_var_call at /home/somewhere/micropython/py/objfun.c:119
0x400df959: mp_call_function_n_kw at /home/somewhere/micropython/py/runtime.c:707
0x400dfa1d: mp_call_method_n_kw at /home/somewhere/micropython/py/runtime.c:723
0x400862ce: mp_execute_bytecode at /home/somewhere/micropython/py/vm.c:1042
0x400d9b43: fun_bc_call at /home/somewhere/micropython/py/objfun.c:273
0x400df959: mp_call_function_n_kw at /home/somewhere/micropython/py/runtime.c:707
0x400dfa1d: mp_call_method_n_kw at /home/somewhere/micropython/py/runtime.c:723
0x400862ce: mp_execute_bytecode at /home/somewhere/micropython/py/vm.c:1042
0x400d9b43: fun_bc_call at /home/somewhere/micropython/py/objfun.c:273
0x400df959: mp_call_function_n_kw at /home/somewhere/micropython/py/runtime.c:707
0x4008622d: mp_execute_bytecode at /home/somewhere/micropython/py/vm.c:957
0x400d9b43: fun_bc_call at /home/somewhere/micropython/py/objfun.c:273
0x400df959: mp_call_function_n_kw at /home/somewhere/micropython/py/runtime.c:707
0x400dfa1d: mp_call_method_n_kw at /home/somewhere/micropython/py/runtime.c:723
0x400862ce: mp_execute_bytecode at /home/somewhere/micropython/py/vm.c:1042
0x400d9b43: fun_bc_call at /home/somewhere/micropython/py/objfun.c:273
0x400df959: mp_call_function_n_kw at /home/somewhere/micropython/py/runtime.c:707
0x400dfa1d: mp_call_method_n_kw at /home/somewhere/micropython/py/runtime.c:723
0x400862ce: mp_execute_bytecode at /home/somewhere/micropython/py/vm.c:1042
0x400d9b43: fun_bc_call at /home/somewhere/micropython/py/objfun.c:273
0x400df959: mp_call_function_n_kw at /home/somewhere/micropython/py/runtime.c:707
0x400dfa1d: mp_call_method_n_kw at /home/somewhere/micropython/py/runtime.c:723
0x400862ce: mp_execute_bytecode at /home/somewhere/micropython/py/vm.c:1042
0x400d9b43: fun_bc_call at /home/somewhere/micropython/py/objfun.c:273
0x400df959: mp_call_function_n_kw at /home/somewhere/micropython/py/runtime.c:707
0x400df96e: mp_call_function_0 at /home/somewhere/micropython/py/runtime.c:681
0x4010b58b: parse_compile_execute at /home/somewhere/micropython/shared/runtime/pyexec.c:123
0x4010b89d: pyexec_friendly_repl at /home/somewhere/micropython/shared/runtime/pyexec.c:675
0x4010e17c: mp_task at /home/karlp/src/pk-matter/matter-micropython-esp32/components/micropython/mp_main.c:149
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment