Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libpthread_dbg don't use kernel types.



details:   https://anonhg.NetBSD.org/src/rev/ac26bc0da2e9
branches:  trunk
changeset: 813275:ac26bc0da2e9
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Jan 23 14:02:21 2016 +0000

description:
don't use kernel types.

diffstat:

 lib/libpthread_dbg/pthread_dbg.c     |  47 +++++++++++++----------------------
 lib/libpthread_dbg/pthread_dbg_int.h |  24 +++++++++---------
 2 files changed, 30 insertions(+), 41 deletions(-)

diffs (188 lines):

diff -r a33f95fb686e -r ac26bc0da2e9 lib/libpthread_dbg/pthread_dbg.c
--- a/lib/libpthread_dbg/pthread_dbg.c  Sat Jan 23 08:17:18 2016 +0000
+++ b/lib/libpthread_dbg/pthread_dbg.c  Sat Jan 23 14:02:21 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_dbg.c,v 1.43 2015/05/29 07:37:32 manu Exp $    */
+/*     $NetBSD: pthread_dbg.c,v 1.44 2016/01/23 14:02:21 christos Exp $        */
 
 /*-
  * Copyright (c) 2002 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_dbg.c,v 1.43 2015/05/29 07:37:32 manu Exp $");
+__RCSID("$NetBSD: pthread_dbg.c,v 1.44 2016/01/23 14:02:21 christos Exp $");
 
 #define __EXPOSE_STACK 1
 
@@ -59,6 +59,8 @@
 #include <pthread_dbg_int.h>
 
 #define PT_STACKMASK (proc->stackmask)
+#define OFFSET(thread, field) \
+    (((char *)(thread)->addr) + offsetof(struct __pthread_st, field))
 
 /* Compensate for debuggers that want a zero ID to be a sentinel */
 #define TN_OFFSET 1
@@ -216,9 +218,8 @@
                return TD_ERR_BADTHREAD;
 
        info->thread_addr = thread->addr;
-       if ((val = READ(thread->proc, 
-                     thread->addr + offsetof(struct __pthread_st, pt_state), 
-                     &tmp, sizeof(tmp))) != 0)
+       if ((val = READ(thread->proc,
+           OFFSET(thread, pt_state), &tmp, sizeof(tmp))) != 0)
                return val;
        switch (tmp) {
        case PT_STATE_RUNNING:
@@ -238,18 +239,15 @@
 
        info->thread_type = TD_TYPE_USER;
 
-       if ((val = READ(thread->proc, 
-           thread->addr + offsetof(struct __pthread_st, pt_stack),
+       if ((val = READ(thread->proc, OFFSET(thread, pt_stack),
            &info->thread_stack, sizeof(stack_t))) != 0)
                return val;
 
-       if ((val = READ(thread->proc, 
-           thread->addr + offsetof(struct __pthread_st, pt_errno),
+       if ((val = READ(thread->proc, OFFSET(thread, pt_errno),
            &info->thread_errno, sizeof(info->thread_errno))) != 0)
                return val;
 
-       if ((val = READ(thread->proc, 
-           thread->addr + offsetof(struct __pthread_st, pt_lid),
+       if ((val = READ(thread->proc, OFFSET(thread, pt_lid),
            &info->thread_id, sizeof(info->thread_id))) != 0)
                return val;
 
@@ -272,8 +270,7 @@
        if (tmp != PT_MAGIC)
                return TD_ERR_BADTHREAD;
 
-       if ((val = READ(thread->proc,
-           thread->addr + offsetof(struct __pthread_st, pt_name),
+       if ((val = READ(thread->proc, OFFSET(thread, pt_name),
            &nameaddr, sizeof(nameaddr))) != 0)
                return val;
 
@@ -291,9 +288,8 @@
 {
        int tmp, val;
 
-       if ((val = READ(thread->proc, 
-                     thread->addr + offsetof(struct __pthread_st, pt_state), 
-                     &tmp, sizeof(tmp))) != 0)
+       if ((val = READ(thread->proc, OFFSET(thread, pt_state),
+           &tmp, sizeof(tmp))) != 0)
                return val;
 
        switch (tmp) {
@@ -319,9 +315,8 @@
 {
        int val, tmp;
 
-       if ((val = READ(thread->proc, 
-                     thread->addr + offsetof(struct __pthread_st, pt_state), 
-                     &tmp, sizeof(tmp))) != 0)
+       if ((val = READ(thread->proc, OFFSET(thread, pt_state),
+           &tmp, sizeof(tmp))) != 0)
                return val;
 
        switch (tmp) {
@@ -378,8 +373,7 @@
        threadid -= TN_OFFSET;
        next = (void *)allq.ptqh_first;
        while (next != NULL) {
-               val = READ(proc, 
-                   next + offsetof(struct __pthread_st, pt_lid), 
+               val = READ(proc, next + offsetof(struct __pthread_st, pt_lid), 
                    &num, sizeof(num));
 
                if (num == threadid)
@@ -453,9 +447,7 @@
        if (tmp != PT_MAGIC)
                return TD_ERR_BADTHREAD;
 
-       val = READ(thread->proc, thread->addr +
-           offsetof(struct __pthread_st, pt_lid),
-           &tmp, sizeof(tmp));
+       val = READ(thread->proc, OFFSET(thread, pt_lid), &tmp, sizeof(tmp));
        if (val != 0)
                return val;
 
@@ -477,9 +469,7 @@
        if (tmp != PT_MAGIC)
                return TD_ERR_BADTHREAD;
 
-       val = READ(thread->proc, thread->addr +
-           offsetof(struct __pthread_st, pt_lid),
-           &tmp, sizeof(tmp));
+       val = READ(thread->proc, OFFSET(thread, pt_lid), &tmp, sizeof(tmp));
        if (val != 0)
                return val;
 
@@ -522,8 +512,7 @@
 {
        int val;
 
-       val = READ(thread->proc, thread->addr + 
-           offsetof(struct __pthread_st, pt_specific) +
+       val = READ(thread->proc, OFFSET(thread, pt_specific) +
            key * sizeof(void *), value, sizeof(*value));
 
        return val;
diff -r a33f95fb686e -r ac26bc0da2e9 lib/libpthread_dbg/pthread_dbg_int.h
--- a/lib/libpthread_dbg/pthread_dbg_int.h      Sat Jan 23 08:17:18 2016 +0000
+++ b/lib/libpthread_dbg/pthread_dbg_int.h      Sat Jan 23 14:02:21 2016 +0000
@@ -6,19 +6,19 @@
        struct td_proc_callbacks_t *cb;
        void *arg;
 
-       caddr_t dbgaddr;
-       caddr_t allqaddr;
-       caddr_t runqaddr;       
-       caddr_t idleqaddr;
-       caddr_t suspqaddr;
-       caddr_t maxlwpsaddr;
-       caddr_t tsdlistaddr;
-       caddr_t tsddestaddr;
+       void *dbgaddr;
+       void *allqaddr;
+       void *runqaddr; 
+       void *idleqaddr;
+       void *suspqaddr;
+       void *maxlwpsaddr;
+       void *tsdlistaddr;
+       void *tsddestaddr;
 
-       caddr_t stacksizeaddr;
+       void *stacksizeaddr;
        int stacksizelg;
        size_t stacksize;
-       vaddr_t stackmask;
+       uintptr_t stackmask;
        struct reg *regbuf;
        struct fpreg *fpregbuf;
 
@@ -28,7 +28,7 @@
 
 struct td_thread_st {
        td_proc_t *proc;
-       caddr_t addr;
+       void *addr;
        lwpid_t lwp;
        PTQ_ENTRY(td_thread_st) list;
 };
@@ -36,7 +36,7 @@
 
 struct td_sync_st {
        td_proc_t *proc;
-       caddr_t addr;
+       void *addr;
        PTQ_ENTRY(td_sync_st) list;
 };
 



Home | Main Index | Thread Index | Old Index