mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-03 03:31:41 +03:00
refactor(panic): route panic handlers through esp_sys_event
Let panic-related components register their hooks through esp_sys_event so panic sequencing stays extensible without hardcoded esp_system dependencies.
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2024-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#include "esp_private/startup_internal.h"
|
||||
#include "esp_private/esp_sys_event_system_init.h"
|
||||
#include "esp_private/esp_sys_event_panic.h"
|
||||
#include "esp_private/panic_internal.h"
|
||||
#include "esp_core_dump.h"
|
||||
|
||||
// Hook to force the linker to include this file
|
||||
@@ -18,3 +21,20 @@ ESP_SYSTEM_INIT_FN(init_coredump, SECONDARY, BIT(0), 130)
|
||||
esp_core_dump_init();
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
// Panic event handler - writes core dump on panic
|
||||
ESP_PANIC_HANDLER_REGISTER(esp_coredump_panic, 200)
|
||||
{
|
||||
(void)user_arg;
|
||||
esp_panic_ctx_t *panic_ctx = (esp_panic_ctx_t *)ctx;
|
||||
|
||||
static bool s_dumping_core = false;
|
||||
if (s_dumping_core) {
|
||||
panic_print_str("Re-entered core dump! Exception happened during core dump!\r\n");
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
s_dumping_core = true;
|
||||
esp_core_dump_write((panic_info_t *)panic_ctx->info);
|
||||
s_dumping_core = false;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user