int global_seen;
};
-/* Initialize the index symtab iterator ITER. */
+/* Initialize the index symtab iterator ITER, common part. */
static void
-dw2_symtab_iter_init (struct dw2_symtab_iterator *iter,
- dwarf2_per_objfile *per_objfile,
- gdb::optional<block_enum> block_index,
- domain_enum domain,
- const char *name)
+dw2_symtab_iter_init_common (struct dw2_symtab_iterator *iter,
+ dwarf2_per_objfile *per_objfile,
+ gdb::optional<block_enum> block_index,
+ domain_enum domain)
{
iter->per_objfile = per_objfile;
iter->block_index = block_index;
iter->domain = domain;
iter->next = 0;
iter->global_seen = 0;
+ iter->vec = NULL;
+ iter->length = 0;
+}
- mapped_index *index = per_objfile->per_bfd->index_table.get ();
+/* Initialize the index symtab iterator ITER, const char *NAME variant. */
+
+static void
+dw2_symtab_iter_init (struct dw2_symtab_iterator *iter,
+ dwarf2_per_objfile *per_objfile,
+ gdb::optional<block_enum> block_index,
+ domain_enum domain,
+ const char *name)
+{
+ dw2_symtab_iter_init_common (iter, per_objfile, block_index, domain);
+ mapped_index *index = per_objfile->per_bfd->index_table.get ();
/* index is NULL if OBJF_READNOW. */
- if (index != NULL && find_slot_in_mapped_hash (index, name, &iter->vec))
+ if (index == NULL)
+ return;
+
+ if (find_slot_in_mapped_hash (index, name, &iter->vec))
iter->length = MAYBE_SWAP (*iter->vec);
- else
- {
- iter->vec = NULL;
- iter->length = 0;
- }
+}
+
+/* Initialize the index symtab iterator ITER, offset_type NAMEI variant. */
+
+static void
+dw2_symtab_iter_init (struct dw2_symtab_iterator *iter,
+ dwarf2_per_objfile *per_objfile,
+ gdb::optional<block_enum> block_index,
+ domain_enum domain, offset_type namei)
+{
+ dw2_symtab_iter_init_common (iter, per_objfile, block_index, domain);
+
+ mapped_index *index = per_objfile->per_bfd->index_table.get ();
+ /* index is NULL if OBJF_READNOW. */
+ if (index == NULL)
+ return;
+
+ gdb_assert (!index->symbol_name_slot_invalid (namei));
+ const auto &bucket = index->symbol_table[namei];
+
+ iter->vec = (offset_type *) (index->constant_pool
+ + MAYBE_SWAP (bucket.vec));
+ iter->length = MAYBE_SWAP (*iter->vec);
}
/* Return the next matching CU or NULL if there are no more. */
if (per_objfile->per_bfd->index_table != nullptr)
{
- /* Ada currently doesn't support .gdb_index (see PR24713). We can get
- here though if the current language is Ada for a non-Ada objfile
- using GNU index. */
mapped_index &index = *per_objfile->per_bfd->index_table;
const char *match_name = name.ada ().lookup_name ().c_str ();
struct dwarf2_per_cu_data *per_cu;
dw2_symtab_iter_init (&iter, per_objfile, block_kind, domain,
- match_name);
+ namei);
while ((per_cu = dw2_symtab_iter_next (&iter)) != NULL)
dw2_expand_symtabs_matching_one (per_cu, per_objfile, nullptr,
nullptr);
const language_defn *lang = language_def (lang_e);
symbol_name_matcher_ftype *name_matcher
- = get_symbol_name_matcher (lang, lookup_name_without_params);
+ = lang->get_symbol_name_matcher (lookup_name_without_params);
name_and_matcher key {
name_matcher,
return true;
}
+ /* There might already be partial symtabs built for this BFD. This happens
+ when loading the same binary twice with the index-cache enabled. If so,
+ don't try to read an index. The objfile / per_objfile initialization will
+ be completed in dwarf2_build_psymtabs, in the standard partial symtabs
+ code path. */
+ if (per_bfd->partial_symtabs != nullptr)
+ return false;
+
if (dwarf2_read_debug_names (per_objfile))
{
*index_kind = dw_index_kind::DEBUG_NAMES;
variant_part *part = new (obstack) variant_part;
part->discriminant_index = discriminant_index;
- part->is_unsigned = TYPE_UNSIGNED (TYPE_FIELD_TYPE (type,
- discriminant_index));
+ part->is_unsigned = TYPE_UNSIGNED (type->field (discriminant_index).type ());
part->variants = gdb::array_view<variant> (variants, n_variants);
void *storage = obstack_alloc (obstack, sizeof (gdb::array_view<variant_part>));
/* Decode the field name to find the offset of the
discriminant. */
ULONGEST bit_offset = 0;
- struct type *field_type = TYPE_FIELD_TYPE (type, 0);
+ struct type *field_type = type->field (0).type ();
while (name[0] >= '0' && name[0] <= '9')
{
char *tail;
++name;
bit_offset += TYPE_FIELD_BITPOS (field_type, index);
- field_type = TYPE_FIELD_TYPE (field_type, index);
+ field_type = field_type->field (index).type ();
}
/* Smash this type to be a structure type. We have to do this
field at index 1 and the data-less field at index 2. */
type->field (1) = saved_field;
TYPE_FIELD_NAME (type, 1)
- = rust_last_path_segment (TYPE_FIELD_TYPE (type, 1)->name ());
- TYPE_FIELD_TYPE (type, 1)->set_name
+ = rust_last_path_segment (type->field (1).type ()->name ());
+ type->field (1).type ()->set_name
(rust_fully_qualify (&objfile->objfile_obstack, type->name (),
TYPE_FIELD_NAME (type, 1)));
because the type has already been recorded. */
type->set_code (TYPE_CODE_STRUCT);
- struct type *field_type = TYPE_FIELD_TYPE (type, 0);
+ struct type *field_type = type->field (0).type ();
const char *variant_name
= rust_last_path_segment (field_type->name ());
TYPE_FIELD_NAME (type, 0) = variant_name;
struct type *disr_type = nullptr;
for (int i = 0; i < type->num_fields (); ++i)
{
- disr_type = TYPE_FIELD_TYPE (type, i);
+ disr_type = type->field (i).type ();
if (disr_type->code () != TYPE_CODE_STRUCT)
{
That name can be used to look up the correct
discriminant. */
const char *variant_name
- = rust_last_path_segment (TYPE_FIELD_TYPE (type, i)->name ());
+ = rust_last_path_segment (type->field (i).type ()->name ());
auto iter = discriminant_map.find (variant_name);
if (iter != discriminant_map.end ())
}
/* Remove the discriminant field, if it exists. */
- struct type *sub_type = TYPE_FIELD_TYPE (type, i);
+ struct type *sub_type = type->field (i).type ();
if (sub_type->num_fields () > 0)
{
sub_type->set_num_fields (sub_type->num_fields () - 1);
the two cases. */
if (type->num_fields () > 0
&& TYPE_FIELD_ARTIFICIAL (type, 0)
- && TYPE_FIELD_TYPE (type, 0)->code () == TYPE_CODE_PTR
- && TYPE_CONST (TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type,
- 0))))
+ && type->field (0).type ()->code () == TYPE_CODE_PTR
+ && TYPE_CONST (TYPE_TARGET_TYPE (type->field (0).type ())))
buf.puts (" const");
}
}
else
{
fnp->fcontext
- = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (this_type, 0));
+ = TYPE_TARGET_TYPE (this_type->field (0).type ());
}
}
}
return;
/* Find the type of the method. */
- pfn_type = TYPE_FIELD_TYPE (type, 0);
+ pfn_type = type->field (0).type ();
if (pfn_type == NULL
|| pfn_type->code () != TYPE_CODE_PTR
|| TYPE_TARGET_TYPE (pfn_type)->code () != TYPE_CODE_FUNC)
/* Look for the "this" argument. */
pfn_type = TYPE_TARGET_TYPE (pfn_type);
if (pfn_type->num_fields () == 0
- /* || TYPE_FIELD_TYPE (pfn_type, 0) == NULL */
- || TYPE_FIELD_TYPE (pfn_type, 0)->code () != TYPE_CODE_PTR)
+ /* || pfn_type->field (0).type () == NULL */
+ || pfn_type->field (0).type ()->code () != TYPE_CODE_PTR)
return;
- self_type = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (pfn_type, 0));
+ self_type = TYPE_TARGET_TYPE (pfn_type->field (0).type ());
new_type = alloc_type (objfile);
smash_to_method_type (new_type, self_type, TYPE_TARGET_TYPE (pfn_type),
pfn_type->fields (), pfn_type->num_fields (),
&& child_pdi->linkage_name != NULL)
{
gdb::unique_xmalloc_ptr<char> actual_class_name
- (language_class_name_from_physname (cu->language_defn,
- child_pdi->linkage_name));
+ (cu->language_defn->class_name_from_physname
+ (child_pdi->linkage_name));
if (actual_class_name != NULL)
{
struct objfile *objfile = cu->per_objfile->objfile;
if (linkage_name != NULL)
{
gdb::unique_xmalloc_ptr<char> actual_name
- (language_class_name_from_physname (cu->language_defn,
- linkage_name));
+ (cu->language_defn->class_name_from_physname (linkage_name));
const char *name = NULL;
if (actual_name != NULL)