From patchwork Mon Apr 28 20:09:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Brobecker X-Patchwork-Id: 737 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx22.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id 1CE75360060 for ; Mon, 28 Apr 2014 13:09:50 -0700 (PDT) Received: by homiemail-mx22.g.dreamhost.com (Postfix, from userid 14314964) id C96965070FA8; Mon, 28 Apr 2014 13:09:49 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx22.g.dreamhost.com 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 homiemail-mx22.g.dreamhost.com (Postfix) with ESMTPS id 8229B4EEB32D for ; Mon, 28 Apr 2014 13:09:49 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=h14pQNtVz9MMgKqS4zhcObhZzvE2nd2 Sg3MCN/Lfn4GBmbwuyJTYvBBuc9uuqjkhKQkQ5iY0WaS9sHIt1aPtlIPRH8BHVz9 5TBLR0nb48NPQTm6bdPTtBS0CwN36zQX2tnNNciJtnzCoWKsouEDW/Pz8smVpIbj K6MRNfhYf/40= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=TeiGN6lpOXlqHg/HeiX4V2w7j0E=; b=ChYqn jek/uLNXZtIixcZqLqO2hiOWIkQCLOEIbRU+hxbO27Mr2pMlc7KqUIkowo13g2UU IKfnCNUvdkcrDkAGJnAzBBZgAVzcvbKE5g61N1vTzOAC02PN70WPSEQ9fKeyzVd4 GCc+mCZdt9x3tj3zzgKT6x1t9PDX9hSV/OotwE= Received: (qmail 20985 invoked by alias); 28 Apr 2014 20:09:43 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 20908 invoked by uid 89); 28 Apr 2014 20:09:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 28 Apr 2014 20:09:41 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 8F4C0116166 for ; Mon, 28 Apr 2014 16:09:39 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id CFDb0j+Z59jT for ; Mon, 28 Apr 2014 16:09:39 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 77F30116164 for ; Mon, 28 Apr 2014 16:09:39 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 5CDB3E0487; Mon, 28 Apr 2014 16:09:39 -0400 (EDT) From: Joel Brobecker To: gdb-patches@sourceware.org Subject: [pushed 3/4] dwarf2read.c::read_subrange_type: Handle dynamic lower bounds Date: Mon, 28 Apr 2014 16:09:23 -0400 Message-Id: <1398715764-1548-4-git-send-email-brobecker@adacore.com> In-Reply-To: <1398715764-1548-1-git-send-email-brobecker@adacore.com> References: <1398715764-1548-1-git-send-email-brobecker@adacore.com> X-DH-Original-To: gdb@patchwork.siddhesh.in Currently, read_subrange_type handles dynamicity only in the case of the upper bound, and assumes that the lower bound is always static. That's rooted in the fact that dynamicity was added to support C99 variable-length arrays, where the lower bound is always zero, and therefore never dynamic. But the lower bound can, in fact, be dynamic in other languages such as Ada. Consider for instance the following declaration in Ada... type Array_Type is array (L .. U) of Natural; ... where L and U are parameters of the function where the declaration above was made, and whose value are 5 and 10. Currently, the debugger is able to print the value of the upper bound correctly, but not the lower bound: (gdb) ptype array_type type = array (1 .. 10) of natural After this patch, the debugger now prints: (gdb) ptype array_type type = array (5 .. 10) of natural gdb/ChangeLog: * dwarf2read.c (read_subrange_type): Handle dynamic DW_AT_lower_bound attributes. Tested on x86_64-linux, pushed. --- gdb/ChangeLog | 5 +++++ gdb/dwarf2read.c | 6 +----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6c811ea..56f3c17 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2014-04-28 Joel Brobecker + * dwarf2read.c (read_subrange_type): Handle dynamic + DW_AT_lower_bound attributes. + +2014-04-28 Joel Brobecker + * ada-lang.c (ada_discrete_type_high_bound): Resolve the type's dynamic bounds before computing its upper bound. (ada_discrete_type_low_bound): Same as above with the lower bound. diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index e72cc4b..bf1e3d0 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -14572,13 +14572,9 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) break; } - /* FIXME: For variable sized arrays either of these could be - a variable rather than a constant value. We'll allow it, - but we don't know how to handle it. */ attr = dwarf2_attr (die, DW_AT_lower_bound, cu); if (attr) - low.data.const_val - = dwarf2_get_attr_constant_value (attr, low.data.const_val); + attr_to_dynamic_prop (attr, die, cu, &low); else if (!low_default_is_valid) complaint (&symfile_complaints, _("Missing DW_AT_lower_bound " "- DIE at 0x%x [in module %s]"),