Uninitialized map has CU_COUNT 0. */
struct mapped_debug_names final : public mapped_index_base
{
+ mapped_debug_names (struct dwarf2_per_objfile *dwarf2_per_objfile_)
+ : dwarf2_per_objfile (dwarf2_per_objfile_)
+ {}
+
+ struct dwarf2_per_objfile *dwarf2_per_objfile;
bfd_endian dwarf5_byte_order;
bool dwarf5_is_dwarf64;
bool augmentation_is_gdb;
gdb::optional<filename_seen_cache> filenames_cache;
};
-static struct dwarf2_per_objfile *dwarf2_per_objfile;
+/* Get the dwarf2_per_objfile associated to OBJFILE. */
+
+struct dwarf2_per_objfile *
+get_dwarf2_per_objfile (struct objfile *objfile)
+{
+ return ((struct dwarf2_per_objfile *)
+ objfile_data (objfile, dwarf2_objfile_data_key));
+}
+
+/* Set the dwarf2_per_objfile associated to OBJFILE. */
+
+void
+set_dwarf2_per_objfile (struct objfile *objfile,
+ struct dwarf2_per_objfile *dwarf2_per_objfile)
+{
+ gdb_assert (get_dwarf2_per_objfile (objfile) == NULL);
+ set_objfile_data (objfile, dwarf2_objfile_data_key, dwarf2_per_objfile);
+}
/* Default names of the debugging sections. */
struct die_info *type_unit_die,
int has_children, void *data);
-static void dwarf2_build_psymtabs_hard (struct objfile *);
+static void dwarf2_build_psymtabs_hard
+ (struct dwarf2_per_objfile *dwarf2_per_objfile);
static void scan_partial_symbols (struct partial_die_info *,
CORE_ADDR *, CORE_ADDR *,
(const struct abbrev_table *, unsigned int);
static struct abbrev_table *abbrev_table_read_table
- (struct dwarf2_section_info *, sect_offset);
+ (struct dwarf2_per_objfile *dwarf2_per_objfile, struct dwarf2_section_info *,
+ sect_offset);
static void abbrev_table_free (struct abbrev_table *);
static LONGEST read_offset_1 (bfd *, const gdb_byte *, unsigned int);
-static sect_offset read_abbrev_offset (struct dwarf2_section_info *,
- sect_offset);
+static sect_offset read_abbrev_offset
+ (struct dwarf2_per_objfile *dwarf2_per_objfile,
+ struct dwarf2_section_info *, sect_offset);
static const gdb_byte *read_n_bytes (bfd *, const gdb_byte *, unsigned int);
static const char *read_direct_string (bfd *, const gdb_byte *, unsigned int *);
-static const char *read_indirect_string (bfd *, const gdb_byte *,
- const struct comp_unit_head *,
- unsigned int *);
+static const char *read_indirect_string
+ (struct dwarf2_per_objfile *dwarf2_per_objfile, bfd *, const gdb_byte *,
+ const struct comp_unit_head *, unsigned int *);
-static const char *read_indirect_line_string (bfd *, const gdb_byte *,
- const struct comp_unit_head *,
- unsigned int *);
+static const char *read_indirect_line_string
+ (struct dwarf2_per_objfile *dwarf2_per_objfile, bfd *, const gdb_byte *,
+ const struct comp_unit_head *, unsigned int *);
-static const char *read_indirect_string_at_offset (bfd *abfd,
- LONGEST str_offset);
+static const char *read_indirect_string_at_offset
+ (struct dwarf2_per_objfile *dwarf2_per_objfile, bfd *abfd,
+ LONGEST str_offset);
-static const char *read_indirect_string_from_dwz (struct dwz_file *, LONGEST);
+static const char *read_indirect_string_from_dwz
+ (struct objfile *objfile, struct dwz_file *, LONGEST);
static LONGEST read_signed_leb128 (bfd *, const gdb_byte *, unsigned int *);
static int partial_die_eq (const void *item_lhs, const void *item_rhs);
static struct dwarf2_per_cu_data *dwarf2_find_containing_comp_unit
- (sect_offset sect_off, unsigned int offset_in_dwz, struct objfile *objfile);
+ (sect_offset sect_off, unsigned int offset_in_dwz,
+ struct dwarf2_per_objfile *dwarf2_per_objfile);
static void init_one_comp_unit (struct dwarf2_cu *cu,
struct dwarf2_per_cu_data *per_cu);
static void free_cached_comp_units (void *);
-static void age_cached_comp_units (void);
+static void age_cached_comp_units (struct dwarf2_per_objfile *dwarf2_per_objfile);
static void free_one_cached_comp_unit (struct dwarf2_per_cu_data *);
static struct type *set_die_type (struct die_info *, struct type *,
struct dwarf2_cu *);
-static void create_all_comp_units (struct objfile *);
+static void create_all_comp_units (struct dwarf2_per_objfile *dwarf2_per_objfile);
-static int create_all_type_units (struct objfile *);
+static int create_all_type_units (struct dwarf2_per_objfile *dwarf2_per_objfile);
static void load_full_comp_unit (struct dwarf2_per_cu_data *,
enum language);
static void queue_comp_unit (struct dwarf2_per_cu_data *per_cu,
enum language pretend_language);
-static void process_queue (void);
+static void process_queue (struct dwarf2_per_objfile *dwarf2_per_objfile);
/* The return type of find_file_and_directory. Note, the enclosed
string pointers are only valid while this object is valid. */
enum class rcuh_kind { COMPILE, TYPE };
static const gdb_byte *read_and_check_comp_unit_head
- (struct comp_unit_head *header,
+ (struct dwarf2_per_objfile* dwarf2_per_objfile,
+ struct comp_unit_head *header,
struct dwarf2_section_info *section,
struct dwarf2_section_info *abbrev_section, const gdb_byte *info_ptr,
rcuh_kind section_kind);
static htab_t allocate_dwo_unit_table (struct objfile *objfile);
static struct dwo_unit *lookup_dwo_unit_in_dwp
- (struct dwp_file *dwp_file, const char *comp_dir,
+ (struct dwarf2_per_objfile *dwarf2_per_objfile,
+ struct dwp_file *dwp_file, const char *comp_dir,
ULONGEST signature, int is_debug_types);
-static struct dwp_file *get_dwp_file (void);
+static struct dwp_file *get_dwp_file
+ (struct dwarf2_per_objfile *dwarf2_per_objfile);
static struct dwo_unit *lookup_dwo_comp_unit
(struct dwarf2_per_cu_data *, const char *, const char *, ULONGEST);
static void free_dwo_file_cleanup (void *);
-static void process_cu_includes (void);
+struct free_dwo_file_cleanup_data
+{
+ struct dwo_file *dwo_file;
+ struct dwarf2_per_objfile *dwarf2_per_objfile;
+};
+
+static void process_cu_includes (struct dwarf2_per_objfile *dwarf2_per_objfile);
static void check_producer (struct dwarf2_cu *cu);
if (objfile->flags & OBJF_READNEVER)
return 0;
- dwarf2_per_objfile = ((struct dwarf2_per_objfile *)
- objfile_data (objfile, dwarf2_objfile_data_key));
- if (!dwarf2_per_objfile)
+ struct dwarf2_per_objfile *dwarf2_per_objfile
+ = get_dwarf2_per_objfile (objfile);
+
+ if (dwarf2_per_objfile == NULL)
{
/* Initialize per-objfile state. */
struct dwarf2_per_objfile *data
= XOBNEW (&objfile->objfile_obstack, struct dwarf2_per_objfile);
dwarf2_per_objfile = new (data) struct dwarf2_per_objfile (objfile, names);
- set_objfile_data (objfile, dwarf2_objfile_data_key, dwarf2_per_objfile);
+ set_dwarf2_per_objfile (objfile, dwarf2_per_objfile);
}
return (!dwarf2_per_objfile->info.is_virtual
&& dwarf2_per_objfile->info.s.section != NULL
is such a section but the file cannot be found. */
static struct dwz_file *
-dwarf2_get_dwz_file (void)
+dwarf2_get_dwz_file (struct dwarf2_per_objfile *dwarf2_per_objfile)
{
const char *filename;
struct dwz_file *result;
dw2_do_instantiate_symtab (struct dwarf2_per_cu_data *per_cu)
{
struct cleanup *back_to;
+ struct dwarf2_per_objfile *dwarf2_per_objfile = per_cu->dwarf2_per_objfile;
/* Skip type_unit_groups, reading the type units they contain
is handled elsewhere. */
&& dwarf2_per_objfile->index_table != NULL
&& dwarf2_per_objfile->index_table->version <= 7
/* DWP files aren't supported yet. */
- && get_dwp_file () == NULL)
+ && get_dwp_file (dwarf2_per_objfile) == NULL)
queue_and_load_all_dwo_tus (per_cu);
}
- process_queue ();
+ process_queue (dwarf2_per_objfile);
/* Age the cache, releasing compilation units that have not
been used recently. */
- age_cached_comp_units ();
+ age_cached_comp_units (dwarf2_per_objfile);
do_cleanups (back_to);
}
static struct compunit_symtab *
dw2_instantiate_symtab (struct dwarf2_per_cu_data *per_cu)
{
+ struct dwarf2_per_objfile *dwarf2_per_objfile = per_cu->dwarf2_per_objfile;
+
gdb_assert (dwarf2_per_objfile->using_index);
if (!per_cu->v.quick->compunit_symtab)
{
- struct cleanup *back_to = make_cleanup (free_cached_comp_units, NULL);
+ struct cleanup *back_to = make_cleanup (free_cached_comp_units,
+ dwarf2_per_objfile);
scoped_restore decrementer = increment_reading_symtab ();
dw2_do_instantiate_symtab (per_cu);
- process_cu_includes ();
+ process_cu_includes (dwarf2_per_objfile);
do_cleanups (back_to);
}
*/
static struct dwarf2_per_cu_data *
-dw2_get_cutu (int index)
+dw2_get_cutu (struct dwarf2_per_objfile *dwarf2_per_objfile,
+ int index)
{
if (index >= dwarf2_per_objfile->n_comp_units)
{
refers to a CU. */
static struct dwarf2_per_cu_data *
-dw2_get_cu (int index)
+dw2_get_cu (struct dwarf2_per_objfile *dwarf2_per_objfile, int index)
{
gdb_assert (index >= 0 && index < dwarf2_per_objfile->n_comp_units);
values. */
static dwarf2_per_cu_data *
-create_cu_from_index_list (struct objfile *objfile,
+create_cu_from_index_list (struct dwarf2_per_objfile *dwarf2_per_objfile,
struct dwarf2_section_info *section,
int is_dwz,
sect_offset sect_off, ULONGEST length)
{
+ struct objfile *objfile = dwarf2_per_objfile->objfile;
dwarf2_per_cu_data *the_cu
= OBSTACK_ZALLOC (&objfile->objfile_obstack,
struct dwarf2_per_cu_data);
int base_offset)
{
offset_type i;
+ struct dwarf2_per_objfile *dwarf2_per_objfile
+ = get_dwarf2_per_objfile (objfile);
for (i = 0; i < n_elements; i += 2)
{
cu_list += 2 * 8;
dwarf2_per_objfile->all_comp_units[base_offset + i / 2]
- = create_cu_from_index_list (objfile, section, is_dwz, sect_off, length);
+ = create_cu_from_index_list (dwarf2_per_objfile, section, is_dwz,
+ sect_off, length);
}
}
const gdb_byte *dwz_list, offset_type dwz_elements)
{
struct dwz_file *dwz;
+ struct dwarf2_per_objfile *dwarf2_per_objfile
+ = get_dwarf2_per_objfile (objfile);
dwarf2_per_objfile->n_comp_units = (cu_list_elements + dwz_elements) / 2;
dwarf2_per_objfile->all_comp_units =
if (dwz_elements == 0)
return;
- dwz = dwarf2_get_dwz_file ();
+ dwz = dwarf2_get_dwz_file (dwarf2_per_objfile);
create_cus_from_index_list (objfile, dwz_list, dwz_elements, &dwz->info, 1,
cu_list_elements / 2);
}
{
offset_type i;
htab_t sig_types_hash;
+ struct dwarf2_per_objfile *dwarf2_per_objfile
+ = get_dwarf2_per_objfile (objfile);
dwarf2_per_objfile->n_type_units
= dwarf2_per_objfile->n_allocated_type_units
static void
create_signatured_type_table_from_debug_names
- (struct objfile *objfile,
+ (struct dwarf2_per_objfile *dwarf2_per_objfile,
const mapped_debug_names &map,
struct dwarf2_section_info *section,
struct dwarf2_section_info *abbrev_section)
{
+ struct objfile *objfile = dwarf2_per_objfile->objfile;
+
dwarf2_read_section (objfile, section);
dwarf2_read_section (objfile, abbrev_section);
map.dwarf5_byte_order));
comp_unit_head cu_header;
- read_and_check_comp_unit_head (&cu_header, section, abbrev_section,
+ read_and_check_comp_unit_head (dwarf2_per_objfile, &cu_header, section,
+ abbrev_section,
section->buffer + to_underlying (sect_off),
rcuh_kind::TYPE);
populate the objfile's psymtabs_addrmap. */
static void
-create_addrmap_from_index (struct objfile *objfile, struct mapped_index *index)
+create_addrmap_from_index (struct dwarf2_per_objfile *dwarf2_per_objfile,
+ struct mapped_index *index)
{
+ struct objfile *objfile = dwarf2_per_objfile->objfile;
struct gdbarch *gdbarch = get_objfile_arch (objfile);
const gdb_byte *iter, *end;
struct addrmap *mutable_map;
lo = gdbarch_adjust_dwarf2_addr (gdbarch, lo + baseaddr);
hi = gdbarch_adjust_dwarf2_addr (gdbarch, hi + baseaddr);
- addrmap_set_empty (mutable_map, lo, hi - 1, dw2_get_cutu (cu_index));
+ addrmap_set_empty (mutable_map, lo, hi - 1,
+ dw2_get_cutu (dwarf2_per_objfile, cu_index));
}
objfile->psymtabs_addrmap = addrmap_create_fixed (mutable_map,
populate the objfile's psymtabs_addrmap. */
static void
-create_addrmap_from_aranges (struct objfile *objfile,
+create_addrmap_from_aranges (struct dwarf2_per_objfile *dwarf2_per_objfile,
struct dwarf2_section_info *section)
{
+ struct objfile *objfile = dwarf2_per_objfile->objfile;
bfd *abfd = objfile->obfd;
struct gdbarch *gdbarch = get_objfile_arch (objfile);
const CORE_ADDR baseaddr = ANOFFSET (objfile->section_offsets,
debug_info_offset_to_per_cu;
for (int cui = 0; cui < dwarf2_per_objfile->n_comp_units; ++cui)
{
- dwarf2_per_cu_data *per_cu = dw2_get_cutu (cui);
+ dwarf2_per_cu_data *per_cu = dw2_get_cutu (dwarf2_per_objfile, cui);
const auto insertpair
= debug_info_offset_to_per_cu.emplace (per_cu->sect_off, per_cu);
if (!insertpair.second)
const gdb_byte *cu_list, *types_list, *dwz_list = NULL;
offset_type cu_list_elements, types_list_elements, dwz_list_elements = 0;
struct dwz_file *dwz;
+ struct dwarf2_per_objfile *dwarf2_per_objfile
+ = get_dwarf2_per_objfile (objfile);
if (!read_index_from_section (objfile, objfile_name (objfile),
use_deprecated_index_sections,
/* If there is a .dwz file, read it so we can get its CU list as
well. */
- dwz = dwarf2_get_dwz_file ();
+ dwz = dwarf2_get_dwz_file (dwarf2_per_objfile);
if (dwz != NULL)
{
struct mapped_index dwz_map;
types_list_elements);
}
- create_addrmap_from_index (objfile, &local_map);
+ create_addrmap_from_index (dwarf2_per_objfile, &local_map);
map = XOBNEW (&objfile->objfile_obstack, struct mapped_index);
map = new (map) mapped_index ();
return 1;
}
-/* A helper for the "quick" functions which sets the global
- dwarf2_per_objfile according to OBJFILE. */
-
-static void
-dw2_setup (struct objfile *objfile)
-{
- dwarf2_per_objfile = ((struct dwarf2_per_objfile *)
- objfile_data (objfile, dwarf2_objfile_data_key));
- gdb_assert (dwarf2_per_objfile);
-}
-
/* die_reader_func for dw2_get_file_names. */
static void
void *data)
{
struct dwarf2_cu *cu = reader->cu;
- struct dwarf2_per_cu_data *this_cu = cu->per_cu;
+ struct dwarf2_per_cu_data *this_cu = cu->per_cu;
+ struct dwarf2_per_objfile *dwarf2_per_objfile = cu->dwarf2_per_objfile;
struct objfile *objfile = dwarf2_per_objfile->objfile;
struct dwarf2_per_cu_data *lh_cu;
struct attribute *attr;
static struct symtab *
dw2_find_last_source_symtab (struct objfile *objfile)
{
- struct compunit_symtab *cust;
- int index;
+ struct dwarf2_per_objfile *dwarf2_per_objfile
+ = get_dwarf2_per_objfile (objfile);
+ int index = dwarf2_per_objfile->n_comp_units - 1;
+ dwarf2_per_cu_data *dwarf_cu = dw2_get_cutu (dwarf2_per_objfile, index);
+ compunit_symtab *cust = dw2_instantiate_symtab (dwarf_cu);
- dw2_setup (objfile);
- index = dwarf2_per_objfile->n_comp_units - 1;
- cust = dw2_instantiate_symtab (dw2_get_cutu (index));
if (cust == NULL)
return NULL;
+
return compunit_primary_filetab (cust);
}
static void
dw2_forget_cached_source_info (struct objfile *objfile)
{
- dw2_setup (objfile);
+ struct dwarf2_per_objfile *dwarf2_per_objfile
+ = get_dwarf2_per_objfile (objfile);
htab_traverse_noresize (dwarf2_per_objfile->quick_file_names_table,
dw2_free_cached_file_names, NULL);
{
int i;
const char *name_basename = lbasename (name);
-
- dw2_setup (objfile);
+ struct dwarf2_per_objfile *dwarf2_per_objfile
+ = get_dwarf2_per_objfile (objfile);
/* The rule is CUs specify all the files, including those used by
any TU, so there's no need to scan TUs here. */
- for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
+ for (int i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
{
int j;
- struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i);
+ struct dwarf2_per_cu_data *per_cu = dw2_get_cu (dwarf2_per_objfile, i);
struct quick_file_names *file_data;
/* We only need to look at symtabs not already expanded. */
struct dw2_symtab_iterator
{
- /* The internalized form of .gdb_index. */
- struct mapped_index *index;
+ /* The dwarf2_per_objfile owning the CUs we are iterating on. */
+ struct dwarf2_per_objfile *dwarf2_per_objfile;
/* If non-zero, only look for symbols that match BLOCK_INDEX. */
int want_specific_block;
/* One of GLOBAL_BLOCK or STATIC_BLOCK.
static void
dw2_symtab_iter_init (struct dw2_symtab_iterator *iter,
- struct mapped_index *index,
+ struct dwarf2_per_objfile *dwarf2_per_objfile,
int want_specific_block,
int block_index,
domain_enum domain,
const char *name)
{
- iter->index = index;
+ iter->dwarf2_per_objfile = dwarf2_per_objfile;
iter->want_specific_block = want_specific_block;
iter->block_index = block_index;
iter->domain = domain;
iter->next = 0;
iter->global_seen = 0;
- if (find_slot_in_mapped_hash (index, name, &iter->vec))
+ mapped_index *index = dwarf2_per_objfile->index_table;
+
+ /* index is NULL if OBJF_READNOW. */
+ if (index != NULL && find_slot_in_mapped_hash (index, name, &iter->vec))
iter->length = MAYBE_SWAP (*iter->vec);
else
{
static struct dwarf2_per_cu_data *
dw2_symtab_iter_next (struct dw2_symtab_iterator *iter)
{
+ struct dwarf2_per_objfile *dwarf2_per_objfile = iter->dwarf2_per_objfile;
+
for ( ; iter->next < iter->length; ++iter->next)
{
offset_type cu_index_and_attrs =
and indices >= 7 may elide them for certain symbols
(gold does this). */
int attrs_valid =
- (iter->index->version >= 7
+ (dwarf2_per_objfile->index_table->version >= 7
&& symbol_kind != GDB_INDEX_SYMBOL_KIND_NONE);
/* Don't crash on bad data. */
continue;
}
- per_cu = dw2_get_cutu (cu_index);
+ per_cu = dw2_get_cutu (dwarf2_per_objfile, cu_index);
/* Skip if already read in. */
if (per_cu->v.quick->compunit_symtab)
const char *name, domain_enum domain)
{
struct compunit_symtab *stab_best = NULL;
- struct mapped_index *index;
-
- dw2_setup (objfile);
+ struct dwarf2_per_objfile *dwarf2_per_objfile
+ = get_dwarf2_per_objfile (objfile);
lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
- index = dwarf2_per_objfile->index_table;
-
- /* index is NULL if OBJF_READNOW. */
- if (index)
- {
- struct dw2_symtab_iterator iter;
- struct dwarf2_per_cu_data *per_cu;
+ struct dw2_symtab_iterator iter;
+ struct dwarf2_per_cu_data *per_cu;
- dw2_symtab_iter_init (&iter, index, 1, block_index, domain, name);
+ dw2_symtab_iter_init (&iter, dwarf2_per_objfile, 1, block_index, domain, name);
- while ((per_cu = dw2_symtab_iter_next (&iter)) != NULL)
- {
- struct symbol *sym, *with_opaque = NULL;
- struct compunit_symtab *stab = dw2_instantiate_symtab (per_cu);
- const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (stab);
- struct block *block = BLOCKVECTOR_BLOCK (bv, block_index);
+ while ((per_cu = dw2_symtab_iter_next (&iter)) != NULL)
+ {
+ struct symbol *sym, *with_opaque = NULL;
+ struct compunit_symtab *stab = dw2_instantiate_symtab (per_cu);
+ const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (stab);
+ struct block *block = BLOCKVECTOR_BLOCK (bv, block_index);
- sym = block_find_symbol (block, name, domain,
- block_find_non_opaque_type_preferred,
- &with_opaque);
+ sym = block_find_symbol (block, name, domain,
+ block_find_non_opaque_type_preferred,
+ &with_opaque);
- /* Some caution must be observed with overloaded functions
- and methods, since the index will not contain any overload
- information (but NAME might contain it). */
+ /* Some caution must be observed with overloaded functions
+ and methods, since the index will not contain any overload
+ information (but NAME might contain it). */
- if (sym != NULL
- && SYMBOL_MATCHES_SEARCH_NAME (sym, lookup_name))
- return stab;
- if (with_opaque != NULL
- && SYMBOL_MATCHES_SEARCH_NAME (with_opaque, lookup_name))
- stab_best = stab;
+ if (sym != NULL
+ && SYMBOL_MATCHES_SEARCH_NAME (sym, lookup_name))
+ return stab;
+ if (with_opaque != NULL
+ && SYMBOL_MATCHES_SEARCH_NAME (with_opaque, lookup_name))
+ stab_best = stab;
- /* Keep looking through other CUs. */
- }
+ /* Keep looking through other CUs. */
}
return stab_best;
static void
dw2_print_stats (struct objfile *objfile)
{
- int i, total, count;
+ struct dwarf2_per_objfile *dwarf2_per_objfile
+ = get_dwarf2_per_objfile (objfile);
+ int total = dwarf2_per_objfile->n_comp_units + dwarf2_per_objfile->n_type_units;
+ int count = 0;
- dw2_setup (objfile);
- total = dwarf2_per_objfile->n_comp_units + dwarf2_per_objfile->n_type_units;
- count = 0;
- for (i = 0; i < total; ++i)
+ for (int i = 0; i < total; ++i)
{
- struct dwarf2_per_cu_data *per_cu = dw2_get_cutu (i);
+ struct dwarf2_per_cu_data *per_cu = dw2_get_cutu (dwarf2_per_objfile, i);
if (!per_cu->v.quick->compunit_symtab)
++count;
static void
dw2_dump (struct objfile *objfile)
{
- dw2_setup (objfile);
+ struct dwarf2_per_objfile *dwarf2_per_objfile
+ = get_dwarf2_per_objfile (objfile);
+
gdb_assert (dwarf2_per_objfile->using_index);
printf_filtered (".gdb_index:");
if (dwarf2_per_objfile->index_table != NULL)
dw2_expand_symtabs_for_function (struct objfile *objfile,
const char *func_name)
{
- struct mapped_index *index;
-
- dw2_setup (objfile);
+ struct dwarf2_per_objfile *dwarf2_per_objfile
+ = get_dwarf2_per_objfile (objfile);
- index = dwarf2_per_objfile->index_table;
+ struct dw2_symtab_iterator iter;
+ struct dwarf2_per_cu_data *per_cu;
- /* index is NULL if OBJF_READNOW. */
- if (index)
- {
- struct dw2_symtab_iterator iter;
- struct dwarf2_per_cu_data *per_cu;
+ /* Note: It doesn't matter what we pass for block_index here. */
+ dw2_symtab_iter_init (&iter, dwarf2_per_objfile, 0, GLOBAL_BLOCK, VAR_DOMAIN,
+ func_name);
- /* Note: It doesn't matter what we pass for block_index here. */
- dw2_symtab_iter_init (&iter, index, 0, GLOBAL_BLOCK, VAR_DOMAIN,
- func_name);
+ while ((per_cu = dw2_symtab_iter_next (&iter)) != NULL)
+ dw2_instantiate_symtab (per_cu);
- while ((per_cu = dw2_symtab_iter_next (&iter)) != NULL)
- dw2_instantiate_symtab (per_cu);
- }
}
static void
dw2_expand_all_symtabs (struct objfile *objfile)
{
- int i;
+ struct dwarf2_per_objfile *dwarf2_per_objfile
+ = get_dwarf2_per_objfile (objfile);
+ int total_units = (dwarf2_per_objfile->n_comp_units
+ + dwarf2_per_objfile->n_type_units);
- dw2_setup (objfile);
-
- for (i = 0; i < (dwarf2_per_objfile->n_comp_units
- + dwarf2_per_objfile->n_type_units); ++i)
+ for (int i = 0; i < total_units; ++i)
{
- struct dwarf2_per_cu_data *per_cu = dw2_get_cutu (i);
+ struct dwarf2_per_cu_data *per_cu
+ = dw2_get_cutu (dwarf2_per_objfile, i);
dw2_instantiate_symtab (per_cu);
}
dw2_expand_symtabs_with_fullname (struct objfile *objfile,
const char *fullname)
{
- int i;
-
- dw2_setup (objfile);
+ struct dwarf2_per_objfile *dwarf2_per_objfile
+ = get_dwarf2_per_objfile (objfile);
/* We don't need to consider type units here.
This is only called for examining code, e.g. expand_line_sal.
There can be an order of magnitude (or more) more type units
than comp units, and we avoid them if we can. */
- for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
+ for (int i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
{
int j;
- struct dwarf2_per_cu_data *per_cu = dw2_get_cutu (i);
+ struct dwarf2_per_cu_data *per_cu = dw2_get_cutu (dwarf2_per_objfile, i);
struct quick_file_names *file_data;
/* We only need to look at symtabs not already expanded. */
static void
dw2_expand_marked_cus
- (mapped_index &index, offset_type idx,
- struct objfile *objfile,
+ (struct dwarf2_per_objfile *dwarf2_per_objfile, offset_type idx,
gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher,
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
search_domain kind)
{
offset_type *vec, vec_len, vec_idx;
bool global_seen = false;
+ mapped_index &index = *dwarf2_per_objfile->index_table;
vec = (offset_type *) (index.constant_pool
+ MAYBE_SWAP (index.symbol_table[idx].vec));
{
complaint (&symfile_complaints,
_(".gdb_index entry has bad CU index"
- " [in module %s]"), objfile_name (objfile));
+ " [in module %s]"),
+ objfile_name (dwarf2_per_objfile->objfile));
continue;
}
- per_cu = dw2_get_cutu (cu_index);
+ per_cu = dw2_get_cutu (dwarf2_per_objfile, cu_index);
dw2_expand_symtabs_matching_one (per_cu, file_matcher,
expansion_notify);
}
static void
dw_expand_symtabs_matching_file_matcher
- (gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher)
+ (struct dwarf2_per_objfile *dwarf2_per_objfile,
+ gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher)
{
if (file_matcher == NULL)
return;
for (int i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
{
int j;
- struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i);
+ struct dwarf2_per_cu_data *per_cu = dw2_get_cu (dwarf2_per_objfile, i);
struct quick_file_names *file_data;
void **slot;
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
enum search_domain kind)
{
- dw2_setup (objfile);
+ struct dwarf2_per_objfile *dwarf2_per_objfile
+ = get_dwarf2_per_objfile (objfile);
/* index_table is NULL if OBJF_READNOW. */
if (!dwarf2_per_objfile->index_table)
return;
- dw_expand_symtabs_matching_file_matcher (file_matcher);
+ dw_expand_symtabs_matching_file_matcher (dwarf2_per_objfile, file_matcher);
mapped_index &index = *dwarf2_per_objfile->index_table;
symbol_matcher,
kind, [&] (offset_type idx)
{
- dw2_expand_marked_cus (index, idx, objfile, file_matcher,
+ dw2_expand_marked_cus (dwarf2_per_objfile, idx, file_matcher,
expansion_notify, kind);
});
}
struct dwarf2_per_cu_data *data;
struct compunit_symtab *result;
- dw2_setup (objfile);
-
if (!objfile->psymtabs_addrmap)
return NULL;
dw2_map_symbol_filenames (struct objfile *objfile, symbol_filename_ftype *fun,
void *data, int need_fullname)
{
- dw2_setup (objfile);
+ struct dwarf2_per_objfile *dwarf2_per_objfile
+ = get_dwarf2_per_objfile (objfile);
if (!dwarf2_per_objfile->filenames_cache)
{
for (int i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
{
- struct dwarf2_per_cu_data *per_cu = dw2_get_cutu (i);
+ dwarf2_per_cu_data *per_cu = dw2_get_cutu (dwarf2_per_objfile, i);
if (per_cu->v.quick->compunit_symtab)
{
for (int i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
{
- struct dwarf2_per_cu_data *per_cu = dw2_get_cu (i);
+ dwarf2_per_cu_data *per_cu = dw2_get_cu (dwarf2_per_objfile, i);
struct quick_file_names *file_data;
void **slot;
list. */
static void
-create_cus_from_debug_names_list (struct objfile *objfile,
+create_cus_from_debug_names_list (struct dwarf2_per_objfile *dwarf2_per_objfile,
const mapped_debug_names &map,
dwarf2_section_info §ion,
bool is_dwz, int base_offset)
{
const ULONGEST length = sect_off_next - sect_off_prev;
dwarf2_per_objfile->all_comp_units[base_offset + (i - 1)]
- = create_cu_from_index_list (objfile, §ion, is_dwz,
+ = create_cu_from_index_list (dwarf2_per_objfile, §ion, is_dwz,
sect_off_prev, length);
}
sect_off_prev = sect_off_next;
}
/* Read the CU list from the mapped index, and use it to create all
- the CU objects for this objfile. */
+ the CU objects for this dwarf2_per_objfile. */
static void
-create_cus_from_debug_names (struct objfile *objfile,
+create_cus_from_debug_names (struct dwarf2_per_objfile *dwarf2_per_objfile,
const mapped_debug_names &map,
const mapped_debug_names &dwz_map)
{
+ struct objfile *objfile = dwarf2_per_objfile->objfile;
dwarf2_per_objfile->n_comp_units = map.cu_count + dwz_map.cu_count;
dwarf2_per_objfile->all_comp_units
= XOBNEWVEC (&objfile->objfile_obstack, struct dwarf2_per_cu_data *,
dwarf2_per_objfile->n_comp_units);
- create_cus_from_debug_names_list (objfile, map, dwarf2_per_objfile->info,
+ create_cus_from_debug_names_list (dwarf2_per_objfile, map,
+ dwarf2_per_objfile->info,
false /* is_dwz */,
0 /* base_offset */);
if (dwz_map.cu_count == 0)
return;
- dwz_file *dwz = dwarf2_get_dwz_file ();
- create_cus_from_debug_names_list (objfile, dwz_map, dwz->info,
+ dwz_file *dwz = dwarf2_get_dwz_file (dwarf2_per_objfile);
+ create_cus_from_debug_names_list (dwarf2_per_objfile, dwz_map, dwz->info,
true /* is_dwz */,
map.cu_count /* base_offset */);
}
elements of all the CUs and return true. Otherwise, return false. */
static bool
-dwarf2_read_debug_names (struct objfile *objfile)
+dwarf2_read_debug_names (struct dwarf2_per_objfile *dwarf2_per_objfile)
{
- mapped_debug_names local_map, dwz_map;
+ mapped_debug_names local_map (dwarf2_per_objfile);
+ mapped_debug_names dwz_map (dwarf2_per_objfile);
+ struct objfile *objfile = dwarf2_per_objfile->objfile;
if (!read_debug_names_from_section (objfile, objfile_name (objfile),
&dwarf2_per_objfile->debug_names,
/* If there is a .dwz file, read it so we can get its CU list as
well. */
- dwz_file *dwz = dwarf2_get_dwz_file ();
+ dwz_file *dwz = dwarf2_get_dwz_file (dwarf2_per_objfile);
if (dwz != NULL)
{
if (!read_debug_names_from_section (objfile,
}
}
- create_cus_from_debug_names (objfile, local_map, dwz_map);
+ create_cus_from_debug_names (dwarf2_per_objfile, local_map, dwz_map);
if (local_map.tu_count != 0)
{
dwarf2_per_objfile->types, 0);
create_signatured_type_table_from_debug_names
- (objfile, local_map, section, &dwarf2_per_objfile->abbrev);
+ (dwarf2_per_objfile, local_map, section, &dwarf2_per_objfile->abbrev);
}
- create_addrmap_from_aranges (objfile, &dwarf2_per_objfile->debug_aranges);
+ create_addrmap_from_aranges (dwarf2_per_objfile,
+ &dwarf2_per_objfile->debug_aranges);
- dwarf2_per_objfile->debug_names_table.reset (new mapped_debug_names);
+ dwarf2_per_objfile->debug_names_table.reset
+ (new mapped_debug_names (dwarf2_per_objfile));
*dwarf2_per_objfile->debug_names_table = std::move (local_map);
dwarf2_per_objfile->using_index = 1;
dwarf2_per_objfile->quick_file_names_table =
offset_size,
dwarf5_byte_order);
return read_indirect_string_at_offset
- (dwarf2_per_objfile->objfile->obfd, namei_string_offs);
+ (dwarf2_per_objfile, dwarf2_per_objfile->objfile->obfd, namei_string_offs);
}
/* Find a slot in .debug_names for the object named NAME. If NAME is
_("Wrong .debug_names with name index %u but name_count=%u "
"[in module %s]"),
namei, map.name_count,
- objfile_name (dwarf2_per_objfile->objfile));
+ objfile_name (map.dwarf2_per_objfile->objfile));
return NULL;
}
_("Wrong .debug_names with name index %u but name_count=%u "
"[in module %s]"),
namei, map.name_count,
- objfile_name (dwarf2_per_objfile->objfile));
+ objfile_name (map.dwarf2_per_objfile->objfile));
return NULL;
}
if (m_addr == NULL)
return NULL;
- bfd *const abfd = dwarf2_per_objfile->objfile->obfd;
+ struct dwarf2_per_objfile *dwarf2_per_objfile = m_map.dwarf2_per_objfile;
+ struct objfile *objfile = dwarf2_per_objfile->objfile;
+ bfd *const abfd = objfile->obfd;
again:
complaint (&symfile_complaints,
_("Wrong .debug_names undefined abbrev code %s "
"[in module %s]"),
- pulongest (abbrev), objfile_name (dwarf2_per_objfile->objfile));
+ pulongest (abbrev), objfile_name (objfile));
return NULL;
}
const mapped_debug_names::index_val &indexval = indexval_it->second;
complaint (&symfile_complaints,
_("Unsupported .debug_names form %s [in module %s]"),
dwarf_form_name (attr.form),
- objfile_name (dwarf2_per_objfile->objfile));
+ objfile_name (objfile));
return NULL;
}
switch (attr.dw_idx)
objfile_name (dwarf2_per_objfile->objfile));
continue;
}
- per_cu = dw2_get_cutu (ull);
+ per_cu = dw2_get_cutu (dwarf2_per_objfile, ull);
break;
case DW_IDX_type_unit:
/* Don't crash on bad data. */
objfile_name (dwarf2_per_objfile->objfile));
continue;
}
- per_cu = dw2_get_cutu (dwarf2_per_objfile->n_comp_units + ull);
+ per_cu = dw2_get_cutu (dwarf2_per_objfile,
+ dwarf2_per_objfile->n_comp_units + ull);
break;
case DW_IDX_GNU_internal:
if (!m_map.augmentation_is_gdb)
const char *name, domain_enum domain)
{
const block_enum block_index = static_cast<block_enum> (block_index_int);
- dw2_setup (objfile);
+ struct dwarf2_per_objfile *dwarf2_per_objfile
+ = get_dwarf2_per_objfile (objfile);
const auto &mapp = dwarf2_per_objfile->debug_names_table;
if (!mapp)
static void
dw2_debug_names_dump (struct objfile *objfile)
{
- dw2_setup (objfile);
+ struct dwarf2_per_objfile *dwarf2_per_objfile
+ = get_dwarf2_per_objfile (objfile);
+
gdb_assert (dwarf2_per_objfile->using_index);
printf_filtered (".debug_names:");
if (dwarf2_per_objfile->debug_names_table)
dw2_debug_names_expand_symtabs_for_function (struct objfile *objfile,
const char *func_name)
{
- dw2_setup (objfile);
+ struct dwarf2_per_objfile *dwarf2_per_objfile
+ = get_dwarf2_per_objfile (objfile);
/* dwarf2_per_objfile->debug_names_table is NULL if OBJF_READNOW. */
if (dwarf2_per_objfile->debug_names_table)
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
enum search_domain kind)
{
- dw2_setup (objfile);
+ struct dwarf2_per_objfile *dwarf2_per_objfile
+ = get_dwarf2_per_objfile (objfile);
/* debug_names_table is NULL if OBJF_READNOW. */
if (!dwarf2_per_objfile->debug_names_table)
return;
- dw_expand_symtabs_matching_file_matcher (file_matcher);
+ dw_expand_symtabs_matching_file_matcher (dwarf2_per_objfile, file_matcher);
mapped_debug_names &map = *dwarf2_per_objfile->debug_names_table;
bool
dwarf2_initialize_objfile (struct objfile *objfile, dw_index_kind *index_kind)
{
+ struct dwarf2_per_objfile *dwarf2_per_objfile
+ = get_dwarf2_per_objfile (objfile);
+
/* If we're about to read full symbols, don't bother with the
indices. In this case we also don't care if some other debug
format is making psymtabs, because they are all about to be
int i;
dwarf2_per_objfile->using_index = 1;
- create_all_comp_units (objfile);
- create_all_type_units (objfile);
+ create_all_comp_units (dwarf2_per_objfile);
+ create_all_type_units (dwarf2_per_objfile);
dwarf2_per_objfile->quick_file_names_table =
create_quick_file_names_table (dwarf2_per_objfile->n_comp_units);
for (i = 0; i < (dwarf2_per_objfile->n_comp_units
+ dwarf2_per_objfile->n_type_units); ++i)
{
- struct dwarf2_per_cu_data *per_cu = dw2_get_cutu (i);
+ dwarf2_per_cu_data *per_cu = dw2_get_cutu (dwarf2_per_objfile, i);
per_cu->v.quick = OBSTACK_ZALLOC (&objfile->objfile_obstack,
struct dwarf2_per_cu_quick_data);
return true;
}
- if (dwarf2_read_debug_names (objfile))
+ if (dwarf2_read_debug_names (dwarf2_per_objfile))
{
*index_kind = dw_index_kind::DEBUG_NAMES;
return true;
void
dwarf2_build_psymtabs (struct objfile *objfile)
{
+ struct dwarf2_per_objfile *dwarf2_per_objfile
+ = get_dwarf2_per_objfile (objfile);
if (objfile->global_psymbols.capacity () == 0
&& objfile->static_psymbols.capacity () == 0)
objfile's obstack is still uselessly kept around. However,
freeing it seems unsafe. */
psymtab_discarder psymtabs (objfile);
- dwarf2_build_psymtabs_hard (objfile);
+ dwarf2_build_psymtabs_hard (dwarf2_per_objfile);
psymtabs.keep ();
}
CATCH (except, RETURN_MASK_ERROR)
get_abbrev_section_for_cu (struct dwarf2_per_cu_data *this_cu)
{
struct dwarf2_section_info *abbrev;
+ struct dwarf2_per_objfile *dwarf2_per_objfile = this_cu->dwarf2_per_objfile;
if (this_cu->is_dwz)
- abbrev = &dwarf2_get_dwz_file ()->abbrev;
+ abbrev = &dwarf2_get_dwz_file (dwarf2_per_objfile)->abbrev;
else
abbrev = &dwarf2_per_objfile->abbrev;
Perform various error checking on the header. */
static void
-error_check_comp_unit_head (struct comp_unit_head *header,
+error_check_comp_unit_head (struct dwarf2_per_objfile *dwarf2_per_objfile,
+ struct comp_unit_head *header,
struct dwarf2_section_info *section,
struct dwarf2_section_info *abbrev_section)
{
The result is a pointer to the start of the first DIE. */
static const gdb_byte *
-read_and_check_comp_unit_head (struct comp_unit_head *header,
+read_and_check_comp_unit_head (struct dwarf2_per_objfile *dwarf2_per_objfile,
+ struct comp_unit_head *header,
struct dwarf2_section_info *section,
struct dwarf2_section_info *abbrev_section,
const gdb_byte *info_ptr,
header->first_die_cu_offset = (cu_offset) (info_ptr - beg_of_comp_unit);
- error_check_comp_unit_head (header, section, abbrev_section);
+ error_check_comp_unit_head (dwarf2_per_objfile, header, section,
+ abbrev_section);
return info_ptr;
}
/* Fetch the abbreviation table offset from a comp or type unit header. */
static sect_offset
-read_abbrev_offset (struct dwarf2_section_info *section,
+read_abbrev_offset (struct dwarf2_per_objfile *dwarf2_per_objfile,
+ struct dwarf2_section_info *section,
sect_offset sect_off)
{
bfd *abfd = get_section_bfd_owner (section);
therefore DW_UT_type. */
static void
-create_debug_type_hash_table (struct dwo_file *dwo_file,
+create_debug_type_hash_table (struct dwarf2_per_objfile *dwarf2_per_objfile,
+ struct dwo_file *dwo_file,
dwarf2_section_info *section, htab_t &types_htab,
rcuh_kind section_kind)
{
/* We need to read the type's signature in order to build the hash
table, but we don't need anything else just yet. */
- ptr = read_and_check_comp_unit_head (&header, section,
+ ptr = read_and_check_comp_unit_head (dwarf2_per_objfile, &header, section,
abbrev_section, ptr, section_kind);
length = get_cu_length (&header);
Note: This function processes DWO files only, not DWP files. */
static void
-create_debug_types_hash_table (struct dwo_file *dwo_file,
+create_debug_types_hash_table (struct dwarf2_per_objfile *dwarf2_per_objfile,
+ struct dwo_file *dwo_file,
VEC (dwarf2_section_info_def) *types,
htab_t &types_htab)
{
for (ix = 0;
VEC_iterate (dwarf2_section_info_def, types, ix, section);
++ix)
- create_debug_type_hash_table (dwo_file, section, types_htab,
- rcuh_kind::TYPE);
+ create_debug_type_hash_table (dwarf2_per_objfile, dwo_file, section,
+ types_htab, rcuh_kind::TYPE);
}
/* Create the hash table of all entries in the .debug_types section,
otherwise non-zero. */
static int
-create_all_type_units (struct objfile *objfile)
+create_all_type_units (struct dwarf2_per_objfile *dwarf2_per_objfile)
{
htab_t types_htab = NULL;
struct signatured_type **iter;
- create_debug_type_hash_table (NULL, &dwarf2_per_objfile->info, types_htab,
+ create_debug_type_hash_table (dwarf2_per_objfile, NULL,
+ &dwarf2_per_objfile->info, types_htab,
rcuh_kind::COMPILE);
- create_debug_types_hash_table (NULL, dwarf2_per_objfile->types, types_htab);
+ create_debug_types_hash_table (dwarf2_per_objfile, NULL,
+ dwarf2_per_objfile->types, types_htab);
if (types_htab == NULL)
{
dwarf2_per_objfile->signatured_types = NULL;
Otherwise we find one. */
static struct signatured_type *
-add_type_unit (ULONGEST sig, void **slot)
+add_type_unit (struct dwarf2_per_objfile *dwarf2_per_objfile, ULONGEST sig,
+ void **slot)
{
struct objfile *objfile = dwarf2_per_objfile->objfile;
int n_type_units = dwarf2_per_objfile->n_type_units;
Fill in SIG_ENTRY with DWO_ENTRY. */
static void
-fill_in_sig_entry_from_dwo_entry (struct objfile *objfile,
+fill_in_sig_entry_from_dwo_entry (struct dwarf2_per_objfile *dwarf2_per_objfile,
struct signatured_type *sig_entry,
struct dwo_unit *dwo_entry)
{
static struct signatured_type *
lookup_dwo_signatured_type (struct dwarf2_cu *cu, ULONGEST sig)
{
+ struct dwarf2_per_objfile *dwarf2_per_objfile = cu->dwarf2_per_objfile;
struct objfile *objfile = dwarf2_per_objfile->objfile;
struct dwo_file *dwo_file;
struct dwo_unit find_dwo_entry, *dwo_entry;
/* If the global table doesn't have an entry for this TU, add one. */
if (sig_entry == NULL)
- sig_entry = add_type_unit (sig, slot);
+ sig_entry = add_type_unit (dwarf2_per_objfile, sig, slot);
- fill_in_sig_entry_from_dwo_entry (objfile, sig_entry, dwo_entry);
+ fill_in_sig_entry_from_dwo_entry (dwarf2_per_objfile, sig_entry, dwo_entry);
sig_entry->per_cu.tu_read = 1;
return sig_entry;
}
static struct signatured_type *
lookup_dwp_signatured_type (struct dwarf2_cu *cu, ULONGEST sig)
{
+ struct dwarf2_per_objfile *dwarf2_per_objfile = cu->dwarf2_per_objfile;
struct objfile *objfile = dwarf2_per_objfile->objfile;
- struct dwp_file *dwp_file = get_dwp_file ();
+ struct dwp_file *dwp_file = get_dwp_file (dwarf2_per_objfile);
struct dwo_unit *dwo_entry;
struct signatured_type find_sig_entry, *sig_entry;
void **slot;
if (dwp_file->tus == NULL)
return NULL;
- dwo_entry = lookup_dwo_unit_in_dwp (dwp_file, NULL,
+ dwo_entry = lookup_dwo_unit_in_dwp (dwarf2_per_objfile, dwp_file, NULL,
sig, 1 /* is_debug_types */);
if (dwo_entry == NULL)
return NULL;
- sig_entry = add_type_unit (sig, slot);
- fill_in_sig_entry_from_dwo_entry (objfile, sig_entry, dwo_entry);
+ sig_entry = add_type_unit (dwarf2_per_objfile, sig, slot);
+ fill_in_sig_entry_from_dwo_entry (dwarf2_per_objfile, sig_entry, dwo_entry);
return sig_entry;
}
static struct signatured_type *
lookup_signatured_type (struct dwarf2_cu *cu, ULONGEST sig)
{
+ struct dwarf2_per_objfile *dwarf2_per_objfile = cu->dwarf2_per_objfile;
+
if (cu->dwo_unit
&& dwarf2_per_objfile->using_index)
{
/* We're in a DWO/DWP file, and we're using .gdb_index.
These cases require special processing. */
- if (get_dwp_file () == NULL)
+ if (get_dwp_file (dwarf2_per_objfile) == NULL)
return lookup_dwo_signatured_type (cu, sig);
else
return lookup_dwp_signatured_type (cu, sig);
struct die_info **result_comp_unit_die,
int *result_has_children)
{
+ struct dwarf2_per_objfile *dwarf2_per_objfile = this_cu->dwarf2_per_objfile;
struct objfile *objfile = dwarf2_per_objfile->objfile;
struct dwarf2_cu *cu = this_cu->cu;
struct dwarf2_section_info *section;
{
struct signatured_type *sig_type = (struct signatured_type *) this_cu;
- info_ptr = read_and_check_comp_unit_head (&cu->header, section,
+ info_ptr = read_and_check_comp_unit_head (dwarf2_per_objfile,
+ &cu->header, section,
dwo_abbrev_section,
info_ptr, rcuh_kind::TYPE);
/* This is not an assert because it can be caused by bad debug info. */
}
else
{
- info_ptr = read_and_check_comp_unit_head (&cu->header, section,
+ info_ptr = read_and_check_comp_unit_head (dwarf2_per_objfile,
+ &cu->header, section,
dwo_abbrev_section,
info_ptr, rcuh_kind::COMPILE);
gdb_assert (dwo_unit->sect_off == cu->header.sect_off);
const gdb_byte *info_ptr;
struct die_info *comp_unit_die;
int has_children;
+ struct dwarf2_per_objfile *dwarf2_per_objfile = this_cu->dwarf2_per_objfile;
/* Verify we can do the following downcast, and that we have the
data we need. */
die_reader_func_ftype *die_reader_func,
void *data)
{
+ struct dwarf2_per_objfile *dwarf2_per_objfile = this_cu->dwarf2_per_objfile;
struct objfile *objfile = dwarf2_per_objfile->objfile;
struct dwarf2_section_info *section = this_cu->section;
bfd *abfd = get_section_bfd_owner (section);
{
if (this_cu->is_debug_types)
{
- info_ptr = read_and_check_comp_unit_head (&cu->header, section,
+ info_ptr = read_and_check_comp_unit_head (dwarf2_per_objfile,
+ &cu->header, section,
abbrev_section, info_ptr,
rcuh_kind::TYPE);
}
else
{
- info_ptr = read_and_check_comp_unit_head (&cu->header, section,
+ info_ptr = read_and_check_comp_unit_head (dwarf2_per_objfile,
+ &cu->header, section,
abbrev_section,
info_ptr,
rcuh_kind::COMPILE);
die_reader_func_ftype *die_reader_func,
void *data)
{
+ struct dwarf2_per_objfile *dwarf2_per_objfile = this_cu->dwarf2_per_objfile;
struct objfile *objfile = dwarf2_per_objfile->objfile;
struct dwarf2_section_info *section = this_cu->section;
bfd *abfd = get_section_bfd_owner (section);
cleanups = make_cleanup (free_stack_comp_unit, &cu);
begin_info_ptr = info_ptr = section->buffer + to_underlying (this_cu->sect_off);
- info_ptr = read_and_check_comp_unit_head (&cu.header, section,
+ info_ptr = read_and_check_comp_unit_head (dwarf2_per_objfile,
+ &cu.header, section,
abbrev_section, info_ptr,
(this_cu->is_debug_types
? rcuh_kind::TYPE
/* Allocate a hash table for type unit groups. */
static htab_t
-allocate_type_unit_groups_table (void)
+allocate_type_unit_groups_table (struct objfile *objfile)
{
return htab_create_alloc_ex (3,
hash_type_unit_group,
eq_type_unit_group,
NULL,
- &dwarf2_per_objfile->objfile->objfile_obstack,
+ &objfile->objfile_obstack,
hashtab_obstack_allocate,
dummy_obstack_deallocate);
}
static struct type_unit_group *
create_type_unit_group (struct dwarf2_cu *cu, sect_offset line_offset_struct)
{
+ struct dwarf2_per_objfile *dwarf2_per_objfile = cu->dwarf2_per_objfile;
struct objfile *objfile = dwarf2_per_objfile->objfile;
struct dwarf2_per_cu_data *per_cu;
struct type_unit_group *tu_group;
static struct type_unit_group *
get_type_unit_group (struct dwarf2_cu *cu, const struct attribute *stmt_list)
{
+ struct dwarf2_per_objfile *dwarf2_per_objfile = cu->dwarf2_per_objfile;
struct tu_stats *tu_stats = &dwarf2_per_objfile->tu_stats;
struct type_unit_group *tu_group;
void **slot;
if (dwarf2_per_objfile->type_unit_groups == NULL)
{
dwarf2_per_objfile->type_unit_groups =
- allocate_type_unit_groups_table ();
+ allocate_type_unit_groups_table (dwarf2_per_objfile->objfile);
}
/* Do we need to create a new group, or can we use an existing one? */
}
/* Age out any secondary CUs. */
- age_cached_comp_units ();
+ age_cached_comp_units (this_cu->dwarf2_per_objfile);
}
/* Reader function for build_type_psymtabs. */
int has_children,
void *data)
{
+ struct dwarf2_per_objfile *dwarf2_per_objfile
+ = reader->cu->dwarf2_per_objfile;
struct objfile *objfile = dwarf2_per_objfile->objfile;
struct dwarf2_cu *cu = reader->cu;
struct dwarf2_per_cu_data *per_cu = cu->per_cu;
dwarf2_per_objfile->type_unit_groups. */
static void
-build_type_psymtabs_1 (void)
+build_type_psymtabs_1 (struct dwarf2_per_objfile *dwarf2_per_objfile)
{
struct tu_stats *tu_stats = &dwarf2_per_objfile->tu_stats;
struct cleanup *cleanups;
sorted_by_abbrev[i].sig_type = sig_type;
sorted_by_abbrev[i].abbrev_offset =
- read_abbrev_offset (sig_type->per_cu.section,
+ read_abbrev_offset (dwarf2_per_objfile,
+ sig_type->per_cu.section,
sig_type->per_cu.sect_off);
}
cleanups = make_cleanup (xfree, sorted_by_abbrev);
}
abbrev_offset = tu->abbrev_offset;
abbrev_table =
- abbrev_table_read_table (&dwarf2_per_objfile->abbrev,
+ abbrev_table_read_table (dwarf2_per_objfile,
+ &dwarf2_per_objfile->abbrev,
abbrev_offset);
++tu_stats->nr_uniq_abbrev_tables;
}
/* Print collected type unit statistics. */
static void
-print_tu_stats (void)
+print_tu_stats (struct dwarf2_per_objfile *dwarf2_per_objfile)
{
struct tu_stats *tu_stats = &dwarf2_per_objfile->tu_stats;
static int
build_type_psymtab_dependencies (void **slot, void *info)
{
+ struct dwarf2_per_objfile *dwarf2_per_objfile
+ = (struct dwarf2_per_objfile *) info;
struct objfile *objfile = dwarf2_per_objfile->objfile;
struct type_unit_group *tu_group = (struct type_unit_group *) *slot;
struct dwarf2_per_cu_data *per_cu = &tu_group->per_cu;
Build partial symbol tables for the .debug_types comp-units. */
static void
-build_type_psymtabs (struct objfile *objfile)
+build_type_psymtabs (struct dwarf2_per_objfile *dwarf2_per_objfile)
{
- if (! create_all_type_units (objfile))
+ if (! create_all_type_units (dwarf2_per_objfile))
return;
- build_type_psymtabs_1 ();
+ build_type_psymtabs_1 (dwarf2_per_objfile);
}
/* Traversal function for process_skeletonless_type_unit.
process_skeletonless_type_unit (void **slot, void *info)
{
struct dwo_unit *dwo_unit = (struct dwo_unit *) *slot;
- struct objfile *objfile = (struct objfile *) info;
+ struct dwarf2_per_objfile *dwarf2_per_objfile
+ = (struct dwarf2_per_objfile *) info;
struct signatured_type find_entry, *entry;
/* If this TU doesn't exist in the global table, add it and read it in. */
if (dwarf2_per_objfile->signatured_types == NULL)
{
dwarf2_per_objfile->signatured_types
- = allocate_signatured_type_table (objfile);
+ = allocate_signatured_type_table (dwarf2_per_objfile->objfile);
}
find_entry.signature = dwo_unit->signature;
/* This does the job that create_all_type_units would have done for
this TU. */
- entry = add_type_unit (dwo_unit->signature, slot);
- fill_in_sig_entry_from_dwo_entry (objfile, entry, dwo_unit);
+ entry = add_type_unit (dwarf2_per_objfile, dwo_unit->signature, slot);
+ fill_in_sig_entry_from_dwo_entry (dwarf2_per_objfile, entry, dwo_unit);
*slot = entry;
/* This does the job that build_type_psymtabs_1 would have done. */
Note: This can't be done until we know what all the DWO files are. */
static void
-process_skeletonless_type_units (struct objfile *objfile)
+process_skeletonless_type_units (struct dwarf2_per_objfile *dwarf2_per_objfile)
{
/* Skeletonless TUs in DWP files without .gdb_index is not supported yet. */
- if (get_dwp_file () == NULL
+ if (get_dwp_file (dwarf2_per_objfile) == NULL
&& dwarf2_per_objfile->dwo_files != NULL)
{
htab_traverse_noresize (dwarf2_per_objfile->dwo_files,
process_dwo_file_for_skeletonless_type_units,
- objfile);
+ dwarf2_per_objfile);
}
}
-/* Compute the 'user' field for each psymtab in OBJFILE. */
+/* Compute the 'user' field for each psymtab in DWARF2_PER_OBJFILE. */
static void
-set_partial_user (struct objfile *objfile)
+set_partial_user (struct dwarf2_per_objfile *dwarf2_per_objfile)
{
int i;
for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
{
- struct dwarf2_per_cu_data *per_cu = dw2_get_cutu (i);
+ struct dwarf2_per_cu_data *per_cu = dw2_get_cutu (dwarf2_per_objfile, i);
struct partial_symtab *pst = per_cu->v.psymtab;
int j;
.debug_info and .debug_abbrev sections. */
static void
-dwarf2_build_psymtabs_hard (struct objfile *objfile)
+dwarf2_build_psymtabs_hard (struct dwarf2_per_objfile *dwarf2_per_objfile)
{
struct cleanup *back_to;
int i;
+ struct objfile *objfile = dwarf2_per_objfile->objfile;
if (dwarf_read_debug)
{
/* Any cached compilation units will be linked by the per-objfile
read_in_chain. Make sure to free them when we're done. */
- back_to = make_cleanup (free_cached_comp_units, NULL);
+ back_to = make_cleanup (free_cached_comp_units, dwarf2_per_objfile);
- build_type_psymtabs (objfile);
+ build_type_psymtabs (dwarf2_per_objfile);
- create_all_comp_units (objfile);
+ create_all_comp_units (dwarf2_per_objfile);
/* Create a temporary address map on a temporary obstack. We later
copy this to the final obstack. */
for (i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
{
- struct dwarf2_per_cu_data *per_cu = dw2_get_cutu (i);
+ struct dwarf2_per_cu_data *per_cu = dw2_get_cutu (dwarf2_per_objfile, i);
process_psymtab_comp_unit (per_cu, 0, language_minimal);
}
/* This has to wait until we read the CUs, we need the list of DWOs. */
- process_skeletonless_type_units (objfile);
+ process_skeletonless_type_units (dwarf2_per_objfile);
/* Now that all TUs have been processed we can fill in the dependencies. */
if (dwarf2_per_objfile->type_unit_groups != NULL)
{
htab_traverse_noresize (dwarf2_per_objfile->type_unit_groups,
- build_type_psymtab_dependencies, NULL);
+ build_type_psymtab_dependencies, dwarf2_per_objfile);
}
if (dwarf_read_debug)
- print_tu_stats ();
+ print_tu_stats (dwarf2_per_objfile);
- set_partial_user (objfile);
+ set_partial_user (dwarf2_per_objfile);
objfile->psymtabs_addrmap = addrmap_create_fixed (objfile->psymtabs_addrmap,
&objfile->objfile_obstack);
}
static void
-read_comp_units_from_section (struct objfile *objfile,
+read_comp_units_from_section (struct dwarf2_per_objfile *dwarf2_per_objfile,
struct dwarf2_section_info *section,
struct dwarf2_section_info *abbrev_section,
unsigned int is_dwz,
struct dwarf2_per_cu_data ***all_comp_units)
{
const gdb_byte *info_ptr;
+ struct objfile *objfile = dwarf2_per_objfile->objfile;
if (dwarf_read_debug)
fprintf_unfiltered (gdb_stdlog, "Reading %s for %s\n",
sect_offset sect_off = (sect_offset) (info_ptr - section->buffer);
comp_unit_head cu_header;
- read_and_check_comp_unit_head (&cu_header, section, abbrev_section,
- info_ptr, rcuh_kind::COMPILE);
+ read_and_check_comp_unit_head (dwarf2_per_objfile, &cu_header, section,
+ abbrev_section, info_ptr,
+ rcuh_kind::COMPILE);
/* Save the compilation unit for later lookup. */
if (cu_header.unit_type != DW_UT_type)
This is only done for -readnow and building partial symtabs. */
static void
-create_all_comp_units (struct objfile *objfile)
+create_all_comp_units (struct dwarf2_per_objfile *dwarf2_per_objfile)
{
int n_allocated;
int n_comp_units;
struct dwarf2_per_cu_data **all_comp_units;
struct dwz_file *dwz;
+ struct objfile *objfile = dwarf2_per_objfile->objfile;
n_comp_units = 0;
n_allocated = 10;
all_comp_units = XNEWVEC (struct dwarf2_per_cu_data *, n_allocated);
- read_comp_units_from_section (objfile, &dwarf2_per_objfile->info,
+ read_comp_units_from_section (dwarf2_per_objfile, &dwarf2_per_objfile->info,
&dwarf2_per_objfile->abbrev, 0,
&n_allocated, &n_comp_units, &all_comp_units);
- dwz = dwarf2_get_dwz_file ();
+ dwz = dwarf2_get_dwz_file (dwarf2_per_objfile);
if (dwz != NULL)
- read_comp_units_from_section (objfile, &dwz->info, &dwz->abbrev, 1,
- &n_allocated, &n_comp_units,
+ read_comp_units_from_section (dwarf2_per_objfile, &dwz->info, &dwz->abbrev,
+ 1, &n_allocated, &n_comp_units,
&all_comp_units);
dwarf2_per_objfile->all_comp_units = XOBNEWVEC (&objfile->objfile_obstack,
per_cu = dwarf2_find_containing_comp_unit
(pdi->d.sect_off, pdi->is_dwz,
- cu->dwarf2_per_objfile->objfile);
+ cu->dwarf2_per_objfile);
/* Go read the partial unit, if needed. */
if (per_cu->v.psymtab == NULL)
static void
add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
{
- struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
+ struct dwarf2_per_objfile *dwarf2_per_objfile = cu->dwarf2_per_objfile;
+ struct objfile *objfile = dwarf2_per_objfile->objfile;
struct gdbarch *gdbarch = get_objfile_arch (objfile);
CORE_ADDR addr = 0;
const char *actual_name = NULL;
dwarf2_read_symtab (struct partial_symtab *self,
struct objfile *objfile)
{
+ struct dwarf2_per_objfile *dwarf2_per_objfile
+ = get_dwarf2_per_objfile (objfile);
+
if (self->readin)
{
warning (_("bug: psymtab for %s is already read in."),
gdb_flush (gdb_stdout);
}
- /* Restore our global data. */
- dwarf2_per_objfile
- = (struct dwarf2_per_objfile *) objfile_data (objfile,
- dwarf2_objfile_data_key);
-
/* If this psymtab is constructed from a debug-only objfile, the
has_section_at_zero flag will not necessarily be correct. We
can get the correct value for this flag by looking at the data
if (objfile->separate_debug_objfile_backlink)
{
struct dwarf2_per_objfile *dpo_backlink
- = ((struct dwarf2_per_objfile *)
- objfile_data (objfile->separate_debug_objfile_backlink,
- dwarf2_objfile_data_key));
+ = get_dwarf2_per_objfile (objfile->separate_debug_objfile_backlink);
dwarf2_per_objfile->has_section_at_zero
= dpo_backlink->has_section_at_zero;
printf_filtered (_("done.\n"));
}
- process_cu_includes ();
+ process_cu_includes (dwarf2_per_objfile);
}
\f
/* Reading in full CUs. */
/* We may arrive here during partial symbol reading, if we need full
DIEs to process an unusual case (e.g. template arguments). Do
not queue PER_CU, just tell our caller to load its DIEs. */
- if (dwarf2_per_objfile->reading_partial_symbols)
+ if (per_cu->dwarf2_per_objfile->reading_partial_symbols)
{
if (per_cu->cu == NULL || per_cu->cu->dies == NULL)
return 1;
/* Process the queue. */
static void
-process_queue (void)
+process_queue (struct dwarf2_per_objfile *dwarf2_per_objfile)
{
struct dwarf2_queue_item *item, *next_item;
static struct compunit_symtab *
get_compunit_symtab (struct dwarf2_per_cu_data *per_cu)
{
- return (dwarf2_per_objfile->using_index
+ return (per_cu->dwarf2_per_objfile->using_index
? per_cu->v.quick->compunit_symtab
: per_cu->v.psymtab->compunit_symtab);
}
/* Now we have a transitive closure of all the included symtabs. */
len = VEC_length (compunit_symtab_ptr, result_symtabs);
cust->includes
- = XOBNEWVEC (&dwarf2_per_objfile->objfile->objfile_obstack,
+ = XOBNEWVEC (&per_cu->dwarf2_per_objfile->objfile->objfile_obstack,
struct compunit_symtab *, len + 1);
for (ix = 0;
VEC_iterate (compunit_symtab_ptr, result_symtabs, ix,
read. */
static void
-process_cu_includes (void)
+process_cu_includes (struct dwarf2_per_objfile *dwarf2_per_objfile)
{
int ix;
struct dwarf2_per_cu_data *iter;
enum language pretend_language)
{
struct dwarf2_cu *cu = per_cu->cu;
- struct objfile *objfile = per_cu->dwarf2_per_objfile->objfile;
+ struct dwarf2_per_objfile *dwarf2_per_objfile = per_cu->dwarf2_per_objfile;
+ struct objfile *objfile = dwarf2_per_objfile->objfile;
struct gdbarch *gdbarch = get_objfile_arch (objfile);
CORE_ADDR lowpc, highpc;
struct compunit_symtab *cust;
enum language pretend_language)
{
struct dwarf2_cu *cu = per_cu->cu;
- struct objfile *objfile = per_cu->dwarf2_per_objfile->objfile;
+ struct dwarf2_per_objfile *dwarf2_per_objfile = per_cu->dwarf2_per_objfile;
+ struct objfile *objfile = dwarf2_per_objfile->objfile;
struct compunit_symtab *cust;
struct cleanup *delayed_list_cleanup;
struct signatured_type *sig_type;
bool is_dwz = (attr->form == DW_FORM_GNU_ref_alt || cu->per_cu->is_dwz);
dwarf2_per_cu_data *per_cu
= dwarf2_find_containing_comp_unit (sect_off, is_dwz,
- cu->dwarf2_per_objfile->objfile);
+ cu->dwarf2_per_objfile);
/* If necessary, add it to the queue and load its DIEs. */
if (maybe_queue_comp_unit (cu, per_cu, cu->language))
handle_DW_AT_stmt_list (struct die_info *die, struct dwarf2_cu *cu,
const char *comp_dir, CORE_ADDR lowpc) /* ARI: editCase function */
{
+ struct dwarf2_per_objfile *dwarf2_per_objfile = cu->dwarf2_per_objfile;
struct objfile *objfile = dwarf2_per_objfile->objfile;
struct attribute *attr;
struct line_header line_header_local;
static void
read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
{
+ struct dwarf2_per_objfile *dwarf2_per_objfile = cu->dwarf2_per_objfile;
struct objfile *objfile = dwarf2_per_objfile->objfile;
struct gdbarch *gdbarch = get_objfile_arch (objfile);
CORE_ADDR lowpc = ((CORE_ADDR) -1);
/* Allocate a hash table for DWO files. */
static htab_t
-allocate_dwo_file_hash_table (void)
+allocate_dwo_file_hash_table (struct objfile *objfile)
{
- struct objfile *objfile = dwarf2_per_objfile->objfile;
-
return htab_create_alloc_ex (41,
hash_dwo_file,
eq_dwo_file,
/* Lookup DWO file DWO_NAME. */
static void **
-lookup_dwo_file_slot (const char *dwo_name, const char *comp_dir)
+lookup_dwo_file_slot (struct dwarf2_per_objfile *dwarf2_per_objfile,
+ const char *dwo_name,
+ const char *comp_dir)
{
struct dwo_file find_entry;
void **slot;
if (dwarf2_per_objfile->dwo_files == NULL)
- dwarf2_per_objfile->dwo_files = allocate_dwo_file_hash_table ();
+ dwarf2_per_objfile->dwo_files
+ = allocate_dwo_file_hash_table (dwarf2_per_objfile->objfile);
memset (&find_entry, 0, sizeof (find_entry));
find_entry.dwo_name = dwo_name;
Note: This function processes DWO files only, not DWP files. */
static void
-create_cus_hash_table (struct dwo_file &dwo_file, dwarf2_section_info §ion,
+create_cus_hash_table (struct dwarf2_per_objfile *dwarf2_per_objfile,
+ struct dwo_file &dwo_file, dwarf2_section_info §ion,
htab_t &cus_htab)
{
struct objfile *objfile = dwarf2_per_objfile->objfile;
Note: This function processes DWP files only, not DWO files. */
static struct dwp_hash_table *
-create_dwp_hash_table (struct dwp_file *dwp_file, int is_debug_types)
+create_dwp_hash_table (struct dwarf2_per_objfile *dwarf2_per_objfile,
+ struct dwp_file *dwp_file, int is_debug_types)
{
struct objfile *objfile = dwarf2_per_objfile->objfile;
bfd *dbfd = dwp_file->dbfd;
This is for DWP version 1 files. */
static struct dwo_unit *
-create_dwo_unit_in_dwp_v1 (struct dwp_file *dwp_file,
+create_dwo_unit_in_dwp_v1 (struct dwarf2_per_objfile *dwarf2_per_objfile,
+ struct dwp_file *dwp_file,
uint32_t unit_index,
const char *comp_dir,
ULONGEST signature, int is_debug_types)
get_section_id (§ions.loc),
get_section_id (§ions.str_offsets));
/* Can we use an existing virtual DWO file? */
- dwo_file_slot = lookup_dwo_file_slot (virtual_dwo_name.c_str (), comp_dir);
+ dwo_file_slot = lookup_dwo_file_slot (dwarf2_per_objfile,
+ virtual_dwo_name.c_str (),
+ comp_dir);
/* Create one if necessary. */
if (*dwo_file_slot == NULL)
{
of just that piece. */
static struct dwarf2_section_info
-create_dwp_v2_section (struct dwarf2_section_info *section,
+create_dwp_v2_section (struct dwarf2_per_objfile *dwarf2_per_objfile,
+ struct dwarf2_section_info *section,
bfd_size_type offset, bfd_size_type size)
{
struct dwarf2_section_info result;
This is for DWP version 2 files. */
static struct dwo_unit *
-create_dwo_unit_in_dwp_v2 (struct dwp_file *dwp_file,
+create_dwo_unit_in_dwp_v2 (struct dwarf2_per_objfile *dwarf2_per_objfile,
+ struct dwp_file *dwp_file,
uint32_t unit_index,
const char *comp_dir,
ULONGEST signature, int is_debug_types)
(long) (sections.str_offsets_size
? sections.str_offsets_offset : 0));
/* Can we use an existing virtual DWO file? */
- dwo_file_slot = lookup_dwo_file_slot (virtual_dwo_name.c_str (), comp_dir);
+ dwo_file_slot = lookup_dwo_file_slot (dwarf2_per_objfile,
+ virtual_dwo_name.c_str (),
+ comp_dir);
/* Create one if necessary. */
if (*dwo_file_slot == NULL)
{
virtual_dwo_name.size ());
dwo_file->comp_dir = comp_dir;
dwo_file->sections.abbrev =
- create_dwp_v2_section (&dwp_file->sections.abbrev,
+ create_dwp_v2_section (dwarf2_per_objfile, &dwp_file->sections.abbrev,
sections.abbrev_offset, sections.abbrev_size);
dwo_file->sections.line =
- create_dwp_v2_section (&dwp_file->sections.line,
+ create_dwp_v2_section (dwarf2_per_objfile, &dwp_file->sections.line,
sections.line_offset, sections.line_size);
dwo_file->sections.loc =
- create_dwp_v2_section (&dwp_file->sections.loc,
+ create_dwp_v2_section (dwarf2_per_objfile, &dwp_file->sections.loc,
sections.loc_offset, sections.loc_size);
dwo_file->sections.macinfo =
- create_dwp_v2_section (&dwp_file->sections.macinfo,
+ create_dwp_v2_section (dwarf2_per_objfile, &dwp_file->sections.macinfo,
sections.macinfo_offset, sections.macinfo_size);
dwo_file->sections.macro =
- create_dwp_v2_section (&dwp_file->sections.macro,
+ create_dwp_v2_section (dwarf2_per_objfile, &dwp_file->sections.macro,
sections.macro_offset, sections.macro_size);
dwo_file->sections.str_offsets =
- create_dwp_v2_section (&dwp_file->sections.str_offsets,
+ create_dwp_v2_section (dwarf2_per_objfile,
+ &dwp_file->sections.str_offsets,
sections.str_offsets_offset,
sections.str_offsets_size);
/* The "str" section is global to the entire DWP file. */
dwo_unit->signature = signature;
dwo_unit->section =
XOBNEW (&objfile->objfile_obstack, struct dwarf2_section_info);
- *dwo_unit->section = create_dwp_v2_section (is_debug_types
+ *dwo_unit->section = create_dwp_v2_section (dwarf2_per_objfile,
+ is_debug_types
? &dwp_file->sections.types
: &dwp_file->sections.info,
sections.info_or_types_offset,
Returns NULL if the signature isn't found. */
static struct dwo_unit *
-lookup_dwo_unit_in_dwp (struct dwp_file *dwp_file, const char *comp_dir,
+lookup_dwo_unit_in_dwp (struct dwarf2_per_objfile *dwarf2_per_objfile,
+ struct dwp_file *dwp_file, const char *comp_dir,
ULONGEST signature, int is_debug_types)
{
const struct dwp_hash_table *dwp_htab =
if (dwp_file->version == 1)
{
- *slot = create_dwo_unit_in_dwp_v1 (dwp_file, unit_index,
+ *slot = create_dwo_unit_in_dwp_v1 (dwarf2_per_objfile,
+ dwp_file, unit_index,
comp_dir, signature,
is_debug_types);
}
else
{
- *slot = create_dwo_unit_in_dwp_v2 (dwp_file, unit_index,
+ *slot = create_dwo_unit_in_dwp_v2 (dwarf2_per_objfile,
+ dwp_file, unit_index,
comp_dir, signature,
is_debug_types);
}
NOTE: This function is derived from symfile_bfd_open. */
static gdb_bfd_ref_ptr
-try_open_dwop_file (const char *file_name, int is_dwp, int search_cwd)
+try_open_dwop_file (struct dwarf2_per_objfile *dwarf2_per_objfile,
+ const char *file_name, int is_dwp, int search_cwd)
{
int desc, flags;
char *absolute_name;
same as symfile_bfd_open. */
static gdb_bfd_ref_ptr
-open_dwo_file (const char *file_name, const char *comp_dir)
+open_dwo_file (struct dwarf2_per_objfile *dwarf2_per_objfile,
+ const char *file_name, const char *comp_dir)
{
if (IS_ABSOLUTE_PATH (file_name))
- return try_open_dwop_file (file_name, 0 /*is_dwp*/, 0 /*search_cwd*/);
+ return try_open_dwop_file (dwarf2_per_objfile, file_name,
+ 0 /*is_dwp*/, 0 /*search_cwd*/);
/* Before trying the search path, try DWO_NAME in COMP_DIR. */
/* NOTE: If comp_dir is a relative path, this will also try the
search path, which seems useful. */
- gdb_bfd_ref_ptr abfd (try_open_dwop_file (path_to_try, 0 /*is_dwp*/,
+ gdb_bfd_ref_ptr abfd (try_open_dwop_file (dwarf2_per_objfile,
+ path_to_try,
+ 0 /*is_dwp*/,
1 /*search_cwd*/));
xfree (path_to_try);
if (abfd != NULL)
if (*debug_file_directory == '\0')
return NULL;
- return try_open_dwop_file (file_name, 0 /*is_dwp*/, 1 /*search_cwd*/);
+ return try_open_dwop_file (dwarf2_per_objfile, file_name,
+ 0 /*is_dwp*/, 1 /*search_cwd*/);
}
/* This function is mapped across the sections and remembers the offset and
open_and_init_dwo_file (struct dwarf2_per_cu_data *per_cu,
const char *dwo_name, const char *comp_dir)
{
+ struct dwarf2_per_objfile *dwarf2_per_objfile = per_cu->dwarf2_per_objfile;
struct objfile *objfile = dwarf2_per_objfile->objfile;
struct dwo_file *dwo_file;
struct cleanup *cleanups;
- gdb_bfd_ref_ptr dbfd (open_dwo_file (dwo_name, comp_dir));
+ gdb_bfd_ref_ptr dbfd (open_dwo_file (dwarf2_per_objfile, dwo_name, comp_dir));
if (dbfd == NULL)
{
if (dwarf_read_debug)
dwo_file->comp_dir = comp_dir;
dwo_file->dbfd = dbfd.release ();
- cleanups = make_cleanup (free_dwo_file_cleanup, dwo_file);
+ free_dwo_file_cleanup_data *cleanup_data = XNEW (free_dwo_file_cleanup_data);
+ cleanup_data->dwo_file = dwo_file;
+ cleanup_data->dwarf2_per_objfile = dwarf2_per_objfile;
+
+ cleanups = make_cleanup (free_dwo_file_cleanup, cleanup_data);
bfd_map_over_sections (dwo_file->dbfd, dwarf2_locate_dwo_sections,
&dwo_file->sections);
- create_cus_hash_table (*dwo_file, dwo_file->sections.info, dwo_file->cus);
+ create_cus_hash_table (dwarf2_per_objfile, *dwo_file, dwo_file->sections.info,
+ dwo_file->cus);
- create_debug_types_hash_table (dwo_file, dwo_file->sections.types,
- dwo_file->tus);
+ create_debug_types_hash_table (dwarf2_per_objfile, dwo_file,
+ dwo_file->sections.types, dwo_file->tus);
discard_cleanups (cleanups);
same as symfile_bfd_open. */
static gdb_bfd_ref_ptr
-open_dwp_file (const char *file_name)
+open_dwp_file (struct dwarf2_per_objfile *dwarf2_per_objfile,
+ const char *file_name)
{
- gdb_bfd_ref_ptr abfd (try_open_dwop_file (file_name, 1 /*is_dwp*/,
+ gdb_bfd_ref_ptr abfd (try_open_dwop_file (dwarf2_per_objfile, file_name,
+ 1 /*is_dwp*/,
1 /*search_cwd*/));
if (abfd != NULL)
return abfd;
/* Don't implicitly search the current directory here.
If the user wants to search "." to handle this case,
it must be added to debug-file-directory. */
- return try_open_dwop_file (lbasename (file_name), 1 /*is_dwp*/,
+ return try_open_dwop_file (dwarf2_per_objfile,
+ lbasename (file_name), 1 /*is_dwp*/,
0 /*search_cwd*/);
}
The result is NULL if it can't be found. */
static struct dwp_file *
-open_and_init_dwp_file (void)
+open_and_init_dwp_file (struct dwarf2_per_objfile *dwarf2_per_objfile)
{
struct objfile *objfile = dwarf2_per_objfile->objfile;
struct dwp_file *dwp_file;
dwp_name += ".dwp";
- gdb_bfd_ref_ptr dbfd (open_dwp_file (dwp_name.c_str ()));
+ gdb_bfd_ref_ptr dbfd (open_dwp_file (dwarf2_per_objfile, dwp_name.c_str ()));
if (dbfd == NULL
&& strcmp (objfile->original_name, objfile_name (objfile)) != 0)
{
/* Try to find .dwp for the binary file after gdb_realpath resolving. */
dwp_name = objfile_name (objfile);
dwp_name += ".dwp";
- dbfd = open_dwp_file (dwp_name.c_str ());
+ dbfd = open_dwp_file (dwarf2_per_objfile, dwp_name.c_str ());
}
if (dbfd == NULL)
bfd_map_over_sections (dwp_file->dbfd, dwarf2_locate_common_dwp_sections,
dwp_file);
- dwp_file->cus = create_dwp_hash_table (dwp_file, 0);
+ dwp_file->cus = create_dwp_hash_table (dwarf2_per_objfile, dwp_file, 0);
- dwp_file->tus = create_dwp_hash_table (dwp_file, 1);
+ dwp_file->tus = create_dwp_hash_table (dwarf2_per_objfile, dwp_file, 1);
/* The DWP file version is stored in the hash table. Oh well. */
if (dwp_file->cus && dwp_file->tus
/* Wrapper around open_and_init_dwp_file, only open it once. */
static struct dwp_file *
-get_dwp_file (void)
+get_dwp_file (struct dwarf2_per_objfile *dwarf2_per_objfile)
{
if (! dwarf2_per_objfile->dwp_checked)
{
- dwarf2_per_objfile->dwp_file = open_and_init_dwp_file ();
+ dwarf2_per_objfile->dwp_file
+ = open_and_init_dwp_file (dwarf2_per_objfile);
dwarf2_per_objfile->dwp_checked = 1;
}
return dwarf2_per_objfile->dwp_file;
const char *dwo_name, const char *comp_dir,
ULONGEST signature, int is_debug_types)
{
+ struct dwarf2_per_objfile *dwarf2_per_objfile = this_unit->dwarf2_per_objfile;
struct objfile *objfile = dwarf2_per_objfile->objfile;
const char *kind = is_debug_types ? "TU" : "CU";
void **dwo_file_slot;
look for the original DWO file. It makes gdb behave differently
depending on whether one is debugging in the build tree. */
- dwp_file = get_dwp_file ();
+ dwp_file = get_dwp_file (dwarf2_per_objfile);
if (dwp_file != NULL)
{
const struct dwp_hash_table *dwp_htab =
if (dwp_htab != NULL)
{
struct dwo_unit *dwo_cutu =
- lookup_dwo_unit_in_dwp (dwp_file, comp_dir,
+ lookup_dwo_unit_in_dwp (dwarf2_per_objfile, dwp_file, comp_dir,
signature, is_debug_types);
if (dwo_cutu != NULL)
{
/* No DWP file, look for the DWO file. */
- dwo_file_slot = lookup_dwo_file_slot (dwo_name, comp_dir);
+ dwo_file_slot = lookup_dwo_file_slot (dwarf2_per_objfile,
+ dwo_name, comp_dir);
if (*dwo_file_slot == NULL)
{
/* Read in the file and build a table of the CUs/TUs it contains. */
struct dwo_file *dwo_file;
gdb_assert (!per_cu->is_debug_types);
- gdb_assert (get_dwp_file () == NULL);
+ gdb_assert (get_dwp_file (per_cu->dwarf2_per_objfile) == NULL);
gdb_assert (per_cu->cu != NULL);
dwo_unit = per_cu->cu->dwo_unit;
static void
free_dwo_file_cleanup (void *arg)
{
- struct dwo_file *dwo_file = (struct dwo_file *) arg;
- struct objfile *objfile = dwarf2_per_objfile->objfile;
+ struct free_dwo_file_cleanup_data *data
+ = (struct free_dwo_file_cleanup_data *) arg;
+ struct objfile *objfile = data->dwarf2_per_objfile->objfile;
- free_dwo_file (dwo_file, objfile);
+ free_dwo_file (data->dwo_file, objfile);
+
+ xfree (data);
}
/* Traversal function for free_dwo_files. */
dwarf2_rnglists_process (unsigned offset, struct dwarf2_cu *cu,
Callback &&callback)
{
- struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
+ struct dwarf2_per_objfile *dwarf2_per_objfile
+ = cu->dwarf2_per_objfile;
+ struct objfile *objfile = dwarf2_per_objfile->objfile;
bfd *obfd = objfile->obfd;
/* Base address selection entry. */
CORE_ADDR base;
dwarf2_ranges_process (unsigned offset, struct dwarf2_cu *cu,
Callback &&callback)
{
- struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
+ struct dwarf2_per_objfile *dwarf2_per_objfile
+ = cu->dwarf2_per_objfile;
+ struct objfile *objfile = dwarf2_per_objfile->objfile;
struct comp_unit_head *cu_header = &cu->header;
bfd *obfd = objfile->obfd;
unsigned int addr_size = cu_header->addr_size;
CORE_ADDR *highpc, struct dwarf2_cu *cu,
struct partial_symtab *pst)
{
+ struct dwarf2_per_objfile *dwarf2_per_objfile = cu->dwarf2_per_objfile;
struct attribute *attr;
struct attribute *attr_high;
CORE_ADDR low = 0;
struct attribute *member_loc,
struct dwarf2_cu *cu)
{
+ struct dwarf2_per_objfile *dwarf2_per_objfile = cu->dwarf2_per_objfile;
struct objfile *objfile = dwarf2_per_objfile->objfile;
struct dwarf2_locexpr_baton *baton;
gdb_byte *ptr;
/* Read in an abbrev table. */
static struct abbrev_table *
-abbrev_table_read_table (struct dwarf2_section_info *section,
+abbrev_table_read_table (struct dwarf2_per_objfile *dwarf2_per_objfile,
+ struct dwarf2_section_info *section,
sect_offset sect_off)
{
struct objfile *objfile = dwarf2_per_objfile->objfile;
struct dwarf2_section_info *abbrev_section)
{
cu->abbrev_table =
- abbrev_table_read_table (abbrev_section, cu->header.abbrev_sect_off);
+ abbrev_table_read_table (cu->dwarf2_per_objfile, abbrev_section,
+ cu->header.abbrev_sect_off);
}
/* Release the memory used by the abbrev table for a compilation unit. */
const gdb_byte *info_ptr)
{
struct dwarf2_cu *cu = reader->cu;
- struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
+ struct dwarf2_per_objfile *dwarf2_per_objfile = cu->dwarf2_per_objfile;
+ struct objfile *objfile = dwarf2_per_objfile->objfile;
const gdb_byte *buffer = reader->buffer;
unsigned int i;
struct attribute attr;
static struct partial_die_info *
find_partial_die (sect_offset sect_off, int offset_in_dwz, struct dwarf2_cu *cu)
{
- struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
+ struct dwarf2_per_objfile *dwarf2_per_objfile = cu->dwarf2_per_objfile;
+ struct objfile *objfile = dwarf2_per_objfile->objfile;
struct dwarf2_per_cu_data *per_cu = NULL;
struct partial_die_info *pd = NULL;
bfd_get_filename (objfile->obfd));
}
per_cu = dwarf2_find_containing_comp_unit (sect_off, offset_in_dwz,
- objfile);
+ dwarf2_per_objfile);
if (per_cu->cu == NULL || per_cu->cu->partial_dies == NULL)
load_partial_comp_unit (per_cu);
children, see if we can determine the namespace from their linkage
name. */
if (cu->language == language_cplus
- && !VEC_empty (dwarf2_section_info_def, dwarf2_per_objfile->types)
+ && !VEC_empty (dwarf2_section_info_def, cu->dwarf2_per_objfile->types)
&& part_die->die_parent == NULL
&& part_die->has_children
&& (part_die->tag == DW_TAG_class_type
LONGEST implicit_const, const gdb_byte *info_ptr)
{
struct dwarf2_cu *cu = reader->cu;
- struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
+ struct dwarf2_per_objfile *dwarf2_per_objfile = cu->dwarf2_per_objfile;
+ struct objfile *objfile = dwarf2_per_objfile->objfile;
struct gdbarch *gdbarch = get_objfile_arch (objfile);
bfd *abfd = reader->abfd;
struct comp_unit_head *cu_header = &cu->header;
case DW_FORM_strp:
if (!cu->per_cu->is_dwz)
{
- DW_STRING (attr) = read_indirect_string (abfd, info_ptr, cu_header,
+ DW_STRING (attr) = read_indirect_string (dwarf2_per_objfile,
+ abfd, info_ptr, cu_header,
&bytes_read);
DW_STRING_IS_CANONICAL (attr) = 0;
info_ptr += bytes_read;
case DW_FORM_line_strp:
if (!cu->per_cu->is_dwz)
{
- DW_STRING (attr) = read_indirect_line_string (abfd, info_ptr,
+ DW_STRING (attr) = read_indirect_line_string (dwarf2_per_objfile,
+ abfd, info_ptr,
cu_header, &bytes_read);
DW_STRING_IS_CANONICAL (attr) = 0;
info_ptr += bytes_read;
/* FALLTHROUGH */
case DW_FORM_GNU_strp_alt:
{
- struct dwz_file *dwz = dwarf2_get_dwz_file ();
+ struct dwz_file *dwz = dwarf2_get_dwz_file (dwarf2_per_objfile);
LONGEST str_offset = read_offset (abfd, info_ptr, cu_header,
&bytes_read);
- DW_STRING (attr) = read_indirect_string_from_dwz (dwz, str_offset);
+ DW_STRING (attr) = read_indirect_string_from_dwz (objfile,
+ dwz, str_offset);
DW_STRING_IS_CANONICAL (attr) = 0;
info_ptr += bytes_read;
}
reporting strings FORM_NAME and SECT_NAME. */
static const char *
-read_indirect_string_at_offset_from (bfd *abfd, LONGEST str_offset,
+read_indirect_string_at_offset_from (struct objfile *objfile,
+ bfd *abfd, LONGEST str_offset,
struct dwarf2_section_info *sect,
const char *form_name,
const char *sect_name)
{
- dwarf2_read_section (dwarf2_per_objfile->objfile, sect);
+ dwarf2_read_section (objfile, sect);
if (sect->buffer == NULL)
error (_("%s used without %s section [in module %s]"),
form_name, sect_name, bfd_get_filename (abfd));
/* Return pointer to string at .debug_str offset STR_OFFSET. */
static const char *
-read_indirect_string_at_offset (bfd *abfd, LONGEST str_offset)
+read_indirect_string_at_offset (struct dwarf2_per_objfile *dwarf2_per_objfile,
+ bfd *abfd, LONGEST str_offset)
{
- return read_indirect_string_at_offset_from (abfd, str_offset,
+ return read_indirect_string_at_offset_from (dwarf2_per_objfile->objfile,
+ abfd, str_offset,
&dwarf2_per_objfile->str,
"DW_FORM_strp", ".debug_str");
}
/* Return pointer to string at .debug_line_str offset STR_OFFSET. */
static const char *
-read_indirect_line_string_at_offset (bfd *abfd, LONGEST str_offset)
+read_indirect_line_string_at_offset (struct dwarf2_per_objfile *dwarf2_per_objfile,
+ bfd *abfd, LONGEST str_offset)
{
- return read_indirect_string_at_offset_from (abfd, str_offset,
+ return read_indirect_string_at_offset_from (dwarf2_per_objfile->objfile,
+ abfd, str_offset,
&dwarf2_per_objfile->line_str,
"DW_FORM_line_strp",
".debug_line_str");
return a pointer to the string. */
static const char *
-read_indirect_string_from_dwz (struct dwz_file *dwz, LONGEST str_offset)
+read_indirect_string_from_dwz (struct objfile *objfile, struct dwz_file *dwz,
+ LONGEST str_offset)
{
- dwarf2_read_section (dwarf2_per_objfile->objfile, &dwz->str);
+ dwarf2_read_section (objfile, &dwz->str);
if (dwz->str.buffer == NULL)
error (_("DW_FORM_GNU_strp_alt used without .debug_str "
Return *BYTES_READ_PTR count of bytes read from BUF. */
static const char *
-read_indirect_string (bfd *abfd, const gdb_byte *buf,
+read_indirect_string (struct dwarf2_per_objfile *dwarf2_per_objfile, bfd *abfd,
+ const gdb_byte *buf,
const struct comp_unit_head *cu_header,
unsigned int *bytes_read_ptr)
{
LONGEST str_offset = read_offset (abfd, buf, cu_header, bytes_read_ptr);
- return read_indirect_string_at_offset (abfd, str_offset);
+ return read_indirect_string_at_offset (dwarf2_per_objfile, abfd, str_offset);
}
/* Return pointer to string at .debug_line_str offset as read from BUF.
Return *BYTES_READ_PTR count of bytes read from BUF. */
static const char *
-read_indirect_line_string (bfd *abfd, const gdb_byte *buf,
+read_indirect_line_string (struct dwarf2_per_objfile *dwarf2_per_objfile,
+ bfd *abfd, const gdb_byte *buf,
const struct comp_unit_head *cu_header,
unsigned int *bytes_read_ptr)
{
LONGEST str_offset = read_offset (abfd, buf, cu_header, bytes_read_ptr);
- return read_indirect_line_string_at_offset (abfd, str_offset);
+ return read_indirect_line_string_at_offset (dwarf2_per_objfile, abfd,
+ str_offset);
}
ULONGEST
ADDR_SIZE is the size of addresses from the CU header. */
static CORE_ADDR
-read_addr_index_1 (unsigned int addr_index, ULONGEST addr_base, int addr_size)
+read_addr_index_1 (struct dwarf2_per_objfile *dwarf2_per_objfile,
+ unsigned int addr_index, ULONGEST addr_base, int addr_size)
{
struct objfile *objfile = dwarf2_per_objfile->objfile;
bfd *abfd = objfile->obfd;
static CORE_ADDR
read_addr_index (struct dwarf2_cu *cu, unsigned int addr_index)
{
- return read_addr_index_1 (addr_index, cu->addr_base, cu->header.addr_size);
+ return read_addr_index_1 (cu->dwarf2_per_objfile, addr_index, cu->addr_base,
+ cu->header.addr_size);
}
/* Given a pointer to an leb128 value, fetch the value from .debug_addr. */
dwarf2_read_addr_index (struct dwarf2_per_cu_data *per_cu,
unsigned int addr_index)
{
- struct objfile *objfile = per_cu->dwarf2_per_objfile->objfile;
+ struct dwarf2_per_objfile *dwarf2_per_objfile = per_cu->dwarf2_per_objfile;
+ struct objfile *objfile = dwarf2_per_objfile->objfile;
struct dwarf2_cu *cu = per_cu->cu;
ULONGEST addr_base;
int addr_size;
- /* This is intended to be called from outside this file. */
- dw2_setup (objfile);
-
/* We need addr_base and addr_size.
If we don't have PER_CU->cu, we have to get it.
Nasty, but the alternative is storing the needed info in PER_CU,
addr_size = aidata.addr_size;
}
- return read_addr_index_1 (addr_index, addr_base, addr_size);
+ return read_addr_index_1 (dwarf2_per_objfile, addr_index, addr_base,
+ addr_size);
}
/* Given a DW_FORM_GNU_str_index, fetch the string.
static const char *
read_str_index (const struct die_reader_specs *reader, ULONGEST str_index)
{
+ struct dwarf2_cu *cu = reader->cu;
+ struct dwarf2_per_objfile *dwarf2_per_objfile = cu->dwarf2_per_objfile;
struct objfile *objfile = dwarf2_per_objfile->objfile;
const char *objf_name = objfile_name (objfile);
bfd *abfd = objfile->obfd;
- struct dwarf2_cu *cu = reader->cu;
struct dwarf2_section_info *str_section = &reader->dwo_file->sections.str;
struct dwarf2_section_info *str_offsets_section =
&reader->dwo_file->sections.str_offsets;
get_debug_line_section (struct dwarf2_cu *cu)
{
struct dwarf2_section_info *section;
+ struct dwarf2_per_objfile *dwarf2_per_objfile = cu->dwarf2_per_objfile;
/* For TUs in DWO files, the DW_AT_stmt_list attribute lives in the
DWO file. */
section = &cu->dwo_unit->dwo_file->sections.line;
else if (cu->per_cu->is_dwz)
{
- struct dwz_file *dwz = dwarf2_get_dwz_file ();
+ struct dwz_file *dwz = dwarf2_get_dwz_file (dwarf2_per_objfile);
section = &dwz->line;
}
format. */
static void
-read_formatted_entries (bfd *abfd, const gdb_byte **bufp,
+read_formatted_entries (struct dwarf2_per_objfile *dwarf2_per_objfile,
+ bfd *abfd, const gdb_byte **bufp,
struct line_header *lh,
const struct comp_unit_head *cu_header,
void (*callback) (struct line_header *lh,
break;
case DW_FORM_line_strp:
- string.emplace (read_indirect_line_string (abfd, buf,
+ string.emplace (read_indirect_line_string (dwarf2_per_objfile,
+ abfd, buf,
cu_header,
&bytes_read));
buf += bytes_read;
const char *cur_dir, *cur_file;
struct dwarf2_section_info *section;
bfd *abfd;
+ struct dwarf2_per_objfile *dwarf2_per_objfile = cu->dwarf2_per_objfile;
section = get_debug_line_section (cu);
dwarf2_read_section (dwarf2_per_objfile->objfile, section);
if (lh->version >= 5)
{
/* Read directory table. */
- read_formatted_entries (abfd, &line_ptr, lh.get (), &cu->header,
+ read_formatted_entries (dwarf2_per_objfile, abfd, &line_ptr, lh.get (),
+ &cu->header,
[] (struct line_header *lh, const char *name,
dir_index d_index, unsigned int mod_time,
unsigned int length)
});
/* Read file name table. */
- read_formatted_entries (abfd, &line_ptr, lh.get (), &cu->header,
+ read_formatted_entries (dwarf2_per_objfile, abfd, &line_ptr, lh.get (),
+ &cu->header,
[] (struct line_header *lh, const char *name,
dir_index d_index, unsigned int mod_time,
unsigned int length)
new_symbol_full (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
struct symbol *space)
{
- struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
+ struct dwarf2_per_objfile *dwarf2_per_objfile = cu->dwarf2_per_objfile;
+ struct objfile *objfile = dwarf2_per_objfile->objfile;
struct gdbarch *gdbarch = get_objfile_arch (objfile);
struct symbol *sym = NULL;
const char *name;
static struct type *
build_error_marker_type (struct dwarf2_cu *cu, struct die_info *die)
{
+ struct dwarf2_per_objfile *dwarf2_per_objfile = cu->dwarf2_per_objfile;
struct objfile *objfile = dwarf2_per_objfile->objfile;
char *message, *saved;
lookup_die_type (struct die_info *die, const struct attribute *attr,
struct dwarf2_cu *cu)
{
- struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
+ struct dwarf2_per_objfile *dwarf2_per_objfile = cu->dwarf2_per_objfile;
+ struct objfile *objfile = dwarf2_per_objfile->objfile;
struct type *this_type;
gdb_assert (attr->name == DW_AT_type
struct dwarf2_per_cu_data *per_cu;
sect_offset sect_off = dwarf2_get_ref_die_offset (attr);
- per_cu = dwarf2_find_containing_comp_unit (sect_off, 1, objfile);
+ per_cu = dwarf2_find_containing_comp_unit (sect_off, 1,
+ dwarf2_per_objfile);
this_type = get_die_type_at_offset (sect_off, per_cu);
}
else if (attr_form_is_ref (attr))
static const char *
determine_prefix (struct die_info *die, struct dwarf2_cu *cu)
{
+ struct dwarf2_per_objfile *dwarf2_per_objfile = cu->dwarf2_per_objfile;
struct die_info *parent, *spec_die;
struct dwarf2_cu *spec_cu;
struct type *parent_type;
{
struct die_info temp_die;
struct dwarf2_cu *target_cu, *cu = *ref_cu;
- struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
+ struct dwarf2_per_objfile *dwarf2_per_objfile = cu->dwarf2_per_objfile;
+ struct objfile *objfile = dwarf2_per_objfile->objfile;
gdb_assert (cu->per_cu != NULL);
struct dwarf2_per_cu_data *per_cu;
per_cu = dwarf2_find_containing_comp_unit (sect_off, offset_in_dwz,
- objfile);
+ dwarf2_per_objfile);
/* If necessary, add it to the queue and load its DIEs. */
if (maybe_queue_comp_unit (cu, per_cu, cu->language))
struct attribute *attr;
struct dwarf2_locexpr_baton retval;
struct objfile *objfile = per_cu->dwarf2_per_objfile->objfile;
-
- dw2_setup (objfile);
+ struct dwarf2_per_objfile *dwarf2_per_objfile
+ = get_dwarf2_per_objfile (objfile);
if (per_cu->cu == NULL)
load_cu (per_cu);
}
retval.per_cu = cu->per_cu;
- age_cached_comp_units ();
+ age_cached_comp_units (dwarf2_per_objfile);
return retval;
}
enum bfd_endian byte_order;
struct objfile *objfile = per_cu->dwarf2_per_objfile->objfile;
- dw2_setup (objfile);
-
if (per_cu->cu == NULL)
load_cu (per_cu);
cu = per_cu->cu;
struct dwarf2_cu *cu;
struct die_info *die;
- dw2_setup (per_cu->dwarf2_per_objfile->objfile);
-
if (per_cu->cu == NULL)
load_cu (per_cu);
cu = per_cu->cu;
dwarf2_get_die_type (cu_offset die_offset,
struct dwarf2_per_cu_data *per_cu)
{
- dw2_setup (per_cu->dwarf2_per_objfile->objfile);
-
sect_offset die_offset_sect = per_cu->sect_off + to_underlying (die_offset);
return get_die_type_at_offset (die_offset_sect, per_cu);
}
to_underlying (temp_die.sect_off));
if (die)
{
+ struct dwarf2_per_objfile *dwarf2_per_objfile
+ = (*ref_cu)->dwarf2_per_objfile;
+
/* For .gdb_index version 7 keep track of included TUs.
http://sourceware.org/bugzilla/show_bug.cgi?id=15021. */
if (dwarf2_per_objfile->index_table != NULL
get_signatured_type (struct die_info *die, ULONGEST signature,
struct dwarf2_cu *cu)
{
+ struct dwarf2_per_objfile *dwarf2_per_objfile = cu->dwarf2_per_objfile;
struct signatured_type *sig_type;
struct dwarf2_cu *type_cu;
struct die_info *type_die;
}
else
{
+ struct dwarf2_per_objfile *dwarf2_per_objfile = cu->dwarf2_per_objfile;
+
complaint (&symfile_complaints,
_("Dwarf Error: DW_AT_signature has bad form %s in DIE"
" at 0x%x [in module %s]"),
including DW_MACRO_import. */
static void
-dwarf_decode_macro_bytes (bfd *abfd,
+dwarf_decode_macro_bytes (struct dwarf2_per_objfile *dwarf2_per_objfile,
+ bfd *abfd,
const gdb_byte *mac_ptr, const gdb_byte *mac_end,
struct macro_source_file *current_file,
struct line_header *lh,
|| macinfo_type == DW_MACRO_undef_sup
|| section_is_dwz)
{
- struct dwz_file *dwz = dwarf2_get_dwz_file ();
+ struct dwz_file *dwz
+ = dwarf2_get_dwz_file (dwarf2_per_objfile);
- body = read_indirect_string_from_dwz (dwz, str_offset);
+ body = read_indirect_string_from_dwz (objfile,
+ dwz, str_offset);
}
else
- body = read_indirect_string_at_offset (abfd, str_offset);
+ body = read_indirect_string_at_offset (dwarf2_per_objfile,
+ abfd, str_offset);
}
is_define = (macinfo_type == DW_MACRO_define
if (macinfo_type == DW_MACRO_import_sup)
{
- struct dwz_file *dwz = dwarf2_get_dwz_file ();
+ struct dwz_file *dwz = dwarf2_get_dwz_file (dwarf2_per_objfile);
dwarf2_read_section (objfile, &dwz->macro);
{
*slot = (void *) new_mac_ptr;
- dwarf_decode_macro_bytes (include_bfd, new_mac_ptr,
+ dwarf_decode_macro_bytes (dwarf2_per_objfile,
+ include_bfd, new_mac_ptr,
include_mac_end, current_file, lh,
section, section_is_gnu, is_dwz,
offset_size, include_hash);
dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset,
int section_is_gnu)
{
+ struct dwarf2_per_objfile *dwarf2_per_objfile = cu->dwarf2_per_objfile;
struct objfile *objfile = dwarf2_per_objfile->objfile;
struct line_header *lh = cu->line_header;
bfd *abfd;
mac_ptr = section->buffer + offset;
slot = htab_find_slot (include_hash.get (), mac_ptr, INSERT);
*slot = (void *) mac_ptr;
- dwarf_decode_macro_bytes (abfd, mac_ptr, mac_end,
+ dwarf_decode_macro_bytes (dwarf2_per_objfile,
+ abfd, mac_ptr, mac_end,
current_file, lh, section,
section_is_gnu, 0, offset_size,
include_hash.get ());
static struct dwarf2_section_info *
cu_debug_loc_section (struct dwarf2_cu *cu)
{
+ struct dwarf2_per_objfile *dwarf2_per_objfile = cu->dwarf2_per_objfile;
+
if (cu->dwo_unit)
{
struct dwo_sections *sections = &cu->dwo_unit->dwo_file->sections;
struct dwarf2_loclist_baton *baton,
const struct attribute *attr)
{
+ struct dwarf2_per_objfile *dwarf2_per_objfile = cu->dwarf2_per_objfile;
struct dwarf2_section_info *section = cu_debug_loc_section (cu);
dwarf2_read_section (dwarf2_per_objfile->objfile, section);
dwarf2_symbol_mark_computed (const struct attribute *attr, struct symbol *sym,
struct dwarf2_cu *cu, int is_block)
{
+ struct dwarf2_per_objfile *dwarf2_per_objfile = cu->dwarf2_per_objfile;
struct objfile *objfile = dwarf2_per_objfile->objfile;
struct dwarf2_section_info *section = cu_debug_loc_section (cu);
static struct dwarf2_per_cu_data *
dwarf2_find_containing_comp_unit (sect_offset sect_off,
unsigned int offset_in_dwz,
- struct objfile *objfile)
+ struct dwarf2_per_objfile *dwarf2_per_objfile)
{
struct dwarf2_per_cu_data *this_cu;
int low, high;
if (low == 0 || this_cu->is_dwz != offset_in_dwz)
error (_("Dwarf Error: could not find partial DIE containing "
"offset 0x%x [in module %s]"),
- to_underlying (sect_off), bfd_get_filename (objfile->obfd));
+ to_underlying (sect_off),
+ bfd_get_filename (dwarf2_per_objfile->objfile->obfd));
gdb_assert (dwarf2_per_objfile->all_comp_units[low-1]->sect_off
<= sect_off);
static void
free_cached_comp_units (void *data)
{
+ struct dwarf2_per_objfile *dwarf2_per_objfile
+ = (struct dwarf2_per_objfile *) data;
+
dwarf2_per_objfile->free_cached_comp_units ();
}
any that are too old. */
static void
-age_cached_comp_units (void)
+age_cached_comp_units (struct dwarf2_per_objfile *dwarf2_per_objfile)
{
struct dwarf2_per_cu_data *per_cu, **last_chain;
free_one_cached_comp_unit (struct dwarf2_per_cu_data *target_per_cu)
{
struct dwarf2_per_cu_data *per_cu, **last_chain;
+ struct dwarf2_per_objfile *dwarf2_per_objfile
+ = target_per_cu->dwarf2_per_objfile;
per_cu = dwarf2_per_objfile->read_in_chain;
last_chain = &dwarf2_per_objfile->read_in_chain;
void
dwarf2_free_objfile (struct objfile *objfile)
{
- dwarf2_per_objfile
- = (struct dwarf2_per_objfile *) objfile_data (objfile,
- dwarf2_objfile_data_key);
+ struct dwarf2_per_objfile *dwarf2_per_objfile
+ = get_dwarf2_per_objfile (objfile);
if (dwarf2_per_objfile == NULL)
return;
static struct type *
set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
{
+ struct dwarf2_per_objfile *dwarf2_per_objfile = cu->dwarf2_per_objfile;
struct dwarf2_per_cu_offset_and_type **slot, ofs;
- struct objfile *objfile = cu->dwarf2_per_objfile->objfile;
+ struct objfile *objfile = dwarf2_per_objfile->objfile;
struct attribute *attr;
struct dynamic_prop prop;
struct dwarf2_per_cu_data *per_cu)
{
struct dwarf2_per_cu_offset_and_type *slot, ofs;
+ struct dwarf2_per_objfile *dwarf2_per_objfile = per_cu->dwarf2_per_objfile;
if (dwarf2_per_objfile->die_type_hash == NULL)
return NULL;
struct dwarf2_per_objfile *data = (struct dwarf2_per_objfile *) d;
int ix;
- /* Make sure we don't accidentally use dwarf2_per_objfile while
- cleaning up. */
- dwarf2_per_objfile = NULL;
-
for (ix = 0; ix < data->n_comp_units; ++ix)
VEC_free (dwarf2_per_cu_ptr, data->all_comp_units[ix]->imported_symtabs);
class debug_names
{
public:
- debug_names (bool is_dwarf64, bfd_endian dwarf5_byte_order)
+ debug_names (struct dwarf2_per_objfile *dwarf2_per_objfile, bool is_dwarf64,
+ bfd_endian dwarf5_byte_order)
: m_dwarf5_byte_order (dwarf5_byte_order),
m_dwarf32 (dwarf5_byte_order),
m_dwarf64 (dwarf5_byte_order),
? static_cast<dwarf &> (m_dwarf64)
: static_cast<dwarf &> (m_dwarf32)),
m_name_table_string_offs (m_dwarf.name_table_string_offs),
- m_name_table_entry_offs (m_dwarf.name_table_entry_offs)
+ m_name_table_entry_offs (m_dwarf.name_table_entry_offs),
+ m_debugstrlookup (dwarf2_per_objfile)
{}
int dwarf5_offset_size () const
/* Object costructor to be called for current DWARF2_PER_OBJFILE.
All .debug_str section strings are automatically stored. */
- debug_str_lookup ()
- : m_abfd (dwarf2_per_objfile->objfile->obfd)
+ debug_str_lookup (struct dwarf2_per_objfile *dwarf2_per_objfile)
+ : m_abfd (dwarf2_per_objfile->objfile->obfd),
+ m_dwarf2_per_objfile (dwarf2_per_objfile)
{
dwarf2_read_section (dwarf2_per_objfile->objfile,
&dwarf2_per_objfile->str);
const auto it = m_str_table.find (c_str_view (s));
if (it != m_str_table.end ())
return it->second;
- const size_t offset = (dwarf2_per_objfile->str.size
+ const size_t offset = (m_dwarf2_per_objfile->str.size
+ m_str_add_buf.size ());
m_str_table.emplace (c_str_view (s), offset);
m_str_add_buf.append_cstr0 (s);
private:
std::unordered_map<c_str_view, size_t, c_str_view_hasher> m_str_table;
bfd *const m_abfd;
+ struct dwarf2_per_objfile *m_dwarf2_per_objfile;
/* Data to add at the end of .debug_str for new needed symbol names. */
data_buf m_str_add_buf;
.debug_names section. */
static bool
-check_dwarf64_offsets ()
+check_dwarf64_offsets (struct dwarf2_per_objfile *dwarf2_per_objfile)
{
for (int i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
{
malloc/free. */
static size_t
-psyms_seen_size ()
+psyms_seen_size (struct dwarf2_per_objfile *dwarf2_per_objfile)
{
size_t psyms_count = 0;
for (int i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
Return how many bytes were expected to be written into OUT_FILE. */
static size_t
-write_gdbindex (struct objfile *objfile, FILE *out_file)
+write_gdbindex (struct dwarf2_per_objfile *dwarf2_per_objfile, FILE *out_file)
{
+ struct objfile *objfile = dwarf2_per_objfile->objfile;
mapped_symtab symtab;
data_buf cu_list;
work here. Also, the debug_types entries do not appear in
all_comp_units, but only in their own hash table. */
- std::unordered_set<partial_symbol *> psyms_seen (psyms_seen_size ());
+ std::unordered_set<partial_symbol *> psyms_seen
+ (psyms_seen_size (dwarf2_per_objfile));
for (int i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
{
struct dwarf2_per_cu_data *per_cu
many bytes were expected to be written into OUT_FILE. */
static size_t
-write_debug_names (struct objfile *objfile, FILE *out_file, FILE *out_file_str)
+write_debug_names (struct dwarf2_per_objfile *dwarf2_per_objfile,
+ FILE *out_file, FILE *out_file_str)
{
- const bool dwarf5_is_dwarf64 = check_dwarf64_offsets ();
+ const bool dwarf5_is_dwarf64 = check_dwarf64_offsets (dwarf2_per_objfile);
+ struct objfile *objfile = dwarf2_per_objfile->objfile;
const enum bfd_endian dwarf5_byte_order
= gdbarch_byte_order (get_objfile_arch (objfile));
work here. Also, the debug_types entries do not appear in
all_comp_units, but only in their own hash table. */
data_buf cu_list;
- debug_names nametable (dwarf5_is_dwarf64, dwarf5_byte_order);
- std::unordered_set<partial_symbol *> psyms_seen (psyms_seen_size ());
+ debug_names nametable (dwarf2_per_objfile, dwarf5_is_dwarf64,
+ dwarf5_byte_order);
+ std::unordered_set<partial_symbol *>
+ psyms_seen (psyms_seen_size (dwarf2_per_objfile));
for (int i = 0; i < dwarf2_per_objfile->n_comp_units; ++i)
{
const dwarf2_per_cu_data *per_cu = dwarf2_per_objfile->all_comp_units[i];
/* Create an index file for OBJFILE in the directory DIR. */
static void
-write_psymtabs_to_index (struct objfile *objfile, const char *dir,
+write_psymtabs_to_index (struct dwarf2_per_objfile *dwarf2_per_objfile,
+ const char *dir,
dw_index_kind index_kind)
{
+ struct objfile *objfile = dwarf2_per_objfile->objfile;
+
if (dwarf2_per_objfile->using_index)
error (_("Cannot use an index to create the index"));
gdb_file_up close_out_file_str (out_file_str);
const size_t total_len
- = write_debug_names (objfile, out_file, out_file_str);
+ = write_debug_names (dwarf2_per_objfile, out_file, out_file_str);
assert_file_size (out_file, filename.c_str (), total_len);
/* We want to keep the file .debug_str file too. */
else
{
const size_t total_len
- = write_gdbindex (objfile, out_file);
+ = write_gdbindex (dwarf2_per_objfile, out_file);
assert_file_size (out_file, filename.c_str (), total_len);
}
if (stat (objfile_name (objfile), &st) < 0)
continue;
- dwarf2_per_objfile
- = (struct dwarf2_per_objfile *) objfile_data (objfile,
- dwarf2_objfile_data_key);
- if (dwarf2_per_objfile)
- {
+ struct dwarf2_per_objfile *dwarf2_per_objfile
+ = get_dwarf2_per_objfile (objfile);
+ if (dwarf2_per_objfile != NULL)
+ {
TRY
{
- write_psymtabs_to_index (objfile, arg, index_kind);
+ write_psymtabs_to_index (dwarf2_per_objfile, arg, index_kind);
}
CATCH (except, RETURN_MASK_ERROR)
{
}
END_CATCH
}
+
}
}