From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19770 invoked by alias); 31 Aug 2006 11:34:14 -0000 Received: (qmail 19760 invoked by uid 22791); 31 Aug 2006 11:34:13 -0000 X-Spam-Check-By: sourceware.org Received: from fra-del-01.spheriq.net (HELO fra-del-01.spheriq.net) (195.46.51.97) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 31 Aug 2006 11:34:08 +0000 Received: from fra-out-02.spheriq.net (fra-out-02.spheriq.net [195.46.51.130]) by fra-del-01.spheriq.net with ESMTP id k7VBY32e013682 for ; Thu, 31 Aug 2006 11:34:03 GMT Received: from fra-cus-01.spheriq.net (fra-cus-01.spheriq.net [195.46.51.37]) by fra-out-02.spheriq.net with ESMTP id k7VBXxln013899 for ; Thu, 31 Aug 2006 11:34:01 GMT Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by fra-cus-01.spheriq.net with ESMTP id k7VBXvnW010437 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=OK); Thu, 31 Aug 2006 11:33:58 GMT Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id CE814DA42; Thu, 31 Aug 2006 11:33:56 +0000 (GMT) Received: from mail1.cro.st.com (mail1.cro.st.com [164.129.40.131]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 98B9E4744C; Thu, 31 Aug 2006 11:33:56 +0000 (GMT) Received: from crx549.cro.st.com (crx549.cro.st.com [164.129.44.49]) by mail1.cro.st.com (MOS 3.5.8-GR) with ESMTP id CII14128 (AUTH "frederic riss"); Thu, 31 Aug 2006 13:33:55 +0200 (CEST) Subject: Get versioned minsyms from dynamic symtab (Was: Re: How to call operator<< functions?) From: Frederic RISS To: gdb@sourceware.org Cc: GDB Patches In-Reply-To: <1156944608.3429.275.camel@crx549.cro.st.com> References: <44F5645F.4000301@tx.technion.ac.il> <1156936373.3429.250.camel@crx549.cro.st.com> <1156944608.3429.275.camel@crx549.cro.st.com> Content-Type: multipart/mixed; boundary="=-U5WlrocvRRBvckZZ3Z1f" Date: Thu, 31 Aug 2006 11:34:00 -0000 Message-Id: <1157024034.3429.303.camel@crx549.cro.st.com> Mime-Version: 1.0 X-Mailer: Evolution 2.6.0 X-IsSubscribed: yes 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-08/txt/msg00270.txt.bz2 --=-U5WlrocvRRBvckZZ3Z1f Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 1159 On Linux, versioned ELF symbols are stored in the static symtab with an (@)@VERSION suffix. We store such symbols with the suffix and thus fail to find them when looking up the real name. This causes failures such as the one described here: http://www.sourceware.org/ml/gdb/2006-08/msg00244.html In the general case, GDB doesn't use the dynamic symtab because it contains usually only a subset of the static table information. The attached patch make GDB store dynamic versioned symbols. Maybe this is harvests too much symbols, and we should limit it to the dynamic symbols of the main executable. It's easy enough to do, we just need to pass the 'mainline' flag to elf_symfile_read from elf_symtab_read. I've no idea if this could break something on non-Linux platforms, I've just tested on x86-linux. I'm also attaching a little testsuite patch that fails for me on current GDB and works with the patch. Opinions? 2006-08-31 Frederic Riss * elfread.c (elf_symtab_read): Read versioned symbols from the dynamic symtab. 2006-08-31 Frederic Riss * gdb.cp/userdef.exp: Test use of std::cout. --=-U5WlrocvRRBvckZZ3Z1f Content-Disposition: attachment; filename=versioned-symbols.patch Content-Type: text/x-patch; name=versioned-symbols.patch; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-length: 993 Index: elfread.c =================================================================== RCS file: /cvs/src/src/gdb/elfread.c,v retrieving revision 1.55 diff -u -p -r1.55 elfread.c --- elfread.c 21 Feb 2006 20:38:48 -0000 1.55 +++ elfread.c 31 Aug 2006 10:50:17 -0000 @@ -211,9 +211,14 @@ elf_symtab_read (struct objfile *objfile /* If it is a nonstripped executable, do not enter dynamic symbols, as the dynamic symbol table is usually a subset - of the main symbol table. */ - if (dynamic && !stripped) + of the main symbol table. + The Linux ELF symbol versionning requires that the versioned + static symbols are suffixed with (@)@VERSION, thus the + entries we got from the static symtab for these symbols have + suffixed names. The entries in the dynamic symtab don't have + the suffix (version info is stored in .gnu_version section). */ + if (dynamic && !stripped && !((elf_symbol_type *) sym)->version) continue; if (sym->flags & BSF_FILE) { --=-U5WlrocvRRBvckZZ3Z1f Content-Disposition: attachment; filename=testsuite-cout.patch Content-Type: text/x-patch; name=testsuite-cout.patch; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-length: 719 ? testsuite-cout.patch Index: gdb.cp/userdef.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/userdef.exp,v retrieving revision 1.6 diff -u -p -r1.6 userdef.exp --- gdb.cp/userdef.exp 10 Aug 2006 05:27:20 -0000 1.6 +++ gdb.cp/userdef.exp 31 Aug 2006 10:58:01 -0000 @@ -151,5 +151,8 @@ gdb_test "print *c" "\\\$\[0-9\]* = \\(M gdb_test "print &*c" "\\\$\[0-9\]* = \\(Member \\*\\) $hex" gdb_test "ptype &*c" "type = struct Member {\[\r\n \]+int z;\[\r\n\]+} &\\*" +# Check that we're able to use std::cout +gdb_test "print 'operator<<'(std::cout, one)" "\[\r\n\]+x = 9\[\r\n\]+y = 10\[\r\n\]+-------\[\r\n\]+\\\$\[0-9\]* = .*" + gdb_exit return 0 --=-U5WlrocvRRBvckZZ3Z1f--