Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions cm_backtrace/cm_backtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Copy link

@gangli01 gangli01 May 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是否可以使用TaskHandle_t替换tskTCB_t *
TaskHandle_t task_handle = xTaskGetCurrentTaskHandle();

Copy link

@gangli01 gangli01 May 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我尝试这样修改,存在”struct tskTaskControlBlock“未定义的问题。
我改用traceRETURN_xTaskGetCurrentTaskHandle来实现,
#82

return task_handle->pcTaskName;
#elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_RTX5)
return osRtxInfo.thread.run.curr->name;
#endif
Expand Down
21 changes: 17 additions & 4 deletions cm_backtrace/cmb_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,23 @@ if (!(EXPR)) \
#elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_UCOSIII)
#include <os.h>
#elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_FREERTOS)
#include <FreeRTOS.h>
extern uint32_t *vTaskStackAddr(void);/* need to modify the FreeRTOS/tasks source code */
extern uint32_t vTaskStackSize(void);
extern char * vTaskName(void);
#include <FreeRTOS.h>
#include <task.h>
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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @fyyxxm, 这里的tskTCB_t和task.c中tskTCB_t并没有完全对齐,如果FreeRTOSConfig.h中使能了更多的feature, 两边的结构体就会不一致,是不是存在解析错位的风险?

extern TaskHandle_t xTaskGetCurrentTaskHandle(void);
#elif (CMB_OS_PLATFORM_TYPE == CMB_OS_PLATFORM_RTX5)
#include "rtx_os.h"
#else
Expand Down