{"id":13802678,"url":"https://github.com/tve/esp32-backtrace","last_synced_at":"2025-03-19T17:30:34.759Z","repository":{"id":146951418,"uuid":"194022128","full_name":"tve/esp32-backtrace","owner":"tve","description":"Simple bash script to annotate an ESP32 exception backtrace with source code info","archived":false,"fork":false,"pushed_at":"2019-08-21T15:37:17.000Z","size":7,"stargazers_count":21,"open_issues_count":2,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-22T13:31:31.348Z","etag":null,"topics":["esp32","esp32-arduino"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tve.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-06-27T04:22:36.000Z","updated_at":"2024-03-15T13:37:04.000Z","dependencies_parsed_at":"2024-01-27T08:46:50.113Z","dependency_job_id":null,"html_url":"https://github.com/tve/esp32-backtrace","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tve%2Fesp32-backtrace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tve%2Fesp32-backtrace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tve%2Fesp32-backtrace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tve%2Fesp32-backtrace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tve","download_url":"https://codeload.github.com/tve/esp32-backtrace/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221729375,"owners_count":16871004,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["esp32","esp32-arduino"],"created_at":"2024-08-04T00:01:50.120Z","updated_at":"2024-10-27T20:25:49.877Z","avatar_url":"https://github.com/tve.png","language":"Shell","readme":"ESP32 Exception Stack Backtrace Analyzer\n========================================\n\nThis little bash script parses the exception backtrace printed by the ESP32 firmware\nand uses GDB to print out the source location of all code addresses.\n\nIt is heavily inspired by https://github.com/me-no-dev/EspExceptionDecoder but only uses\nbash and xtensa-esp32-elf GDB.\n\n__Install:__ Place the esp32-backtrace script somewhere in your path or use the full pathname to run\nit. If you are not using platformio to build your project you need to edit the `XTENSA_GDB`\ndefinition at the top of the script.\n\nExample\n-------\nMy program crashed printing:\n```\nGuru Meditation Error: Core  0 panic'ed (Unhandled debug exception)\nDebug exception reason: Stack canary watchpoint triggered (Tmr Svc)\nCore 0 register dump:\nPC      : 0x40081708  PS      : 0x00060336  A0      : 0x3ffbc990  A1      : 0x3ffbc8d0\nA2      : 0x3ffb7dd0  A3      : 0x00000000  A4      : 0x3ffb7e18  A5      : 0x00000000\nA6      : 0x00000001  A7      : 0x00000018  A8      : 0x800894ac  A9      : 0x3ffbc970\nA10     : 0x00000000  A11     : 0x3ffc12c8  A12     : 0x3ffc12c8  A13     : 0x00000001\nA14     : 0x00060320  A15     : 0x00000000  SAR     : 0x00000002  EXCCAUSE: 0x00000001\nEXCVADDR: 0x00000000  LBEG    : 0x40001609  LEND    : 0x4000160d  LCOUNT  : 0x00000000\n\nBacktrace: 0x40081708:0x3ffbc8d0 0x3ffbc98d:0x3ffbc9d0 0x400d85b6:0x3ffbc9f0 0x40082926:0x3ffbca10 0\nx400822fe:0x3ffbca30 0x400dd591:0x3ffbcaa0 0x400dc019:0x3ffbcac0 0x400dc467:0x3ffbcae0 0x400dc5f5:0x\n3ffbcb50 0x400db105:0x3ffbcbd0 0x400db1b4:0x3ffbcc50 0x400da27e:0x3ffbccb0 0x400da7b1:0x3ffbccf0 0x4\n01396b2:0x3ffbcd10 0x401398a6:0x3ffbcd60 0x401398f9:0x3ffbcd90 0x401017ec:0x3ffbcdb0 0x401019fa:0x3f\nfbcde0 0x400d9721:0x3ffbce10 0x400\n```\nI use platformio so the elf file for my application is in\n`.pio/build/{environment}/{project}.elf`\nso I launched the esp-backtrace as:\n`esp32-backtrace .pio/build/usb/esp32-secure-base.elf`\nand I pasted the crash printout into its stdin and the result is:\n```\nPC: 0x40081708 is at esp-idf-public/components/freertos/xtensa_vectors.S:1118.\nBT-0: 0x40081708 is at esp-idf-public/components/freertos/xtensa_vectors.S:1118.\nBT-2: 0x400d85b6 is in esp_ipc_call (esp-idf-public/components/esp32/ipc.c:123).\nBT-3: 0x40082926 is in spi_flash_disable_interrupts_caches_and_other_cpu (esp-idf-public/components/\nspi_flash/cache_utils.c:120).\nBT-4: 0x400822fe is in spi_flash_read (esp-idf-public/components/spi_flash/flash_ops.c:154).\nBT-5: 0x400dd591 is in nvs::nvs_flash_read(unsigned int, void*, unsigned int) (esp-idf-public/compon\nents/nvs_flash/src/nvs_ops.cpp:70).\nBT-6: 0x400dc019 is in nvs::Page::readEntry(unsigned int, nvs::Item\u0026) const (esp-idf-public/componen\nts/nvs_flash/src/nvs_page.cpp:717).\nBT-7: 0x400dc467 is in nvs::Page::findItem(unsigned char, nvs::ItemType, char const*, unsigned int\u0026,\n nvs::Item\u0026, unsigned char, nvs::VerOffset) (esp-idf-public/components/nvs_flash/src/nvs_page.cpp:76\n1).\nBT-8: 0x400dc5f5 is in nvs::Page::readItem(unsigned char, nvs::ItemType, char const*, void*, unsigne\nd int, unsigned char, nvs::VerOffset) (esp-idf-public/components/nvs_flash/src/nvs_page.cpp:266).\nBT-9: 0x400db105 is in nvs::Storage::readMultiPageBlob(unsigned char, char const*, void*, unsigned i\nnt) (esp-idf-public/components/nvs_flash/src/nvs_storage.cpp:430).\nBT-10: 0x400db1b4 is in nvs::Storage::readItem(unsigned char, nvs::ItemType, char const*, void*, uns\nigned int) (esp-idf-public/components/nvs_flash/src/nvs_storage.cpp:455).\nBT-11: 0x400da27e is in nvs_get_str_or_blob(nvs_handle, nvs::ItemType, char const*, void*, size_t*)\n(esp-idf-public/components/nvs_flash/src/nvs_api.cpp:515).\nBT-12: 0x400da7b1 is in nvs_get_blob(nvs_handle, char const*, void*, size_t*) (esp-idf-public/compon\nents/nvs_flash/src/nvs_api.cpp:525).\nBT-18: 0x400d9721 is in esp_wifi_init (esp-idf-public/components/esp32/wifi_init.c:51).\nBT-24: 0x4008b3ba is in prvProcessExpiredTimer (esp-idf-public/components/freertos/timers.c:524).\nBT-25: 0x4008b3ed is in prvProcessTimerOrBlockTask (esp-idf-public/components/freertos/timers.c:571)\n.\nBT-26: 0x4008b508 is in prvTimerTask (esp-idf-public/components/freertos/timers.c:544).\nBT-27: 0x40088781 is in vPortTaskWrapper (esp-idf-public/components/freertos/port.c:143).\n```\nThis tells me that the problem happens in an Arduino system task somewhere in\n`esp_wifi_init` (see BT-18).\n\n### Notes:\n- the backtrace shows the inner-most frame first (BT-0) and then goes back in history.\n- instead of pasting the exception text on stdin you can also specify a file to read from as second\n  argument.\n- it is OK to have the \"Backtrace:\" line from the exception text be split up due to copy\u0026paste\n  line-wrapping caused by the terminal emulator, the script joins them back together.\n\nIssues\n------\n- While the script handles `Backtrace` continuation lines it doesn't join addresses that get split\n  at the end of the terminal window.\n- GDB is invoked for each address, which is inefficient. It works ok for me, but it would be more\n  elegant to construct a script for GDB and pipe that in so GDB only reads and parses the elf file\n  once.\n- Anything that looks like an address in a register will be printed, whether it's live data or some\n  stale value.\n","funding_links":[],"categories":["Development"],"sub_categories":["Debugging"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftve%2Fesp32-backtrace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftve%2Fesp32-backtrace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftve%2Fesp32-backtrace/lists"}