From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29067 invoked by alias); 28 Dec 2008 13:09:23 -0000 Received: (qmail 29059 invoked by uid 22791); 28 Dec 2008 13:09:22 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00 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; Sun, 28 Dec 2008 13:08:47 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 533122A9618; Sun, 28 Dec 2008 08:08:45 -0500 (EST) 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 HG8Kzu6DSn9J; Sun, 28 Dec 2008 08:08:45 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 3BC542A96C9; Sun, 28 Dec 2008 08:08:44 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id 461DAE7ACD; Sun, 28 Dec 2008 17:08:36 +0400 (RET) Date: Sun, 28 Dec 2008 13:09:00 -0000 From: Joel Brobecker To: Jan Kratochvil Cc: gdb-patches@sourceware.org, Ulrich Weigand , Jim Blandy , Tobias Burnus Subject: Re: [patch] (for VLA) Prepare for 3-fields TYPE_CODE_RANGE (TYPE_HIGH_BOUND) Message-ID: <20081228130836.GD4216@adacore.com> References: <20081226224219.GA3513@host0.dyn.jankratochvil.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20081226224219.GA3513@host0.dyn.jankratochvil.net> User-Agent: Mutt/1.4.2.2i 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/msg00420.txt.bz2 > Questionable is whether ada_array_bound_from_type() can get something besides > TYPE_CODE_RANGE or TYPE_CODE_ENUM which gets internal_error()ed now. I did > not find such case but the TYPE_CODE_ENUM case could be changed to `default:' > if it can happen. Initially, I was thinking that maybe we could get a range type that's a TYPE_CODE_INT. But that's not possible either with stabs nor DWARF. But I think the code is fine as it is. > 2008-12-26 Jan Kratochvil > > Fix TYPE_HIGH_BOUND for TYPE_CODE_RANGE using arbitrary TYPE_NFIELDS. Perhaps you could mention that this is in preparation for supporting DW_AT_byte_stride. > * ada-lang.c (packed_array_type, ada_index_type): Use TYPE_INDEX_TYPE. > (ada_array_bound_from_type): Move `index_type' declaration to the > function start. Return the bounds for TYPE_CODE_RANGE using > TYPE_LOW_BOUND and TYPE_HIGH_BOUND. Abort on invalid index type codes. > * ada-typeprint.c (print_range): Set `upper_bound' for TYPE_CODE_RANGE > now using TYPE_HIGH_BOUND. > * ada-valprint.c (val_print_packed_array_elements): Use `index_type'. > * eval.c (evaluate_subexp_standard): Use TYPE_INDEX_TYPE. > * gdbtypes.c (create_range_type): Use TYPE_LOW_BOUND, TYPE_HIGH_BOUND, > refer to the number of fields only through TYPE_NFIELDS. > (create_array_type): Use TYPE_INDEX_TYPE. > (check_typedef): Use TYPE_INDEX_TYPE, TYPE_LOW_BOUND, TYPE_HIGH_BOUND. > * gdbtypes.h (TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED) > (TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED): Use TYPE_INDEX_TYPE. > (TYPE_ARRAY_UPPER_BOUND_VALUE, TYPE_ARRAY_LOWER_BOUND_VALUE): Use > TYPE_INDEX_TYPE, TYPE_LOW_BOUND, TYPE_HIGH_BOUND, > * hppa-tdep.c (hppa_alignof ): Use TYPE_INDEX_TYPE. > * mdebugread.c (parse_type): Use TYPE_LOW_BOUND, TYPE_HIGH_BOUND, > * valarith.c (value_bit_index): Use TYPE_INDEX_TYPE. OK. Please just make a tiny change before checking in. (in ada_array_bound_from_type): > + if (typep != NULL) > + *typep = index_type; > > - return > - (LONGEST) (which == 0 > - ? TYPE_LOW_BOUND (index_type) > - : TYPE_HIGH_BOUND (index_type)); > + switch (TYPE_CODE (index_type)) > + { > + case TYPE_CODE_RANGE: > + return which == 0 ? TYPE_LOW_BOUND (index_type) > + : TYPE_HIGH_BOUND (index_type); > + case TYPE_CODE_ENUM: > + return which == 0 ? TYPE_FIELD_BITPOS (index_type, 0) > + : TYPE_FIELD_BITPOS (index_type, > + TYPE_NFIELDS (index_type) - 1); > + default: > + internal_error (__FILE__, __LINE__, _("invalid type code of index type")); > } If we raise the internal_error, I'd rather we do no assign *typep. Can you instead compute the bound value first, and then, if we haven't detected the internal error, assign *typep before returning the bound? Thanks, -- Joel