aboutsummaryrefslogtreecommitdiff
path: root/gdb/ada-lang.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/ada-lang.c')
-rw-r--r--gdb/ada-lang.c630
1 files changed, 359 insertions, 271 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 329d114..0dfcc10 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -18,7 +18,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#include <ctype.h>
#include "event-top.h"
#include "exceptions.h"
#include "extract-store-integer.h"
@@ -183,7 +182,7 @@ static struct value *ada_search_struct_field (const char *, struct value *, int,
struct type *);
static int find_struct_field (const char *, struct type *, int,
- struct type **, int *, int *, int *, int *);
+ struct type **, int *, int *, int *, LONGEST *);
static int ada_resolve_function (std::vector<struct block_symbol> &,
struct value **, int, const char *,
@@ -875,7 +874,7 @@ is_compiler_suffix (const char *str)
{
gdb_assert (*str == '[');
++str;
- while (*str != '\0' && isalpha (*str))
+ while (*str != '\0' && c_isalpha (*str))
++str;
/* We accept a missing "]" in order to support completion. */
return *str == '\0' || (str[0] == ']' && str[1] == '\0');
@@ -1167,7 +1166,7 @@ ada_encode (const char *decoded, bool fold)
static int
is_lower_alphanum (const char c)
{
- return (isdigit (c) || (isalpha (c) && islower (c)));
+ return (c_isdigit (c) || (c_isalpha (c) && c_islower (c)));
}
/* ENCODED is the linkage name of a symbol and LEN contains its length.
@@ -1185,11 +1184,11 @@ is_lower_alphanum (const char c)
static void
ada_remove_trailing_digits (const char *encoded, int *len)
{
- if (*len > 1 && isdigit (encoded[*len - 1]))
+ if (*len > 1 && c_isdigit (encoded[*len - 1]))
{
int i = *len - 2;
- while (i > 0 && isdigit (encoded[i]))
+ while (i > 0 && c_isdigit (encoded[i]))
i--;
if (i >= 0 && encoded[i] == '.')
*len = i;
@@ -1220,7 +1219,7 @@ ada_remove_po_subprogram_suffix (const char *encoded, int *len)
if (*len > 1
&& encoded[*len - 1] == 'N'
- && (isdigit (encoded[*len - 2]) || islower (encoded[*len - 2])))
+ && (c_isdigit (encoded[*len - 2]) || c_islower (encoded[*len - 2])))
*len = *len - 1;
}
@@ -1232,7 +1231,7 @@ static int
remove_compiler_suffix (const char *encoded, int *len)
{
int offset = *len - 1;
- while (offset > 0 && isalpha (encoded[offset]))
+ while (offset > 0 && c_isalpha (encoded[offset]))
--offset;
if (offset > 0 && encoded[offset] == '.')
{
@@ -1252,7 +1251,7 @@ convert_hex (const char *str, int n, uint32_t *out)
for (int i = 0; i < n; ++i)
{
- if (!isxdigit (str[i]))
+ if (!c_isxdigit (str[i]))
return false;
result <<= 4;
result |= fromhex (str[i]);
@@ -1311,7 +1310,7 @@ convert_from_hex_encoded (std::string &out, const char *str, int n)
/* See ada-lang.h. */
std::string
-ada_decode (const char *encoded, bool wrap, bool operators, bool wide)
+ada_decode (const char *encoded, bool wrap, bool translate)
{
int i;
int len0;
@@ -1384,11 +1383,11 @@ ada_decode (const char *encoded, bool wrap, bool operators, bool wide)
/* Remove trailing __{digit}+ or trailing ${digit}+. */
- if (len0 > 1 && isdigit (encoded[len0 - 1]))
+ if (len0 > 1 && c_isdigit (encoded[len0 - 1]))
{
i = len0 - 2;
- while ((i >= 0 && isdigit (encoded[i]))
- || (i >= 1 && encoded[i] == '_' && isdigit (encoded[i - 1])))
+ while ((i >= 0 && c_isdigit (encoded[i]))
+ || (i >= 1 && encoded[i] == '_' && c_isdigit (encoded[i - 1])))
i -= 1;
if (i > 1 && encoded[i] == '_' && encoded[i - 1] == '_')
len0 = i - 1;
@@ -1399,14 +1398,14 @@ ada_decode (const char *encoded, bool wrap, bool operators, bool wide)
/* The first few characters that are not alphabetic are not part
of any encoding we use, so we can copy them over verbatim. */
- for (i = 0; i < len0 && !isalpha (encoded[i]); i += 1)
+ for (i = 0; i < len0 && !c_isalpha (encoded[i]); i += 1)
decoded.push_back (encoded[i]);
at_start_name = 1;
while (i < len0)
{
/* Is this a symbol function? */
- if (operators && at_start_name && encoded[i] == 'O')
+ if (at_start_name && encoded[i] == 'O')
{
int k;
@@ -1415,9 +1414,12 @@ ada_decode (const char *encoded, bool wrap, bool operators, bool wide)
int op_len = strlen (ada_opname_table[k].encoded);
if ((strncmp (ada_opname_table[k].encoded + 1, encoded + i + 1,
op_len - 1) == 0)
- && !isalnum (encoded[i + op_len]))
+ && !c_isalnum (encoded[i + op_len]))
{
- decoded.append (ada_opname_table[k].decoded);
+ if (translate)
+ decoded.append (ada_opname_table[k].decoded);
+ else
+ decoded.append (ada_opname_table[k].encoded);
at_start_name = 0;
i += op_len;
break;
@@ -1440,11 +1442,11 @@ ada_decode (const char *encoded, bool wrap, bool operators, bool wide)
if (len0 - i > 5 && encoded [i] == '_' && encoded [i+1] == '_'
&& encoded [i+2] == 'B' && encoded [i+3] == '_'
- && isdigit (encoded [i+4]))
+ && c_isdigit (encoded [i+4]))
{
int k = i + 5;
- while (k < len0 && isdigit (encoded[k]))
+ while (k < len0 && c_isdigit (encoded[k]))
k++; /* Skip any extra digit. */
/* Double-check that the "__B_{DIGITS}+" sequence we found
@@ -1467,11 +1469,11 @@ ada_decode (const char *encoded, bool wrap, bool operators, bool wide)
internally generated. */
if (len0 - i > 3 && encoded [i] == '_' && encoded[i+1] == 'E'
- && isdigit (encoded[i+2]))
+ && c_isdigit (encoded[i+2]))
{
int k = i + 3;
- while (k < len0 && isdigit (encoded[k]))
+ while (k < len0 && c_isdigit (encoded[k]))
k++;
if (k < len0
@@ -1505,33 +1507,65 @@ ada_decode (const char *encoded, bool wrap, bool operators, bool wide)
i++;
}
- if (wide && i < len0 + 3 && encoded[i] == 'U' && isxdigit (encoded[i + 1]))
+ /* Handle wide characters while respecting the arguments to the
+ function: we may want to copy them verbatim, but in this case
+ we do not want to register that we've copied an upper-case
+ character. */
+ if (i < len0 + 3 && encoded[i] == 'U' && c_isxdigit (encoded[i + 1]))
{
- if (convert_from_hex_encoded (decoded, &encoded[i + 1], 2))
+ if (translate)
{
- i += 3;
+ if (convert_from_hex_encoded (decoded, &encoded[i + 1], 2))
+ {
+ i += 3;
+ continue;
+ }
+ }
+ else
+ {
+ decoded.push_back (encoded[i]);
+ ++i;
continue;
}
}
- else if (wide && i < len0 + 5 && encoded[i] == 'W' && isxdigit (encoded[i + 1]))
+ else if (i < len0 + 5 && encoded[i] == 'W'
+ && c_isxdigit (encoded[i + 1]))
{
- if (convert_from_hex_encoded (decoded, &encoded[i + 1], 4))
+ if (translate)
{
- i += 5;
+ if (convert_from_hex_encoded (decoded, &encoded[i + 1], 4))
+ {
+ i += 5;
+ continue;
+ }
+ }
+ else
+ {
+ decoded.push_back (encoded[i]);
+ ++i;
continue;
}
}
- else if (wide && i < len0 + 10 && encoded[i] == 'W' && encoded[i + 1] == 'W'
- && isxdigit (encoded[i + 2]))
+ else if (i < len0 + 10 && encoded[i] == 'W' && encoded[i + 1] == 'W'
+ && c_isxdigit (encoded[i + 2]))
{
- if (convert_from_hex_encoded (decoded, &encoded[i + 2], 8))
+ if (translate)
{
- i += 10;
+ if (convert_from_hex_encoded (decoded, &encoded[i + 2], 8))
+ {
+ i += 10;
+ continue;
+ }
+ }
+ else
+ {
+ decoded.push_back (encoded[i]);
+ ++i;
continue;
}
}
- if (encoded[i] == 'X' && i != 0 && isalnum (encoded[i - 1]))
+ if (encoded[i] == 'X' && i != 0 && c_isalnum (encoded[i - 1]))
{
/* This is a X[bn]* sequence not separated from the previous
part of the name with a non-alpha-numeric character (in other
@@ -1553,6 +1587,12 @@ ada_decode (const char *encoded, bool wrap, bool operators, bool wide)
at_start_name = 1;
i += 2;
}
+ else if (isupper (encoded[i]) || encoded[i] == ' ')
+ {
+ /* Decoded names should never contain any uppercase
+ character. */
+ goto Suppress;
+ }
else
{
/* It's a character part of the decoded name, so just copy it
@@ -1562,16 +1602,6 @@ ada_decode (const char *encoded, bool wrap, bool operators, bool wide)
}
}
- /* Decoded names should never contain any uppercase character.
- Double-check this, and abort the decoding if we find one. */
-
- if (operators)
- {
- for (i = 0; i < decoded.length(); ++i)
- if (isupper (decoded[i]) || decoded[i] == ' ')
- goto Suppress;
- }
-
/* If the compiler added a suffix, append it now. */
if (suffix >= 0)
decoded = decoded + "[" + &encoded[suffix] + "]";
@@ -1597,6 +1627,13 @@ ada_decode_tests ()
/* This isn't valid, but used to cause a crash. PR gdb/30639. The
result does not really matter very much. */
SELF_CHECK (ada_decode ("44") == "44");
+
+ /* Check that the settings used by the DWARF reader have the desired
+ effect. */
+ SELF_CHECK (ada_decode ("symada__cS", false, false) == "");
+ SELF_CHECK (ada_decode ("pkg__Oxor", false, false) == "pkg.Oxor");
+ SELF_CHECK (ada_decode ("pack__func_W017b", false, false)
+ == "pack.func_W017b");
}
#endif
@@ -1677,8 +1714,6 @@ ada_decode_symbol (const struct general_symbol_info *arg)
void
ada_fixup_array_indexes_type (struct type *index_desc_type)
{
- int i;
-
if (index_desc_type == NULL)
return;
gdb_assert (index_desc_type->num_fields () > 0);
@@ -1696,13 +1731,13 @@ ada_fixup_array_indexes_type (struct type *index_desc_type)
return;
/* Fixup each field of INDEX_DESC_TYPE. */
- for (i = 0; i < index_desc_type->num_fields (); i++)
+ for (auto &field : index_desc_type->fields ())
{
- const char *name = index_desc_type->field (i).name ();
+ const char *name = field.name ();
struct type *raw_type = ada_check_typedef (ada_find_any_type (name));
if (raw_type)
- index_desc_type->field (i).set_type (raw_type);
+ field.set_type (raw_type);
}
}
@@ -1729,16 +1764,6 @@ desc_base_type (struct type *type)
return type;
}
-/* True iff TYPE indicates a "thin" array pointer type. */
-
-static int
-is_thin_pntr (struct type *type)
-{
- return
- is_suffix (ada_type_name (desc_base_type (type)), "___XUT")
- || is_suffix (ada_type_name (desc_base_type (type)), "___XUT___XVE");
-}
-
/* The descriptor type for thin pointer type TYPE. */
static struct type *
@@ -1777,14 +1802,45 @@ thin_data_pntr (struct value *val)
return value_from_longest (data_type, val->address ());
}
-/* True iff TYPE indicates a "thick" array pointer type. */
+/* Different kinds of Ada-specific pointers. */
+enum class pointer_kind
+{
+ /* Not a thin or thick pointer. */
+ NOT_SPECIAL,
+ /* A thin pointer. */
+ THIN,
+ /* Thick pointer where the bounds are accessed via the P_BOUNDS
+ member, a pointer to the bounds. */
+ P_BOUNDS,
+ /* Thick pointer where the bounds are accessed via the BOUNDS
+ member, which directly holds the bounds. */
+ EXTENDED_ACCESS,
+};
+
+/* Return a pointer_kind indicating whether TYPE is a special category
+ of pointer. Note that TYPE may be NULL, in which case NOT_SPECIAL
+ is returned. */
-static int
-is_thick_pntr (struct type *type)
+static pointer_kind
+categorize_pointer (struct type *type)
{
type = desc_base_type (type);
- return (type != NULL && type->code () == TYPE_CODE_STRUCT
- && lookup_struct_elt_type (type, "P_BOUNDS", 1) != NULL);
+ if (type == nullptr)
+ return pointer_kind::NOT_SPECIAL;
+
+ if (is_suffix (ada_type_name (type), "___XUT")
+ || is_suffix (ada_type_name (type), "___XUT___XVE"))
+ return pointer_kind::THIN;
+
+ if (type->code () == TYPE_CODE_STRUCT)
+ {
+ if (lookup_struct_elt_type (type, "P_BOUNDS", 1) != nullptr)
+ return pointer_kind::P_BOUNDS;
+ if (lookup_struct_elt_type (type, "BOUNDS", 1) != nullptr)
+ return pointer_kind::EXTENDED_ACCESS;
+ }
+
+ return pointer_kind::NOT_SPECIAL;
}
/* If TYPE is the type of an array descriptor (fat or thin pointer) or a
@@ -1795,11 +1851,9 @@ desc_bounds_type (struct type *type)
{
struct type *r;
+ pointer_kind kind = categorize_pointer (type);
type = desc_base_type (type);
-
- if (type == NULL)
- return NULL;
- else if (is_thin_pntr (type))
+ if (kind == pointer_kind::THIN)
{
type = thin_descriptor_type (type);
if (type == NULL)
@@ -1808,25 +1862,36 @@ desc_bounds_type (struct type *type)
if (r != NULL)
return ada_check_typedef (r);
}
- else if (type->code () == TYPE_CODE_STRUCT)
+ else if (kind == pointer_kind::P_BOUNDS
+ || kind == pointer_kind::EXTENDED_ACCESS)
{
- r = lookup_struct_elt_type (type, "P_BOUNDS", 1);
+ const char *field_name = (kind == pointer_kind::EXTENDED_ACCESS
+ ? "BOUNDS"
+ : "P_BOUNDS");
+ r = lookup_struct_elt_type (type, field_name, 1);
if (r != NULL)
- return ada_check_typedef (ada_check_typedef (r)->target_type ());
+ {
+ struct type *bounds_type = ada_check_typedef (r);
+ if (bounds_type->code () == TYPE_CODE_PTR)
+ bounds_type = ada_check_typedef (bounds_type->target_type ());
+ return bounds_type;
+ }
}
return NULL;
}
/* If ARR is an array descriptor (fat or thin pointer), or pointer to
- one, a pointer to its bounds data. Otherwise, throw an
- exception. */
+ one, return a pointer to its bounds data. For a fat pointer, this
+ means the structure holding the bounds -- so for extended access
+ pointers in particular, it will just return the descriptor itself.
+ Otherwise, throw an exception. */
static struct value *
desc_bounds (struct value *arr)
{
struct type *type = ada_check_typedef (arr->type ());
-
- if (is_thin_pntr (type))
+ pointer_kind kind = categorize_pointer (type);
+ if (kind == pointer_kind::THIN)
{
struct type *bounds_type =
desc_bounds_type (thin_descriptor_type (type));
@@ -1847,14 +1912,18 @@ desc_bounds (struct value *arr)
value_from_longest (lookup_pointer_type (bounds_type),
addr - bounds_type->length ());
}
-
- else if (is_thick_pntr (type))
+ else if (kind == pointer_kind::P_BOUNDS
+ || kind == pointer_kind::EXTENDED_ACCESS)
{
- struct value *p_bounds = value_struct_elt (&arr, {}, "P_BOUNDS", NULL,
- _("Bad GNAT array descriptor"));
+ const char *field_name = (kind == pointer_kind::EXTENDED_ACCESS
+ ? "BOUNDS"
+ : "P_BOUNDS");
+ struct value *p_bounds
+ = value_struct_elt (&arr, {}, field_name, nullptr,
+ _("Bad GNAT array descriptor"));
struct type *p_bounds_type = p_bounds->type ();
- if (p_bounds_type
+ if (p_bounds_type != nullptr
&& p_bounds_type->code () == TYPE_CODE_PTR)
{
struct type *target_type = p_bounds_type->target_type ();
@@ -1864,7 +1933,8 @@ desc_bounds (struct value *arr)
(ada_check_typedef (target_type)),
p_bounds);
}
- else
+ else if (p_bounds_type == nullptr
+ || kind != pointer_kind::EXTENDED_ACCESS)
error (_("Bad GNAT array descriptor"));
return p_bounds;
@@ -1904,12 +1974,13 @@ fat_pntr_bounds_bitsize (struct type *type)
static struct type *
desc_data_target_type (struct type *type)
{
+ pointer_kind kind = categorize_pointer (type);
type = desc_base_type (type);
-
/* NOTE: The following is bogus; see comment in desc_bounds. */
- if (is_thin_pntr (type))
+ if (kind == pointer_kind::THIN)
return desc_base_type (thin_descriptor_type (type)->field (1).type ());
- else if (is_thick_pntr (type))
+ else if (kind == pointer_kind::P_BOUNDS
+ || kind == pointer_kind::EXTENDED_ACCESS)
{
struct type *data_type = lookup_struct_elt_type (type, "P_ARRAY", 1);
@@ -1928,10 +1999,11 @@ static struct value *
desc_data (struct value *arr)
{
struct type *type = arr->type ();
-
- if (is_thin_pntr (type))
+ pointer_kind kind = categorize_pointer (type);
+ if (kind == pointer_kind::THIN)
return thin_data_pntr (arr);
- else if (is_thick_pntr (type))
+ else if (kind == pointer_kind::P_BOUNDS
+ || kind == pointer_kind::EXTENDED_ACCESS)
return value_struct_elt (&arr, {}, "P_ARRAY", NULL,
_("Bad GNAT array descriptor"));
else
@@ -2129,7 +2201,10 @@ ada_type_of_array (struct value *arr, int bounds)
return ada_check_typedef (arr->type ());
descriptor = desc_bounds (arr);
- if (value_as_long (descriptor) == 0)
+ /* In the extended access case, the bounds struct is "inline" so
+ the pointer cannot be NULL. */
+ if (ada_check_typedef (descriptor->type ())->code () == TYPE_CODE_PTR
+ && value_as_long (descriptor) == 0)
return NULL;
while (arity > 0)
{
@@ -2140,8 +2215,8 @@ ada_type_of_array (struct value *arr, int bounds)
arity -= 1;
struct type *range_type
= create_static_range_type (alloc, low->type (),
- longest_to_int (value_as_long (low)),
- longest_to_int (value_as_long (high)));
+ value_as_long (low),
+ value_as_long (high));
elt_type = create_array_type (alloc, elt_type, range_type);
INIT_GNAT_SPECIFIC (elt_type);
@@ -2270,7 +2345,8 @@ ada_is_unconstrained_packed_array_type (struct type *type)
/* If we saw GNAT encodings, then the above code is sufficient.
However, with minimal encodings, we will just have a thick
pointer instead. */
- if (is_thick_pntr (type))
+ pointer_kind kind = categorize_pointer (type);
+ if (kind == pointer_kind::P_BOUNDS || kind == pointer_kind::EXTENDED_ACCESS)
{
type = desc_base_type (type);
/* The structure's first field is a pointer to an array, so this
@@ -2322,7 +2398,9 @@ decode_packed_array_bitsize (struct type *type)
tail = strstr (raw_name, "___XP");
if (tail == nullptr)
{
- gdb_assert (is_thick_pntr (type));
+ pointer_kind kind = categorize_pointer (type);
+ gdb_assert (kind == pointer_kind::P_BOUNDS
+ || kind == pointer_kind::EXTENDED_ACCESS);
/* The structure's first field is a pointer to an array, so this
fetches the array type. */
type = type->field (0).type ()->target_type ();
@@ -2983,8 +3061,11 @@ value_assign_to_component (struct value *container, struct value *component,
bool
ada_is_access_to_unconstrained_array (struct type *type)
{
- return (type->code () == TYPE_CODE_TYPEDEF
- && is_thick_pntr (ada_typedef_target_type (type)));
+ if (type->code () != TYPE_CODE_TYPEDEF)
+ return false;
+ pointer_kind kind = categorize_pointer (ada_typedef_target_type (type));
+ return (kind == pointer_kind::P_BOUNDS
+ || kind == pointer_kind::EXTENDED_ACCESS);
}
/* The value of the element of array ARR at the ARITY indices given in IND.
@@ -3084,7 +3165,7 @@ ada_value_ptr_subscript (struct value *arr, int arity, struct value **ind)
this array is LOW, as per Ada rules. */
static struct value *
ada_value_slice_from_ptr (struct value *array_ptr, struct type *type,
- int low, int high)
+ LONGEST low, LONGEST high)
{
struct type *type0 = ada_check_typedef (type);
struct type *base_index_type = type0->index_type ()->target_type ();
@@ -3095,7 +3176,7 @@ ada_value_slice_from_ptr (struct value *array_ptr, struct type *type,
(alloc, type0->target_type (), index_type,
type0->dyn_prop (DYN_PROP_BYTE_STRIDE),
type0->field (0).bitsize ());
- int base_low = ada_discrete_type_low_bound (type0->index_type ());
+ LONGEST base_low = ada_discrete_type_low_bound (type0->index_type ());
std::optional<LONGEST> base_low_pos, low_pos;
CORE_ADDR base;
@@ -3119,7 +3200,7 @@ ada_value_slice_from_ptr (struct value *array_ptr, struct type *type,
static struct value *
-ada_value_slice (struct value *array, int low, int high)
+ada_value_slice (struct value *array, LONGEST low, LONGEST high)
{
struct type *type = ada_check_typedef (array->type ());
struct type *base_index_type = type->index_type ()->target_type ();
@@ -3392,7 +3473,7 @@ ada_array_length (struct value *arr, int n)
less than LOW, then LOW-1 is used. */
static struct value *
-empty_array (struct type *arr_type, int low, int high)
+empty_array (struct type *arr_type, LONGEST low, LONGEST high)
{
struct type *arr_type0 = ada_check_typedef (arr_type);
type_allocator alloc (arr_type0->index_type ()->target_type ());
@@ -3639,7 +3720,7 @@ See set/show multiple-symbol."));
if (syms[i].symbol == NULL)
continue;
- if (syms[i].symbol->aclass () == LOC_BLOCK)
+ if (syms[i].symbol->loc_class () == LOC_BLOCK)
{
struct symtab_and_line sal =
find_function_start_sal (syms[i].symbol, 1);
@@ -3661,7 +3742,7 @@ See set/show multiple-symbol."));
else
{
int is_enumeral =
- (syms[i].symbol->aclass () == LOC_CONST
+ (syms[i].symbol->loc_class () == LOC_CONST
&& syms[i].symbol->type () != NULL
&& syms[i].symbol->type ()->code () == TYPE_CODE_ENUM);
struct symtab *symtab = NULL;
@@ -3824,7 +3905,7 @@ ada_resolve_variable (struct symbol *sym, const struct block *block,
candidates.end (),
[] (block_symbol &bsym)
{
- switch (bsym.symbol->aclass ())
+ switch (bsym.symbol->loc_class ())
{
case LOC_REGISTER:
case LOC_ARG:
@@ -3847,7 +3928,7 @@ ada_resolve_variable (struct symbol *sym, const struct block *block,
candidates.end (),
[] (block_symbol &bsym)
{
- return bsym.symbol->aclass () == LOC_TYPEDEF;
+ return bsym.symbol->loc_class () == LOC_TYPEDEF;
}),
candidates.end ());
}
@@ -4002,7 +4083,7 @@ ada_args_match (struct symbol *func, struct value **actuals, int n_actuals)
int i;
struct type *func_type = func->type ();
- if (func->aclass () == LOC_CONST
+ if (func->loc_class () == LOC_CONST
&& func_type->code () == TYPE_CODE_ENUM)
return (n_actuals == 0);
else if (func_type == NULL || func_type->code () != TYPE_CODE_FUNC)
@@ -4312,7 +4393,7 @@ ada_parse_renaming (struct symbol *sym,
if (sym == NULL)
return ADA_NOT_RENAMING;
- switch (sym->aclass ())
+ switch (sym->loc_class ())
{
default:
return ADA_NOT_RENAMING;
@@ -4778,7 +4859,7 @@ is_nonfunction (const std::vector<struct block_symbol> &syms)
for (const block_symbol &sym : syms)
if (sym.symbol->type ()->code () != TYPE_CODE_FUNC
&& (sym.symbol->type ()->code () != TYPE_CODE_ENUM
- || sym.symbol->aclass () != LOC_CONST))
+ || sym.symbol->loc_class () != LOC_CONST))
return 1;
return 0;
@@ -4813,10 +4894,10 @@ lesseq_defined_than (struct symbol *sym0, struct symbol *sym1)
if (sym0 == sym1)
return 1;
if (sym0->domain () != sym1->domain ()
- || sym0->aclass () != sym1->aclass ())
+ || sym0->loc_class () != sym1->loc_class ())
return 0;
- switch (sym0->aclass ())
+ switch (sym0->loc_class ())
{
case LOC_UNDEF:
return 1;
@@ -4903,9 +4984,8 @@ ada_lookup_simple_minsym (const char *name, struct objfile *objfile)
symbol_name_matcher_ftype *match_name
= ada_get_symbol_name_matcher (lookup_name);
- gdbarch_iterate_over_objfiles_in_search_order
- (objfile != NULL ? objfile->arch () : current_inferior ()->arch (),
- [&result, lookup_name, match_name] (struct objfile *obj)
+ current_program_space->iterate_over_objfiles_in_search_order
+ ([&result, lookup_name, match_name] (struct objfile *obj)
{
for (minimal_symbol *msymbol : obj->msymbols ())
{
@@ -5071,7 +5151,7 @@ remove_extra_symbols (std::vector<struct block_symbol> &syms)
should be identical. */
else if (syms[i].symbol->linkage_name () != NULL
- && syms[i].symbol->aclass () == LOC_STATIC
+ && syms[i].symbol->loc_class () == LOC_STATIC
&& is_nondebugging_type (syms[i].symbol->type ()))
{
for (j = 0; !remove_p && j < syms.size (); j += 1)
@@ -5080,8 +5160,8 @@ remove_extra_symbols (std::vector<struct block_symbol> &syms)
&& syms[j].symbol->linkage_name () != NULL
&& strcmp (syms[i].symbol->linkage_name (),
syms[j].symbol->linkage_name ()) == 0
- && (syms[i].symbol->aclass ()
- == syms[j].symbol->aclass ())
+ && (syms[i].symbol->loc_class ()
+ == syms[j].symbol->loc_class ())
&& syms[i].symbol->value_address ()
== syms[j].symbol->value_address ())
remove_p = true;
@@ -5090,12 +5170,12 @@ remove_extra_symbols (std::vector<struct block_symbol> &syms)
/* Two functions with the same block are identical. */
- else if (syms[i].symbol->aclass () == LOC_BLOCK)
+ else if (syms[i].symbol->loc_class () == LOC_BLOCK)
{
for (j = 0; !remove_p && j < syms.size (); j += 1)
{
if (i != j
- && syms[j].symbol->aclass () == LOC_BLOCK
+ && syms[j].symbol->loc_class () == LOC_BLOCK
&& (syms[i].symbol->value_block ()
== syms[j].symbol->value_block ()))
remove_p = true;
@@ -5172,7 +5252,7 @@ is_package_name (const char *name)
static int
old_renaming_is_invisible (const struct symbol *sym, const char *function_name)
{
- if (sym->aclass () != LOC_TYPEDEF)
+ if (sym->loc_class () != LOC_TYPEDEF)
return 0;
std::string scope = xget_renaming_scope (sym->type ());
@@ -5251,7 +5331,7 @@ remove_irrelevant_renamings (std::vector<struct block_symbol> *syms,
const char *name;
const char *suffix;
- if (sym == NULL || sym->aclass () == LOC_TYPEDEF)
+ if (sym == NULL || sym->loc_class () == LOC_TYPEDEF)
continue;
name = sym->linkage_name ();
suffix = strstr (name, "___XR");
@@ -5376,7 +5456,7 @@ match_data::operator() (struct block_symbol *bsym)
}
else
{
- if (sym->aclass () == LOC_UNRESOLVED)
+ if (sym->loc_class () == LOC_UNRESOLVED)
return true;
else if (sym->is_argument ())
arg_sym = sym;
@@ -5475,22 +5555,19 @@ map_matching_symbols (struct objfile *objfile,
match_data &data)
{
data.objfile = objfile;
- objfile->expand_symtabs_matching (nullptr, &lookup_name,
- nullptr, nullptr,
- global
- ? SEARCH_GLOBAL_BLOCK
- : SEARCH_STATIC_BLOCK,
- domain);
const int block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK;
- for (compunit_symtab *symtab : objfile->compunits ())
+ auto callback = [&] (compunit_symtab *symtab)
{
const struct block *block
= symtab->blockvector ()->block (block_kind);
- if (!iterate_over_symbols_terminated (block, lookup_name,
- domain, data))
- break;
- }
+ return iterate_over_symbols_terminated (block, lookup_name,
+ domain, data);
+ };
+
+ objfile->search (nullptr, &lookup_name, nullptr, callback,
+ global ? SEARCH_GLOBAL_BLOCK : SEARCH_STATIC_BLOCK,
+ domain);
}
/* Add to RESULT all non-local symbols whose name and domain match
@@ -5732,10 +5809,10 @@ is_name_suffix (const char *str)
/* Skip optional leading __[0-9]+. */
- if (len > 3 && str[0] == '_' && str[1] == '_' && isdigit (str[2]))
+ if (len > 3 && str[0] == '_' && str[1] == '_' && c_isdigit (str[2]))
{
str += 3;
- while (isdigit (str[0]))
+ while (c_isdigit (str[0]))
str += 1;
}
@@ -5744,7 +5821,7 @@ is_name_suffix (const char *str)
if (str[0] == '.' || str[0] == '$')
{
matching = str + 1;
- while (isdigit (matching[0]))
+ while (c_isdigit (matching[0]))
matching += 1;
if (matching[0] == '\0')
return 1;
@@ -5755,7 +5832,7 @@ is_name_suffix (const char *str)
if (len > 3 && str[0] == '_' && str[1] == '_' && str[2] == '_')
{
matching = str + 3;
- while (isdigit (matching[0]))
+ while (c_isdigit (matching[0]))
matching += 1;
if (matching[0] == '\0')
return 1;
@@ -5784,10 +5861,10 @@ is_name_suffix (const char *str)
#endif
/* _E[0-9]+[bs]$ */
- if (len > 3 && str[0] == '_' && str [1] == 'E' && isdigit (str[2]))
+ if (len > 3 && str[0] == '_' && str [1] == 'E' && c_isdigit (str[2]))
{
matching = str + 3;
- while (isdigit (matching[0]))
+ while (c_isdigit (matching[0]))
matching += 1;
if ((matching[0] == 'b' || matching[0] == 's')
&& matching [1] == '\0')
@@ -5837,17 +5914,17 @@ is_name_suffix (const char *str)
return 1;
return 0;
}
- if (!isdigit (str[2]))
+ if (!c_isdigit (str[2]))
return 0;
for (k = 3; str[k] != '\0'; k += 1)
- if (!isdigit (str[k]) && str[k] != '_')
+ if (!c_isdigit (str[k]) && str[k] != '_')
return 0;
return 1;
}
- if (str[0] == '$' && isdigit (str[1]))
+ if (str[0] == '$' && c_isdigit (str[1]))
{
for (k = 2; str[k] != '\0'; k += 1)
- if (!isdigit (str[k]) && str[k] != '_')
+ if (!c_isdigit (str[k]) && str[k] != '_')
return 0;
return 1;
}
@@ -5870,7 +5947,7 @@ is_valid_name_for_wild_match (const char *name0)
return 0;
for (i=0; decoded_name[i] != '\0'; i++)
- if (isalpha (decoded_name[i]) && !islower (decoded_name[i]))
+ if (c_isalpha (decoded_name[i]) && !c_islower (decoded_name[i]))
return 0;
return 1;
@@ -5981,7 +6058,7 @@ ada_add_block_symbols (std::vector<struct block_symbol> &result,
{
if (sym->matches (domain))
{
- if (sym->aclass () != LOC_UNRESOLVED)
+ if (sym->loc_class () != LOC_UNRESOLVED)
{
if (sym->is_argument ())
arg_sym = sym;
@@ -6030,7 +6107,7 @@ ada_add_block_symbols (std::vector<struct block_symbol> &result,
if (cmp == 0
&& is_name_suffix (sym->linkage_name () + name_len + 5))
{
- if (sym->aclass () != LOC_UNRESOLVED)
+ if (sym->loc_class () != LOC_UNRESOLVED)
{
if (sym->is_argument ())
arg_sym = sym;
@@ -6094,7 +6171,7 @@ ada_lookup_name_info::matches
angle bracket notation. */
const char *tmp;
- for (tmp = sym_name; *tmp != '\0' && !isupper (*tmp); tmp++);
+ for (tmp = sym_name; *tmp != '\0' && !c_isupper (*tmp); tmp++);
if (*tmp != '\0')
match = false;
}
@@ -6209,7 +6286,7 @@ ada_is_ignored_field (struct type *type, int field_num)
{
/* Wrapper field. */
}
- else if (isupper (name[0]))
+ else if (c_isupper (name[0]))
return 1;
}
@@ -6433,7 +6510,7 @@ ada_get_tsd_type (struct inferior *inf)
if (data->tsd_type == 0)
data->tsd_type
- = lookup_transparent_type ("<ada__tags__type_specific_data>",
+ = lookup_transparent_type ("ada.tags.type_specific_data",
SEARCH_TYPE_DOMAIN);
return data->tsd_type;
}
@@ -6720,14 +6797,14 @@ ada_scan_number (const char str[], int k, LONGEST * R, int *new_k)
{
ULONGEST RU;
- if (!isdigit (str[k]))
+ if (!c_isdigit (str[k]))
return 0;
/* Do it the hard way so as not to make any assumption about
the relationship of unsigned long (%lu scan format code) and
LONGEST. */
RU = 0;
- while (isdigit (str[k]))
+ while (c_isdigit (str[k]))
{
RU = RU * 10 + (str[k] - '0');
k += 1;
@@ -6901,7 +6978,7 @@ static int
find_struct_field (const char *name, struct type *type, int offset,
struct type **field_type_p,
int *byte_offset_p, int *bit_offset_p, int *bit_size_p,
- int *index_p)
+ LONGEST *index_p)
{
int i;
int parent_offset = -1;
@@ -7015,12 +7092,10 @@ find_struct_field (const char *name, struct type *type, int offset,
/* Number of user-visible fields in record type TYPE. */
-static int
+static LONGEST
num_visible_fields (struct type *type)
{
- int n;
-
- n = 0;
+ LONGEST n = 0;
find_struct_field (NULL, type, 0, NULL, NULL, NULL, NULL, &n);
return n;
}
@@ -7080,17 +7155,16 @@ ada_search_struct_field (const char *name, struct value *arg, int offset,
else if (ada_is_variant_part (type, i))
{
/* PNH: Do we ever get here? See find_struct_field. */
- int j;
struct type *field_type = ada_check_typedef (type->field (i).type ());
int var_offset = offset + type->field (i).loc_bitpos () / 8;
- for (j = 0; j < field_type->num_fields (); j += 1)
+ for (const auto &field : field_type->fields ())
{
- struct value *v = ada_search_struct_field /* Force line
- break. */
- (name, arg,
- var_offset + field_type->field (j).loc_bitpos () / 8,
- field_type->field (j).type ());
+ struct value *v
+ = (ada_search_struct_field
+ (name, arg,
+ var_offset + field.loc_bitpos () / 8,
+ field.type ()));
if (v != NULL)
return v;
@@ -7384,10 +7458,10 @@ field_alignment (struct type *type, int f)
len = strlen (name);
- if (!isdigit (name[len - 1]))
+ if (!c_isdigit (name[len - 1]))
return 1;
- if (isdigit (name[len - 2]))
+ if (c_isdigit (name[len - 2]))
align_offset = len - 2;
else
align_offset = len - 1;
@@ -8182,12 +8256,11 @@ ada_is_redundant_index_type_desc (struct type *array_type,
struct type *desc_type)
{
struct type *this_layer = check_typedef (array_type);
- int i;
- for (i = 0; i < desc_type->num_fields (); i++)
+ for (const auto &field : desc_type->fields ())
{
if (!ada_is_redundant_range_encoding (this_layer->index_type (),
- desc_type->field (i).type ()))
+ field.type ()))
return 0;
this_layer = check_typedef (this_layer->target_type ());
}
@@ -8784,9 +8857,9 @@ ada_atr_enum_val (struct expression *exp, enum noside noside, struct type *type,
error (_("'Enum_Val requires integral argument"));
LONGEST value = value_as_long (arg);
- for (int i = 0; i < type->num_fields (); ++i)
+ for (const auto &field : type->fields ())
{
- if (type->field (i).loc_enumval () == value)
+ if (field.loc_enumval () == value)
return value_from_longest (original_type, value);
}
@@ -8969,7 +9042,7 @@ ada_unqualify_enum_name (const char *name)
{
while ((tmp = strstr (name, "__")) != NULL)
{
- if (isdigit (tmp[2]))
+ if (c_isdigit (tmp[2]))
break;
else
name = tmp + 2;
@@ -9012,7 +9085,7 @@ ada_enum_name (const char *name)
else
return name;
- if (isascii (v) && isprint (v))
+ if (c_isascii (v) && c_isprint (v))
storage = string_printf ("'%c'", v);
else if (name[1] == 'U')
storage = string_printf ("'[\"%02x\"]'", v);
@@ -9540,12 +9613,12 @@ void
ada_name_association::assign (aggregate_assigner &assigner,
operation_up &op)
{
- int index;
+ LONGEST index;
if (ada_is_direct_array_type (assigner.lhs->type ()))
{
value *tem = m_val->evaluate (nullptr, assigner.exp, EVAL_NORMAL);
- index = longest_to_int (value_as_long (tem));
+ index = value_as_long (tem);
}
else
{
@@ -10046,14 +10119,19 @@ ada_unop_neg (struct type *expect_type,
return value_neg (arg1);
}
-/* A helper function for UNOP_IN_RANGE. */
+namespace expr
+{
+
+/* Implement UNOP_IN_RANGE. */
value *
-ada_unop_in_range (struct type *expect_type,
- struct expression *exp,
- enum noside noside, enum exp_opcode op,
- struct value *arg1, struct type *type)
+ada_unop_range_operation::evaluate (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside)
{
+ value *arg1 = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
+ struct type *type = std::get<1> (m_storage);
+
struct value *arg2, *arg3;
switch (type->code ())
{
@@ -10080,6 +10158,8 @@ ada_unop_in_range (struct type *expect_type,
}
}
+} /* namespace expr */
+
/* A helper function for OP_ATR_TAG. */
value *
@@ -10167,14 +10247,21 @@ ada_mult_binop (struct type *expect_type,
}
}
-/* A helper function for BINOP_EQUAL and BINOP_NOTEQUAL. */
+namespace expr
+{
+
+/* Implement BINOP_EQUAL and BINOP_NOTEQUAL. */
value *
-ada_equal_binop (struct type *expect_type,
- struct expression *exp,
- enum noside noside, enum exp_opcode op,
- struct value *arg1, struct value *arg2)
+ada_binop_equal_operation::evaluate (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside)
{
+ enum exp_opcode op = std::get<0> (m_storage);
+ value *arg1 = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
+ value *arg2 = std::get<2> (m_storage)->evaluate (arg1->type (),
+ exp, noside);
+
int tem;
if (noside == EVAL_AVOID_SIDE_EFFECTS)
tem = 0;
@@ -10189,14 +10276,19 @@ ada_equal_binop (struct type *expect_type,
return value_from_longest (type, tem);
}
-/* A helper function for TERNOP_SLICE. */
+/* Implement TERNOP_SLICE. */
value *
-ada_ternop_slice (struct expression *exp,
- enum noside noside,
- struct value *array, struct value *low_bound_val,
- struct value *high_bound_val)
+ada_ternop_slice_operation::evaluate (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside)
{
+ value *array = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
+ value *low_bound_val
+ = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
+ value *high_bound_val
+ = std::get<2> (m_storage)->evaluate (nullptr, exp, noside);
+
LONGEST low_bound;
LONGEST high_bound;
@@ -10257,8 +10349,7 @@ ada_ternop_slice (struct expression *exp,
to_fixed_array_type (type0->target_type (), NULL, 1);
return ada_value_slice_from_ptr (array, arr_type0,
- longest_to_int (low_bound),
- longest_to_int (high_bound));
+ low_bound, high_bound);
}
}
else if (noside == EVAL_AVOID_SIDE_EFFECTS)
@@ -10266,16 +10357,20 @@ ada_ternop_slice (struct expression *exp,
else if (high_bound < low_bound)
return empty_array (array->type (), low_bound, high_bound);
else
- return ada_value_slice (array, longest_to_int (low_bound),
- longest_to_int (high_bound));
+ return ada_value_slice (array, low_bound, high_bound);
}
-/* A helper function for BINOP_IN_BOUNDS. */
+/* Implement BINOP_IN_BOUNDS. */
value *
-ada_binop_in_bounds (struct expression *exp, enum noside noside,
- struct value *arg1, struct value *arg2, int n)
+ada_binop_in_bounds_operation::evaluate (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside)
{
+ value *arg1 = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
+ value *arg2 = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
+ int n = std::get<2> (m_storage);
+
if (noside == EVAL_AVOID_SIDE_EFFECTS)
{
struct type *type = language_bool_type (exp->language_defn,
@@ -10300,6 +10395,8 @@ ada_binop_in_bounds (struct expression *exp, enum noside noside,
|| value_equal (arg2, arg1)));
}
+} /* namespace expr */
+
/* A helper function for some attribute operations. */
static value *
@@ -10502,7 +10599,6 @@ static LONGEST
convert_char_literal (struct type *type, LONGEST val)
{
char name[12];
- int f;
if (type == NULL)
return val;
@@ -10519,17 +10615,17 @@ convert_char_literal (struct type *type, LONGEST val)
else
xsnprintf (name, sizeof (name), "QWW%08lx", (unsigned long) val);
size_t len = strlen (name);
- for (f = 0; f < type->num_fields (); f += 1)
+ for (const auto &field : type->fields ())
{
/* Check the suffix because an enum constant in a package will
have a name like "pkg__QUxx". This is safe enough because we
already have the correct type, and because mangling means
there can't be clashes. */
- const char *ename = type->field (f).name ();
+ const char *ename = field.name ();
size_t elen = strlen (ename);
if (elen >= len && strcmp (name, ename + elen - len) == 0)
- return type->field (f).loc_enumval ();
+ return field.loc_enumval ();
}
return val;
}
@@ -11004,7 +11100,9 @@ ada_unop_ind_operation::evaluate (struct type *expect_type,
if (arrType == NULL)
error (_("Attempt to dereference null array pointer."));
- if (is_thick_pntr (type))
+ pointer_kind kind = categorize_pointer (type);
+ if (kind == pointer_kind::P_BOUNDS
+ || kind == pointer_kind::EXTENDED_ACCESS)
return arg1;
return value_at_lazy (arrType, 0);
}
@@ -11712,9 +11810,9 @@ ada_has_this_exception_support (const struct exception_support_info *einfo)
/* Make sure that the symbol we found corresponds to a function. */
- if (sym->aclass () != LOC_BLOCK)
+ if (sym->loc_class () != LOC_BLOCK)
error (_("Symbol \"%s\" is not a function (class = %d)"),
- sym->linkage_name (), sym->aclass ());
+ sym->linkage_name (), sym->loc_class ());
sym = standard_lookup (einfo->catch_handlers_sym, NULL,
SEARCH_FUNCTION_DOMAIN);
@@ -11734,9 +11832,9 @@ ada_has_this_exception_support (const struct exception_support_info *einfo)
/* Make sure that the symbol we found corresponds to a function. */
- if (sym->aclass () != LOC_BLOCK)
+ if (sym->loc_class () != LOC_BLOCK)
error (_("Symbol \"%s\" is not a function (class = %d)"),
- sym->linkage_name (), sym->aclass ());
+ sym->linkage_name (), sym->loc_class ());
return 1;
}
@@ -12536,7 +12634,7 @@ catch_ada_exception_command_split (const char *args,
args = skip_spaces (args);
if (startswith (args, "if")
- && (isspace (args[2]) || args[2] == '\0'))
+ && (c_isspace (args[2]) || args[2] == '\0'))
{
args += 2;
args = skip_spaces (args);
@@ -12691,7 +12789,7 @@ ada_exception_sal (enum ada_exception_catchpoint_kind ex)
throw_error (NOT_FOUND_ERROR, _("Catchpoint symbol not found: %s"),
sym_name);
- if (sym->aclass () != LOC_BLOCK)
+ if (sym->loc_class () != LOC_BLOCK)
error (_("Unable to insert catchpoint. %s is not a function."), sym_name);
return find_function_start_sal (sym, 1);
@@ -12813,7 +12911,7 @@ catch_ada_assert_command_split (const char *args, std::string &cond_string)
/* Check whether a condition was provided. */
if (startswith (args, "if")
- && (isspace (args[2]) || args[2] == '\0'))
+ && (c_isspace (args[2]) || args[2] == '\0'))
{
args += 2;
args = skip_spaces (args);
@@ -12857,10 +12955,10 @@ ada_is_exception_sym (struct symbol *sym)
{
const char *type_name = sym->type ()->name ();
- return (sym->aclass () != LOC_TYPEDEF
- && sym->aclass () != LOC_BLOCK
- && sym->aclass () != LOC_CONST
- && sym->aclass () != LOC_UNRESOLVED
+ return (sym->loc_class () != LOC_TYPEDEF
+ && sym->loc_class () != LOC_BLOCK
+ && sym->loc_class () != LOC_CONST
+ && sym->loc_class () != LOC_UNRESOLVED
&& type_name != NULL && strcmp (type_name, "exception") == 0);
}
@@ -12993,7 +13091,7 @@ ada_add_exceptions_from_frame (compiled_regex *preg,
{
for (struct symbol *sym : block_iterator_range (block))
{
- switch (sym->aclass ())
+ switch (sym->loc_class ())
{
case LOC_TYPEDEF:
case LOC_BLOCK:
@@ -13044,31 +13142,11 @@ ada_add_global_exceptions (compiled_regex *preg,
return preg == nullptr || preg->exec (name, 0, NULL, 0) == 0;
};
-
- /* In Ada, the symbol "search name" is a linkage name, whereas the
- regular expression used to do the matching refers to the natural
- name. So match against the decoded name. */
- expand_symtabs_matching (NULL,
- lookup_name_info::match_any (),
- [&] (const char *search_name)
- {
- std::string decoded = ada_decode (search_name);
- return name_matches_regex (decoded.c_str ());
- },
- NULL,
- SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
- SEARCH_VAR_DOMAIN,
- [&] (enum language lang)
- {
- /* Try to skip non-Ada CUs. */
- return lang == language_ada;
- });
-
/* Iterate over all objfiles irrespective of scope or linker namespaces
so we get all exceptions anywhere in the progspace. */
for (objfile *objfile : current_program_space->objfiles ())
{
- for (compunit_symtab *s : objfile->compunits ())
+ auto callback = [&] (compunit_symtab *s)
{
const struct blockvector *bv = s->blockvector ();
int i;
@@ -13087,7 +13165,30 @@ ada_add_global_exceptions (compiled_regex *preg,
exceptions->push_back (info);
}
}
- }
+
+ return true;
+ };
+
+ /* In Ada, the symbol "search name" is a linkage name, whereas
+ the regular expression used to do the matching refers to the
+ natural name. So match against the decoded name. */
+ auto any = lookup_name_info::match_any ();
+ objfile->search
+ (nullptr,
+ &any,
+ [&] (const char *search_name)
+ {
+ std::string decoded = ada_decode (search_name);
+ return name_matches_regex (decoded.c_str ());
+ },
+ callback,
+ SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
+ SEARCH_VAR_DOMAIN,
+ [&] (enum language lang)
+ {
+ /* Try to skip non-Ada CUs. */
+ return lang == language_ada;
+ });
}
}
@@ -13217,7 +13318,7 @@ do_full_match (const char *symbol_search_name,
&& symbol_search_name[1] == '_')
{
symbol_search_name += 2;
- while (isdigit (*symbol_search_name))
+ while (c_isdigit (*symbol_search_name))
++symbol_search_name;
if (symbol_search_name[0] == '_'
&& symbol_search_name[1] == '_')
@@ -13294,7 +13395,7 @@ ada_lookup_name_info::ada_lookup_name_info (const lookup_name_info &lookup_name)
else
m_standard_p = false;
- m_decoded_name = ada_decode (m_encoded_name.c_str (), true, false, false);
+ m_decoded_name = ada_decode (m_encoded_name.c_str (), true, false);
/* If the name contains a ".", then the user is entering a fully
qualified entity name, and the match must not be done in wild
@@ -13595,20 +13696,12 @@ public:
const char *text, const char *word,
enum type_code code) const override
{
- const struct block *b, *surrounding_static_block = 0;
+ const struct block *surrounding_static_block = 0;
gdb_assert (code == TYPE_CODE_UNDEF);
lookup_name_info lookup_name (text, name_match_type, true);
- /* First, look at the partial symtab symbols. */
- expand_symtabs_matching (NULL,
- lookup_name,
- NULL,
- NULL,
- SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
- SEARCH_ALL_DOMAINS);
-
/* At this point scan through the misc symbol vectors and add each
symbol you find to the list. Eventually we want to ignore
anything that isn't a text symbol (everything else will be
@@ -13650,7 +13743,9 @@ public:
/* Search upwards from currently selected frame (so that we can
complete on local vars. */
- for (b = get_selected_block (0); b != NULL; b = b->superblock ())
+ for (const block *b = get_selected_block (0);
+ b != nullptr;
+ b = b->superblock ())
{
if (b->is_static_block ())
surrounding_static_block = b; /* For elmin of dups */
@@ -13672,43 +13767,36 @@ public:
for (objfile *objfile : current_program_space->objfiles ())
{
- for (compunit_symtab *s : objfile->compunits ())
+ auto callback = [&] (compunit_symtab *s)
{
QUIT;
- b = s->blockvector ()->global_block ();
- for (struct symbol *sym : block_iterator_range (b))
+ for (const block *b = s->blockvector ()->static_block ();
+ b != nullptr;
+ b = b->superblock ())
{
- if (completion_skip_symbol (mode, sym))
- continue;
+ /* Don't do this block twice. */
+ if (b == surrounding_static_block)
+ break;
- completion_list_add_name (tracker,
- sym->language (),
- sym->linkage_name (),
- lookup_name, text, word);
+ for (struct symbol *sym : block_iterator_range (b))
+ {
+ if (completion_skip_symbol (mode, sym))
+ continue;
+
+ completion_list_add_name (tracker,
+ sym->language (),
+ sym->linkage_name (),
+ lookup_name, text, word);
+ }
}
- }
- }
- for (objfile *objfile : current_program_space->objfiles ())
- {
- for (compunit_symtab *s : objfile->compunits ())
- {
- QUIT;
- b = s->blockvector ()->static_block ();
- /* Don't do this block twice. */
- if (b == surrounding_static_block)
- continue;
- for (struct symbol *sym : block_iterator_range (b))
- {
- if (completion_skip_symbol (mode, sym))
- continue;
+ return true;
+ };
- completion_list_add_name (tracker,
- sym->language (),
- sym->linkage_name (),
- lookup_name, text, word);
- }
- }
+ objfile->search
+ (nullptr, &lookup_name, nullptr, callback,
+ SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
+ SEARCH_ALL_DOMAINS);
}
}