gdbstub:Return non-zero value for thread-id in user mode
PATCH 1/1 gdbstub:Return non-zero value for thread-id in user mode
When client requests the stop information by sending ? packet, the gdbstub replies with stop info packet which includes thread-id of the stopped thread. In user mode this thread-id is given by cpu->host_tid, which could be zero. Some clients treats thread-id zero as invalid thread-id.
This patch ensures that in user mode, gdbstub returns non-zero value for thread-id in stop reply packet.
--- include/exec/gdbstub.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/exec/gdbstub.h +1 -1
@@ -33,7 +33,7 @@ void gdb_register_coprocessor(CPUState *cpu,static inline int cpu_index (CPUState *cpu) {#if defined(CONFIG_USER_ONLY ) -return cpu->host_tid; +return cpu->host_tid ? cpu->host_tid :1 ;#else return cpu->cpu_index +1 ;#endif
Signature · 1 line
2.4.4
Quoted 7 lines · Bhushan Attarde
When client requests the stop information by sending ? packet, the gdbstub replies with stop info packet which includes thread-id of the stopped thread. In user mode this thread-id is given by
cpu->host_tid, which could be zero. Some clients treats thread-id zero as invalid thread-id.This patch ensures that in user mode, gdbstub returns non-zero value for thread-id in stop reply packet.
Wouldn't it be better to identify why cpu->host_tid might be zero and fix that?
It looks like this might just be that we only set cpu->host_tid when the linux-user process runs clone(), so it gets set for new threads but not for the original one. We could fix that by having linux-user/ set it for the initial thread too.
thanks
-- PMM