From patchwork Mon Apr 28 20:09:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Brobecker X-Patchwork-Id: 736 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx23.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id A4297360060 for ; Mon, 28 Apr 2014 13:09:43 -0700 (PDT) Received: by homiemail-mx23.g.dreamhost.com (Postfix, from userid 14314964) id 67053632F4944; Mon, 28 Apr 2014 13:09:43 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx23.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-mx23.g.dreamhost.com (Postfix) with ESMTPS id 4AC63632F4938 for ; Mon, 28 Apr 2014 13:09:43 -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=oOa5Ht04NtEmP0Fu4BSJYYq93WIe7Dv DZh6IPuI0lyJEd4JAD9mYmp0l7kylf9JV4H8d11Xd4ozJvpLgUY9SqgLb9xRdm9D nkLywMBren6TWmzNT+Z9an3hr+qTNsVShac7rNP7bE/JsLqp8wZes7W0uyL9SY7z jt6ehEtbRTFs= 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=gZdgvfqy/lcALT6/5nivUG76EY4=; b=OLSg1 nANASu5H70gOPw7tG+xku/M+v3Al7Cv8Amu7xRpSz1cc3Ml5AYcad4OsDDmkEkza vfs6LRDcVllQuIlWXsH2kk5gj0pZf7H9oBlzs0l6Mshn4p9WpoSDuhKnH56gDJiU UZmgsOiJ+PPpYd8CZV/QkY7uBZRew1JH9QXApI= Received: (qmail 20339 invoked by alias); 28 Apr 2014 20:09:37 -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 20191 invoked by uid 89); 28 Apr 2014 20:09:36 -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:35 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id D1C1B116166 for ; Mon, 28 Apr 2014 16:09:33 -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 Dep38w7AvwVn for ; Mon, 28 Apr 2014 16:09:33 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id BA71A11610B for ; Mon, 28 Apr 2014 16:09:33 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 9E8D0E0487; Mon, 28 Apr 2014 16:09:33 -0400 (EDT) From: Joel Brobecker To: gdb-patches@sourceware.org Subject: [pushed 2/4] Improve Ada dynamic range type handling. Date: Mon, 28 Apr 2014 16:09:22 -0400 Message-Id: <1398715764-1548-3-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 Consider 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. At the moment, GDB relies on descriptive types in order to properly decode the array bounds. For instance, if L was 5, and U was 10, we would see the following: (gdb) ptype array_type type = array (5 .. 10) of natural (gdb) maintenance set ada ignore-descriptive-types (gdb) ptype array_type type = array (1 .. 28544912) of natural This patch enhances ada_discrete_type_{high,low}_bound to resolve any dynamicity. This is sufficient to fix the case of the upper bound. For the lower bound, the dwarf2read module does not handle dynamic lower bounds yet, but once it does, the lower bound should be correctly handled as well [1]. gdb/ChangeLog: * 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. Tested on x86_64-linux, pushed. [1]: The reason why we do not enhance dwarf2read to handle dynamic lower bounds ahead of this patch is because it unveils some latent issues such as this one. --- gdb/ChangeLog | 6 ++++++ gdb/ada-lang.c | 2 ++ 2 files changed, 8 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e1dda4c..6c811ea 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,11 @@ 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. + +2014-04-28 Joel Brobecker + * dwarf2read.c (is_dynamic_type): Return true for dynamic range types. Adjust the array handling implementation to take advantage of this change. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 0acc1b5..38972c6 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -793,6 +793,7 @@ min_of_type (struct type *t) LONGEST ada_discrete_type_high_bound (struct type *type) { + type = resolve_dynamic_type (type, 0); switch (TYPE_CODE (type)) { case TYPE_CODE_RANGE: @@ -813,6 +814,7 @@ ada_discrete_type_high_bound (struct type *type) LONGEST ada_discrete_type_low_bound (struct type *type) { + type = resolve_dynamic_type (type, 0); switch (TYPE_CODE (type)) { case TYPE_CODE_RANGE: