Skip to content

Commit

Permalink
Merge branch 'bugfix/allow_coredump_gdb_simu' into 'master'
Browse files Browse the repository at this point in the history
coredump: allow coredump at panic even if gdbstub is used.

Closes IDFGH-8567

See merge request espressif/esp-idf!22103
  • Loading branch information
ESP-Marius committed Feb 20, 2023
2 parents eb40fc9 + ec57895 commit 89190fa
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
16 changes: 8 additions & 8 deletions components/esp_system/panic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down
16 changes: 16 additions & 0 deletions tools/test_apps/system/panic/pytest_panic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions tools/test_apps/system/panic/sdkconfig.ci.gdbstub_coredump
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 89190fa

Please sign in to comment.