From patchwork Mon Sep 10 15:42:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Brobecker X-Patchwork-Id: 29289 Received: (qmail 85356 invoked by alias); 10 Sep 2018 15:42:19 -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 85247 invoked by uid 89); 10 Sep 2018 15:42:18 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= 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 ESMTP; Mon, 10 Sep 2018 15:42:16 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 2F15B116263; Mon, 10 Sep 2018 11:42:15 -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 JnM1tgSBoSby; Mon, 10 Sep 2018 11:42:15 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) by rock.gnat.com (Postfix) with ESMTP id 1FB1A1161AB; Mon, 10 Sep 2018 11:42:15 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4233) id 1F0A755F; Mon, 10 Sep 2018 11:42:15 -0400 (EDT) From: Joel Brobecker To: gdb-patches@sourceware.org Cc: Xavier Roirand Subject: [PATCH 2/6] (Ada) New function ada_is_access_to_unconstrained_array Date: Mon, 10 Sep 2018 11:42:04 -0400 Message-Id: <1536594128-6487-3-git-send-email-brobecker@adacore.com> In-Reply-To: <1536594128-6487-1-git-send-email-brobecker@adacore.com> References: <1536594128-6487-1-git-send-email-brobecker@adacore.com> From: Xavier Roirand Add a new function to check if a given type is an access to an unconstrained array. This function contains code that is present only once in the current sources but will be used in a future patch. gdb/ChangeLog: * ada-lang.c (ada_is_access_to_unconstrained_array): New function. (ada_check_typedef): Use it. Tested on x86_64-linux. --- gdb/ChangeLog | 5 +++++ gdb/ada-lang.c | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ca678dd..5401864 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2018-09-10 Xavier Roirand + * ada-lang.c (ada_is_access_to_unconstrained_array): New function. + (ada_check_typedef): Use it. + +2018-09-10 Xavier Roirand + * ada-varobj.c (ada_varobj_describe_struct_child) (ada_varobj_describe_child): Handle union case like struct one. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index b8a11cd..83421ac 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -2832,6 +2832,15 @@ value_assign_to_component (struct value *container, struct value *component, value_contents (val), 0, bits, 0); } +/* Determine if TYPE is an access to an unconstrained array. */ + +static bool +ada_is_access_to_unconstrained_array (struct type *type) +{ + return (TYPE_CODE (type) == TYPE_CODE_TYPEDEF + && is_thick_pntr (ada_typedef_target_type (type))); +} + /* The value of the element of array ARR at the ARITY indices given in IND. ARR may be either a simple array, GNAT array descriptor, or pointer thereto. */ @@ -9245,13 +9254,13 @@ ada_check_typedef (struct type *type) if (type == NULL) return NULL; - /* If our type is a typedef type of a fat pointer, then we're done. + /* If our type is an access to an unconstrained array, which is encoded + as a TYPE_CODE_TYPEDEF of a fat pointer, then we're done. We don't want to strip the TYPE_CODE_TYPDEF layer, because this is what allows us to distinguish between fat pointers that represent array types, and fat pointers that represent array access types (in both cases, the compiler implements them as fat pointers). */ - if (TYPE_CODE (type) == TYPE_CODE_TYPEDEF - && is_thick_pntr (ada_typedef_target_type (type))) + if (ada_is_access_to_unconstrained_array (type)) return type; type = check_typedef (type);