How to save backtrace and registers in NVS on failure before reboot ESP32?

Good time to all.
Maybe I’m asking a stupid question, but I don’t have much experience. Just post a link if this has already been discussed …

So the problem is as follows.
ESP32 works autonomously, without connecting to a computer. But he can send me messages in telegram, for example. The Internet went out tonight, that is, the router was working, there was a connection to the Wifi, but there was no access to the servers. When access was restored, the device rebooted. I received a message in telegram:

:small_orange_diamond: The device is started
Firmware version: ESPIDF-20210327.04
Restart reason: Software reset due to exception / panic

If at that moment I was connected to the device via UART, then I could see the backtrace and the state of the registers, and from them I can decipher exactly where the exception occurred and try to fix it. But for an autonomously working device, this is not possible.

Question: how, in case of any failures, to save the backtrace and the state of the registers, for example, in NVS, so that after a restart, send this data to me in a message.

I need that something like this came to me in telegram after the failure of ESP 32:

Core 0 register dump:
PC: 0x400e14ed PS: 0x00060030 A0: 0x800d0805 A1: 0x3ffb5030
A2: 0x00000000 A3: 0x00000001 A4: 0x00000001 A5: 0x3ffb50dc
A6: 0x00000000 A7: 0x00000001 A8: 0x00000000 A9: 0x3ffb5000
A10: 0x00000000 A11: 0x3ffb2bac A12: 0x40082d1c A13: 0x06ff1ff8
A14: 0x3ffb7078 A15: 0x00000000 SAR: 0x00000014 EXCCAUSE: 0x0000001d
EXCVADDR: 0x00000000 LBEG: 0x4000c46c LEND: 0x4000c477 LCOUNT: 0xffffffff
Backtrace: 0x400e14ed: 0x3ffb5030 0x400d0802: 0x3ffb5050

I tried to read the “Save core dump to Flash (Flash)” manual, but I’m afraid that’s not what I want at all.

PS: On ESP8266 & Arduino using ESP.getResetInfo () I get the following data:

:small_orange_diamond: The device is started
Sketch version: 20190917.44
Fatal exception: 29 flag: 2 (EXCEPTION) epc1: 0x4021ee62 epc2: 0x00000000 epc3: 0x00000000 excvaddr: 0x00000100 depc: 0x00000000

According to this data, at least something can be understood. Well, I just can’t get anything on ESP32.

Same question! Any idea?

Best to ask the ESP-IDF people if such a feature exists. They would know.

Good day.
I did solve this problem. If interested, the solution is outlined here: Удаленный перехват backtrace на ESP32 | kotyara12.ru