From patchwork Sun Mar 23 11:17:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Wielaard X-Patchwork-Id: 332880 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 59FD52C00C2 for ; Sun, 23 Mar 2014 22:17:53 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id; q=dns; s=default; b=ujD1MZQ4D4aB Gy/vNBiRblphXm0ED1WNxx9zGMD3pBIJNvv1DWco5JO4ruFmvfhcPpCFx/cnvB2w fszKxiisOa4E/9uVX3shC2/aZGVGffnh/GaFYseiwi1xLX0aYVoRVmDleI/1CxKK cxu6i38O/xy1v7+3xWoGbTRmLP0TFKo= 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:from :to:cc:subject:date:message-id; s=default; bh=ayNc6doy7Nn626Qsm1 NNAvPex8E=; b=tVVAyoGhkj7CViW6aXJraRHx1PIL0bebkIhKYcrVvqRAm48qgr E+XPCtVRVi/1hTEhMpS2fDfLX8C7DuZ08Ikk7+OPN5HdQX2R1AfgQa7hV9E/89sJ cgb4aSR5epmD3yLvVB643SO6yQNSCWzlB4zpXf3PX1GEDlTadIK3FXYJI= Received: (qmail 26163 invoked by alias); 23 Mar 2014 11:17:45 -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 26152 invoked by uid 89); 23 Mar 2014 11:17:44 -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, SPF_PASS autolearn=ham version=3.3.2 X-HELO: gnu.wildebeest.org Received: from wildebeest.demon.nl (HELO gnu.wildebeest.org) (212.238.236.112) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Sun, 23 Mar 2014 11:17:44 +0000 From: Mark Wielaard To: gcc-patches@gcc.gnu.org Cc: Tom Tromey , Mark Wielaard Subject: [PATCH] Add DW_AT_const_value as unsigned or int depending on type and value used. Date: Sun, 23 Mar 2014 12:17:10 +0100 Message-Id: <1395573430-21207-1-git-send-email-mjw@redhat.com> X-Spam-Score: -2.9 (--) As the comment in the code already indicated DWARF2 does provide DW_FORM_sdata/DW_FORM_udata to represent signed/unsigned data. Enumeration constants wider than HOST_WIDE_INT are already handled separately. Those constant values that do fit a HOST_WIDE_INT can be encoded as signed or unsigned depending on type and value for more efficient encoding. * dwarf2out.c (gen_enumeration_type_die): Add DW_AT_const_value as unsigned or int depending on type and value used. --- gcc/ChangeLog | 5 +++++ gcc/dwarf2out.c | 21 ++++++++------------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8a31187..f3b4f2d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2014-03-21 Mark Wielaard + + * dwarf2out.c (gen_enumeration_type_die): Add DW_AT_const_value + as unsigned or int depending on type and value used. + 2014-03-20 Mark Wielaard * dwarf2out.c (add_bound_info): If HOST_WIDE_INT is big enough, diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 9f8b3b0..af97408 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -17364,19 +17364,14 @@ gen_enumeration_type_die (tree type, dw_die_ref context_die) if (simple_type_size_in_bits (TREE_TYPE (value)) <= HOST_BITS_PER_WIDE_INT || tree_fits_shwi_p (value)) - /* DWARF2 does not provide a way of indicating whether or - not enumeration constants are signed or unsigned. GDB - always assumes the values are signed, so we output all - values as if they were signed. That means that - enumeration constants with very large unsigned values - will appear to have negative values in the debugger. - - TODO: the above comment is wrong, DWARF2 does provide - DW_FORM_sdata/DW_FORM_udata to represent signed/unsigned data. - This should be re-worked to use correct signed/unsigned - int/double tags for all cases, instead of always treating as - signed. */ - add_AT_int (enum_die, DW_AT_const_value, TREE_INT_CST_LOW (value)); + { + HOST_WIDE_INT val = TREE_INT_CST_LOW (value); + if (TYPE_UNSIGNED (TREE_TYPE (value)) || val >= 0) + add_AT_unsigned (enum_die, DW_AT_const_value, + (unsigned HOST_WIDE_INT) val); + else + add_AT_int (enum_die, DW_AT_const_value, val); + } else /* Enumeration constants may be wider than HOST_WIDE_INT. Handle that here. */