From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31257 invoked by alias); 21 Mar 2011 15:44:53 -0000 Received: (qmail 31117 invoked by uid 22791); 21 Mar 2011 15:44:49 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_GD,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, 21 Mar 2011 15:44:33 +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 p2LFiWrv029392 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 21 Mar 2011 11:44:32 -0400 Received: from host1.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p2LFiTdn005990 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 21 Mar 2011 11:44:31 -0400 Received: from host1.jankratochvil.net (localhost [127.0.0.1]) by host1.jankratochvil.net (8.14.4/8.14.4) with ESMTP id p2LFiTbZ004697 for ; Mon, 21 Mar 2011 16:44:29 +0100 Received: (from jkratoch@localhost) by host1.jankratochvil.net (8.14.4/8.14.4/Submit) id p2LFiTRV004696 for gdb-patches@sourceware.org; Mon, 21 Mar 2011 16:44:29 +0100 Date: Mon, 21 Mar 2011 15:47:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Subject: [patch] DWARF-3+ DW_AT_accessibility defaults #2 (GCC PR debug/45124) Message-ID: <20110321154428.GA3761@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-03/txt/msg00958.txt.bz2 Hi, this is a repost for: [patch] Fix DWARF-3+ DW_AT_accessibility default assumption http://sourceware.org/ml/gdb-patches/2011-01/msg00507.html Re: [patch] Fix DWARF-3+ DW_AT_accessibility default assumption http://sourceware.org/ml/gdb-patches/2011-03/msg00546.html revert: Re: [patch] Fix DWARF-3+ DW_AT_accessibility default assumption http://sourceware.org/ml/gdb-patches/2011-03/msg00586.html FSF GDB HEAD: former patch: this patch: dw-2 dw-3 dw-2 dw-3 dw-2 dw-3 gcc-4.5 pass pass 4.5 pass FAIL 4.5 pass pass gcc-4.6 pass FAIL 4.6 pass pass 4.6 pass pass (set -x;for gcc in 45 46;do for dwarf in 2 3;do PATH="/your-gcc-dir/gcc${gcc}-root/bin:$PATH" runtest CXX_FOR_TARGET="g++ -gdwarf-${dwarf}" gdb.cp/casts.exp gdb.cp/classes.exp gdb.cp/virtfunc.exp gdb.mi/gdb792.exp gdb.python/py-value.exp ;done;done) Normally it probably is not of much concern as FSF GCC defaults to -gdwarf-2 where no changes happen. Just Fedoras+RHELs default to -gdwarf-3 where the assumed defaults have changed, therefore proposing for FSF GDB to verify DW_AT_producer - it affects even FSF GCCs when one uses -gdwarf-3 or -gdwarf-4. Due to the mess I did before waiting for a review. I believe this fix should be a gdb-7.3 blocker as gcc-4.6.0 will be released far before gdb-7.4. I do not provide a special new testcase as the testcases already exist and a gdb.dwarf2/ code would just carbon-copy the conditionals while it is more important the conditionals match the real compilers behavior. Thanks, Jan (set -ex;echo 'class C { public: int priv; } c;' | g++ -gdwarf-3 -c -g -o 1.o -x c++ -; readelf -wi 1.o) old = no DW_AT_accessibility new = DW_AT_accessibility: 1 (public) old gcc-4.4.5-6.el6.x86_64 = GNU C++ 4.4.5 20110214 (Red Hat 4.4.5-6) old gcc-4.5.1-4.fc14.x86_64 = GNU C++ 4.5.1 20100924 (Red Hat 4.5.1-4) new gcc-4.6.0-0.14.fc15.x86_64 = GNU C++ 4.6.0 20110318 (Red Hat 4.6.0-0.14) new GNU C++ 4.7.0 20110321 (experimental) new GNU C++ 4.6.0 20110321 (prerelease) old GNU C++ 4.5.3 20110321 (prerelease) XXX GNU C++ 4.4.6 20110321 (prerelease) [-gdwarf-3 not supported] gdb/ 2011-03-21 Jan Kratochvil * dwarf2read.c (producer_is_gxx_lt_4_6): New function. (dwarf2_add_field): Fix new_field->accessibility for cu->header.version >= 3 while verifying also producer_is_gxx_lt_4_6. --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -6209,6 +6209,27 @@ dwarf2_record_block_ranges (struct die_info *die, struct block *block, } } +/* Check for GCC PR debug/45124 fix which is not present in any G++ version up + to 4.5.any hwile it is present already in G++ 4.6.0 - the PR has been fixed + during 4.6.0 experimental. */ + +static int +producer_is_gxx_lt_4_6 (const char *producer) +{ + int major, minor; + + /* Whitespaces are ignored in both PRODUCER and the format string. */ + if (sscanf (producer, "GNU C++ %d.%d", &major, &minor) != 2) + { + /* For non-GCC compilers expect their behavior is DWARF version + compliant. */ + + return 0; + } + + return major < 4 || (major == 4 && minor < 6); +} + /* Add an aggregate field to the field list. */ static void @@ -6239,13 +6260,28 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die, } fip->nfields++; - /* Handle accessibility and virtuality of field. - The default accessibility for members is public, the default - accessibility for inheritance is private. */ - if (die->tag != DW_TAG_inheritance) - new_field->accessibility = DW_ACCESS_public; + if (cu->header.version < 3 || producer_is_gxx_lt_4_6 (cu->producer)) + { + /* The default DWARF 2 accessibility for members is public, the default + accessibility for inheritance is private. */ + + if (die->tag != DW_TAG_inheritance) + new_field->accessibility = DW_ACCESS_public; + else + new_field->accessibility = DW_ACCESS_private; + } else - new_field->accessibility = DW_ACCESS_private; + { + /* DWARF 3+ defines the default accessibility a different way - see + below - than DWARF 2 has defined. The same rules apply now for + DW_TAG_inheritance as for the members and it only depends on the + container kind. */ + + if (die->parent->tag == DW_TAG_class_type) + new_field->accessibility = DW_ACCESS_private; + else + new_field->accessibility = DW_ACCESS_public; + } new_field->virtuality = DW_VIRTUALITY_none; attr = dwarf2_attr (die, DW_AT_accessibility, cu);