diff --git a/cm_backtrace/cm_backtrace.c b/cm_backtrace/cm_backtrace.c index 8390803..f690590 100644 --- a/cm_backtrace/cm_backtrace.c +++ b/cm_backtrace/cm_backtrace.c @@ -208,8 +208,9 @@ static void get_cur_thread_stack_info(uint32_t *sp, uint32_t *start_addr, size_t *start_addr = (uint32_t) OSTCBCurPtr->StkBasePtr; *size = OSTCBCurPtr->StkSize * sizeof(CPU_STK_SIZE); #elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_FREERTOS) - *start_addr = (uint32_t)vTaskStackAddr(); - *size = vTaskStackSize() * sizeof( StackType_t ); + tskTCB_t * task_handle = (tskTCB_t *)xTaskGetCurrentTaskHandle(); + *start_addr = (StackType_t)task_handle->pxStack; + *size = (StackType_t)task_handle - (StackType_t)task_handle->pxStack - 4 * sizeof(StackType_t); #elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_RTX5) osRtxThread_t *thread = osRtxInfo.thread.run.curr; *start_addr = (uint32_t)thread->stack_mem; @@ -241,7 +242,8 @@ static const char *get_cur_thread_name(void) { return (const char *)OSTCBCurPtr->NamePtr; #elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_FREERTOS) - return vTaskName(); + tskTCB_t * task_handle = (tskTCB_t *)xTaskGetCurrentTaskHandle(); + return task_handle->pcTaskName; #elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_RTX5) return osRtxInfo.thread.run.curr->name; #endif diff --git a/cm_backtrace/cmb_def.h b/cm_backtrace/cmb_def.h index a78894b..ea110e5 100644 --- a/cm_backtrace/cmb_def.h +++ b/cm_backtrace/cmb_def.h @@ -342,10 +342,23 @@ if (!(EXPR)) \ #elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_UCOSIII) #include #elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_FREERTOS) - #include - extern uint32_t *vTaskStackAddr(void);/* need to modify the FreeRTOS/tasks source code */ - extern uint32_t vTaskStackSize(void); - extern char * vTaskName(void); + #include + #include + typedef struct /* The old naming convention is used to prevent breaking kernel aware debuggers. */ + { + volatile StackType_t * pxTopOfStack; /*< Points to the location of the last item placed on the tasks stack. THIS MUST BE THE FIRST MEMBER OF THE TCB STRUCT. */ + + #if ( portUSING_MPU_WRAPPERS == 1 ) + xMPU_SETTINGS xMPUSettings; /*< The MPU settings are defined as part of the port layer. THIS MUST BE THE SECOND MEMBER OF THE TCB STRUCT. */ + #endif + + ListItem_t xStateListItem; /*< The list that the state list item of a task is reference from denotes the state of that task (Ready, Blocked, Suspended ). */ + ListItem_t xEventListItem; /*< Used to reference a task from an event list. */ + UBaseType_t uxPriority; /*< The priority of the task. 0 is the lowest priority. */ + StackType_t * pxStack; /*< Points to the start of the stack. */ + char pcTaskName[ configMAX_TASK_NAME_LEN ]; /*< Descriptive name given to the task when created. Facilitates debugging only. */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + } tskTCB_t; + extern TaskHandle_t xTaskGetCurrentTaskHandle(void); #elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_RTX5) #include "rtx_os.h" #else