From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18119 invoked by alias); 1 Oct 2010 16:26:19 -0000 Received: (qmail 18101 invoked by uid 22791); 1 Oct 2010 16:26:18 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 01 Oct 2010 16:26:13 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 5D5192BAD00; Fri, 1 Oct 2010 12:26:11 -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 N1WW3laZiEir; Fri, 1 Oct 2010 12:26:11 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 2556E2BAC49; Fri, 1 Oct 2010 12:26:11 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 308A7F591F; Fri, 1 Oct 2010 09:26:07 -0700 (PDT) From: Joel Brobecker To: gdb-patches@sourceware.org Cc: Joel Brobecker Subject: [commit/Ada] array and bounds in fat pointer can be a stub Date: Fri, 01 Oct 2010 16:26:00 -0000 Message-Id: <1285950364-27954-1-git-send-email-brobecker@adacore.com> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-10/txt/msg00009.txt.bz2 Hello, This patch adds handling of the case when a fat pointer has the P_ARRAY and/or P_BOUNDS fields defined as a stub. In that case, this stub needs to be resolved. There are two issues: . First, making sure that the resolution takes place itself. That's the change to ada_check_typedef. . Make sure that the type returned after resolution is not itself a typedef. This is the change to ada_check_typedef. gdb/ChangeLog (Jerome Guitton, Joel Brobecker): * ada-lang.c (desc_bounds): Add handling of the case where the P_BOUNDS field is a pointer to a stub. (desc_data_target_type): Same for P_ARRAY field. (ada_check_typedef): Strip the typedef layers from the type found by ada_find_any_type. Tested on x86_64-linux, and checked in. --- gdb/ChangeLog | 8 ++++++++ gdb/ada-lang.c | 34 ++++++++++++++++++++++++++++++---- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 3162717..fafee4b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,13 @@ 2010-10-01 Joel Brobecker + * ada-lang.c (desc_bounds): Add handling of the case where + the P_BOUNDS field is a pointer to a stub. + (desc_data_target_type): Same for P_ARRAY field. + (ada_check_typedef): Strip the typedef layers from the type + found by ada_find_any_type. + +2010-10-01 Joel Brobecker + * sparc-tdep.c (sparc32_frame_align): New function. (sparc32_gdbarch_init): Set the frame_align gdbarch method. * sparc64-tdep.c (sparc64_frame_align): New function. diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 3eaf649..173e901 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -1491,8 +1491,26 @@ desc_bounds (struct value *arr) } else if (is_thick_pntr (type)) - return value_struct_elt (&arr, NULL, "P_BOUNDS", NULL, - _("Bad GNAT array descriptor")); + { + struct value *p_bounds = value_struct_elt (&arr, NULL, "P_BOUNDS", NULL, + _("Bad GNAT array descriptor")); + struct type *p_bounds_type = value_type (p_bounds); + + if (p_bounds_type + && TYPE_CODE (p_bounds_type) == TYPE_CODE_PTR) + { + struct type *target_type = TYPE_TARGET_TYPE (p_bounds_type); + + if (TYPE_STUB (target_type)) + p_bounds = value_cast (lookup_pointer_type + (ada_check_typedef (target_type)), + p_bounds); + } + else + error (_("Bad GNAT array descriptor")); + + return p_bounds; + } else return NULL; } @@ -1539,7 +1557,7 @@ desc_data_target_type (struct type *type) if (data_type && TYPE_CODE (ada_check_typedef (data_type)) == TYPE_CODE_PTR) - return TYPE_TARGET_TYPE (data_type); + return ada_check_typedef (TYPE_TARGET_TYPE (data_type)); } return NULL; @@ -7636,7 +7654,15 @@ ada_check_typedef (struct type *type) char *name = TYPE_TAG_NAME (type); struct type *type1 = ada_find_any_type (name); - return (type1 == NULL) ? type : type1; + if (type1 == NULL) + return type; + + /* TYPE1 might itself be a TYPE_CODE_TYPEDEF (this can happen with + stubs pointing to arrays, as we don't create symbols for array + types, only for the typedef-to-array types). This is why + we process TYPE1 with ada_check_typedef before returning + the result. */ + return ada_check_typedef (type1); } } -- 1.7.1