Skip to content

Commit

Permalink
Merge branch 'feature/pseudo_exccause_to_openocd_v5.1' into 'release/…
Browse files Browse the repository at this point in the history
…v5.1'

Feature/pseudo exccause to openocd (v5.1)

See merge request espressif/esp-idf!26544
  • Loading branch information
jack0c committed Nov 21, 2023
2 parents 58344b1 + b07702b commit 2277c3c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions components/esp_system/panic.c
Expand Up @@ -60,6 +60,14 @@
#include "hal/usb_serial_jtag_ll.h"
#endif

#ifdef __XTENSA__
#include "xtensa/semihosting.h"
#elif __riscv
#include "riscv/semihosting.h"
#endif

#define ESP_SEMIHOSTING_SYS_PANIC_REASON 0x116

#define MWDT_DEFAULT_TICKS_PER_US 500

bool g_panic_abort = false;
Expand Down Expand Up @@ -287,6 +295,17 @@ void esp_panic_handler(panic_info_t *info)
// then only print up to details. Users should be able to probe for the other information
// in debug mode.
if (esp_cpu_dbgr_is_attached()) {
char *panic_reason_str = NULL;
if (info->pseudo_excause) {
panic_reason_str = (char *)info->reason;
} else if (g_panic_abort && strlen(g_panic_abort_details)) {
panic_reason_str = g_panic_abort_details;
}
if (panic_reason_str) {
/* OpenOCD will print the halt cause when target is stopped at the below breakpoint (info->addr) */
long args[] = {(long)panic_reason_str, strlen(panic_reason_str)};
semihosting_call_noerrno(ESP_SEMIHOSTING_SYS_PANIC_REASON, args);
}
panic_print_str("Setting breakpoint at 0x");
panic_print_hex((uint32_t)info->addr);
panic_print_str(" and returning...\r\n");
Expand Down

0 comments on commit 2277c3c

Please sign in to comment.