gdbstub: added cpu id of running tasks to the output

This commit is contained in:
Felipe Neves 2020-04-16 17:48:01 -03:00 committed by bot
parent 5279e68146
commit c296d01737
3 changed files with 32 additions and 1 deletions

View file

@ -22,6 +22,7 @@
static void init_task_info(void); static void init_task_info(void);
static void find_paniced_task_index(void); static void find_paniced_task_index(void);
static int handle_task_commands(unsigned char *cmd, int len); static int handle_task_commands(unsigned char *cmd, int len);
static void esp_gdbstub_send_str_as_hex(const char *str);
#endif #endif
static void send_reason(void); static void send_reason(void);
@ -89,6 +90,7 @@ static uint32_t gdbstub_hton(uint32_t i)
return __builtin_bswap32(i); return __builtin_bswap32(i);
} }
#ifdef CONFIG_ESP_GDBSTUB_SUPPORT_TASKS
static void esp_gdbstub_send_str_as_hex(const char *str) static void esp_gdbstub_send_str_as_hex(const char *str)
{ {
while (*str) { while (*str) {
@ -96,6 +98,8 @@ static void esp_gdbstub_send_str_as_hex(const char *str)
str++; str++;
} }
} }
#endif
/** Send all registers to gdb */ /** Send all registers to gdb */
static void handle_g_command(const unsigned char* cmd, int len) static void handle_g_command(const unsigned char* cmd, int len)
{ {
@ -188,6 +192,11 @@ static eTaskState get_task_state(size_t index)
return s_scratch.tasks[index].eState; return s_scratch.tasks[index].eState;
} }
static int get_task_cpu_id(size_t index)
{
return s_scratch.tasks[index].xCpuId;
}
/** Get the index of the task running on the current CPU, and save the result */ /** Get the index of the task running on the current CPU, and save the result */
static void find_paniced_task_index(void) static void find_paniced_task_index(void)
{ {
@ -306,7 +315,9 @@ static void handle_qThreadExtraInfo_command(const unsigned char* cmd, int len)
eTaskState state = get_task_state(task_index); eTaskState state = get_task_state(task_index);
switch (state) { switch (state) {
case eRunning: case eRunning:
esp_gdbstub_send_str_as_hex("State: Running"); esp_gdbstub_send_str_as_hex("State: Running ");
esp_gdbstub_send_str_as_hex("@CPU");
esp_gdbstub_send_hex(get_task_cpu_id(task_index) + '0', 8);
break; break;
case eReady: case eReady:
esp_gdbstub_send_str_as_hex("State: Ready"); esp_gdbstub_send_str_as_hex("State: Ready");

View file

@ -200,6 +200,7 @@ typedef struct xTASK_SNAPSHOT
StackType_t *pxEndOfStack; /*!< Points to the end of the stack. pxTopOfStack < pxEndOfStack, stack grows hi2lo StackType_t *pxEndOfStack; /*!< Points to the end of the stack. pxTopOfStack < pxEndOfStack, stack grows hi2lo
pxTopOfStack > pxEndOfStack, stack grows lo2hi*/ pxTopOfStack > pxEndOfStack, stack grows lo2hi*/
eTaskState eState; /*!< Current state of the task. Can be running or suspended */ eTaskState eState; /*!< Current state of the task. Can be running or suspended */
BaseType_t xCpuId; /*!< CPU where this task was running */
} TaskSnapshot_t; } TaskSnapshot_t;
/** /**

View file

@ -5058,6 +5058,25 @@ TickType_t uxReturn;
pxTaskSnapshotArray[ *uxTask ].pxTCB = pxTCB; pxTaskSnapshotArray[ *uxTask ].pxTCB = pxTCB;
pxTaskSnapshotArray[ *uxTask ].pxTopOfStack = (StackType_t *)pxTCB->pxTopOfStack; pxTaskSnapshotArray[ *uxTask ].pxTopOfStack = (StackType_t *)pxTCB->pxTopOfStack;
pxTaskSnapshotArray[ *uxTask ].eState = eTaskGetState(pxTCB); pxTaskSnapshotArray[ *uxTask ].eState = eTaskGetState(pxTCB);
if(pxTaskSnapshotArray[ *uxTask ].eState == eRunning)
{
BaseType_t xCoreId = xPortGetCoreID();
/* task is running, let's find in which core it is located */
if(pxTCB == pxCurrentTCB[xCoreId])
{
pxTaskSnapshotArray[ *uxTask ].xCpuId = xCoreId;
}
else
{
pxTaskSnapshotArray[ *uxTask ].xCpuId = !xCoreId;
}
}
else
{
pxTaskSnapshotArray[ *uxTask ].xCpuId = -1;
}
#if( portSTACK_GROWTH < 0 ) #if( portSTACK_GROWTH < 0 )
{ {
pxTaskSnapshotArray[ *uxTask ].pxEndOfStack = pxTCB->pxEndOfStack; pxTaskSnapshotArray[ *uxTask ].pxEndOfStack = pxTCB->pxEndOfStack;