gdbstub:fix get thread rsp command crash
riscv-gdb/gdb/thread.c:1309: internal-error: void switch_to_thread(thread_info*): Assertion `thr != NULL' failed. Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
parent
a5cd1cf89b
commit
3312ab2087
@ -781,6 +781,39 @@ static int gdb_send_ok_packet(FAR struct gdb_state_s *state)
|
|||||||
return gdb_send_packet(state);
|
return gdb_send_packet(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: gdb_send_signal_packet
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Send a signal packet (S AA).
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* state - The pointer to the GDB state structure.
|
||||||
|
* signal - The signal to send.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero on success.
|
||||||
|
* Negative value on error.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static int gdb_send_signal_packet(FAR struct gdb_state_s *state,
|
||||||
|
unsigned char signal)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
state->pkt_buf[0] = 'S';
|
||||||
|
ret = gdb_bin2hex(&state->pkt_buf[1], sizeof(state->pkt_buf) - 1,
|
||||||
|
&signal, 1);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
state->pkt_len = 1 + ret;
|
||||||
|
return gdb_send_packet(state);
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: gdb_send_error_packet
|
* Name: gdb_send_error_packet
|
||||||
*
|
*
|
||||||
@ -1316,6 +1349,7 @@ static int gdb_is_thread_active(FAR struct gdb_state_s *state)
|
|||||||
* Negative value on error.
|
* Negative value on error.
|
||||||
*
|
*
|
||||||
* Note : Comand Format: Hg<id>
|
* Note : Comand Format: Hg<id>
|
||||||
|
* Hc-<id>
|
||||||
* Rsponse Format: OK
|
* Rsponse Format: OK
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
@ -1325,12 +1359,19 @@ static int gdb_thread_context(FAR struct gdb_state_s *state)
|
|||||||
uintptr_t pid;
|
uintptr_t pid;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (state->pkt_buf[1] != 'g')
|
if (state->pkt_buf[1] == 'g')
|
||||||
|
{
|
||||||
|
state->pkt_next += 2;
|
||||||
|
}
|
||||||
|
else if (state->pkt_buf[1] == 'c')
|
||||||
|
{
|
||||||
|
state->pkt_next += 3;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
state->pkt_next += 2;
|
|
||||||
ret = gdb_expect_integer(state, &pid);
|
ret = gdb_expect_integer(state, &pid);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
@ -1756,7 +1797,7 @@ int gdb_process(FAR struct gdb_state_s *state, int stopreason,
|
|||||||
switch (state->pkt_buf[0])
|
switch (state->pkt_buf[0])
|
||||||
{
|
{
|
||||||
case '?': /* gdbserial status */
|
case '?': /* gdbserial status */
|
||||||
ret = gdb_send_stop(state, stopreason, stopaddr);
|
ret = gdb_send_signal_packet(state, 0x00);
|
||||||
break;
|
break;
|
||||||
case 'g': /* Read registers */
|
case 'g': /* Read registers */
|
||||||
ret = gdb_read_registers(state);
|
ret = gdb_read_registers(state);
|
||||||
|
Loading…
Reference in New Issue
Block a user