Place backtrace_count before array for forward compatibility

Moving backtrace_count before the variable-length backtrace array
ensures magic, pc, and count are at fixed offsets regardless of
MAX_BACKTRACE value. This makes the .noinit data readable across
firmware versions that may change the max backtrace depth.

Co-Authored-By: J. Nick Koston <nick@koston.org>
This commit is contained in:
J. Nick Koston
2026-03-11 11:21:05 -10:00
co-authored by J. Nick Koston
parent f37610bfe1
commit f2dee1433c
+3 -1
View File
@@ -28,11 +28,13 @@ static inline bool IRAM_ATTR is_code_addr(uint32_t addr) {
// Raw crash data written by the panic handler wrapper.
// Lives in .noinit so it survives software reset but contains garbage after power cycle.
// Validated by magic marker. Static linkage since it's only used within this file.
// Field order matters: magic, pc, and backtrace_count are at fixed offsets
// so the struct remains readable even if MAX_BACKTRACE changes between versions.
struct RawCrashData {
uint32_t magic;
uint32_t pc;
uint32_t backtrace[MAX_BACKTRACE];
uint8_t backtrace_count;
uint32_t backtrace[MAX_BACKTRACE];
};
static RawCrashData __attribute__((section(".noinit"))) s_raw_crash_data;