From 1e9fa730163c2a445014ff8324b169cd82a50df1 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Wed, 3 Jun 2009 11:33:08 -0700 Subject: fix gdbstub support for multiple threads in usermode, v3 When debugging multi-threaded programs, QEMU's gdb stub would report the correct number of threads (the qfThreadInfo and qsThreadInfo packets). However, the stub was unable to actually switch between threads (the T packet), since it would report every thread except the first as being dead. Furthermore, the stub relied upon cpu_index as a reliable means of assigning IDs to the threads. This was a bad idea; if you have this sequence of events: initial thread created new thread #1 new thread #2 thread #1 exits new thread #3 thread #3 will have the same cpu_index as thread #1, which would confuse GDB. (This problem is partly due to the remote protocol not having a good way to send thread creation/destruction events.) We fix this by using the host thread ID for the identifier passed to GDB when debugging a multi-threaded userspace program. The thread ID might wrap, but the same sort of problems with wrapping thread IDs would come up with debugging programs natively, so this doesn't represent a problem. Signed-off-by: Nathan Froyd --- cpu-defs.h | 1 + 1 file changed, 1 insertion(+) (limited to 'cpu-defs.h') diff --git a/cpu-defs.h b/cpu-defs.h index 0d0eaa1c5..fda3044bc 100644 --- a/cpu-defs.h +++ b/cpu-defs.h @@ -184,6 +184,7 @@ typedef struct CPUWatchpoint { \ CPUState *next_cpu; /* next CPU sharing TB cache */ \ int cpu_index; /* CPU index (informative) */ \ + uint32_t host_tid; /* host thread ID */ \ int numa_node; /* NUMA node this cpu is belonging to */ \ int running; /* Nonzero if cpu is currently running(usermode). */ \ /* user data */ \ -- cgit v1.2.3-65-gdbad