From patchwork Mon Jan 2 17:24:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 89562 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp7678174qgi; Mon, 2 Jan 2017 09:25:13 -0800 (PST) X-Received: by 10.99.207.17 with SMTP id j17mr106366489pgg.57.1483377913742; Mon, 02 Jan 2017 09:25:13 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id f9si41338215plm.292.2017.01.02.09.25.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Jan 2017 09:25:13 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-445172-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-445172-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-445172-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=FqIaVbKGIjKzNepww +E1rE012f6VpqfNhj8yxYk7BHEXB+MoCRpPL6BhSI3gw+jcUxJ1RbTkzS3MU/z4R /8bnVVI/YsxUpVhWjpOJJdNpQn0x6ZhlPAHuaLWu8TYEOUKMMJf4BkLXPcrQD/PH O8fRJyhjPLnb091GIwtKAMAHXQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=lPv0wsPNReDdXDZiDjtZk/D kRE8=; b=iwv6ehWtCQxuwmEW2bylZLonXDKKPQMqN0W22halLi6TkJqfEo8aTYL kytG7HABzwCbXGmqnksrwiLh27MAUzExTZ1WxDj0GWD4yWI4JOfLwr7c/WeDrJyq ruWABc0sKdU3GhN/fgQc+VL8rfE3i6WlTqy7zSIhVIqiy4bBhCoQ= Received: (qmail 107209 invoked by alias); 2 Jan 2017 17:24:57 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 107199 invoked by uid 89); 2 Jan 2017 17:24:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=LEB128, leb128, interpret, signedness X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 02 Jan 2017 17:24:46 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 798DC814C8; Mon, 2 Jan 2017 18:24:44 +0100 (CET) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yHi29lmT--js; Mon, 2 Jan 2017 18:24:44 +0100 (CET) Received: from [IPv6:2a02:2ab8:224:1:f21f:afff:fe4c:b838] (cacatoes.act-europe.fr [IPv6:2a02:2ab8:224:1:f21f:afff:fe4c:b838]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id EF1BE814C6; Mon, 2 Jan 2017 18:24:43 +0100 (CET) Subject: Re: [PATCH] DWARF: make signedness explicit for enumerator const values To: Jason Merrill References: <20161013161201.10521-1-derodat@adacore.com> <1478781484.14569.131.camel@klomp.org> <4650aad8-9d49-3924-ffb2-77c42e19e870@adacore.com> <1479125116.14569.234.camel@klomp.org> <3aafd2e8-720a-8cb9-21f6-a718966c7e38@adacore.com> <21ef1b1d-ca1e-4881-c51a-e48ee046ea68@adacore.com> <1481288408.14558.20.camel@klomp.org> Cc: Mark Wielaard , Eric Botcazou , gcc-patches List From: Pierre-Marie de Rodat Message-ID: <389ade79-ed46-f339-5268-41074da5dc14@adacore.com> Date: Mon, 2 Jan 2017 18:24:43 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: X-IsSubscribed: yes On 12/09/2016 03:06 PM, Jason Merrill wrote: > I think it's fine guarded by !dwarf_strict; most consumers should > happily ignore it if they don't know what to do with it. Thank you for your feedback! This ultimate patch is much smaller. :-) Still bootstrapped and tested successfuly on x86_64-linux (GCC+GDB). -- Pierre-Marie de Rodat >From 9b31876c85248817a62d78e1fb7133f610b6555f Mon Sep 17 00:00:00 2001 From: Pierre-Marie de Rodat Date: Mon, 19 Dec 2016 16:01:52 +0100 Subject: [PATCH] DWARF: add DW_AT_encoding attributes for DW_TAG_enumeration_type DIEs Currently, the DWARF description does not specify the signedness of the representation of enumeration types. This is a problem in some contexts where DWARF consumers need to determine if value X is greater than value Y. For instance in Ada: type Enum_Type is ( A, B, C, D); for Enum_Type use (-1, 0, 1, 2); type Rec_Type (E : Enum_Type) is record when A .. B => null; when others => B : Booleann; end record; The above can be described in DWARF the following way: DW_TAG_enumeration_type(Enum_Type) | DW_AT_byte_size: 1 DW_TAG_enumerator(A) | DW_AT_const_value: -1 DW_TAG_enumerator(B) | DW_AT_const_value: 0 DW_TAG_enumerator(C) | DW_AT_const_value: 1 DW_TAG_enumerator(D) | DW_AT_const_value: 2 DW_TAG_structure_type(Rec_Type) DW_TAG_member(E) | DW_AT_type: DW_TAG_variant_part | DW_AT_discr: DW_TAG_variant | DW_AT_discr_list: DW_DSC_range 0x7f 0 DW_TAG_variant | DW_TAG_member(b) DWARF consumers need to know that enumerators (A, B, C and D) are signed in order to determine the set of E values for which Rec_Type has a B field. In practice, they need to know how to interpret the 0x7f LEB128 number above (-1, not 127). When in non-strict DWARF mode, this patch adds a DW_AT_encoding attribute to generated DW_TAG_enumeration_type DIEs to make this signedness explicit. gcc/ * dwarf2out.c (gen_enumeration_type_die): When -gno-strict-dwarf, add a DW_AT_encoding attribute. --- gcc/dwarf2out.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 8dc85237288..7080ea5f12d 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -20930,6 +20930,11 @@ gen_enumeration_type_die (tree type, dw_die_ref context_die) if (ENUM_IS_OPAQUE (type)) add_AT_flag (type_die, DW_AT_declaration, 1); } + if (!dwarf_strict) + add_AT_unsigned (type_die, DW_AT_encoding, + (TYPE_UNSIGNED (type)) + ? DW_ATE_unsigned + : DW_ATE_signed); } else if (! TYPE_SIZE (type)) return type_die; -- 2.11.0