diff options
author | Nathan Froyd <froydnj@codesourcery.com> | 2009-06-03 11:33:08 -0700 |
---|---|---|
committer | Paul Brook <paul@codesourcery.com> | 2009-06-04 10:04:49 +0100 |
commit | 1e9fa730163c2a445014ff8324b169cd82a50df1 (patch) | |
tree | 5d149df819dc4213b77c82ae7eb6249010d68ac3 /linux-user/syscall.c | |
parent | 4548eaea135af6c0570dc220813dab8a017c9ea2 (diff) |
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 <froydnj@codesourcery.com>
Diffstat (limited to 'linux-user/syscall.c')
-rw-r--r-- | linux-user/syscall.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/linux-user/syscall.c b/linux-user/syscall.c index a0915a455b..59c91f8da9 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -3202,6 +3202,7 @@ static void *clone_func(void *arg) env = info->env; thread_env = env; info->tid = gettid(); + env->host_tid = info->tid; if (info->child_tidptr) put_user_u32(info->tid, info->child_tidptr); if (info->parent_tidptr) @@ -3792,6 +3793,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, /* FIXME: This probably breaks if a signal arrives. We should probably be disabling signals. */ if (first_cpu->next_cpu) { + TaskState *ts; CPUState **lastp; CPUState *p; @@ -3809,7 +3811,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, /* Remove the CPU from the list. */ *lastp = p->next_cpu; cpu_list_unlock(); - TaskState *ts = ((CPUState *)cpu_env)->opaque; + ts = ((CPUState *)cpu_env)->opaque; if (ts->child_tidptr) { put_user_u32(0, ts->child_tidptr); sys_futex(g2h(ts->child_tidptr), FUTEX_WAKE, INT_MAX, |