janLo / EspArduinoExceptionDecoder

Python Script to decode ESP8266 Exceptions.
GNU General Public License v3.0
59 stars 25 forks source link

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

Open me21 opened 6 years ago

me21 commented 6 years ago

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

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

kelunik commented 6 years ago

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 commented 6 years ago

Can you please attach your ELF file?

trycoon commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

@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 commented 5 years ago

This worked for me on a esp32 backtrace

sguarin commented 4 years ago

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

mrkeuz commented 3 years ago

Worked on Linux. Thanks!

Couple notices:

Anyway, thanks for all authors! 💪