Add an offset to the thread ID numbers, because GDB really doesn't

cope with "thread 0".
This commit is contained in:
nathanw 2004-06-03 00:20:24 +00:00
parent e7bdadd856
commit bff67c76fe
1 changed files with 9 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: pthread_dbg.c,v 1.19 2004/06/02 21:18:25 nathanw Exp $ */
/* $NetBSD: pthread_dbg.c,v 1.20 2004/06/03 00:20:24 nathanw Exp $ */
/*-
* Copyright (c) 2002 Wasabi Systems, Inc.
@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: pthread_dbg.c,v 1.19 2004/06/02 21:18:25 nathanw Exp $");
__RCSID("$NetBSD: pthread_dbg.c,v 1.20 2004/06/03 00:20:24 nathanw Exp $");
#include <stddef.h>
#include <stdlib.h>
@ -58,6 +58,9 @@ __RCSID("$NetBSD: pthread_dbg.c,v 1.19 2004/06/02 21:18:25 nathanw Exp $");
#define PT_STACKMASK (proc->stackmask)
#endif
/* Compensate for debuggers that want a zero ID to be a sentinel */
#define TN_OFFSET 1
static int td__getthread(td_proc_t *proc, caddr_t addr, td_thread_t **threadp);
static int td__getsync(td_proc_t *proc, caddr_t addr, td_sync_t **syncp);
static int td__getstacksize(td_proc_t *proc);
@ -333,6 +336,8 @@ td_thr_info(td_thread_t *thread, td_thread_info_t *info)
&info->thread_id, sizeof(info->thread_id))) != 0)
return val;
info->thread_id += TN_OFFSET;
if ((val = READ(thread->proc,
thread->addr + offsetof(struct __pthread_st, pt_sigmask),
&info->thread_sigmask, sizeof(info->thread_sigmask))) != 0)
@ -846,6 +851,8 @@ td_map_id2thr(td_proc_t *proc, int threadid, td_thread_t **threadp)
if (val != 0)
return val;
/* Correct for offset */
threadid -= TN_OFFSET;
next = (void *)allq.ptqh_first;
while (next != NULL) {
val = READ(proc,