diff --git a/components/freertos/FreeRTOS-Kernel-SMP/portable/riscv/port.c b/components/freertos/FreeRTOS-Kernel-SMP/portable/riscv/port.c index 1a6ada0cc1..cb4a8bc8bd 100644 --- a/components/freertos/FreeRTOS-Kernel-SMP/portable/riscv/port.c +++ b/components/freertos/FreeRTOS-Kernel-SMP/portable/riscv/port.c @@ -622,14 +622,12 @@ FORCE_INLINE_ATTR UBaseType_t uxInitialiseStackTLS(UBaseType_t uxStackPointer, u * Wrapper to allow task functions to return. Force the optimization option -O1 on that function to make sure there * is no tail-call. Indeed, we need the compiler to keep the return address to this function when calling `panic_abort`. * - * Thanks to the `naked` attribute, GDB stub backtrace doesn't print: - * #2 0x00000000 in ?? () - * - * However, this also means that when calculating vPortTaskWrapper's call frame in a backtrace, return address - * register `ra`, will NOT contain 0x00000000. + * Thanks to `naked` attribute, the compiler won't generate a prologue and epilogue for the function, which saves time + * and stack space. */ static void __attribute__((optimize("O1"), naked)) vPortTaskWrapper(TaskFunction_t pxCode, void *pvParameters) { + asm volatile(".cfi_undefined ra\n"); extern void __attribute__((noreturn)) panic_abort(const char *details); static char DRAM_ATTR msg[80] = "FreeRTOS: FreeRTOS Task \"\0"; pxCode(pvParameters); @@ -639,7 +637,6 @@ static void __attribute__((optimize("O1"), naked)) vPortTaskWrapper(TaskFunction strcat(msg, pcTaskName); strcat(msg, "\" should not return, Aborting now!"); panic_abort(msg); - } #endif // CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER diff --git a/components/freertos/FreeRTOS-Kernel/portable/riscv/port.c b/components/freertos/FreeRTOS-Kernel/portable/riscv/port.c index d3b1582781..13b8cc6cce 100644 --- a/components/freertos/FreeRTOS-Kernel/portable/riscv/port.c +++ b/components/freertos/FreeRTOS-Kernel/portable/riscv/port.c @@ -200,14 +200,12 @@ FORCE_INLINE_ATTR UBaseType_t uxInitialiseStackTLS(UBaseType_t uxStackPointer, u * Wrapper to allow task functions to return. Force the optimization option -O1 on that function to make sure there * is no tail-call. Indeed, we need the compiler to keep the return address to this function when calling `panic_abort`. * - * Thanks to the `naked` attribute, GDB stub backtrace doesn't print: - * #2 0x00000000 in ?? () - * - * However, this also means that when calculating vPortTaskWrapper's call frame in a backtrace, return address - * register `ra`, will NOT contain 0x00000000. + * Thanks to `naked` attribute, the compiler won't generate a prologue and epilogue for the function, which saves time + * and stack space. */ static void __attribute__((optimize("O1"), naked)) vPortTaskWrapper(TaskFunction_t pxCode, void *pvParameters) { + asm volatile(".cfi_undefined ra\n"); extern void __attribute__((noreturn)) panic_abort(const char *details); static char DRAM_ATTR msg[80] = "FreeRTOS: FreeRTOS Task \"\0"; pxCode(pvParameters); @@ -217,7 +215,6 @@ static void __attribute__((optimize("O1"), naked)) vPortTaskWrapper(TaskFunction strcat(msg, pcTaskName); strcat(msg, "\" should not return, Aborting now!"); panic_abort(msg); - } #endif // CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER