diff --git a/components/esp_gdbstub/src/gdbstub.c b/components/esp_gdbstub/src/gdbstub.c index a70dbf60a9..58de02193c 100644 --- a/components/esp_gdbstub/src/gdbstub.c +++ b/components/esp_gdbstub/src/gdbstub.c @@ -396,12 +396,23 @@ const StaticTask_t *esp_gdbstub_find_tcb_by_frame(const esp_gdbstub_frame_t *fra while (xTaskGetNext(&xTaskIter) != -1) { StaticTask_t *tcb = (StaticTask_t *)xTaskIter.pxTaskHandle; - if (tcb->pxDummy1 /* pxTopOfStack */ == frame) { + /* + * For the currently running task, pxTopOfStack is not up-to-date — it is only + * updated on the next context switch. Therefore we cannot rely on it to match + * the frame to a task. Instead, check if the frame lies within the task's stack. + */ + if ((uintptr_t)frame >= (uintptr_t)tcb->pxDummy6 /* pxStack */ && + (uintptr_t)frame <= (uintptr_t)tcb->pxDummy8 /* pxEndOfStack */) { return tcb; } } - return NULL; /* Task not found. */ + /* + * If no task stack contains the frame, it is likely allocated on the interrupt/exception + * stack (e.g. during a panic event). In that case, return the current task handle, + * which is the task that was running on this core when the exception occurred. + */ + return (const StaticTask_t *)xTaskGetCurrentTaskHandle(); } /** Send string as a het to uart */ diff --git a/tools/test_apps/system/gdbstub_runtime/main/coproc_regs.c b/tools/test_apps/system/gdbstub_runtime/main/coproc_regs.c index e8d1b765db..522698de83 100644 --- a/tools/test_apps/system/gdbstub_runtime/main/coproc_regs.c +++ b/tools/test_apps/system/gdbstub_runtime/main/coproc_regs.c @@ -93,7 +93,7 @@ static void test_fpu(void * arg) #if CONFIG_IDF_TARGET_ARCH_XTENSA __asm__ volatile ("ssi f0, %0, 0" :: "a" (&fpu_regs)); #endif -#if 0 // TODO IDF-15053: set CONFIG_IDF_TARGET_ARCH_RISCV +#if CONFIG_IDF_TARGET_ARCH_RISCV __asm__ volatile ("fsw ft0, %0" : "=m" (fpu_regs.ft0)); #endif