offset_type cu_list_elements, types_list_elements, dwz_list_elements = 0;
struct dwz_file *dwz;
struct objfile *objfile = per_objfile->objfile;
+ dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;
gdb::array_view<const gdb_byte> main_index_contents
- = get_gdb_index_contents (objfile, per_objfile->per_bfd);
+ = get_gdb_index_contents (objfile, per_bfd);
if (main_index_contents.empty ())
return 0;
/* If there is a .dwz file, read it so we can get its CU list as
well. */
- dwz = dwarf2_get_dwz_file (per_objfile->per_bfd);
+ dwz = dwarf2_get_dwz_file (per_bfd);
if (dwz != NULL)
{
struct mapped_index dwz_map;
}
}
- create_cus_from_index (per_objfile->per_bfd, cu_list, cu_list_elements,
- dwz_list, dwz_list_elements);
+ create_cus_from_index (per_bfd, cu_list, cu_list_elements, dwz_list,
+ dwz_list_elements);
if (types_list_elements)
{
/* We can only handle a single .debug_types when we have an
index. */
- if (per_objfile->per_bfd->types.size () != 1)
+ if (per_bfd->types.size () != 1)
return 0;
- dwarf2_section_info *section = &per_objfile->per_bfd->types[0];
+ dwarf2_section_info *section = &per_bfd->types[0];
- create_signatured_type_table_from_index (per_objfile->per_bfd,
- section, types_list,
+ create_signatured_type_table_from_index (per_bfd, section, types_list,
types_list_elements);
}
create_addrmap_from_index (per_objfile, map.get ());
- per_objfile->per_bfd->index_table = std::move (map);
- per_objfile->per_bfd->using_index = 1;
- per_objfile->per_bfd->quick_file_names_table =
- create_quick_file_names_table (per_objfile->per_bfd->all_comp_units.size ());
+ per_bfd->index_table = std::move (map);
+ per_bfd->using_index = 1;
+ per_bfd->quick_file_names_table =
+ create_quick_file_names_table (per_bfd->all_comp_units.size ());
+
+ /* Save partial symtabs in the per_bfd object, for the benefit of subsequent
+ objfiles using the same BFD. */
+ gdb_assert (per_bfd->partial_symtabs == nullptr);
+ per_bfd->partial_symtabs = objfile->partial_symtabs;
return 1;
}
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,
std::unique_ptr<mapped_debug_names> map (new mapped_debug_names);
mapped_debug_names dwz_map;
struct objfile *objfile = per_objfile->objfile;
+ dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;
if (!read_debug_names_from_section (objfile, objfile_name (objfile),
&per_objfile->per_bfd->debug_names, *map))
/* If there is a .dwz file, read it so we can get its CU list as
well. */
- dwz_file *dwz = dwarf2_get_dwz_file (per_objfile->per_bfd);
+ dwz_file *dwz = dwarf2_get_dwz_file (per_bfd);
if (dwz != NULL)
{
if (!read_debug_names_from_section (objfile,
}
}
- create_cus_from_debug_names (per_objfile->per_bfd, *map, dwz_map);
+ create_cus_from_debug_names (per_bfd, *map, dwz_map);
if (map->tu_count != 0)
{
/* We can only handle a single .debug_types when we have an
index. */
- if (per_objfile->per_bfd->types.size () != 1)
+ if (per_bfd->types.size () != 1)
return false;
- dwarf2_section_info *section = &per_objfile->per_bfd->types[0];
+ dwarf2_section_info *section = &per_bfd->types[0];
create_signatured_type_table_from_debug_names
- (per_objfile, *map, section, &per_objfile->per_bfd->abbrev);
+ (per_objfile, *map, section, &per_bfd->abbrev);
}
- create_addrmap_from_aranges (per_objfile,
- &per_objfile->per_bfd->debug_aranges);
+ create_addrmap_from_aranges (per_objfile, &per_bfd->debug_aranges);
- per_objfile->per_bfd->debug_names_table = std::move (map);
- per_objfile->per_bfd->using_index = 1;
- per_objfile->per_bfd->quick_file_names_table =
+ per_bfd->debug_names_table = std::move (map);
+ per_bfd->using_index = 1;
+ per_bfd->quick_file_names_table =
create_quick_file_names_table (per_objfile->per_bfd->all_comp_units.size ());
+ /* Save partial symtabs in the per_bfd object, for the benefit of subsequent
+ objfiles using the same BFD. */
+ gdb_assert (per_bfd->partial_symtabs == nullptr);
+ per_bfd->partial_symtabs = objfile->partial_symtabs;
+
return true;
}
if (per_bfd->debug_names_table != nullptr)
{
*index_kind = dw_index_kind::DEBUG_NAMES;
+ per_objfile->objfile->partial_symtabs = per_bfd->partial_symtabs;
per_objfile->resize_symtabs ();
return true;
}
if (per_bfd->index_table != nullptr)
{
*index_kind = dw_index_kind::GDB_INDEX;
+ per_objfile->objfile->partial_symtabs = per_bfd->partial_symtabs;
per_objfile->resize_symtabs ();
return true;
}
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
((struct field *) TYPE_ZALLOC (type, 3 * sizeof (struct field)));
/* Put the discriminant at index 0. */
- TYPE_FIELD_TYPE (type, 0) = field_type;
+ type->field (0).set_type (field_type);
TYPE_FIELD_ARTIFICIAL (type, 0) = 1;
TYPE_FIELD_NAME (type, 0) = "<<discriminant>>";
SET_FIELD_BITPOS (type->field (0), bit_offset);
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)));
name);
struct type *dataless_type = init_type (objfile, TYPE_CODE_VOID, 0,
dataless_name);
- TYPE_FIELD_TYPE (type, 2) = dataless_type;
+ type->field (2).set_type (dataless_type);
/* NAME points into the original discriminant name, which
already has the correct lifetime. */
TYPE_FIELD_NAME (type, 2) = name;
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)
{
/* We need a way to find the correct discriminant given a
variant name. For convenience we build a map here. */
- struct type *enum_type = FIELD_TYPE (*disr_field);
+ struct type *enum_type = disr_field->type ();
std::unordered_map<std::string, ULONGEST> discriminant_map;
for (int i = 0; i < enum_type->num_fields (); ++i)
{
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");
}
}
/* Data member other than a C++ static data member. */
/* Get type of field. */
- fp->type = die_type (die, cu);
+ fp->set_type (die_type (die, cu));
SET_FIELD_BITPOS (*fp, 0);
the bit field must be inferred from the type
attribute of the data member containing the
bit field. */
- anonymous_size = TYPE_LENGTH (fp->type);
+ anonymous_size = TYPE_LENGTH (fp->type ());
}
SET_FIELD_BITPOS (*fp,
(FIELD_BITPOS (*fp)
/* The name is already allocated along with this objfile, so we don't
need to duplicate it for the type. */
SET_FIELD_PHYSNAME (*fp, physname ? physname : "");
- FIELD_TYPE (*fp) = die_type (die, cu);
+ fp->set_type (die_type (die, cu));
FIELD_NAME (*fp) = fieldname;
}
else if (die->tag == DW_TAG_inheritance)
/* C++ base class field. */
handle_data_member_location (die, cu, fp);
FIELD_BITSIZE (*fp) = 0;
- FIELD_TYPE (*fp) = die_type (die, cu);
- FIELD_NAME (*fp) = fp->type->name ();
+ fp->set_type (die_type (die, cu));
+ FIELD_NAME (*fp) = fp->type ()->name ();
}
else
gdb_assert_not_reached ("missing case in dwarf2_add_field");
{
result.discriminant_index = iter->second;
result.is_unsigned
- = TYPE_UNSIGNED (FIELD_TYPE
- (fi->fields[result.discriminant_index].field));
+ = TYPE_UNSIGNED (fi->fields[result.discriminant_index].field.type ());
}
size_t n = builder.variants.size ();
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 (),
/* TYPE_FIELD_TYPE must never be NULL. Pre-fill the array to ensure it
even if we error out during the parameters reading below. */
for (iparams = 0; iparams < nparams; iparams++)
- TYPE_FIELD_TYPE (ftype, iparams) = void_type;
+ ftype->field (iparams).set_type (void_type);
iparams = 0;
child_die = die->child;
arg_type, 0);
}
- TYPE_FIELD_TYPE (ftype, iparams) = arg_type;
+ ftype->field (iparams).set_type (arg_type);
iparams++;
}
child_die = child_die->sibling;
&& 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)