gdbstub: improve format of info thread command output
gdbstub: simplify the state handling on extra thread info
This commit is contained in:
parent
9a54a0af13
commit
5279e68146
2 changed files with 20 additions and 32 deletions
|
@ -76,7 +76,6 @@ void esp_gdbstub_panic_handler(esp_gdbstub_frame_t *frame)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void send_reason(void)
|
static void send_reason(void)
|
||||||
{
|
{
|
||||||
esp_gdbstub_send_start();
|
esp_gdbstub_send_start();
|
||||||
|
@ -90,6 +89,13 @@ static uint32_t gdbstub_hton(uint32_t i)
|
||||||
return __builtin_bswap32(i);
|
return __builtin_bswap32(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void esp_gdbstub_send_str_as_hex(const char *str)
|
||||||
|
{
|
||||||
|
while (*str) {
|
||||||
|
esp_gdbstub_send_hex(*str, 8);
|
||||||
|
str++;
|
||||||
|
}
|
||||||
|
}
|
||||||
/** 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)
|
||||||
{
|
{
|
||||||
|
@ -179,10 +185,6 @@ static bool get_task_handle(size_t index, TaskHandle_t *handle)
|
||||||
|
|
||||||
static eTaskState get_task_state(size_t index)
|
static eTaskState get_task_state(size_t index)
|
||||||
{
|
{
|
||||||
if (index >= s_scratch.task_count) {
|
|
||||||
return eInvalid;
|
|
||||||
}
|
|
||||||
|
|
||||||
return s_scratch.tasks[index].eState;
|
return s_scratch.tasks[index].eState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,14 +290,7 @@ static void handle_qsThreadInfo_command(const unsigned char* cmd, int len)
|
||||||
|
|
||||||
/** qThreadExtraInfo requests the thread name */
|
/** qThreadExtraInfo requests the thread name */
|
||||||
static void handle_qThreadExtraInfo_command(const unsigned char* cmd, int len)
|
static void handle_qThreadExtraInfo_command(const unsigned char* cmd, int len)
|
||||||
{
|
{
|
||||||
uint8_t task_state_string_index = 0;
|
|
||||||
const char task_state_string[][] = "Running",
|
|
||||||
"Ready",
|
|
||||||
"Blocked",
|
|
||||||
"Suspended",
|
|
||||||
"Invalid";
|
|
||||||
|
|
||||||
cmd += sizeof("qThreadExtraInfo,") - 1;
|
cmd += sizeof("qThreadExtraInfo,") - 1;
|
||||||
int task_index = esp_gdbstub_gethex(&cmd, -1);
|
int task_index = esp_gdbstub_gethex(&cmd, -1);
|
||||||
TaskHandle_t handle;
|
TaskHandle_t handle;
|
||||||
|
@ -304,38 +299,31 @@ static void handle_qThreadExtraInfo_command(const unsigned char* cmd, int len)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
esp_gdbstub_send_start();
|
esp_gdbstub_send_start();
|
||||||
const char* task_name = pcTaskGetTaskName(handle);
|
esp_gdbstub_send_str_as_hex("Name: ");
|
||||||
while (*task_name) {
|
esp_gdbstub_send_str_as_hex(pcTaskGetTaskName(handle));
|
||||||
esp_gdbstub_send_hex(*task_name, 8);
|
|
||||||
task_name++;
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_gdbstub_send_hex(' ', 8);
|
esp_gdbstub_send_hex(' ', 8);
|
||||||
|
|
||||||
eTaskState state = get_task_state(task_index);
|
eTaskState state = get_task_state(task_index);
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case eRunning:
|
case eRunning:
|
||||||
task_state_string_index = 0;
|
esp_gdbstub_send_str_as_hex("State: Running");
|
||||||
break;
|
break;
|
||||||
case eReady:
|
case eReady:
|
||||||
task_state_string_index = 1;
|
esp_gdbstub_send_str_as_hex("State: Ready");
|
||||||
break;
|
break;
|
||||||
case eBlocked:
|
case eBlocked:
|
||||||
task_state_string_index = 2;
|
esp_gdbstub_send_str_as_hex("State: Blocked");
|
||||||
break;
|
break;
|
||||||
case eSuspended:
|
case eSuspended:
|
||||||
task_state_string_index = 3;
|
esp_gdbstub_send_str_as_hex("State: Suspended");
|
||||||
|
break;
|
||||||
|
case eDeleted:
|
||||||
|
esp_gdbstub_send_str_as_hex("State: Deleted");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
task_state_string_index = 4;
|
esp_gdbstub_send_str_as_hex("State: Invalid");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* buffer = &task_state_string[task_state_string_index][0];
|
|
||||||
while (*buffer) {
|
|
||||||
esp_gdbstub_send_hex(*buffer, 8);
|
|
||||||
buffer++;
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_gdbstub_send_end();
|
esp_gdbstub_send_end();
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,7 +199,7 @@ typedef struct xTASK_SNAPSHOT
|
||||||
StackType_t *pxTopOfStack; /*!< Points to the location of the last item placed on the tasks stack. */
|
StackType_t *pxTopOfStack; /*!< Points to the location of the last item placed on the tasks stack. */
|
||||||
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 */
|
||||||
} TaskSnapshot_t;
|
} TaskSnapshot_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue