gdbstub:convert gdb pid strat to 1

gdb pid strat is 1, nuttx is 0, so convert it

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
anjiahao 2023-11-13 18:16:31 +08:00 committed by Xiang Xiao
parent bb0a706bdc
commit a423d9b404

View File

@ -860,7 +860,7 @@ static void gdb_get_registers(FAR struct gdb_state_s *state)
int i; int i;
reg = (FAR uint8_t *)tcb->xcp.regs; reg = (FAR uint8_t *)tcb->xcp.regs;
if (state->pid == _SCHED_GETPID()) if (state->pid == _SCHED_GETTID())
{ {
if (up_interrupt_context()) if (up_interrupt_context())
{ {
@ -1148,10 +1148,10 @@ static void gdb_get_thread(FAR struct tcb_s *tcb, FAR void *arg)
{ {
FAR struct gdb_state_s *state = arg; FAR struct gdb_state_s *state = arg;
int pid = tcb->pid; int pid = tcb->pid;
size_t len;
len = sprintf(&state->pkt_buf[state->pkt_len], "%x,", pid); /* Gdb pid start from 1, so add it */
state->pkt_len += len;
state->pkt_len += sprintf(&state->pkt_buf[state->pkt_len], "%x,", pid + 1);
} }
/**************************************************************************** /****************************************************************************
@ -1211,7 +1211,7 @@ static int gdb_query(FAR struct gdb_state_s *state)
return ret; return ret;
} }
tcb = nxsched_get_tcb(pid); tcb = nxsched_get_tcb(pid - 1);
if (tcb == NULL) if (tcb == NULL)
{ {
return -EINVAL; return -EINVAL;
@ -1300,13 +1300,13 @@ static int gdb_is_thread_active(FAR struct gdb_state_s *state)
return ret; return ret;
} }
tcb = nxsched_get_tcb(pid); tcb = nxsched_get_tcb(pid - 1);
if (tcb == NULL) if (tcb == NULL)
{ {
return -EINVAL; return -EINVAL;
} }
state->pid = pid; state->pid = pid - 1;
gdb_send_ok_packet(state); gdb_send_ok_packet(state);
return ret; return ret;
} }
@ -1342,13 +1342,17 @@ static int gdb_thread_context(FAR struct gdb_state_s *state)
return ret; return ret;
} }
tcb = nxsched_get_tcb(pid); if (pid != 0)
{
tcb = nxsched_get_tcb(pid - 1);
if (tcb == NULL) if (tcb == NULL)
{ {
return -EINVAL; return -EINVAL;
} }
state->pid = pid; state->pid = pid - 1;
}
gdb_send_ok_packet(state); gdb_send_ok_packet(state);
return 0; return 0;
} }