From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32471 invoked by alias); 16 May 2011 15:49:19 -0000 Received: (qmail 32457 invoked by uid 22791); 16 May 2011 15:49:17 -0000 X-SWARE-Spam-Status: No, hits=-6.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,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; Mon, 16 May 2011 15:48:57 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p4GFmufQ028051 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 16 May 2011 11:48:56 -0400 Received: from host1.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p4GFmrNs019660 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 16 May 2011 11:48:56 -0400 Received: from host1.jankratochvil.net (localhost [127.0.0.1]) by host1.jankratochvil.net (8.14.4/8.14.4) with ESMTP id p4GFmruV024934; Mon, 16 May 2011 17:48:53 +0200 Received: (from jkratoch@localhost) by host1.jankratochvil.net (8.14.4/8.14.4/Submit) id p4GFmqOc024928; Mon, 16 May 2011 17:48:52 +0200 Date: Mon, 16 May 2011 15:49:00 -0000 From: Jan Kratochvil To: Keith Seitz Cc: gdb-patches@sourceware.org Subject: [rfc] physname cross-check [Re: [RFA] Typedef'd method parameters [0/4]] Message-ID: <20110516154851.GA24555@host1.jankratochvil.net> References: <4DB09E6C.8000202@redhat.com> <4DCC50D8.5030903@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4DCC50D8.5030903@redhat.com> 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-05/txt/msg00358.txt.bz2 Hi Keith, On Thu, 12 May 2011 23:27:52 +0200, Keith Seitz wrote: > I'm sending an updated set of all of the patches just in case > something got foobar'd along the way. I wrote a cross-check of what GDB thinks is the physname (which is in demangled canonical form) vs. what GCC thinkgs is the physname (which needs to be converted from mangled form and canonicalized). It reports for me 34524 unique failures on libwebkit.so.debug. (Sure such count is caused only by a few physname computation bugs.) Therefore I would propose a sinful idea to temporarily just use DW_AT_linkage_name if it is available to ever release gdb-7.3 and make DW_AT_linkage_name-less GDB a feature for gdb-7.4. After all such cross-check should exist anyway for verifying both GCC and GDB bugs this way. This patch preferring DW_AT_linkage_name fixes for example this regression: cat >1.h <1.C <1b.C < does not match demangled (from linkage <_ZN1C1mEP1x>) - DIE at 0x3d [in module .../1]. pre-phyname: $2 = {void (C *, x *)} 0x4004f0 FSF GDB HEAD: $2 = {void (C * const, x *)} 0x4004f0 HEAD + your patch: Cannot take address of method m. your+this patches: $2 = {void (C * const, x *)} 0x4004f0 This is a regression. Just it has some other existing testsuite regressions: gdb.cp/bs15503.exp gdb.cp/cp-relocate.exp gdb.cp/cpexprs.exp gdb.java/jmisc.exp gdb.java/jprint.exp >From a quick loook they seem to me like bugs in GDB expecting the incompatibly computed physname but I did not try to fix it yet. What do you think? Thanks, Jan gdb/ 2011-05-16 Jan Kratochvil * dwarf2read.c (dwarf2_physname): New variables physname, attr, mangled, retval, demangled, canon and back_to. Cross-check DW_AT_linkage_name and PHYS_NAME if both available, return DW_AT_linkage_name in such case. --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -5142,7 +5142,74 @@ dwarf2_full_name (char *name, struct die_info *die, struct dwarf2_cu *cu) static const char * dwarf2_physname (char *name, struct die_info *die, struct dwarf2_cu *cu) { - return dwarf2_compute_name (name, die, cu, NAME_KIND_PHYS); + const char *physname = dwarf2_compute_name (name, die, cu, NAME_KIND_PHYS); + struct attribute *attr; + const char *mangled, *retval; + char *demangled, *canon; + struct cleanup *back_to; + + /* Do not check PHYSNAME if it never will be needed by GDB. GDB does not + need to support something it has no use for. */ + if (!die_needs_namespace (die, cu)) + return physname; + + attr = dwarf2_attr (die, DW_AT_linkage_name, cu); + if (!attr) + attr = dwarf2_attr (die, DW_AT_MIPS_linkage_name, cu); + if (!attr || !DW_STRING (attr)) + { + /* DW_AT_linkage_name is missing in some cases - depend on what GDB has + computed. */ + + return physname; + } + mangled = DW_STRING (attr); + + /* As both DW_AT_linkage_name (MANGLED) and computed PHYSNAME are present + cross-check them. */ + + back_to = make_cleanup (null_cleanup, 0); + + demangled = cplus_demangle (mangled, DMGL_PARAMS | DMGL_ANSI); + if (demangled) + make_cleanup (xfree, demangled); + else + demangled = (char *) mangled; + + if (cu->language == language_cplus) + { + canon = cp_canonicalize_string (demangled); + if (canon != NULL) + make_cleanup (xfree, canon); + else + canon = demangled; + } + else + canon = demangled; + + if (strcmp (physname, canon) != 0) + { + /* It may not mean a bug in GDB. The compiler could also compute + DW_AT_linkage_name incorrectly. But in such case GDB would need to be + bug-to-bug compatible. */ + + complaint (&symfile_complaints, + _("Computed physname <%s> does not match demangled <%s> " + "(from linkage <%s>) - DIE at 0x%x [in module %s]"), + physname, canon, mangled, die->offset, cu->objfile->name); + + /* Prefer DW_AT_linkage_name (in the CANON form) - when it is available + here - over computed PHYSNAME. It is safer against both buggy GDB and + buggy compilers. */ + + retval = obsavestring (canon, strlen (canon), + &cu->objfile->objfile_obstack); + } + else + retval = physname; + + do_cleanups (back_to); + return retval; } static const char *