From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rock.gnat.com (rock.gnat.com [205.232.38.15]) by sourceware.org (Postfix) with ESMTP id 10726386F41D for ; Wed, 20 May 2020 13:20:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 10726386F41D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey@adacore.com Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id D4EB856194; Wed, 20 May 2020 09:20:44 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at gnat.com 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 cNNM6lJnVp-k; Wed, 20 May 2020 09:20:44 -0400 (EDT) Received: from murgatroyd.Home (174-16-104-48.hlrn.qwest.net [174.16.104.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id DDBCC5619F; Wed, 20 May 2020 09:20:37 -0400 (EDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [pushed] Remove bound_name static from ada-lang.c Date: Wed, 20 May 2020 07:20:36 -0600 Message-Id: <20200520132036.19793-1-tromey@adacore.com> X-Mailer: git-send-email 2.21.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-16.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_BARRACUDACENTRAL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 May 2020 13:20:46 -0000 ada-lang.c has a "bound_name" static that is used when finding fields in a structure in some cases. This patch removes it in favor of computing the desired field name at runtime; this avoids an artificial limit. I'm checking this in. Tested on x86-64 Fedora 30, and also on the internal AdaCore test suite. gdb/ChangeLog 2020-05-20 Tom Tromey * ada-lang.c (bound_name, MAX_ADA_DIMENS): Remove. (desc_one_bound, desc_index_type): Compute field name. --- gdb/ChangeLog | 5 +++++ gdb/ada-lang.c | 23 +++++++++-------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 825549d86e9..9f6485e04ab 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -1486,18 +1486,6 @@ ada_fixup_array_indexes_type (struct type *index_desc_type) } } -/* Names of MAX_ADA_DIMENS bounds in P_BOUNDS fields of array descriptors. */ - -static const char *bound_name[] = { - "LB0", "UB0", "LB1", "UB1", "LB2", "UB2", "LB3", "UB3", - "LB4", "UB4", "LB5", "UB5", "LB6", "UB6", "LB7", "UB7" -}; - -/* Maximum number of array dimensions we are prepared to handle. */ - -#define MAX_ADA_DIMENS (sizeof(bound_name) / (2*sizeof(char *))) - - /* The desc_* routines return primitive portions of array descriptors (fat pointers). */ @@ -1760,7 +1748,10 @@ fat_pntr_data_bitsize (struct type *type) static struct value * desc_one_bound (struct value *bounds, int i, int which) { - return value_struct_elt (&bounds, NULL, bound_name[2 * i + which - 2], NULL, + char bound_name[20]; + xsnprintf (bound_name, sizeof (bound_name), "%cB%d", + which ? 'U' : 'L', i - 1); + return value_struct_elt (&bounds, NULL, bound_name, NULL, _("Bad GNAT array descriptor bounds")); } @@ -1798,7 +1789,11 @@ desc_index_type (struct type *type, int i) type = desc_base_type (type); if (type->code () == TYPE_CODE_STRUCT) - return lookup_struct_elt_type (type, bound_name[2 * i - 2], 1); + { + char bound_name[20]; + xsnprintf (bound_name, sizeof (bound_name), "LB%d", i - 1); + return lookup_struct_elt_type (type, bound_name, 1); + } else return NULL; } -- 2.21.3