Skip to content

Fixed running on Windows. Added ESP32 backtrace parsing. #5

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

me21
Copy link

@me21 me21 commented Jul 4, 2018

Partially fixes #4 (backtrace decoding). Registers decoding is not done yet.

Signed-off-by: Alexandr Zarubkin me21@yandex.ru

Signed-off-by: Alexandr Zarubkin <me21@yandex.ru>
@kelunik
Copy link

kelunik commented Aug 16, 2018

This doesn't seem to work correctly:

./decoder.py -p ESP32 -t ~/.platformio/packages/toolchain-xtensa32 -e ~/Documents/PlatformIO/Projects/Test/.pioenvs/esp32dev/firmware.elf -f exception.txt
stack:
Traceback (most recent call last):
  File "./decoder.py", line 319, in <module>
    print_result(parser, resolver, args.platform, args.full, args.stack_only)
  File "./decoder.py", line 271, in print_result
    print_stack_full(parser.stack, resolver)
  File "./decoder.py", line 235, in print_stack_full
    print(line.offset + ":")
TypeError: unsupported operand type(s) for +: 'int' and 'str'
Backtrace: 0x400e6bd9:0x3ffb1f40 0x400d1cc9:0x3ffb1f70 0x4012a943:0x3ffb1fa0

@me21
Copy link
Author

me21 commented Aug 16, 2018

Can you please attach your ELF file?

@trycoon
Copy link

trycoon commented Sep 1, 2018

I have the same problem, you could use mine, please.

./esp-stackstrace-decoder.py -p ESP32 -t ~/.platformio/packages/toolchain-xtensa32 -e liam-esp/.pioenvs/nodemcuv2/firmware.elf stack.trace

"stack.trace" contains:
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x400dd408 PS : 0x00060430 A0 : 0x800ddaa9 A1 : 0x3ffcd1c0
A2 : 0x00000064 A3 : 0x3ffcd1ec A4 : 0x00000000 A5 : 0x3ffcf660
A6 : 0x00000000 A7 : 0x3ffcc1a0 A8 : 0x00000000 A9 : 0x3ffcd1a0
A10 : 0x3ffba660 A11 : 0x00000001 A12 : 0xc1bb94d5 A13 : 0x3ffc6474
A14 : 0x00000020 A15 : 0x00000000 SAR : 0x0000001d EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000064 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xffffffff

Backtrace: 0x400dd408:0x3ffcd1c0 0x400ddaa6:0x3ffcd1e0 0x400d3769:0x3ffcd210 0x400d3959:0x3ffcd240 0x400d3981:0x3ffcd2d0 0x400f6aba:0x3ffcd2f0 0x400f6b27:0x3ffcd310

I zipped the file from liam-esp/.pioenvs/nodemcuv2/firmware.elf
firmware.zip

@janLo
Copy link
Owner

janLo commented Sep 19, 2018

I had a quick look into this. It shouldn't b too difficult to implement a decoder for the ESP32 panic handler format. Information about it can be found at https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/fatal-errors.html#panic-handler and https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/fatal-errors.html#guru-meditation-errors.

The first link on the other hand shows another solution - the IDF Monitor, that seems to have the functionality already implemented: https://docs.espressif.com/projects/esp-idf/en/latest/get-started/idf-monitor.html#automatically-decoding-addresses. The code can be found at https://github.com/espressif/esp-idf/blob/master/tools/idf_monitor.py.

I would prefer to have the parser in a separate class instead of hacked in the one for the 8266. The address-resolver stuff can be reused without problems. maybe @me21 can finish his solution in that sense. I can't promise to have time to do it by myself soon.

If any uncertainties exist about the output of the ESP - its generated from this code: https://github.com/espressif/esp-idf/blob/7abed5fc9e0b652c1db85523a721f56050288d2e/components/esp32/panic.c#L218

@me21
Copy link
Author

me21 commented Sep 20, 2018

@trycoon @janLo Thanks for providing the information. Unfortunately, I've got my hands full at the moment, please feel free to continue working on this.

@BlackEdder
Copy link

This worked for me on a esp32 backtrace

@sguarin
Copy link

sguarin commented Nov 25, 2019

Thanks, worked for me too on a ESP32 on a:
Guru Meditation Error: Core 0 panic'ed (InstrFetchProhibited). Exception was unhandled
...

@mrkeuz
Copy link

mrkeuz commented Sep 1, 2021

Worked on Linux. Thanks!

Couple notices:

  • It does not support uppercase addresses (older version of xtensa gave uppercase, as I found):

    Backtrace: 0x40136DFD:0x3FFB1EC0 0x401515A5:0x3FFB1EE0 ...
    

    Also, I think it needs to sanitize cases 0x vs 0X in address (just in case).

  • It does parse first address without leading space (regexp contain \s+). I think 0x marker is enough for obtain address. Such back trace come from older xtansa

    Backtrace:0x40136DFD:0x3FFB1EC0
    
  • Are you absolutely sure that addresses always start from 0x400-0x402 (decoder.py#L57) ?

    ...
    BACKTRACE_REGEX = re.compile(r"(?:\s+(0x40[0-2](?:\d|[a-f]|[A-F]){5}):0x(?:\d|[a-f]|[A-F]){8})\b")
    ...

    I'm not fluency esp32 developer, don't know lower level "rules".

Anyway, thanks for all authors! 💪

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot decode Guru Meditation Error
7 participants