mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +03:00
fix(esp_system/panic): ensure breakpoint set from panic handler gets hit afterwards
This commit is contained in:
@@ -394,6 +394,12 @@ void esp_panic_handler(panic_info_t *info)
|
||||
}
|
||||
panic_print_str("Setting breakpoint at 0x");
|
||||
panic_print_hex((uint32_t)info->addr);
|
||||
#if __riscv
|
||||
// Interrupts can trigger before the breakpoint is hit,
|
||||
// so disable them on global level to avoid any further execution.
|
||||
RV_CLEAR_CSR(mstatus, MSTATUS_MPIE | MSTATUS_SPIE | MSTATUS_UPIE);
|
||||
panic_print_str(", disabling global interrupts,");
|
||||
#endif
|
||||
panic_print_str(" and returning...\r\n");
|
||||
|
||||
// Trigger early breakpoint handlers before returning to debugger.
|
||||
@@ -404,7 +410,13 @@ void esp_panic_handler(panic_info_t *info)
|
||||
esp_panic_trigger_event(ESP_SYS_EVENT_PANIC_EARLY_BREAK, &panic_ctx);
|
||||
|
||||
panic_disable_all_wdts();
|
||||
esp_cpu_set_breakpoint(0, info->addr); // use breakpoint 0
|
||||
// use breakpoint 0
|
||||
if (esp_cpu_set_breakpoint(0, info->addr) != ESP_OK) {
|
||||
#if __riscv
|
||||
// Halt here if unable to set a breakpoint.
|
||||
asm("ebreak");
|
||||
#endif
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif //CONFIG_ESP_DEBUG_OCDAWARE
|
||||
|
||||
Reference in New Issue
Block a user