EspArduinoExceptionDecoder icon indicating copy to clipboard operation
EspArduinoExceptionDecoder copied to clipboard

Fixed running on Windows. Added ESP32 backtrace parsing.

Open me21 opened this issue 6 years ago • 8 comments

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

Signed-off-by: Alexandr Zarubkin [email protected]

me21 avatar Jul 04 '18 15:07 me21

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

kelunik avatar Aug 16 '18 15:08 kelunik

Can you please attach your ELF file?

me21 avatar Aug 16 '18 15:08 me21

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

trycoon avatar Sep 01 '18 07:09 trycoon

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

janLo avatar Sep 19 '18 21:09 janLo

@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.

me21 avatar Sep 20 '18 14:09 me21

This worked for me on a esp32 backtrace

BlackEdder avatar Jun 29 '19 11:06 BlackEdder

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

sguarin avatar Nov 25 '19 03:11 sguarin

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! 💪

mrkeuz avatar Sep 01 '21 03:09 mrkeuz