Decode stack traces

geschema
Posts: 5
Joined: Thu May 06, 2021 7:59 am

Decode stack traces

Postby geschema » Tue Sep 21, 2021 10:46 am

How do you decode stack traces like this one:

Code: Select all

abort() was called at PC 0x40158ccb on core 0

Backtrace:0x40088eba:0x3ffc5030 0x40089601:0x3ffc5050 0x4008fc62:0x3ffc5070 0x40158ccb:0x3ffc50e0 0x4008c1b5:0x3ffc5110 0x4008c27d:0x3ffc5130 0x4008c585:0x3ffc5150
What I've been doing so far is dump the symbols table to a text file using "readelf.py -s" and then look for approximately matching addresses in that file, but it's a tedious process. Is there a simpler way to do it?

StridingDragon
Posts: 46
Joined: Fri Aug 02, 2019 11:59 pm

Re: Decode stack traces

Postby StridingDragon » Thu Sep 23, 2021 1:51 am

The Espressif tools contain a tool called `xtensa-esp32-elf-addr2line` which will interpret the addresses for you and give you proper information about the source files, lines and function names, etc. You can feed it the entire backtrace and it will display the info for all addresses in one swoop, giving you a pretty good picture of the stack.

ns1668
Posts: 50
Joined: Tue Mar 16, 2021 2:00 pm

Re: Decode stack traces

Postby ns1668 » Thu Sep 23, 2021 12:34 pm

A backtrace can be analysed as per the instructions below

1. Obtain the backtrace output from terminal:

Backtrace:0x4000c269:0x3ffb7810 0x400d5327:0x3ffb7830 0x400d59a2:0x3ffb7850 0x400d600f:0x3ffb7b20 0x400d5039:0x3ffb7b40 0x400d3f17:0x3ffb7b80

2. Obtain the .elf for the corresponding version of software that is suffering from the crash.
3. Use the xtensa GNU tools to convert addresses 2 lines, from a command prompt as follows:

Code: Select all

C:\Users\USERNAME\.espressif\tools\xtensa-esp32-elf\esp-2020r3-8.4.0\xtensa-esp32-elf\bin\xtensa-esp32-elf-addr2line.exe -fe C:\MYPROJECT\build\MYELF.elf 0x4000c269:0x3ffb7810 0x400d5327:0x3ffb7830 0x400d59a2:0x3ffb7850 0x400d600f:0x3ffb7b20 0x400d5039:0x3ffb7b40 0x400d3f17:0x3ffb7b80

geschema
Posts: 5
Joined: Thu May 06, 2021 7:59 am

Re: Decode stack traces

Postby geschema » Tue Oct 05, 2021 8:12 am

StridingDragon wrote:
Thu Sep 23, 2021 1:51 am
The Espressif tools contain a tool called `xtensa-esp32-elf-addr2line` which will interpret the addresses for you and give you proper information about the source files, lines and function names, etc. You can feed it the entire backtrace and it will display the info for all addresses in one swoop, giving you a pretty good picture of the stack.
Very useful, thanks a lot!

Who is online

Users browsing this forum: axellin and 104 guests