From 19c3187bb5c7b056bcb34dbe54ecec613c42d993 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 11 Mar 2026 12:06:18 -1000 Subject: [PATCH] Distinguish trusted vs stack-scanned frames in RISC-V output On RISC-V, register-sourced entries (MEPC/RA) are labeled "backtrace" while stack-scanned entries are labeled "stack scan" to help users identify which frames are most trustworthy. Co-Authored-By: J. Nick Koston --- esphome/components/esp32/crash_handler.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/esphome/components/esp32/crash_handler.cpp b/esphome/components/esp32/crash_handler.cpp index fa66209cfe1..82a3839501b 100644 --- a/esphome/components/esp32/crash_handler.cpp +++ b/esphome/components/esp32/crash_handler.cpp @@ -116,7 +116,12 @@ void crash_handler_log() { if (i >= s_raw_crash_data.reg_frame_count && !is_return_addr(addr)) continue; #endif - ESP_LOGE(TAG, " BT%d: 0x%08" PRIX32 " (backtrace)", bt_num++, addr); +#if CONFIG_IDF_TARGET_ARCH_RISCV + const char *source = (i < s_raw_crash_data.reg_frame_count) ? "backtrace" : "stack scan"; +#else + const char *source = "backtrace"; +#endif + ESP_LOGE(TAG, " BT%d: 0x%08" PRIX32 " (%s)", bt_num++, addr, source); } // Build addr2line hint with all captured addresses for easy copy-paste char hint[256];