From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15768 invoked by alias); 27 May 2006 11:47:52 -0000 Received: (qmail 15149 invoked by uid 22791); 27 May 2006 11:47:51 -0000 X-Spam-Check-By: sourceware.org Received: from mail.gmx.de (HELO mail.gmx.net) (213.165.64.20) by sourceware.org (qpsmtpd/0.31) with SMTP; Sat, 27 May 2006 11:47:49 +0000 Received: (qmail invoked by alias); 27 May 2006 11:47:46 -0000 Received: from p3E9E6A89.dip.t-dialin.net (EHLO licht.localdomain) [62.158.106.137] by mail.gmx.net (mp019) with SMTP; 27 May 2006 13:47:46 +0200 X-Authenticated: #25218368 Received: from licht.localdomain (localhost.localdomain [127.0.0.1]) by licht.localdomain (8.12.5/8.12.5) with ESMTP id k4RBlhbt023133 for ; Sat, 27 May 2006 13:47:43 +0200 Received: (from pes@localhost) by licht.localdomain (8.12.5/8.12.5/Submit) id k4RBlhmv023131 for gdb@sourceware.org; Sat, 27 May 2006 13:47:43 +0200 From: Peter Schauer Message-Id: <200605271147.k4RBlhmv023131@licht.localdomain> Subject: Native Solaris thread debugging is broken since 2006-01-24 To: gdb@sourceware.org Date: Sat, 27 May 2006 17:52:00 -0000 X-Mailer: ELM [version 2.5 PL6] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2006-05/txt/msg00381.txt.bz2 This change: 2006-01-24 Daniel Jacobowitz * infcmd.c: Include "observer.h". (post_create_inferior): New function. (run_command_1): Call it. Also call proceed. * inferior.h (post_create_inferior): New prototype. * Makefile.in (infcmd.o): Update. * gnu-nat.c (gnu_create_inferior): Don't call proceed. * go32-nat.c (go32_create_inferior): Likewise. * nto-procfs.c (procfs_create_inferior): Likewise. * procfs.c (procfs_create_inferior): Likewise. breaks native Solaris thread debugging. Using the pthreads testsuite case, before this change you get the following with the commands break main run info threads: 6 Thread 3 0xdfa39657 in _swtch () from /usr/lib/libthread.so.1 5 Thread 2 (LWP 2) 0xdfadb5a8 in _signotifywait () from /usr/lib/libc.so.1 * 4 Thread 1 (LWP 1) main (argc=0x1, argv=0x8047874) at /users/pes/gdbnd/devo/gdb/testsuite/gdb.threads/pthreads.c:122 3 LWP 3 0xdfa3a158 in _lwp_start () from /usr/lib/libthread.so.1 2 LWP 2 0xdfadb5a8 in _signotifywait () from /usr/lib/libc.so.1 1 LWP 1 main (argc=0x1, argv=0x8047874) at /users/pes/gdbnd/devo/gdb/testsuite/gdb.threads/pthreads.c:122 and after the change you get only: 3 LWP 3 0xdfa3a158 in _lwp_start () from /usr/lib/libthread.so.1 2 LWP 2 0xdfadb5a8 in _signotifywait () from /usr/lib/libc.so.1 * 1 LWP 1 main (argc=0x1, argv=0x8047874) at /users/pes/gdbnd/devo/gdb/testsuite/gdb.threads/pthreads.c:12 Here is the reason for the failure: static void sol_thread_create_inferior (char *exec_file, char *allargs, char **env, int from_tty) { procfs_ops.to_create_inferior (exec_file, allargs, env, from_tty); if (sol_thread_active && !ptid_equal (inferior_ptid, null_ptid)) { /* Save for xfer_memory. */ main_ph.ptid = inferior_ptid; push_target (&sol_thread_ops); Before the change, procfs_ops.to_create_inferior called proceed, which took the execution till the breakpoint at main. This caused the shared libraries to be read in as a side effect, and sol_thread_active was set via the sol_thread_new_objfile hook, after libthread.so was read in. With the removed proceed call, the shared libraries are read in much later, sol_thread_active is not yet set in the above code, and the sol_thread_ops target is never pushed, causing user level thread debugging to fail. A lightly tested patch along the lines of linux-thread-db.c is included below, it brings the testsuite results for the threads tests back to the behaviour in gdb-6.4, but I do not have enough spare time to follow this through on gdb-patches. As I doubt that this can be fixed in time for gdb-6.5, I suggest that an appropriate NEWS entry for this issue should be created, to save Solaris users from grief after upgrading to 6.5. --- sol-thread.c.orig 2006-05-23 18:06:45.000000000 +0200 +++ sol-thread.c 2006-05-27 13:39:00.550131000 +0200 @@ -356,18 +356,6 @@ sol_thread_attach (char *args, int from_ /* Must get symbols from shared libraries before libthread_db can run! */ solib_add (NULL, from_tty, (struct target_ops *) 0, auto_solib_add); - if (sol_thread_active) - { - printf_filtered ("sol-thread active.\n"); - main_ph.ptid = inferior_ptid; /* Save for xfer_memory. */ - push_target (&sol_thread_ops); - inferior_ptid = lwp_to_thread (inferior_ptid); - if (PIDGET (inferior_ptid) == -1) - inferior_ptid = main_ph.ptid; - else - add_thread (inferior_ptid); - } - /* FIXME: Might want to iterate over all the threads and register them. */ } @@ -384,6 +372,7 @@ sol_thread_detach (char *args, int from_ { inferior_ptid = pid_to_ptid (PIDGET (main_ph.ptid)); unpush_target (&sol_thread_ops); + sol_thread_active = 0; procfs_ops.to_detach (args, from_tty); } @@ -756,21 +745,6 @@ sol_thread_create_inferior (char *exec_f int from_tty) { procfs_ops.to_create_inferior (exec_file, allargs, env, from_tty); - - if (sol_thread_active && !ptid_equal (inferior_ptid, null_ptid)) - { - /* Save for xfer_memory. */ - main_ph.ptid = inferior_ptid; - - push_target (&sol_thread_ops); - - inferior_ptid = lwp_to_thread (inferior_ptid); - if (PIDGET (inferior_ptid) == -1) - inferior_ptid = main_ph.ptid; - - if (!in_thread_list (inferior_ptid)) - add_thread (inferior_ptid); - } } /* This routine is called whenever a new symbol table is read in, or @@ -822,7 +796,21 @@ sol_thread_new_objfile (struct objfile * goto quit; } - sol_thread_active = 1; + if (!sol_thread_active && !ptid_equal (inferior_ptid, null_ptid)) + { + /* Save for xfer_memory. */ + main_ph.ptid = inferior_ptid; + + push_target (&sol_thread_ops); + sol_thread_active = 1; + + inferior_ptid = lwp_to_thread (inferior_ptid); + if (PIDGET (inferior_ptid) == -1) + inferior_ptid = main_ph.ptid; + + if (!in_thread_list (inferior_ptid)) + add_thread (inferior_ptid); + } quit: /* Call predecessor on chain, if any. */ @@ -836,6 +824,7 @@ static void sol_thread_mourn_inferior (void) { unpush_target (&sol_thread_ops); + sol_thread_active = 0; procfs_ops.to_mourn_inferior (); } -- Peter Schauer Peter.Schauer@mytum.de