From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8213 invoked by alias); 12 Dec 2008 15:29:59 -0000 Received: (qmail 8137 invoked by uid 22791); 12 Dec 2008 15:29:58 -0000 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (212.99.106.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 12 Dec 2008 15:29:22 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id D9A0829007B; Fri, 12 Dec 2008 16:29:19 +0100 (CET) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Tn-c4+zRvYwt; Fri, 12 Dec 2008 16:29:18 +0100 (CET) Received: from province.act-europe.fr (province.act-europe.fr [10.10.0.214]) by mel.act-europe.fr (Postfix) with ESMTP id D396A290079; Fri, 12 Dec 2008 16:29:18 +0100 (CET) Received: by province.act-europe.fr (Postfix, from userid 560) id CA0DA165BEE; Fri, 12 Dec 2008 16:29:18 +0100 (CET) Date: Fri, 12 Dec 2008 15:29:00 -0000 From: Jerome Guitton To: Joel Brobecker Cc: gdb-patches@sourceware.org Subject: Re: [RFA/Ada] remove ref to fields and ref to slices Message-ID: <20081212152918.GA65464@adacore.com> References: <20081127100443.GA64300@adacore.com> <20081208233013.GJ3823@adacore.com> <20081209100418.GI52346@adacore.com> <20081209105430.GN3823@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="YZ5djTAD1cGYuMQK" Content-Disposition: inline In-Reply-To: <20081209105430.GN3823@adacore.com> User-Agent: Mutt/1.5.17 (2007-11-01) 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: 2008-12/txt/msg00226.txt.bz2 --YZ5djTAD1cGYuMQK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 678 Joel Brobecker (brobecker@adacore.com): > Rats! I'm looking at the code, and I am thinking that there is a bit > of simplification that we could look at, now that the contents of lazy > values is allocated later. For instance: > > ada_coerce_to_simple_array_ptr vs ada_coerce_to_simple_array > > If we got rid of ada_coerce_to_simple_array_ptr, then we probably > wouldn't need ada_value_slice_ptr.. > > But in the meantime, I do think that ada_value_slice_from_ptr is > clearer. Here is a new patch, taking the comments into account. I'll work on the rest of the simplification on the coming month. In the meantime, and if you're OK, I'll commit this first change. --YZ5djTAD1cGYuMQK Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="ref_fields.diff" Content-length: 3185 Index: ada-lang.c =================================================================== RCS file: /cvs/src/src/gdb/ada-lang.c,v retrieving revision 1.184 diff -u -p -r1.184 ada-lang.c --- ada-lang.c 24 Nov 2008 23:21:15 -0000 1.184 +++ ada-lang.c 12 Dec 2008 11:58:42 -0000 @@ -2346,12 +2346,12 @@ ada_value_ptr_subscript (struct value *a } /* Given that ARRAY_PTR is a pointer or reference to an array of type TYPE (the - actual type of ARRAY_PTR is ignored), returns a reference to - the Ada slice of HIGH-LOW+1 elements starting at index LOW. The lower - bound of this array is LOW, as per Ada rules. */ + actual type of ARRAY_PTR is ignored), returns the Ada slice of HIGH-LOW+1 + elements starting at index LOW. The lower bound of this array is LOW, as + per Ada rules. */ static struct value * -ada_value_slice_ptr (struct value *array_ptr, struct type *type, - int low, int high) +ada_value_slice_from_ptr (struct value *array_ptr, struct type *type, + int low, int high) { CORE_ADDR base = value_as_address (array_ptr) + ((low - TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type))) @@ -2361,7 +2361,7 @@ ada_value_slice_ptr (struct value *array low, high); struct type *slice_type = create_array_type (NULL, TYPE_TARGET_TYPE (type), index_type); - return value_from_pointer (lookup_reference_type (slice_type), base); + return value_at_lazy (slice_type, base); } @@ -6178,9 +6178,7 @@ ada_index_struct_field_1 (int *index_p, /* Given ARG, a value of type (pointer or reference to a)* structure/union, extract the component named NAME from the ultimate target structure/union and return it as a value with its - appropriate type. If ARG is a pointer or reference and the field - is not packed, returns a reference to the field, otherwise the - value of the field (an lvalue if ARG is an lvalue). + appropriate type. The routine searches for NAME among all members of the structure itself and (recursively) among all members of any wrapper members @@ -6257,8 +6255,7 @@ ada_value_struct_elt (struct value *arg, field_type); } else - v = value_from_pointer (lookup_reference_type (field_type), - address + byte_offset); + v = value_at_lazy (field_type, address + byte_offset); } } @@ -8808,9 +8805,9 @@ ada_evaluate_subexp (struct type *expect struct type *arr_type0 = to_fixed_array_type (TYPE_TARGET_TYPE (value_type (array)), NULL, 1); - return ada_value_slice_ptr (array, arr_type0, - longest_to_int (low_bound), - longest_to_int (high_bound)); + return ada_value_slice_from_ptr (array, arr_type0, + longest_to_int (low_bound), + longest_to_int (high_bound)); } } else if (noside == EVAL_AVOID_SIDE_EFFECTS) --YZ5djTAD1cGYuMQK--