From bd4e48d0d92c0fab34d12b81a00c619153c9b2bc Mon Sep 17 00:00:00 2001 From: "harshal.patil" Date: Wed, 19 Jun 2024 17:36:14 +0530 Subject: [PATCH] feat(cpu): Configure panic exception generation using asm illegal instruction --- components/esp_system/panic.c | 9 ++++++--- tools/test_apps/system/panic/pytest_panic.py | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/components/esp_system/panic.c b/components/esp_system/panic.c index 20851d554c..4abdac0437 100644 --- a/components/esp_system/panic.c +++ b/components/esp_system/panic.c @@ -461,9 +461,12 @@ void IRAM_ATTR __attribute__((noreturn, no_sanitize_undefined)) panic_abort(cons #endif #endif - ESP_COMPILER_DIAGNOSTIC_PUSH_IGNORE("-Wanalyzer-null-dereference") - *((volatile int *) 0) = 0; // NOLINT(clang-analyzer-core.NullDereference) should be an invalid operation on targets - ESP_COMPILER_DIAGNOSTIC_POP("-Wanalyzer-null-dereference") +#ifdef __XTENSA__ + asm("ill"); // should be an invalid operation on xtensa targets +#elif __riscv + asm("unimp"); // should be an invalid operation on RISC-V targets +#endif + while (1); } diff --git a/tools/test_apps/system/panic/pytest_panic.py b/tools/test_apps/system/panic/pytest_panic.py index a5269a0c6e..3339147b20 100644 --- a/tools/test_apps/system/panic/pytest_panic.py +++ b/tools/test_apps/system/panic/pytest_panic.py @@ -1050,9 +1050,9 @@ def _test_coredump_summary(dut: PanicTestDut, flash_encrypted: bool, coredump_en dut.expect_elf_sha256('App ELF file SHA256: ') dut.expect_exact('Crashed task: main') if dut.is_xtensa: - dut.expect_exact('Exception cause: 29') + dut.expect_exact('Exception cause: 0') else: - dut.expect_exact('Exception cause: 7') + dut.expect_exact('Exception cause: 2') dut.expect(PANIC_ABORT_PREFIX + r'assert failed:[\s\w()]*?\s[.\w/]*\.(?:c|cpp|h|hpp):\d.*$')