From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21851 invoked by alias); 2 Jun 2011 15:33:35 -0000 Received: (qmail 21841 invoked by uid 22791); 2 Jun 2011 15:33:34 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_BJ,TW_YM,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 02 Jun 2011 15:33:13 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p52FXCDf013921 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 2 Jun 2011 11:33:12 -0400 Received: from host1.jankratochvil.net (ovpn-113-38.phx2.redhat.com [10.3.113.38]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p52FXA4J017783 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 2 Jun 2011 11:33:12 -0400 Received: from host1.jankratochvil.net (localhost [127.0.0.1]) by host1.jankratochvil.net (8.14.4/8.14.4) with ESMTP id p52FX9U9027534 for ; Thu, 2 Jun 2011 17:33:09 +0200 Received: (from jkratoch@localhost) by host1.jankratochvil.net (8.14.4/8.14.4/Submit) id p52FX8Lu027530 for gdb-patches@sourceware.org; Thu, 2 Jun 2011 17:33:08 +0200 Date: Thu, 02 Jun 2011 15:33:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Subject: [patch] Fix C++ demangling of minsyms with symver Message-ID: <20110602153308.GA21368@host1.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) 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: 2011-06/txt/msg00023.txt.bz2 Hi, this is not for any regressions, just while playing with breakpoints I have noticed GDB cannot break on some libstdc++ versioned symbols because the demangler fails due to the `@...' suffix: 00000000000607d0 T std::istream::ignore()@@GLIBCXX_3.4.5 00000000000607d0 T std::istream::ignore()@GLIBCXX_3.4 (gdb) b 'std::istream::ignore()@GLIBCXX_3.4' Breakpoint 1 at 0x607d0: file /usr/src/debug/gcc-4.6.0-20110509/obj-x86_64-redhat-linux/x86_64-redhat-linux/libstdc++-v3/include/bits/istream.tcc, line 461. (gdb) b 'std::istream::ignore()@@GLIBCXX_3.4.5' Note: breakpoint 1 also set at pc 0x607d0. Breakpoint 2 at 0x607d0: file /usr/src/debug/gcc-4.6.0-20110509/obj-x86_64-redhat-linux/x86_64-redhat-linux/libstdc++-v3/include/bits/istream.tcc, line 461. (gdb) b 'std::istream::ignore()' Function "std::istream::ignore()" not defined. This is not exactly reproducible with FSF GDB HEAD + this patch as it needs other patches (such as removing DMGL_VERBOSE and others). But it is independent enough with a clear testcase so posting it separately for simplicity. One can see the default resolving to the @@ variant is not implemented. Not sure if it should be but let that be a possible incremental patch in the future. No regressions on {x86_64,x86_64-m32,i686}-fedora15-linux-gnu. I will check it in (not for 7.3) in some time if no comments appear. Thanks, Jan gdb/ 2011-06-02 Jan Kratochvil * symtab.c (symbol_find_demangled_name): New parameter objfile. Always call bfd_demangle, not cplus_demangle. (symbol_set_names): Pass OBJFILE. gdb/testsuite/ 2011-06-02 Jan Kratochvil * gdb.cp/cp-symver.cc: New file. * gdb.cp/cp-symver.exp: New file. --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -478,7 +478,7 @@ create_demangled_names_hash (struct objfile *objfile) static char * symbol_find_demangled_name (struct general_symbol_info *gsymbol, - const char *mangled) + const char *mangled, struct objfile *objfile) { char *demangled = NULL; @@ -499,8 +499,8 @@ symbol_find_demangled_name (struct general_symbol_info *gsymbol, if (gsymbol->language == language_cplus || gsymbol->language == language_auto) { - demangled = - cplus_demangle (mangled, DMGL_PARAMS | DMGL_ANSI | DMGL_VERBOSE); + demangled = bfd_demangle (objfile->obfd, mangled, + DMGL_PARAMS | DMGL_ANSI | DMGL_VERBOSE); if (demangled != NULL) { gsymbol->language = language_cplus; @@ -509,9 +509,8 @@ symbol_find_demangled_name (struct general_symbol_info *gsymbol, } if (gsymbol->language == language_java) { - demangled = - cplus_demangle (mangled, - DMGL_PARAMS | DMGL_ANSI | DMGL_JAVA); + demangled = bfd_demangle (objfile->obfd, mangled, + DMGL_PARAMS | DMGL_ANSI | DMGL_JAVA); if (demangled != NULL) { gsymbol->language = language_java; @@ -651,7 +650,8 @@ symbol_set_names (struct general_symbol_info *gsymbol, if (*slot == NULL) { char *demangled_name = symbol_find_demangled_name (gsymbol, - linkage_name_copy); + linkage_name_copy, + objfile); int demangled_len = demangled_name ? strlen (demangled_name) : 0; /* Suppose we have demangled_name==NULL, copy_name==0, and --- /dev/null +++ b/gdb/testsuite/gdb.cp/cp-symver.cc @@ -0,0 +1,33 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2011 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +void a () {} /* at-func-a */ + +/* Give `a' external name `v()' requiring version `VER_A'. */ +asm (".symver _Z1av, _Z1vv@VER_A"); + +void b () {} /* at-func-b */ + +/* Give `b' external name `v()' with default version `VER_B'. */ +asm (".symver _Z1bv, _Z1vv@@VER_B"); + +int +main () +{ + a (); + b (); +} --- /dev/null +++ b/gdb/testsuite/gdb.cp/cp-symver.exp @@ -0,0 +1,38 @@ +# Copyright 2011 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Test C++ demangling of versioned symbols. + +set testfile cp-symver +set srcfile ${testfile}.cc +if [prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}] { + return -1 +} + +if ![runto_main] { + untested ${testfile}.exp + return -1 +} + +gdb_test_no_output "set breakpoint pending off" + +gdb_breakpoint {'v()@VER_A'} +gdb_breakpoint {'v()@@VER_B'} + +# GDB currently does not support the default version assumption. +gdb_test "break v()" {Function "v\(\)" not defined\.} + +gdb_continue_to_breakpoint "a" ".* at-func-a .*" +gdb_continue_to_breakpoint "b" ".* at-func-b .*"