From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22923 invoked by alias); 19 Mar 2010 12:37:20 -0000 Received: (qmail 22911 invoked by uid 22791); 19 Mar 2010 12:37:19 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,MSGID_FROM_MTA_HEADER X-Spam-Check-By: sourceware.org Received: from mtagate1.de.ibm.com (HELO mtagate1.de.ibm.com) (195.212.17.161) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 19 Mar 2010 12:37:15 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate1.de.ibm.com (8.13.1/8.13.1) with ESMTP id o2JCbCQ9032198 for ; Fri, 19 Mar 2010 12:37:12 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o2JCbCHj1503454 for ; Fri, 19 Mar 2010 13:37:12 +0100 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id o2JCbCAa020626 for ; Fri, 19 Mar 2010 13:37:12 +0100 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with SMTP id o2JCbBAr020607 for ; Fri, 19 Mar 2010 13:37:11 +0100 Message-Id: <201003191237.o2JCbBAr020607@d12av02.megacenter.de.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Fri, 19 Mar 2010 13:37:11 +0100 Subject: [rfc] Work around buggy GCC 4.1 namespace dwarf info (GCC PR c++/28460) To: gdb-patches@sourceware.org Date: Fri, 19 Mar 2010 12:37:00 -0000 From: "Ulrich Weigand" MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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: 2010-03/txt/msg00727.txt.bz2 Hello, since recent patches to improve C++ namespace support went in, I'm seeing large numbers (>150) of C++ test case failures. It turns out that these were caused by a bug in G++ 4.1 (GCC PR c++/28460) that generates bogus DW_TAG_namespace DIEs for the global namespace. With current GDB these bogus DIEs have the effect that the debugger will no longer have debug info for any global variable. This seriously affects debugging capabilities ... While the bug is indeed in GCC rather than GDB (and has long since been fixed), I'm wondering whether it would still make sense for us to work around the problem, because: - GCC 4.1 is still in widespread use (e.g. as system compiler in RHEL 5.x and SLES 10). - The impact of the bug seriously affects debugging with current mainline GDB. Note that there is precendent for working around buggy GCC debug info generation in serious cases already ... The following patch works around the problem for me. Tested on powerpc-linux, fixes (most) C++ test case failures. Any comments? Does anybody see a simpler way to work around the problem? Bye, Ulrich ChangeLog: * dwarf2read.c (partial_die_parent_scope): Work around buggy GCC 4.1 debug info generation (GCC PR c++/28460). (determine_prefix): Likewise. Index: gdb/dwarf2read.c =================================================================== RCS file: /cvs/src/src/gdb/dwarf2read.c,v retrieving revision 1.370 diff -u -p -r1.370 dwarf2read.c --- gdb/dwarf2read.c 17 Mar 2010 19:16:02 -0000 1.370 +++ gdb/dwarf2read.c 18 Mar 2010 19:26:51 -0000 @@ -2307,6 +2307,19 @@ partial_die_parent_scope (struct partial grandparent_scope = partial_die_parent_scope (parent, cu); + /* GCC 4.0 and 4.1 had a bug (PR c++/28460) where they generated bogus + DW_TAG_namespace DIEs with a name of "::" for the global namespace. + Work around this problem here. */ + if (cu->language == language_cplus + && parent->tag == DW_TAG_namespace + && strcmp (parent->name, "::") == 0 + && grandparent_scope == NULL) + { + parent->scope = NULL; + parent->scope_set = 1; + return NULL; + } + if (parent->tag == DW_TAG_namespace || parent->tag == DW_TAG_structure_type || parent->tag == DW_TAG_class_type @@ -9012,6 +9025,12 @@ determine_prefix (struct die_info *die, { case DW_TAG_namespace: parent_type = read_type_die (parent, cu); + /* GCC 4.0 and 4.1 had a bug (PR c++/28460) where they generated bogus + DW_TAG_namespace DIEs with a name of "::" for the global namespace. + Work around this problem here. */ + if (cu->language == language_cplus + && strcmp (TYPE_TAG_NAME (parent_type), "::") == 0) + return ""; /* We give a name to even anonymous namespaces. */ return TYPE_TAG_NAME (parent_type); case DW_TAG_class_type: -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com