int len;
VgdbShared vgdbinit =
{0, 0, (Addr) VG_(invoke_gdbserver),
- (Addr) VG_(threads), sizeof(ThreadState),
+ (Addr) VG_(threads), VG_N_THREADS, sizeof(ThreadState),
offsetof(ThreadState, status),
offsetof(ThreadState, os_state) + offsetof(ThreadOSstate, lwpid),
0};
Int lwpid;
}
VgdbThreadState;
-static VgdbThreadState vgdb_threads[VG_N_THREADS];
+static VgdbThreadState *vgdb_threads;
+static int vg_n_threads;
static const
HChar* name_of_ThreadStatus ( ThreadStatus status )
if (shared32 != NULL) {
vgt = shared32->threads;
+ vg_n_threads = shared32->vg_n_threads;
sz_tst = shared32->sizeof_ThreadState;
off_status = shared32->offset_status;
off_lwpid = shared32->offset_lwpid;
}
else if (shared64 != NULL) {
vgt = shared64->threads;
+ vg_n_threads = shared64->vg_n_threads;
sz_tst = shared64->sizeof_ThreadState;
off_status = shared64->offset_status;
off_lwpid = shared64->offset_lwpid;
assert (0);
}
+ vgdb_threads = vmalloc(vg_n_threads * sizeof vgdb_threads[0]);
+
/* note: the entry 0 is unused */
- for (i = 1; i < VG_N_THREADS; i++) {
+ DEBUG(1, "examining thread entries from tid 1 to tid %d\n", vg_n_threads-1);
+ for (i = 1; i < vg_n_threads; i++) {
vgt += sz_tst;
rw = ptrace_read_memory(pid, vgt+off_status,
&(vgdb_threads[i].status),
Bool pid_found = False;
/* detach from all the threads */
- for (i = 1; i < VG_N_THREADS; i++) {
+ for (i = 1; i < vg_n_threads; i++) {
if (vgdb_threads[i].status != VgTs_Empty) {
if (vgdb_threads[i].status == VgTs_Init
&& vgdb_threads[i].lwpid == 0) {
}
}
+ free (vgdb_threads);
+
if (!pid_found && pid) {
/* No threads are live. Process is busy stopping.
We need to detach from pid explicitely. */