mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-02 20:24:32 +02:00
RISC-V: fix PC not saved when using backtrace
This commit is contained in:
@@ -509,14 +509,12 @@ void vApplicationGetTimerTaskMemory(StaticTask_t **ppxTimerTaskTCBBuffer,
|
|||||||
* Wrapper to allow task functions to return. Force the optimization option -O1 on that function to make sure there
|
* 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`.
|
* 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:
|
* Thanks to `naked` attribute, the compiler won't generate a prologue and epilogue for the function, which saves time
|
||||||
* #2 0x00000000 in ?? ()
|
* and stack space.
|
||||||
*
|
|
||||||
* However, this also means that when calculating vPortTaskWrapper's call frame in a backtrace, return address
|
|
||||||
* register `ra`, will NOT contain 0x00000000.
|
|
||||||
*/
|
*/
|
||||||
static void __attribute__((optimize("O1"), naked)) vPortTaskWrapper(TaskFunction_t pxCode, void *pvParameters)
|
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);
|
extern void __attribute__((noreturn)) panic_abort(const char *details);
|
||||||
static char DRAM_ATTR msg[80] = "FreeRTOS: FreeRTOS Task \"\0";
|
static char DRAM_ATTR msg[80] = "FreeRTOS: FreeRTOS Task \"\0";
|
||||||
pxCode(pvParameters);
|
pxCode(pvParameters);
|
||||||
@@ -526,7 +524,6 @@ static void __attribute__((optimize("O1"), naked)) vPortTaskWrapper(TaskFunction
|
|||||||
strcat(msg, pcTaskName);
|
strcat(msg, pcTaskName);
|
||||||
strcat(msg, "\" should not return, Aborting now!");
|
strcat(msg, "\" should not return, Aborting now!");
|
||||||
panic_abort(msg);
|
panic_abort(msg);
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif // CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER
|
#endif // CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER
|
||||||
|
|
||||||
|
@@ -118,11 +118,12 @@ void vPortEndScheduler(void)
|
|||||||
* Wrapper to allow task functions to return. Force the optimization option -O1 on that function to make sure there
|
* 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`.
|
* 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:
|
* Thanks to `naked` attribute, the compiler won't generate a prologue and epilogue for the function, which saves time
|
||||||
* #2 0x00000000 in ?? ()
|
* and stack space.
|
||||||
*/
|
*/
|
||||||
static void __attribute__((optimize("O1"), naked)) vPortTaskWrapper(TaskFunction_t pxCode, void *pvParameters)
|
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);
|
extern void __attribute__((noreturn)) panic_abort(const char *details);
|
||||||
static char DRAM_ATTR msg[80] = "FreeRTOS: FreeRTOS Task \"\0";
|
static char DRAM_ATTR msg[80] = "FreeRTOS: FreeRTOS Task \"\0";
|
||||||
pxCode(pvParameters);
|
pxCode(pvParameters);
|
||||||
@@ -132,7 +133,6 @@ static void __attribute__((optimize("O1"), naked)) vPortTaskWrapper(TaskFunction
|
|||||||
strcat(msg, pcTaskName);
|
strcat(msg, pcTaskName);
|
||||||
strcat(msg, "\" should not return, Aborting now!");
|
strcat(msg, "\" should not return, Aborting now!");
|
||||||
panic_abort(msg);
|
panic_abort(msg);
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif // CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER
|
#endif // CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user