I have just implemented a new target for gdb-4.18 which allows programs
which use FreeBSD's user threads library to be effectively debugged. The
new target automatically detects the presence of user threads when a
program is started or attached to and examined using the gdb commands
'info thread' and 'thread'.

To allow individual threads to be distinguished from gdb, I had to make
the following minor change to uthread. Unless anyone has any objections, I
will be committing this change and the new gdb target into -current.

Index: pthread_private.h
===================================================================
RCS file: /home/ncvs/src/lib/libc_r/uthread/pthread_private.h,v
retrieving revision 1.17
diff -u -r1.17 pthread_private.h
--- pthread_private.h   1999/03/23 05:07:54     1.17
+++ pthread_private.h   1999/05/06 15:26:53
@@ -420,6 +420,7 @@
 #define        PTHREAD_MAGIC           ((u_int32_t) 0xd09ba115)
        u_int32_t               magic;
        char                    *name;
+       int                     tid; /* for gdb */
 
        /*
         * Lock for accesses to this thread structure.
Index: uthread_create.c
===================================================================
RCS file: /home/ncvs/src/lib/libc_r/uthread/uthread_create.c,v
retrieving revision 1.12
diff -u -r1.12 uthread_create.c
--- uthread_create.c    1999/03/23 05:07:55     1.12
+++ uthread_create.c    1999/05/06 15:27:33
@@ -42,6 +42,8 @@
 #include "pthread_private.h"
 #include "libc_private.h"
 
+static int next_tid = 1;
+
 int
 pthread_create(pthread_t * thread, const pthread_attr_t * attr,
               void *(*start_routine) (void *), void *arg)
@@ -87,6 +89,7 @@
                } else {
                        /* Initialise the thread structure: */
                        memset(new_thread, 0, sizeof(struct pthread));
+                       new_thread->tid = next_tid++;
                        new_thread->slice_usec = -1;
                        new_thread->sig_saved = 0;
                        new_thread->stack = stack;

--
Doug Rabson                             Mail:  d...@nlsystems.com
Nonlinear Systems Ltd.                  Phone: +44 181 442 9037




To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-current" in the body of the message

Reply via email to