From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31132 invoked by alias); 19 Feb 2014 14:34:25 -0000 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 Received: (qmail 31117 invoked by uid 89); 19 Feb 2014 14:34:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.3 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 19 Feb 2014 14:34:24 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s1JEYHuZ014359 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 19 Feb 2014 09:34:17 -0500 Received: from [10.36.116.65] (ovpn-116-65.ams2.redhat.com [10.36.116.65]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s1JEYGdl026232; Wed, 19 Feb 2014 09:34:16 -0500 Subject: Re: [RFA/DWARF] Set enum type "flag_enum" and "unsigned" flags at type creation. From: Mark Wielaard To: Joel Brobecker Cc: gdb-patches@sourceware.org In-Reply-To: <1390796357-3739-1-git-send-email-brobecker@adacore.com> References: <1390796357-3739-1-git-send-email-brobecker@adacore.com> Content-Type: text/plain; charset="UTF-8" Date: Wed, 19 Feb 2014 14:34:00 -0000 Message-ID: <1392820455.21975.235.camel@bordewijk.wildebeest.org> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-SW-Source: 2014-02/txt/msg00599.txt.bz2 On Mon, 2014-01-27 at 08:19 +0400, Joel Brobecker wrote: > To understand why the range type's upper bound is read as a negative > value, one needs to look at how it is determined, in read_subrange_type: > > orig_base_type = die_type (die, cu); > base_type = check_typedef (orig_base_type); > [... high is first correctly read as 128, but then ...] > if (!TYPE_UNSIGNED (base_type) && (high & negative_mask)) > high |= negative_mask; > > The negative_mask is applied, here, because BASE_TYPE->FLAG_UNSIGNED > is not set. And the reason for that is because the base_type was only > partially constructed during the call to die_type. While the enum > is constructed on the fly by read_enumeration_type, its flag_unsigned > flag is only set later on, while creating the symbols corresponding to > the enum type's enumerators (see process_enumeration_scope), after > we've already finished creating our range type - and therefore too > late. This looks suspicious. I think the explicit sign-extension is in general wrong. It seems to assume that the DWARF producer encoded the DW_AT_upper_bound wrongly (not as a signed value, but as an unsigned value that needs to be sign-extended). Something like that might happen in theory if the producer used DW_FORM_data[1248] because DWARF doesn't define how to encode signed values in that case. But in practice this seems to have been settled by interpreting these values as zero-extended values (not sign-extended) and by the producer using either DW_FORM_sdata or DW_FORM_udata to remove any ambiguity (like in your testcase). Does anything break if you just remove the sign-extension part? If not, then you don't have to go through the whole update_enumeration_type_from_children. Or do you need that for anything else? Cheers, Mark