Source-Changes-HG archive

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

[src/trunk]: src/lib/libpthread_dbg Add td__getstacksize() to support variabl...



details:   https://anonhg.NetBSD.org/src/rev/f47ff02f323e
branches:  trunk
changeset: 555774:f47ff02f323e
user:      cl <cl%NetBSD.org@localhost>
date:      Thu Nov 27 16:32:09 2003 +0000

description:
Add td__getstacksize() to support variable stack sizes.

diffstat:

 lib/libpthread_dbg/Makefile      |   5 +++-
 lib/libpthread_dbg/pthread_dbg.c |  42 ++++++++++++++++++++++++++++++++++++++-
 2 files changed, 44 insertions(+), 3 deletions(-)

diffs (100 lines):

diff -r c3402cb37d84 -r f47ff02f323e lib/libpthread_dbg/Makefile
--- a/lib/libpthread_dbg/Makefile       Thu Nov 27 16:30:54 2003 +0000
+++ b/lib/libpthread_dbg/Makefile       Thu Nov 27 16:32:09 2003 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.3 2003/10/26 07:25:34 lukem Exp $
+#      $NetBSD: Makefile,v 1.4 2003/11/27 16:32:09 cl Exp $
 #
 
 WARNS= 2
@@ -7,6 +7,9 @@
 
 LIBPDIR=       ${.CURDIR}/../libpthread
 
+# Define PT_FIXEDSTACKSIZE_LG to set a fixed stacksize (same as libpthread)
+#CPPFLAGS+=-DPT_FIXEDSTACKSIZE_LG=18
+
 .if exists(${LIBPDIR}/arch/${MACHINE_ARCH})
 ARCHSUBDIR=    ${MACHINE_ARCH}
 .elif exists(${LIBPDIR}/arch/${MACHINE_CPU}) 
diff -r c3402cb37d84 -r f47ff02f323e lib/libpthread_dbg/pthread_dbg.c
--- a/lib/libpthread_dbg/pthread_dbg.c  Thu Nov 27 16:30:54 2003 +0000
+++ b/lib/libpthread_dbg/pthread_dbg.c  Thu Nov 27 16:32:09 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_dbg.c,v 1.9 2003/09/11 21:57:32 christos Exp $ */
+/*     $NetBSD: pthread_dbg.c,v 1.10 2003/11/27 16:32:09 cl Exp $      */
 
 /*-
  * Copyright (c) 2002 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_dbg.c,v 1.9 2003/09/11 21:57:32 christos Exp $");
+__RCSID("$NetBSD: pthread_dbg.c,v 1.10 2003/11/27 16:32:09 cl Exp $");
 
 #include <stddef.h>
 #include <stdlib.h>
@@ -55,6 +55,15 @@
 
 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);
+
+#ifndef PT_FIXEDSTACKSIZE_LG
+caddr_t        pt_stacksize_lg_addr = NULL;
+int    pt_stacksize_lg = -1;
+size_t pt_stacksize;
+vaddr_t        pt_stackmask;
+#endif /* !PT_FIXEDSTACKSIZE_LG */
+
 
 int
 td_open(struct td_proc_callbacks_t *cb, void *arg, td_proc_t **procp)
@@ -524,6 +533,8 @@
                                ptm_owner),
                            &taddr, sizeof(taddr))) != 0)
                                return val;
+                       if ((val = td__getstacksize(s->proc)) != 0)
+                               return val;
                        taddr = pthread__id(taddr);
                        td__getthread(s->proc, (void *)taddr, 
                            &info->sync_data.mutex.owner);
@@ -773,6 +784,10 @@
 
        PTHREAD_REG_TO_UCONTEXT(&uc, &gregs);
 
+       val = td__getstacksize(proc);
+       if (val != 0)
+               return val;
+
        th = pthread__id(pthread__uc_sp(&uc));
 
        val = READ(proc, th, &magic, sizeof(magic));
@@ -942,3 +957,26 @@
        return val;
 }
 
+
+static int
+td__getstacksize(td_proc_t *proc)
+{
+#ifndef PT_FIXEDSTACKSIZE_LG
+       int lg, val;
+
+       if (pt_stacksize_lg_addr == NULL) {
+               val = LOOKUP(proc, "pt_stacksize_lg", &pt_stacksize_lg_addr);
+               if (val != 0)
+                       return val;
+       }
+       val = READ(proc, pt_stacksize_lg_addr, &lg, sizeof(int));
+       if (val != 0)
+               return val;
+       if (lg != pt_stacksize_lg) {
+               pt_stacksize_lg = lg;
+               pt_stacksize = (1 << pt_stacksize_lg);
+               pt_stackmask = pt_stacksize - 1;
+       }
+#endif /* !PT_FIXEDSTACKSIZE_LG */
+       return 0;
+}



Home | Main Index | Thread Index | Old Index