diff --git a/components/esp_system/panic.c b/components/esp_system/panic.c index 4073564742a4..9bcada6312e9 100644 --- a/components/esp_system/panic.c +++ b/components/esp_system/panic.c @@ -352,14 +352,6 @@ void esp_panic_handler(panic_info_t *info) esp_panic_handler_reconfigure_wdts(1000); // restore WDT config #endif // CONFIG_APPTRACE_ENABLE -#if CONFIG_ESP_SYSTEM_PANIC_GDBSTUB - disable_all_wdts(); - wdt_hal_write_protect_disable(&rtc_wdt_ctx); - wdt_hal_disable(&rtc_wdt_ctx); - wdt_hal_write_protect_enable(&rtc_wdt_ctx); - panic_print_str("Entering gdb stub now.\r\n"); - esp_gdbstub_panic_handler((void *)info->frame); -#else #if CONFIG_ESP_COREDUMP_ENABLE static bool s_dumping_core; if (s_dumping_core) { @@ -379,6 +371,14 @@ void esp_panic_handler(panic_info_t *info) } #endif /* CONFIG_ESP_COREDUMP_ENABLE */ +#if CONFIG_ESP_SYSTEM_PANIC_GDBSTUB + disable_all_wdts(); + wdt_hal_write_protect_disable(&rtc_wdt_ctx); + wdt_hal_disable(&rtc_wdt_ctx); + wdt_hal_write_protect_enable(&rtc_wdt_ctx); + panic_print_str("Entering gdb stub now.\r\n"); + esp_gdbstub_panic_handler((void *)info->frame); +#else #if CONFIG_ESP_SYSTEM_PANIC_REBOOT_DELAY_SECONDS // start RTC WDT if it hasn't been started yet and set the timeout to more than the delay time wdt_hal_init(&rtc_wdt_ctx, WDT_RWDT, 0, false); diff --git a/tools/test_apps/system/panic/pytest_panic.py b/tools/test_apps/system/panic/pytest_panic.py index 64ad0319a7df..a0900c0c72b9 100644 --- a/tools/test_apps/system/panic/pytest_panic.py +++ b/tools/test_apps/system/panic/pytest_panic.py @@ -705,3 +705,19 @@ def test_rtc_slow_reg2_execute_violation(dut: PanicTestDut, test_func_name: str) dut.expect(r'Read operation at address [0-9xa-f]+ not permitted \((\S+)\)') dut.expect_reg_dump(0) dut.expect_corrupted_backtrace() + + +@pytest.mark.esp32 +@pytest.mark.parametrize('config', ['gdbstub_coredump'], indirect=True) +def test_gdbstub_coredump(dut: PanicTestDut) -> None: + test_func_name = 'test_storeprohibited' + dut.run_test_func(test_func_name) + + dut.process_coredump_uart() + + dut.expect_exact('Entering gdb stub now.') + dut.start_gdb() + frames = dut.gdb_backtrace() + dut.verify_gdb_backtrace(frames, get_default_backtrace(test_func_name)) + dut.revert_log_level() + return # don't expect "Rebooting" output below diff --git a/tools/test_apps/system/panic/sdkconfig.ci.gdbstub_coredump b/tools/test_apps/system/panic/sdkconfig.ci.gdbstub_coredump new file mode 100644 index 000000000000..dfece5b17229 --- /dev/null +++ b/tools/test_apps/system/panic/sdkconfig.ci.gdbstub_coredump @@ -0,0 +1,4 @@ +CONFIG_ESP_COREDUMP_ENABLE_TO_UART=y +CONFIG_ESP_COREDUMP_DATA_FORMAT_BIN=y +CONFIG_ESP_COREDUMP_CHECKSUM_CRC32=y +CONFIG_ESP_SYSTEM_PANIC_GDBSTUB=y