/* First try the file name given in the section. If that doesn't
work, try to use the build-id instead. */
- gdb_bfd_ref_ptr dwz_bfd (gdb_bfd_open (filename, gnutarget, -1));
+ gdb_bfd_ref_ptr dwz_bfd (gdb_bfd_open (filename, gnutarget));
if (dwz_bfd != NULL)
{
if (!build_id_verify (dwz_bfd.get (), buildid_len, buildid))
if (fd.get () >= 0)
{
/* File successfully retrieved from server. */
- dwz_bfd = gdb_bfd_open (alt_filename.get (), gnutarget, -1);
+ dwz_bfd = gdb_bfd_open (alt_filename.get (), gnutarget);
if (dwz_bfd == nullptr)
warning (_("File \"%s\" from debuginfod cannot be opened as bfd"),
}
}
+static void
+dw2_expand_symtabs_matching_symbol
+ (mapped_index_base &index,
+ const lookup_name_info &lookup_name_in,
+ gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
+ enum search_domain kind,
+ gdb::function_view<bool (offset_type)> match_callback);
+
+static void
+dw2_expand_symtabs_matching_one
+ (struct dwarf2_per_cu_data *per_cu,
+ gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher,
+ gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify);
+
static void
dw2_map_matching_symbols
(struct objfile *objfile,
struct dwarf2_per_objfile *dwarf2_per_objfile
= get_dwarf2_per_objfile (objfile);
+ const block_enum block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK;
+
if (dwarf2_per_objfile->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. As Ada does not look for non-Ada symbols this
- function should just return. */
- return;
- }
+ using GNU index. */
+ mapped_index &index = *dwarf2_per_objfile->index_table;
- /* We have -readnow: no .gdb_index, but no partial symtabs either. So,
- inline psym_map_matching_symbols here, assuming all partial symtabs have
- been read in. */
- const int block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK;
+ const char *match_name = name.ada ().lookup_name ().c_str ();
+ auto matcher = [&] (const char *symname)
+ {
+ if (ordered_compare == nullptr)
+ return true;
+ return ordered_compare (symname, match_name) == 0;
+ };
+
+ dw2_expand_symtabs_matching_symbol (index, name, matcher, ALL_DOMAIN,
+ [&] (offset_type namei)
+ {
+ struct dw2_symtab_iterator iter;
+ struct dwarf2_per_cu_data *per_cu;
+
+ dw2_symtab_iter_init (&iter, dwarf2_per_objfile, block_kind, domain,
+ match_name);
+ while ((per_cu = dw2_symtab_iter_next (&iter)) != NULL)
+ dw2_expand_symtabs_matching_one (per_cu, nullptr, nullptr);
+ return true;
+ });
+ }
+ else
+ {
+ /* We have -readnow: no .gdb_index, but no partial symtabs either. So,
+ proceed assuming all symtabs have been read in. */
+ }
for (compunit_symtab *cust : objfile->compunits ())
{
dwarf2_section_info §ion,
bool is_dwz)
{
+ if (!map.augmentation_is_gdb)
+ {
+ for (uint32_t i = 0; i < map.cu_count; ++i)
+ {
+ sect_offset sect_off
+ = (sect_offset) (extract_unsigned_integer
+ (map.cu_table_reordered + i * map.offset_size,
+ map.offset_size,
+ map.dwarf5_byte_order));
+ /* We don't know the length of the CU, because the CU list in a
+ .debug_names index can be incomplete, so we can't use the start of
+ the next CU as end of this CU. We create the CUs here with length 0,
+ and in cutu_reader::cutu_reader we'll fill in the actual length. */
+ dwarf2_per_cu_data *per_cu
+ = create_cu_from_index_list (dwarf2_per_objfile, §ion, is_dwz,
+ sect_off, 0);
+ dwarf2_per_objfile->all_comp_units.push_back (per_cu);
+ }
+ }
+
sect_offset sect_off_prev;
for (uint32_t i = 0; i <= map.cu_count; ++i)
{
ull = read_unsigned_leb128 (abfd, m_addr, &bytes_read);
m_addr += bytes_read;
break;
+ case DW_FORM_ref4:
+ ull = read_4_bytes (abfd, m_addr);
+ m_addr += 4;
+ break;
+ case DW_FORM_ref8:
+ ull = read_8_bytes (abfd, m_addr);
+ m_addr += 8;
+ break;
+ case DW_FORM_ref_sig8:
+ ull = read_8_bytes (abfd, m_addr);
+ m_addr += 8;
+ break;
default:
complaint (_("Unsupported .debug_names form %s [in module %s]"),
dwarf_form_name (attr.form),
}
per_cu = &dwarf2_per_objfile->get_tu (ull)->per_cu;
break;
+ case DW_IDX_die_offset:
+ /* In a per-CU index (as opposed to a per-module index), index
+ entries without CU attribute implicitly refer to the single CU. */
+ if (per_cu == NULL)
+ per_cu = dwarf2_per_objfile->get_cu (0);
+ break;
case DW_IDX_GNU_internal:
if (!m_map.augmentation_is_gdb)
break;
rcuh_kind::COMPILE);
gdb_assert (this_cu->sect_off == cu->header.sect_off);
- gdb_assert (this_cu->length == cu->header.get_length ());
+ if (this_cu->length == 0)
+ this_cu->length = cu->header.get_length ();
+ else
+ gdb_assert (this_cu->length == cu->header.get_length ());
this_cu->dwarf_version = cu->header.version;
}
}
saved_package_name);
struct symbol *sym;
- sym = allocate_symbol (objfile);
+ sym = new (&objfile->objfile_obstack) symbol;
sym->set_language (language_go, &objfile->objfile_obstack);
sym->compute_and_set_names (saved_package_name, false, objfile->per_bfd);
/* This is not VAR_DOMAIN because we want a way to ensure a lookup of,
/* When DISCRIMINANT_INDEX == -1, we have a univariant enum. Those
must be handled by the caller. */
gdb_assert (discriminant_index >= 0
- && discriminant_index < TYPE_NFIELDS (type));
+ && discriminant_index < type->num_fields ());
gdb_assert (default_index == -1
- || (default_index >= 0 && default_index < TYPE_NFIELDS (type)));
+ || (default_index >= 0 && default_index < type->num_fields ()));
/* We have one variant for each non-discriminant field. */
- int n_variants = TYPE_NFIELDS (type) - 1;
+ int n_variants = type->num_fields () - 1;
variant *variants = new (obstack) variant[n_variants];
int var_idx = 0;
int range_idx = 0;
- for (int i = 0; i < TYPE_NFIELDS (type); ++i)
+ for (int i = 0; i < type->num_fields (); ++i)
{
if (i == discriminant_index)
continue;
prop.kind = PROP_VARIANT_PARTS;
prop.data.variant_parts = prop_value;
- add_dyn_prop (DYN_PROP_VARIANT_PARTS, prop, type);
+ type->add_dyn_prop (DYN_PROP_VARIANT_PARTS, prop);
}
/* Some versions of rustc emitted enums in an unusual way.
static void
quirk_rust_enum (struct type *type, struct objfile *objfile)
{
- gdb_assert (TYPE_CODE (type) == TYPE_CODE_UNION);
+ gdb_assert (type->code () == TYPE_CODE_UNION);
/* We don't need to deal with empty enums. */
- if (TYPE_NFIELDS (type) == 0)
+ if (type->num_fields () == 0)
return;
#define RUST_ENUM_PREFIX "RUST$ENCODED$ENUM$"
- if (TYPE_NFIELDS (type) == 1
+ if (type->num_fields () == 1
&& startswith (TYPE_FIELD_NAME (type, 0), RUST_ENUM_PREFIX))
{
const char *name = TYPE_FIELD_NAME (type, 0) + strlen (RUST_ENUM_PREFIX);
unsigned long index = strtoul (name, &tail, 10);
name = tail;
if (*name != '$'
- || index >= TYPE_NFIELDS (field_type)
+ || index >= field_type->num_fields ()
|| (TYPE_FIELD_LOC_KIND (field_type, index)
!= FIELD_LOC_KIND_BITPOS))
{
/* Smash this type to be a structure type. We have to do this
because the type has already been recorded. */
- TYPE_CODE (type) = TYPE_CODE_STRUCT;
- TYPE_NFIELDS (type) = 3;
+ type->set_code (TYPE_CODE_STRUCT);
+ type->set_num_fields (3);
/* Save the field we care about. */
- struct field saved_field = TYPE_FIELD (type, 0);
- TYPE_FIELDS (type)
- = (struct field *) TYPE_ZALLOC (type, 3 * sizeof (struct field));
+ struct field saved_field = type->field (0);
+ type->set_fields
+ ((struct field *) TYPE_ZALLOC (type, 3 * sizeof (struct field)));
/* Put the discriminant at index 0. */
TYPE_FIELD_TYPE (type, 0) = field_type;
TYPE_FIELD_ARTIFICIAL (type, 0) = 1;
TYPE_FIELD_NAME (type, 0) = "<<discriminant>>";
- SET_FIELD_BITPOS (TYPE_FIELD (type, 0), bit_offset);
+ SET_FIELD_BITPOS (type->field (0), bit_offset);
/* The order of fields doesn't really matter, so put the real
field at index 1 and the data-less field at index 2. */
- TYPE_FIELD (type, 1) = saved_field;
+ type->field (1) = saved_field;
TYPE_FIELD_NAME (type, 1)
- = rust_last_path_segment (TYPE_NAME (TYPE_FIELD_TYPE (type, 1)));
- TYPE_NAME (TYPE_FIELD_TYPE (type, 1))
- = rust_fully_qualify (&objfile->objfile_obstack, TYPE_NAME (type),
- TYPE_FIELD_NAME (type, 1));
+ = rust_last_path_segment (TYPE_FIELD_TYPE (type, 1)->name ());
+ TYPE_FIELD_TYPE (type, 1)->set_name
+ (rust_fully_qualify (&objfile->objfile_obstack, type->name (),
+ TYPE_FIELD_NAME (type, 1)));
const char *dataless_name
- = rust_fully_qualify (&objfile->objfile_obstack, TYPE_NAME (type),
+ = rust_fully_qualify (&objfile->objfile_obstack, type->name (),
name);
struct type *dataless_type = init_type (objfile, TYPE_CODE_VOID, 0,
dataless_name);
/* NAME points into the original discriminant name, which
already has the correct lifetime. */
TYPE_FIELD_NAME (type, 2) = name;
- SET_FIELD_BITPOS (TYPE_FIELD (type, 2), 0);
+ SET_FIELD_BITPOS (type->field (2), 0);
/* Indicate that this is a variant type. */
static discriminant_range ranges[1] = { { 0, 0 } };
}
/* A union with a single anonymous field is probably an old-style
univariant enum. */
- else if (TYPE_NFIELDS (type) == 1 && streq (TYPE_FIELD_NAME (type, 0), ""))
+ else if (type->num_fields () == 1 && streq (TYPE_FIELD_NAME (type, 0), ""))
{
/* Smash this type to be a structure type. We have to do this
because the type has already been recorded. */
- TYPE_CODE (type) = TYPE_CODE_STRUCT;
+ type->set_code (TYPE_CODE_STRUCT);
struct type *field_type = TYPE_FIELD_TYPE (type, 0);
const char *variant_name
- = rust_last_path_segment (TYPE_NAME (field_type));
+ = rust_last_path_segment (field_type->name ());
TYPE_FIELD_NAME (type, 0) = variant_name;
- TYPE_NAME (field_type)
- = rust_fully_qualify (&objfile->objfile_obstack,
- TYPE_NAME (type), variant_name);
+ field_type->set_name
+ (rust_fully_qualify (&objfile->objfile_obstack,
+ type->name (), variant_name));
}
else
{
struct type *disr_type = nullptr;
- for (int i = 0; i < TYPE_NFIELDS (type); ++i)
+ for (int i = 0; i < type->num_fields (); ++i)
{
disr_type = TYPE_FIELD_TYPE (type, i);
- if (TYPE_CODE (disr_type) != TYPE_CODE_STRUCT)
+ if (disr_type->code () != TYPE_CODE_STRUCT)
{
/* All fields of a true enum will be structs. */
return;
}
- else if (TYPE_NFIELDS (disr_type) == 0)
+ else if (disr_type->num_fields () == 0)
{
/* Could be data-less variant, so keep going. */
disr_type = nullptr;
/* Smash this type to be a structure type. We have to do this
because the type has already been recorded. */
- TYPE_CODE (type) = TYPE_CODE_STRUCT;
+ type->set_code (TYPE_CODE_STRUCT);
/* Make space for the discriminant field. */
- struct field *disr_field = &TYPE_FIELD (disr_type, 0);
+ struct field *disr_field = &disr_type->field (0);
field *new_fields
- = (struct field *) TYPE_ZALLOC (type, (TYPE_NFIELDS (type)
+ = (struct field *) TYPE_ZALLOC (type, ((type->num_fields () + 1)
* sizeof (struct field)));
- memcpy (new_fields + 1, TYPE_FIELDS (type),
- TYPE_NFIELDS (type) * sizeof (struct field));
- TYPE_FIELDS (type) = new_fields;
- TYPE_NFIELDS (type) = TYPE_NFIELDS (type) + 1;
+ memcpy (new_fields + 1, type->fields (),
+ type->num_fields () * sizeof (struct field));
+ type->set_fields (new_fields);
+ type->set_num_fields (type->num_fields () + 1);
/* Install the discriminant at index 0 in the union. */
- TYPE_FIELD (type, 0) = *disr_field;
+ type->field (0) = *disr_field;
TYPE_FIELD_ARTIFICIAL (type, 0) = 1;
TYPE_FIELD_NAME (type, 0) = "<<discriminant>>";
variant name. For convenience we build a map here. */
struct type *enum_type = FIELD_TYPE (*disr_field);
std::unordered_map<std::string, ULONGEST> discriminant_map;
- for (int i = 0; i < TYPE_NFIELDS (enum_type); ++i)
+ for (int i = 0; i < enum_type->num_fields (); ++i)
{
if (TYPE_FIELD_LOC_KIND (enum_type, i) == FIELD_LOC_KIND_ENUMVAL)
{
}
}
- int n_fields = TYPE_NFIELDS (type);
+ int n_fields = type->num_fields ();
/* We don't need a range entry for the discriminant, but we do
need one for every other field, as there is no default
variant. */
That name can be used to look up the correct
discriminant. */
const char *variant_name
- = rust_last_path_segment (TYPE_NAME (TYPE_FIELD_TYPE (type, i)));
+ = rust_last_path_segment (TYPE_FIELD_TYPE (type, i)->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);
- if (TYPE_NFIELDS (sub_type) > 0)
+ if (sub_type->num_fields () > 0)
{
- --TYPE_NFIELDS (sub_type);
- ++TYPE_FIELDS (sub_type);
+ sub_type->set_num_fields (sub_type->num_fields () - 1);
+ sub_type->set_fields (sub_type->fields () + 1);
}
TYPE_FIELD_NAME (type, i) = variant_name;
- TYPE_NAME (sub_type)
- = rust_fully_qualify (&objfile->objfile_obstack,
- TYPE_NAME (type), variant_name);
+ sub_type->set_name
+ (rust_fully_qualify (&objfile->objfile_obstack,
+ type->name (), variant_name));
}
/* Indicate that this is a variant type. */
marks unnamed (and thus unused) parameters as
artificial; there is no way to differentiate
the two cases. */
- if (TYPE_NFIELDS (type) > 0
+ if (type->num_fields () > 0
&& TYPE_FIELD_ARTIFICIAL (type, 0)
- && TYPE_CODE (TYPE_FIELD_TYPE (type, 0)) == TYPE_CODE_PTR
+ && TYPE_FIELD_TYPE (type, 0)->code () == TYPE_CODE_PTR
&& TYPE_CONST (TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type,
0))))
buf.puts (" const");
sect_offset sect_off = attr->get_ref_die_offset ();
type = get_die_type_at_offset (sect_off, cu->per_cu);
- if (type != NULL && TYPE_CODE (type) == TYPE_CODE_NAMESPACE)
+ if (type != NULL && type->code () == TYPE_CODE_NAMESPACE)
{
/* This declaration is a global namespace alias. Add
a symbol for it whose type is the aliased namespace. */
COMPUNIT_DIRNAME (cust),
compunit_language (cust),
0, cust));
+ list_in_scope = get_builder ()->get_file_symbols ();
}
return;
}
COMPUNIT_DIRNAME (cust),
compunit_language (cust),
0, cust));
+ list_in_scope = get_builder ()->get_file_symbols ();
auto &file_names = line_header->file_names ();
for (i = 0; i < file_names.size (); ++i)
if (child_die->tag == DW_TAG_template_type_param
|| child_die->tag == DW_TAG_template_value_param)
{
- templ_func = allocate_template_symbol (objfile);
+ templ_func = new (&objfile->objfile_obstack) template_symbol;
templ_func->subclass = SYMBOL_TEMPLATE;
break;
}
for (child_die = die->child;
child_die != NULL && child_die->tag;
child_die = child_die->sibling)
- process_die (child_die, cu);
+ {
+ /* We might already be processing this DIE. This can happen
+ in an unusual circumstance -- where a subroutine A
+ appears lexically in another subroutine B, but A actually
+ inlines B. The recursion is broken here, rather than in
+ inherit_abstract_dies, because it seems better to simply
+ drop concrete children here. */
+ if (!child_die->in_process)
+ process_die (child_die, cu);
+ }
return;
case PC_BOUNDS_INVALID:
return;
func_type = get_die_type (func_die, cu);
if (func_type != NULL)
{
- gdb_assert (TYPE_CODE (func_type) == TYPE_CODE_FUNC);
+ gdb_assert (func_type->code () == TYPE_CODE_FUNC);
/* Enlist this call site to the function. */
call_site->tail_call_next = TYPE_TAIL_CALL_LIST (func_type);
{
struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile;
- storage = new (&objfile->objfile_obstack) rust_vtable_symbol ();
- initialize_objfile_symbol (storage);
+ storage = new (&objfile->objfile_obstack) rust_vtable_symbol;
storage->concrete_type = containing_type;
storage->subclass = SYMBOL_RUST_VTABLE;
}
handle_data_member_location (die, cu, fp);
FIELD_BITSIZE (*fp) = 0;
FIELD_TYPE (*fp) = die_type (die, cu);
- FIELD_NAME (*fp) = TYPE_NAME (fp->type);
+ FIELD_NAME (*fp) = fp->type->name ();
}
else
gdb_assert_not_reached ("missing case in dwarf2_add_field");
/* A convenience typedef that's used when finding the discriminant
field for a variant part. */
-typedef std::unordered_map<sect_offset, int> offset_map_type;
+typedef std::unordered_map<sect_offset, int, gdb::hash_enum<sect_offset>>
+ offset_map_type;
/* Compute the discriminant range for a given variant. OBSTACK is
where the results will be stored. VARIANT is the variant to
= ((gdb::array_view<variant_part> *)
obstack_copy (&objfile->objfile_obstack, &parts, sizeof (parts)));
- add_dyn_prop (DYN_PROP_VARIANT_PARTS, prop, type);
+ type->add_dyn_prop (DYN_PROP_VARIANT_PARTS, prop);
}
/* Create the vector of fields, and attach it to the type. */
/* Record the field count, allocate space for the array of fields,
and create blank accessibility bitfields if necessary. */
- TYPE_NFIELDS (type) = nfields;
- TYPE_FIELDS (type) = (struct field *)
- TYPE_ZALLOC (type, sizeof (struct field) * nfields);
+ type->set_num_fields (nfields);
+ type->set_fields
+ ((struct field *) TYPE_ZALLOC (type, sizeof (struct field) * nfields));
if (fip->non_public_fields && cu->language != language_ada)
{
= ((i < fip->baseclasses.size ()) ? fip->baseclasses[i]
: fip->fields[i - fip->baseclasses.size ()]);
- TYPE_FIELD (type, i) = field.field;
+ type->field (i) = field.field;
switch (field.accessibility)
{
case DW_ACCESS_private:
fnp->type = alloc_type (objfile);
this_type = read_type_die (die, cu);
- if (this_type && TYPE_CODE (this_type) == TYPE_CODE_FUNC)
+ if (this_type && this_type->code () == TYPE_CODE_FUNC)
{
- int nparams = TYPE_NFIELDS (this_type);
+ int nparams = this_type->num_fields ();
/* TYPE is the domain of this method, and THIS_TYPE is the type
of the method itself (TYPE_CODE_METHOD). */
smash_to_method_type (fnp->type, type,
TYPE_TARGET_TYPE (this_type),
- TYPE_FIELDS (this_type),
- TYPE_NFIELDS (this_type),
+ this_type->fields (),
+ this_type->num_fields (),
TYPE_VARARGS (this_type));
/* Handle static member functions.
/* If there is no `this' field and no DW_AT_containing_type,
we cannot actually find a base class context for the
vtable! */
- if (TYPE_NFIELDS (this_type) == 0
+ if (this_type->num_fields () == 0
|| !TYPE_FIELD_ARTIFICIAL (this_type, 0))
{
complaint (_("cannot determine context for virtual member "
struct type *pfn_type, *self_type, *new_type;
/* Check for a structure with no name and two children. */
- if (TYPE_CODE (type) != TYPE_CODE_STRUCT || TYPE_NFIELDS (type) != 2)
+ if (type->code () != TYPE_CODE_STRUCT || type->num_fields () != 2)
return;
/* Check for __pfn and __delta members. */
/* Find the type of the method. */
pfn_type = TYPE_FIELD_TYPE (type, 0);
if (pfn_type == NULL
- || TYPE_CODE (pfn_type) != TYPE_CODE_PTR
- || TYPE_CODE (TYPE_TARGET_TYPE (pfn_type)) != TYPE_CODE_FUNC)
+ || pfn_type->code () != TYPE_CODE_PTR
+ || TYPE_TARGET_TYPE (pfn_type)->code () != TYPE_CODE_FUNC)
return;
/* Look for the "this" argument. */
pfn_type = TYPE_TARGET_TYPE (pfn_type);
- if (TYPE_NFIELDS (pfn_type) == 0
+ if (pfn_type->num_fields () == 0
/* || TYPE_FIELD_TYPE (pfn_type, 0) == NULL */
- || TYPE_CODE (TYPE_FIELD_TYPE (pfn_type, 0)) != TYPE_CODE_PTR)
+ || TYPE_FIELD_TYPE (pfn_type, 0)->code () != TYPE_CODE_PTR)
return;
self_type = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (pfn_type, 0));
new_type = alloc_type (objfile);
smash_to_method_type (new_type, self_type, TYPE_TARGET_TYPE (pfn_type),
- TYPE_FIELDS (pfn_type), TYPE_NFIELDS (pfn_type),
+ pfn_type->fields (), pfn_type->num_fields (),
TYPE_VARARGS (pfn_type));
smash_to_methodptr_type (type, new_type);
}
if (get_die_type (die, cu) != NULL)
return get_die_type (die, cu);
- TYPE_NAME (type) = full_name;
+ type->set_name (full_name);
}
else
{
/* The name is already allocated along with this objfile, so
we don't need to duplicate it for the type. */
- TYPE_NAME (type) = name;
+ type->set_name (name);
}
}
if (die->tag == DW_TAG_structure_type)
{
- TYPE_CODE (type) = TYPE_CODE_STRUCT;
+ type->set_code (TYPE_CODE_STRUCT);
}
else if (die->tag == DW_TAG_union_type)
{
- TYPE_CODE (type) = TYPE_CODE_UNION;
+ type->set_code (TYPE_CODE_UNION);
}
else
{
- TYPE_CODE (type) = TYPE_CODE_STRUCT;
+ type->set_code (TYPE_CODE_STRUCT);
}
if (cu->language == language_cplus && die->tag == DW_TAG_class_type)
struct dynamic_prop prop;
if (attr_to_dynamic_prop (attr, die, cu, &prop,
cu->per_cu->addr_type ()))
- add_dyn_prop (DYN_PROP_BYTE_SIZE, prop, type);
+ type->add_dyn_prop (DYN_PROP_BYTE_SIZE, prop);
TYPE_LENGTH (type) = 0;
}
}
int i;
/* Our own class provides vtbl ptr. */
- for (i = TYPE_NFIELDS (t) - 1;
+ for (i = t->num_fields () - 1;
i >= TYPE_N_BASECLASSES (t);
--i)
{
if (i < TYPE_N_BASECLASSES (t))
complaint (_("virtual function table pointer "
"not found when defining class '%s'"),
- TYPE_NAME (type) ? TYPE_NAME (type) : "");
+ type->name () ? type->name () : "");
}
else
{
int i;
- for (i = TYPE_NFIELDS (type) - 1;
+ for (i = type->num_fields () - 1;
i >= TYPE_N_BASECLASSES (type);
--i)
{
these DIEs are identified by the fact that they have no byte_size
attribute, and a declaration attribute. */
if (dwarf2_attr (die, DW_AT_byte_size, cu) != NULL
- || !die_is_declaration (die, cu))
+ || !die_is_declaration (die, cu)
+ || dwarf2_attr (die, DW_AT_signature, cu) != NULL)
{
struct symbol *sym = new_symbol (die, type, cu);
}
}
-/* Assuming DIE is an enumeration type, and TYPE is its associated type,
- update TYPE using some information only available in DIE's children. */
+/* Assuming DIE is an enumeration type, and TYPE is its associated
+ type, update TYPE using some information only available in DIE's
+ children. In particular, the fields are computed. */
static void
update_enumeration_type_from_children (struct die_info *die,
int flag_enum = 1;
auto_obstack obstack;
+ std::vector<struct field> fields;
for (child_die = die->child;
child_die != NULL && child_die->tag;
flag_enum = 0;
}
- /* If we already know that the enum type is neither unsigned, nor
- a flag type, no need to look at the rest of the enumerates. */
- if (!unsigned_enum && !flag_enum)
- break;
+ fields.emplace_back ();
+ struct field &field = fields.back ();
+ FIELD_NAME (field) = dwarf2_physname (name, child_die, cu);
+ SET_FIELD_ENUMVAL (field, value);
+ }
+
+ if (!fields.empty ())
+ {
+ type->set_num_fields (fields.size ());
+ type->set_fields
+ ((struct field *)
+ TYPE_ALLOC (type, sizeof (struct field) * fields.size ()));
+ memcpy (type->fields (), fields.data (),
+ sizeof (struct field) * fields.size ());
}
if (unsigned_enum)
type = alloc_type (objfile);
- TYPE_CODE (type) = TYPE_CODE_ENUM;
+ type->set_code (TYPE_CODE_ENUM);
name = dwarf2_full_name (NULL, die, cu);
if (name != NULL)
- TYPE_NAME (type) = name;
+ type->set_name (name);
attr = dwarf2_attr (die, DW_AT_type, cu);
if (attr != NULL)
if (die_is_declaration (die, cu))
TYPE_STUB (type) = 1;
- /* Finish the creation of this type by using the enum's children.
- We must call this even when the underlying type has been provided
- so that we can determine if we're looking at a "flag" enum. */
- update_enumeration_type_from_children (die, type, cu);
-
/* If this type has an underlying type that is not a stub, then we
may use its attributes. We always use the "unsigned" attribute
in this situation, because ordinarily we guess whether the type
TYPE_DECLARED_CLASS (type) = dwarf2_flag_true_p (die, DW_AT_enum_class, cu);
- return set_die_type (die, type, cu);
+ set_die_type (die, type, cu);
+
+ /* Finish the creation of this type by using the enum's children.
+ Note that, as usual, this must come after set_die_type to avoid
+ infinite recursion when trying to compute the names of the
+ enumerators. */
+ update_enumeration_type_from_children (die, type, cu);
+
+ return type;
}
/* Given a pointer to a die which begins an enumeration, process all
if (die->child != NULL)
{
struct die_info *child_die;
- struct symbol *sym;
- std::vector<struct field> fields;
const char *name;
child_die = die->child;
{
name = dwarf2_name (child_die, cu);
if (name)
- {
- sym = new_symbol (child_die, this_type, cu);
-
- fields.emplace_back ();
- struct field &field = fields.back ();
-
- FIELD_NAME (field) = sym->linkage_name ();
- FIELD_TYPE (field) = NULL;
- SET_FIELD_ENUMVAL (field, SYMBOL_VALUE (sym));
- FIELD_BITSIZE (field) = 0;
- }
+ new_symbol (child_die, this_type, cu);
}
child_die = child_die->sibling;
}
-
- if (!fields.empty ())
- {
- TYPE_NFIELDS (this_type) = fields.size ();
- TYPE_FIELDS (this_type) = (struct field *)
- TYPE_ALLOC (this_type, sizeof (struct field) * fields.size ());
- memcpy (TYPE_FIELDS (this_type), fields.data (),
- sizeof (struct field) * fields.size ());
- }
}
/* If we are reading an enum from a .debug_types unit, and the enum
name = dwarf2_name (die, cu);
if (name)
- TYPE_NAME (type) = name;
+ type->set_name (name);
maybe_set_alignment (cu, die, type);
std::vector<const char *> excludes;
add_using_directive (using_directives (cu),
- previous_prefix, TYPE_NAME (type), NULL,
+ previous_prefix, type->name (), NULL,
NULL, excludes, 0, &objfile->objfile_obstack);
}
}
if (type)
return type;
- if (TYPE_CODE (check_typedef (to_type)) == TYPE_CODE_METHOD)
+ if (check_typedef (to_type)->code () == TYPE_CODE_METHOD)
type = lookup_methodptr_type (to_type);
- else if (TYPE_CODE (check_typedef (to_type)) == TYPE_CODE_FUNC)
+ else if (check_typedef (to_type)->code () == TYPE_CODE_FUNC)
{
struct type *new_type
= alloc_type (cu->per_cu->dwarf2_per_objfile->objfile);
smash_to_method_type (new_type, domain, TYPE_TARGET_TYPE (to_type),
- TYPE_FIELDS (to_type), TYPE_NFIELDS (to_type),
+ to_type->fields (), to_type->num_fields (),
TYPE_VARARGS (to_type));
type = lookup_methodptr_type (new_type);
}
base_type = copy_type (base_type);
inner_array = base_type;
- while (TYPE_CODE (TYPE_TARGET_TYPE (inner_array)) == TYPE_CODE_ARRAY)
+ while (TYPE_TARGET_TYPE (inner_array)->code () == TYPE_CODE_ARRAY)
{
TYPE_TARGET_TYPE (inner_array) =
copy_type (TYPE_TARGET_TYPE (inner_array));
/* In case the const qualifier is applied to an array type, the element type
is so qualified, not the array type (section 6.7.3 of C99). */
- if (TYPE_CODE (base_type) == TYPE_CODE_ARRAY)
+ if (base_type->code () == TYPE_CODE_ARRAY)
return add_array_cv_type (die, cu, base_type, 1, 0);
cv_type = make_cv_type (1, TYPE_VOLATILE (base_type), base_type, 0);
/* In case the volatile qualifier is applied to an array type, the
element type is so qualified, not the array type (section 6.7.3
of C99). */
- if (TYPE_CODE (base_type) == TYPE_CODE_ARRAY)
+ if (base_type->code () == TYPE_CODE_ARRAY)
return add_array_cv_type (die, cu, base_type, 0, 1);
cv_type = make_cv_type (TYPE_CONST (base_type), 1, base_type, 0);
}
/* Allocate storage for parameters and fill them in. */
- TYPE_NFIELDS (ftype) = nparams;
- TYPE_FIELDS (ftype) = (struct field *)
- TYPE_ZALLOC (ftype, nparams * sizeof (struct field));
+ ftype->set_num_fields (nparams);
+ ftype->set_fields
+ ((struct field *) TYPE_ZALLOC (ftype, nparams * sizeof (struct field)));
/* TYPE_FIELD_TYPE must never be NULL. Pre-fill the array to ensure it
even if we error out during the parameters reading below. */
if (tt != nullptr && TYPE_LENGTH (tt) * TARGET_CHAR_BIT != bits)
tt = nullptr;
- const char *name = (tt == nullptr) ? nullptr : TYPE_NAME (tt);
+ const char *name = (tt == nullptr) ? nullptr : tt->name ();
return dwarf2_init_float_type (objfile, bits, name, name_hint, byte_order);
}
case DW_ATE_complex_float:
type = dwarf2_init_complex_target_type (cu, objfile, bits / 2, name,
byte_order);
- if (TYPE_CODE (type) == TYPE_CODE_ERROR)
+ if (type->code () == TYPE_CODE_ERROR)
{
if (name == nullptr)
{
struct obstack *obstack
= &cu->per_cu->dwarf2_per_objfile->objfile->objfile_obstack;
- name = obconcat (obstack, "_Complex ", TYPE_NAME (type),
+ name = obconcat (obstack, "_Complex ", type->name (),
nullptr);
}
type = init_type (objfile, TYPE_CODE_ERROR, bits, name);
GCC produces an empty range DIE.
FIXME: muller/2010-05-28: Possible references to object for low bound,
high bound or count are not yet handled by this code. */
- if (TYPE_CODE (index_type) == TYPE_CODE_VOID)
+ if (index_type->code () == TYPE_CODE_VOID)
index_type = cu->per_cu->addr_sized_int_type (false);
return index_type;
name = dwarf2_name (die, cu);
if (name)
- TYPE_NAME (range_type) = name;
+ range_type->set_name (name);
attr = dwarf2_attr (die, DW_AT_byte_size, cu);
if (attr != nullptr)
type = init_type (cu->per_cu->dwarf2_per_objfile->objfile, TYPE_CODE_VOID,0,
NULL);
- TYPE_NAME (type) = dwarf2_name (die, cu);
+ type->set_name (dwarf2_name (die, cu));
/* In Ada, an unspecified type is typically used when the description
of the type is deferred to a different unit. When encountering
if (space)
sym = space;
else
- sym = allocate_symbol (objfile);
+ sym = new (&objfile->objfile_obstack) symbol;
OBJSTAT (objfile, n_syms++);
/* Cache this symbol's name and the name's demangled form (if any). */
/* Compilation with minimal debug info may result in
variables with missing type entries. Change the
misleading `void' type to something sensible. */
- if (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_VOID)
+ if (SYMBOL_TYPE (sym)->code () == TYPE_CODE_VOID)
SYMBOL_TYPE (sym) = objfile_type (objfile)->builtin_int;
attr = dwarf2_attr (die, DW_AT_const_value, cu);
/* The symbol's name is already allocated along
with this objfile, so we don't need to
duplicate it for the type. */
- if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0)
- TYPE_NAME (SYMBOL_TYPE (sym)) = sym->search_name ();
+ if (SYMBOL_TYPE (sym)->name () == 0)
+ SYMBOL_TYPE (sym)->set_name (sym->search_name ());
}
}
}
DW_TAG_namespace DIEs with a name of "::" for the global namespace.
Work around this problem here. */
if (cu->language == language_cplus
- && strcmp (TYPE_NAME (parent_type), "::") == 0)
+ && strcmp (parent_type->name (), "::") == 0)
return "";
/* We give a name to even anonymous namespaces. */
- return TYPE_NAME (parent_type);
+ return parent_type->name ();
case DW_TAG_class_type:
case DW_TAG_interface_type:
case DW_TAG_structure_type:
case DW_TAG_union_type:
case DW_TAG_module:
parent_type = read_type_die (parent, cu);
- if (TYPE_NAME (parent_type) != NULL)
- return TYPE_NAME (parent_type);
+ if (parent_type->name () != NULL)
+ return parent_type->name ();
else
/* An anonymous structure is only allowed non-static data
members; no typedefs, no member functions, et cetera.
parent_type = read_type_die (parent, cu);
if (TYPE_DECLARED_CLASS (parent_type))
{
- if (TYPE_NAME (parent_type) != NULL)
- return TYPE_NAME (parent_type);
+ if (parent_type->name () != NULL)
+ return parent_type->name ();
return "";
}
/* Fall through. */
{
if (name && cu->language == language_cplus)
{
- std::string canon_name = cp_canonicalize_string (name);
+ gdb::unique_xmalloc_ptr<char> canon_name
+ = cp_canonicalize_string (name);
- if (!canon_name.empty ())
- {
- if (canon_name != name)
- name = objfile->intern (canon_name);
- }
+ if (canon_name != nullptr)
+ name = objfile->intern (canon_name.get ());
}
return name;
But this is not a problem, because the gnat-specific information
is actually not needed for these types. */
if (need_gnat_info (cu)
- && TYPE_CODE (type) != TYPE_CODE_FUNC
- && TYPE_CODE (type) != TYPE_CODE_FLT
- && TYPE_CODE (type) != TYPE_CODE_METHODPTR
- && TYPE_CODE (type) != TYPE_CODE_MEMBERPTR
- && TYPE_CODE (type) != TYPE_CODE_METHOD
+ && type->code () != TYPE_CODE_FUNC
+ && type->code () != TYPE_CODE_FLT
+ && type->code () != TYPE_CODE_METHODPTR
+ && type->code () != TYPE_CODE_MEMBERPTR
+ && type->code () != TYPE_CODE_METHOD
&& !HAVE_GNAT_AUX_INFO (type))
INIT_GNAT_SPECIFIC (type);
{
struct type *prop_type = cu->per_cu->addr_sized_int_type (false);
if (attr_to_dynamic_prop (attr, die, cu, &prop, prop_type))
- add_dyn_prop (DYN_PROP_ALLOCATED, prop, type);
+ type->add_dyn_prop (DYN_PROP_ALLOCATED, prop);
}
else if (attr != NULL)
{
{
struct type *prop_type = cu->per_cu->addr_sized_int_type (false);
if (attr_to_dynamic_prop (attr, die, cu, &prop, prop_type))
- add_dyn_prop (DYN_PROP_ASSOCIATED, prop, type);
+ type->add_dyn_prop (DYN_PROP_ASSOCIATED, prop);
}
else if (attr != NULL)
{
attr = dwarf2_attr (die, DW_AT_data_location, cu);
if (attr_to_dynamic_prop (attr, die, cu, &prop,
cu->per_cu->addr_type ()))
- add_dyn_prop (DYN_PROP_DATA_LOCATION, prop, type);
+ type->add_dyn_prop (DYN_PROP_DATA_LOCATION, prop);
if (dwarf2_per_objfile->die_type_hash == NULL)
dwarf2_per_objfile->die_type_hash