From owner-freebsd-current Fri May 7 13: 7:34 1999 Delivered-To: freebsd-current@freebsd.org Received: from herring.nlsystems.com (nlsys.demon.co.uk [158.152.125.33]) by hub.freebsd.org (Postfix) with ESMTP id B9C0414CFB for ; Fri, 7 May 1999 13:07:15 -0700 (PDT) (envelope-from dfr@nlsystems.com) Received: from localhost (dfr@localhost) by herring.nlsystems.com (8.9.3/8.8.8) with ESMTP id VAA14069 for ; Fri, 7 May 1999 21:07:20 +0100 (BST) (envelope-from dfr@nlsystems.com) Date: Fri, 7 May 1999 21:07:20 +0100 (BST) From: Doug Rabson To: current@freebsd.org Subject: Debugging FreeBSD user threads with gdb Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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: dfr@nlsystems.com Nonlinear Systems Ltd. Phone: +44 181 442 9037 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message