From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5429 invoked by alias); 17 Oct 2006 23:19:16 -0000 Received: (qmail 5420 invoked by uid 22791); 17 Oct 2006 23:19:16 -0000 X-Spam-Check-By: sourceware.org Received: from nile.gnat.com (HELO nile.gnat.com) (205.232.38.5) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 17 Oct 2006 23:19:13 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-nile.gnat.com (Postfix) with ESMTP id CC6C448CE35 for ; Tue, 17 Oct 2006 19:19:11 -0400 (EDT) Received: from nile.gnat.com ([127.0.0.1]) by localhost (nile.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 16187-01-2 for ; Tue, 17 Oct 2006 19:19:11 -0400 (EDT) Received: from takamaka.act-europe.fr (joel.gnat.com [205.232.38.116]) by nile.gnat.com (Postfix) with ESMTP id 81F0D48CE0A for ; Tue, 17 Oct 2006 19:19:11 -0400 (EDT) Received: by takamaka.act-europe.fr (Postfix, from userid 507) id 76A0D47F01; Tue, 17 Oct 2006 19:19:11 -0400 (EDT) Date: Tue, 17 Oct 2006 23:19:00 -0000 From: Joel Brobecker To: gdb-patches@sources.redhat.com Subject: [RFA] load lipthread symbols even when auto-solib-add is off Message-ID: <20061017231911.GR1903@adacore.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="3Pql8miugIZX0722" Content-Disposition: inline User-Agent: Mutt/1.4i Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-10/txt/msg00205.txt.bz2 --3Pql8miugIZX0722 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1151 Hello, Between having to document a side-effect of "set auto-solib-add 0" and fixing the actual issue, I finally decided to try to fix the issue... If you don't remember what the issue is, we started discussing it at: http://www.sourceware.org/ml/gdb/2006-09/msg00065.html In short, when doing "set auto-solib-add 0", and then running a multi-threaded program on x86-linux, the "thread" layer doesn't get pushed on the target stack. I couldn't demonstrate a visibly bad behavior with GDB from CVS, but with gdb-6.4, I get: (gdb) c Continuing. Program terminated with signal SIGTRAP, Trace/breakpoint trap. The program no longer exists. After discussing this a bit with Daniel, we determined that we could always load the symbols for libpthread. This is what this patch implements. 2006-10-17 Joel Brobecker * solib.c (libpthread_solib_p): New function. (solib_add): Always read the symbols from the libpthread library. Tested on x86-linux, no regression. I verified that this also makes GDB push the thread layer despite "set auto-solib-add 0". Is this OK? Thanks, -- Joel --3Pql8miugIZX0722 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="solib.c.diff" Content-length: 1495 Index: solib.c =================================================================== RCS file: /cvs/src/src/gdb/solib.c,v retrieving revision 1.86 diff -u -p -r1.86 solib.c --- solib.c 9 Oct 2006 20:16:10 -0000 1.86 +++ solib.c 17 Oct 2006 23:14:19 -0000 @@ -615,6 +615,17 @@ update_solib_list (int from_tty, struct } } +/* Return non-zero if SO is the libpthread shared library. + + Uses a fairly simplistic heuristic approach where we check + the file name against "/libpthread". This can lead to false + positives, but this should be good enough in practice. */ + +static int +libpthread_solib_p (struct so_list *so) +{ + return (strstr (so->so_name, "/libpthread") != NULL); +} /* GLOBAL FUNCTION @@ -661,8 +672,16 @@ solib_add (char *pattern, int from_tty, for (gdb = so_list_head; gdb; gdb = gdb->next) if (! pattern || re_exec (gdb->so_name)) { + /* Normally, we would read the symbols from that library + only if READSYMS is set. However, we're making a small + exception for the pthread library, because we sometimes + need the library symbols to be loaded in order to provide + thread support (x86-linux for instance). */ + const int add_this_solib = + (readsyms || libpthread_solib_p (gdb)); + any_matches = 1; - if (readsyms && solib_read_symbols (gdb, from_tty)) + if (add_this_solib && solib_read_symbols (gdb, from_tty)) loaded_any_symbols = 1; } --3Pql8miugIZX0722--