From: Tom Tromey Date: Tue, 5 May 2020 12:57:04 +0000 (-0600) Subject: Remove bound_name static from ada-lang.c X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=250106a76acffac0067c6618dd784f2260b56ade;p=deliverable%2Fbinutils-gdb.git Remove bound_name static from ada-lang.c 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. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6a7cbf38c0..bef88d0df6 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2020-05-20 Tom Tromey + + * ada-lang.c (bound_name, MAX_ADA_DIMENS): Remove. + (desc_one_bound, desc_index_type): Compute field name. + 2020-05-20 Tom de Vries PR symtab/25833 diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 825549d86e..9f6485e04a 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; }