/* A helper function to find the sections for a .dwz file. */
static void
-locate_dwz_sections (bfd *abfd, asection *sectp, void *arg)
+locate_dwz_sections (bfd *abfd, asection *sectp, dwz_file *dwz_file)
{
- struct dwz_file *dwz_file = (struct dwz_file *) arg;
-
/* Note that we only support the standard ELF names, because .dwz
is ELF-only (at the time of writing). */
if (section_is_p (sectp->name, &dwarf2_elf_names.abbrev))
std::unique_ptr<struct dwz_file> result
(new struct dwz_file (std::move (dwz_bfd)));
- bfd_map_over_sections (result->dwz_bfd.get (), locate_dwz_sections,
- result.get ());
+ for (asection *sec : gdb_bfd_sections (result->dwz_bfd))
+ locate_dwz_sections (result->dwz_bfd.get (), sec, result.get ());
gdb_bfd_record_inclusion (per_bfd->obfd, result->dwz_bfd.get ());
per_bfd->dwz_file = std::move (result);
part->is_unsigned
= (discriminant_index == -1
? false
- : TYPE_UNSIGNED (type->field (discriminant_index).type ()));
+ : type->field (discriminant_index).type ()->is_unsigned ());
part->variants = gdb::array_view<variant> (variants, n_variants);
void *storage = obstack_alloc (obstack, sizeof (gdb::array_view<variant_part>));
{
int len;
std::vector<compunit_symtab *> result_symtabs;
- htab_t all_children, all_type_symtabs;
compunit_symtab *cust = per_objfile->get_symtab (per_cu);
/* If we don't have a symtab, we can just skip this case. */
if (cust == NULL)
return;
- all_children = htab_create_alloc (1, htab_hash_pointer, htab_eq_pointer,
- NULL, xcalloc, xfree);
- all_type_symtabs = htab_create_alloc (1, htab_hash_pointer, htab_eq_pointer,
- NULL, xcalloc, xfree);
+ htab_up all_children (htab_create_alloc (1, htab_hash_pointer,
+ htab_eq_pointer,
+ NULL, xcalloc, xfree));
+ htab_up all_type_symtabs (htab_create_alloc (1, htab_hash_pointer,
+ htab_eq_pointer,
+ NULL, xcalloc, xfree));
for (dwarf2_per_cu_data *ptr : *per_cu->imported_symtabs)
{
- recursively_compute_inclusions (&result_symtabs, all_children,
- all_type_symtabs, ptr, per_objfile,
- cust);
+ recursively_compute_inclusions (&result_symtabs, all_children.get (),
+ all_type_symtabs.get (), ptr,
+ per_objfile, cust);
}
/* Now we have a transitive closure of all the included symtabs. */
memcpy (cust->includes, result_symtabs.data (),
len * sizeof (compunit_symtab *));
cust->includes[len] = NULL;
-
- htab_delete (all_children);
- htab_delete (all_type_symtabs);
}
}
&cu->comp_unit_obstack, cu,
&value, &bytes, &baton);
- if (TYPE_NOSIGN (type))
+ if (type->has_no_signedness ())
/* GDB prints characters as NUMBER 'CHAR'. If that's
changed, this can use value_print instead. */
c_printchar (value, type, &buf);
if (mangled != NULL)
{
- if (language_def (cu->language)->la_store_sym_names_in_linkage_form_p)
+ if (language_def (cu->language)->store_sym_names_in_linkage_form_p ())
{
/* Do nothing (do not demangle the symbol name). */
}
- else if (cu->language == language_go)
- {
- /* This is a lie, but we already lie to the caller new_symbol.
- new_symbol assumes we return the mangled name.
- This just undoes that lie until things are cleaned up. */
- }
else
{
/* Use DMGL_RET_DROP for C++ template functions to suppress
/* Update SECTIONS with the data from SECTP.
- This function is like the other "locate" section routines that are
- passed to bfd_map_over_sections, but in this context the sections to
- read comes from the DWP V1 hash table, not the full ELF section table.
+ This function is like the other "locate" section routines, but in
+ this context the sections to read comes from the DWP V1 hash table,
+ not the full ELF section table.
The result is non-zero for success, or zero if an error was found. */
size of each of the DWO debugging sections we are interested in. */
static void
-dwarf2_locate_dwo_sections (bfd *abfd, asection *sectp, void *dwo_sections_ptr)
+dwarf2_locate_dwo_sections (bfd *abfd, asection *sectp,
+ dwo_sections *dwo_sections)
{
- struct dwo_sections *dwo_sections = (struct dwo_sections *) dwo_sections_ptr;
const struct dwop_section_names *names = &dwop_section_names;
if (section_is_p (sectp->name, &names->abbrev_dwo))
dwo_file->comp_dir = comp_dir;
dwo_file->dbfd = std::move (dbfd);
- bfd_map_over_sections (dwo_file->dbfd.get (), dwarf2_locate_dwo_sections,
- &dwo_file->sections);
+ for (asection *sec : gdb_bfd_sections (dwo_file->dbfd))
+ dwarf2_locate_dwo_sections (dwo_file->dbfd.get (), sec,
+ &dwo_file->sections);
create_cus_hash_table (per_objfile, cu, *dwo_file, dwo_file->sections.info,
dwo_file->cus);
static void
dwarf2_locate_common_dwp_sections (bfd *abfd, asection *sectp,
- void *dwp_file_ptr)
+ dwp_file *dwp_file)
{
- struct dwp_file *dwp_file = (struct dwp_file *) dwp_file_ptr;
const struct dwop_section_names *names = &dwop_section_names;
unsigned int elf_section_nr = elf_section_data (sectp)->this_idx;
OBSTACK_CALLOC (&per_objfile->per_bfd->obstack,
dwp_file->num_sections, asection *);
- bfd_map_over_sections (dwp_file->dbfd.get (),
- dwarf2_locate_common_dwp_sections,
- dwp_file.get ());
+ for (asection *sec : gdb_bfd_sections (dwp_file->dbfd))
+ dwarf2_locate_common_dwp_sections (dwp_file->dbfd.get (), sec,
+ dwp_file.get ());
dwp_file->cus = create_dwp_hash_table (per_objfile, dwp_file.get (), 0);
else
dwp_file->version = 2;
- if (dwp_file->version == 2)
- bfd_map_over_sections (dwp_file->dbfd.get (),
- dwarf2_locate_v2_dwp_sections,
- dwp_file.get ());
- else if (dwp_file->version == 5)
- bfd_map_over_sections (dwp_file->dbfd.get (),
- dwarf2_locate_v5_dwp_sections,
- dwp_file.get ());
-
+ for (asection *sec : gdb_bfd_sections (dwp_file->dbfd))
+ {
+ if (dwp_file->version == 2)
+ dwarf2_locate_v2_dwp_sections (dwp_file->dbfd.get (), sec,
+ dwp_file.get ());
+ else
+ dwarf2_locate_v5_dwp_sections (dwp_file->dbfd.get (), sec,
+ dwp_file.get ());
+ }
dwp_file->loaded_cus = allocate_dwp_loaded_cutus_table ();
dwp_file->loaded_tus = allocate_dwp_loaded_cutus_table ();
{
result.discriminant_index = iter->second;
result.is_unsigned
- = TYPE_UNSIGNED (fi->fields[result.discriminant_index].field.type ());
+ = fi->fields[result.discriminant_index].field.type ()->is_unsigned ();
}
size_t n = builder.variants.size ();
TYPE_TARGET_TYPE (this_type),
this_type->fields (),
this_type->num_fields (),
- TYPE_VARARGS (this_type));
+ this_type->has_varargs ());
/* Handle static member functions.
Dwarf2 has no clean way to discern C++ static and non-static
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_VARARGS (pfn_type));
+ pfn_type->has_varargs ());
smash_to_methodptr_type (type, new_type);
}
{
/* ICC<14 does not output the required DW_AT_declaration on
incomplete types, but gives them a size of zero. */
- TYPE_STUB (type) = 1;
+ type->set_is_stub (true);
}
else
- TYPE_STUB_SUPPORTED (type) = 1;
+ type->set_stub_is_supported (true);
if (die_is_declaration (die, cu))
- TYPE_STUB (type) = 1;
+ type->set_is_stub (true);
else if (attr == NULL && die->child == NULL
&& producer_is_realview (cu->producer))
/* RealView does not output the required DW_AT_declaration
on incomplete types. */
- TYPE_STUB (type) = 1;
+ type->set_is_stub (true);
/* We need to add the type field to the die immediately so we don't
infinitely recurse when dealing with pointers to the structure
}
if (unsigned_enum)
- TYPE_UNSIGNED (type) = 1;
+ type->set_is_unsigned (true);
+
if (flag_enum)
TYPE_FLAG_ENUM (type) = 1;
}
Types. When another package uses such a type, an incomplete DIE
may be generated by the compiler. */
if (die_is_declaration (die, cu))
- TYPE_STUB (type) = 1;
+ type->set_is_stub (true);
/* If this type has an underlying type that is not a stub, then we
may use its attributes. We always use the "unsigned" attribute
can tell us the reality. However, we defer to a local size
attribute if one exists, because this lets the compiler override
the underlying type if needed. */
- if (TYPE_TARGET_TYPE (type) != NULL && !TYPE_STUB (TYPE_TARGET_TYPE (type)))
+ if (TYPE_TARGET_TYPE (type) != NULL && !TYPE_TARGET_TYPE (type)->is_stub ())
{
struct type *underlying_type = TYPE_TARGET_TYPE (type);
underlying_type = check_typedef (underlying_type);
- TYPE_UNSIGNED (type) = TYPE_UNSIGNED (underlying_type);
+
+ type->set_is_unsigned (underlying_type->is_unsigned ());
+
if (TYPE_LENGTH (type) == 0)
TYPE_LENGTH (type) = TYPE_LENGTH (underlying_type);
+
if (TYPE_RAW_ALIGN (type) == 0
&& TYPE_RAW_ALIGN (underlying_type) != 0)
set_type_align (type, TYPE_RAW_ALIGN (underlying_type));
return DW_ORD_row_major;
}
- switch (cu->language_defn->la_array_ordering)
+ switch (cu->language_defn->array_ordering ())
{
case array_column_major:
return DW_ORD_col_major;
{
if (gdbarch_address_class_type_flags_p (gdbarch))
{
- int type_flags;
-
- type_flags = gdbarch_address_class_type_flags
- (gdbarch, byte_size, addr_class);
+ type_instance_flags type_flags
+ = gdbarch_address_class_type_flags (gdbarch, byte_size,
+ addr_class);
gdb_assert ((type_flags & ~TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL)
== 0);
type = make_type_with_address_space (type, type_flags);
smash_to_method_type (new_type, domain, TYPE_TARGET_TYPE (to_type),
to_type->fields (), to_type->num_fields (),
- TYPE_VARARGS (to_type));
+ to_type->has_varargs ());
type = lookup_methodptr_type (new_type);
}
else
ftype = lookup_function_type (type);
if (prototyped_function_p (die, cu))
- TYPE_PROTOTYPED (ftype) = 1;
+ ftype->set_is_prototyped (true);
/* Store the calling convention in the type if it's available in
the subroutine die. Otherwise set the calling convention to
if (child_die->tag == DW_TAG_formal_parameter)
nparams++;
else if (child_die->tag == DW_TAG_unspecified_parameters)
- TYPE_VARARGS (ftype) = 1;
+ ftype->set_has_varargs (true);
+
child_die = child_die->sibling;
}
name = dwarf2_full_name (NULL, die, cu);
this_type = init_type (objfile, TYPE_CODE_TYPEDEF, 0, name);
- TYPE_TARGET_STUB (this_type) = 1;
+ this_type->set_target_is_stub (true);
set_die_type (die, this_type, cu);
target_type = die_type (die, cu);
if (target_type != this_type)
}
if (name && strcmp (name, "char") == 0)
- TYPE_NOSIGN (type) = 1;
+ type->set_has_no_signedness (true);
maybe_set_alignment (cu, die, type);
- TYPE_ENDIANITY_NOT_DEFAULT (type) = gdbarch_byte_order (arch) != byte_order;
+ type->set_endianity_is_not_default (gdbarch_byte_order (arch) != byte_order);
+
+ if (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_INT)
+ {
+ attr = dwarf2_attr (die, DW_AT_bit_size, cu);
+ if (attr != nullptr && DW_UNSND (attr) <= 8 * TYPE_LENGTH (type))
+ {
+ unsigned real_bit_size = DW_UNSND (attr);
+ attr = dwarf2_attr (die, DW_AT_data_bit_offset, cu);
+ /* Only use the attributes if they make sense together. */
+ if (attr == nullptr
+ || DW_UNSND (attr) + real_bit_size <= 8 * TYPE_LENGTH (type))
+ {
+ TYPE_MAIN_TYPE (type)->type_specific.int_stuff.bit_size
+ = real_bit_size;
+ if (attr != nullptr)
+ TYPE_MAIN_TYPE (type)->type_specific.int_stuff.bit_offset
+ = DW_UNSND (attr);
+ }
+ }
+ }
return set_die_type (die, type, cu);
}
negative_mask =
-((ULONGEST) 1 << (TYPE_LENGTH (base_type) * TARGET_CHAR_BIT - 1));
if (low.kind () == PROP_CONST
- && !TYPE_UNSIGNED (base_type) && (low.const_val () & negative_mask))
+ && !base_type->is_unsigned () && (low.const_val () & negative_mask))
low.set_const_val (low.const_val () | negative_mask);
if (high.kind () == PROP_CONST
- && !TYPE_UNSIGNED (base_type) && (high.const_val () & negative_mask))
+ && !base_type->is_unsigned () && (high.const_val () & negative_mask))
high.set_const_val (high.const_val () | negative_mask);
/* Check for bit and byte strides. */
such a type, we treat it as a stub, and try to resolve it later on,
when needed. */
if (cu->language == language_ada)
- TYPE_STUB (type) = 1;
+ type->set_is_stub (true);
return set_die_type (die, type, cu);
}
if (TYPE_LENGTH (addr_type) == addr_size)
return addr_type;
- addr_type = addr_sized_int_type (TYPE_UNSIGNED (addr_type));
+ addr_type = addr_sized_int_type (addr_type->is_unsigned ());
return addr_type;
}