Fix #9194 - Allow more control over crash dump#9196
Fix #9194 - Allow more control over crash dump#9196DRSDavidSoft wants to merge 4 commits intoesp8266:masterfrom
Conversation
Probably just one callback would be ok? We do have custom 'USER' reasons which are private now, but obviously can be moved to a public header. See
Any reason not to fully hide the whole internal printf with a similar flag? Or, at least hide the part of postmortem & funcs calling postmortem that print stuff, structuring it a bit different in the main func especially.
see #7496 |
|
Thank you for the feedback! I agree with your points. Let me elaborate a bit on the original intentions behind these changes while also addressing your suggestions.
|
ref. esp8266#9193, esp8266#9194, esp8266#9196 - persistent & public REASON_USER_... for user callback rst_info reason - public postmortem callback functions, don't overly hide the implementation - separate reasons for panic, assert, abort and c++ exceptions - put postmortem func one level down in the function chain, allow to override both the function itself or individual internals - stack offset for -fexceptions, skip unwind data to the actual point of origin
@mcspr This is a proof of concept PR for an alternative solution to #9193 and also closes #9194. Could you please verify? I would appreciate any input and feedback. Thanks!
Description
This PR adds more granular control over how the crash dump is delivered, and some more features:
custom_panic_callback(panic_file, panic_line, panic_func, panic_what): Allows the user to additionally listen for panics (useful to record them in flash memory)ets_uart_putc1()→crash_ets_uart_putc1(): renamed function that prints to the Serial port. This allows the function to be overridden, possibly applying transformations on the text (useful if transmitting over a Bus-like UART, such as RS-485), remove clutter or insert additional comments (such as uptime), or completely inhibit the dump (useful is uart is connected to a peripheral device)NO_CUT_HERE: Introduce a macro that allows disabling the "CUT HERE" message and the divider lines. Can be used to minify the number of transmitted/recorded characters over the wire or storage. Can be used with the-Dflag.ets_println()instead ofets_putc('\n'): This makes the new lines use the "cooked" interface instead of the "raw" one, which is also used on the staticets_printf_P()function, which allows:printf_P(...)crash_ets_uart_putc1()is overridenrst_info.exccauseused instead of localexccausefor the6exception (divide by zero): unless I'm missing something, this allows the custom_crash_handler at the end of the postmortem function to also receive a correct exception number. Useful for projects such as EspCrashSave and EspCrashSaveSpiffsAdditional notes
The naming of some functions might not be the optimal value, if you would like to suggest a better one please either modify this PR or submit a comment.