From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23721 invoked by alias); 8 Aug 2008 01:36:00 -0000 Received: (qmail 23709 invoked by uid 22791); 8 Aug 2008 01:35:59 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 08 Aug 2008 01:35:25 +0000 Received: (qmail 32432 invoked from network); 8 Aug 2008 01:35:23 -0000 Received: from unknown (HELO orlando.local) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 8 Aug 2008 01:35:23 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [3/7] Adjust the bsd-uthread target Date: Fri, 08 Aug 2008 01:36:00 -0000 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_EM6mIl8/fUqVvXi" Message-Id: <200808080236.04076.pedro@codesourcery.com> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-08/txt/msg00172.txt.bz2 --Boundary-00=_EM6mIl8/fUqVvXi Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 405 This patch adjusts the bsd-uthread target to use thread_change_ptid, and to never let the core see an event happen in a thread not in the thread table. Tested on i386-unknown-freebsd6.0 with a little hack in the testsuite to link the gdb.thread tests against -lc_r instead of -lpthread, and on i386-unknown-openbsd4.3, where no hack is needed. This patch depends on patch 1 and 2. OK? -- Pedro Alves --Boundary-00=_EM6mIl8/fUqVvXi Content-Type: text/x-diff; charset="utf-8"; name="003-bsd_uthreads.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="003-bsd_uthreads.diff" Content-length: 1719 2008-08-08 Pedro Alves * bsd-uthread.c (bsd_uthread_wait): Decorate the main thread with thread_change_ptid. Check for exited threads. (bsd_uthread_find_new_threads): Check for exited threads. --- gdb/bsd-uthread.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) Index: src/gdb/bsd-uthread.c =================================================================== --- src.orig/gdb/bsd-uthread.c 2008-07-29 12:06:38.000000000 +0100 +++ src/gdb/bsd-uthread.c 2008-07-29 12:17:34.000000000 +0100 @@ -361,14 +361,16 @@ bsd_uthread_wait (ptid_t ptid, struct ta } } - /* HACK: Twiddle INFERIOR_PTID such that the initial thread of a - process isn't recognized as a new thread. */ - if (ptid_get_tid (ptid) != 0 && !in_thread_list (ptid) - && ptid_get_tid (inferior_ptid) == 0) - { - add_thread_silent (ptid); - inferior_ptid = ptid; - } + /* If INFERIOR_PTID doesn't have a tid member yet, and we now have a + ptid with tid set, then ptid is still the initial thread of + the process. Notify GDB core about it. */ + if (ptid_get_tid (inferior_ptid) == 0 + && ptid_get_tid (ptid) != 0 && !in_thread_list (ptid)) + thread_change_ptid (inferior_ptid, ptid); + + /* Don't let the core see a ptid without a corresponding thread. */ + if (!in_thread_list (ptid) || is_exited (ptid)) + add_thread (ptid); return ptid; } @@ -413,7 +415,7 @@ bsd_uthread_find_new_threads (void) { ptid_t ptid = ptid_build (pid, 0, addr); - if (!in_thread_list (ptid)) + if (!in_thread_list (ptid) || is_exited (ptid)) add_thread (ptid); addr = read_memory_typed_address (addr + offset, --Boundary-00=_EM6mIl8/fUqVvXi--