attributes in the stub. */
unsigned int reading_dwo_directly : 1;
+ /* Non-zero if the TU has been read.
+ This is used to assist the "Stay in DWO Optimization" for Fission:
+ When reading a DWO, it's faster to read TUs from the DWO instead of
+ fetching them from random other DWOs (due to comdat folding).
+ If the TU has already been read, the optimization is unnecessary
+ (and unwise - we don't want to change where gdb thinks the TU lives
+ "midflight").
+ This flag is only valid if is_debug_types is true. */
+ unsigned int tu_read : 1;
+
/* The section this CU/TU lives in.
If the DIE refers to a DWO file, this is always the original die,
not the DWO file. */
static struct symbol *new_symbol_full (struct die_info *, struct type *,
struct dwarf2_cu *, struct symbol *);
-static void dwarf2_const_value (struct attribute *, struct symbol *,
+static void dwarf2_const_value (const struct attribute *, struct symbol *,
struct dwarf2_cu *);
-static void dwarf2_const_value_attr (struct attribute *attr,
+static void dwarf2_const_value_attr (const struct attribute *attr,
struct type *type,
const char *name,
struct obstack *obstack,
static struct type *die_containing_type (struct die_info *,
struct dwarf2_cu *);
-static struct type *lookup_die_type (struct die_info *, struct attribute *,
+static struct type *lookup_die_type (struct die_info *, const struct attribute *,
struct dwarf2_cu *);
static struct type *read_type_die (struct die_info *, struct dwarf2_cu *);
static void store_in_ref_table (struct die_info *,
struct dwarf2_cu *);
-static int is_ref_attr (struct attribute *);
-
-static sect_offset dwarf2_get_ref_die_offset (struct attribute *);
+static sect_offset dwarf2_get_ref_die_offset (const struct attribute *);
-static LONGEST dwarf2_get_attr_constant_value (struct attribute *, int);
+static LONGEST dwarf2_get_attr_constant_value (const struct attribute *, int);
static struct die_info *follow_die_ref_or_sig (struct die_info *,
- struct attribute *,
+ const struct attribute *,
struct dwarf2_cu **);
static struct die_info *follow_die_ref (struct die_info *,
- struct attribute *,
+ const struct attribute *,
struct dwarf2_cu **);
static struct die_info *follow_die_sig (struct die_info *,
- struct attribute *,
+ const struct attribute *,
struct dwarf2_cu **);
static struct type *get_signatured_type (struct die_info *, ULONGEST,
struct dwarf2_cu *);
static struct type *get_DW_AT_signature_type (struct die_info *,
- struct attribute *,
+ const struct attribute *,
struct dwarf2_cu *);
static void load_full_type_unit (struct dwarf2_per_cu_data *per_cu);
static void read_signatured_type (struct signatured_type *);
static struct type_unit_group *get_type_unit_group
- (struct dwarf2_cu *, struct attribute *);
+ (struct dwarf2_cu *, const struct attribute *);
static void build_type_unit_groups (die_reader_func_ftype *, void *);
static void dwarf_decode_macros (struct dwarf2_cu *, unsigned int,
const char *, int);
-static int attr_form_is_block (struct attribute *);
+static int attr_form_is_block (const struct attribute *);
+
+static int attr_form_is_section_offset (const struct attribute *);
-static int attr_form_is_section_offset (struct attribute *);
+static int attr_form_is_constant (const struct attribute *);
-static int attr_form_is_constant (struct attribute *);
+static int attr_form_is_ref (const struct attribute *);
static void fill_in_loclist_baton (struct dwarf2_cu *cu,
struct dwarf2_loclist_baton *baton,
- struct attribute *attr);
+ const struct attribute *attr);
-static void dwarf2_symbol_mark_computed (struct attribute *attr,
+static void dwarf2_symbol_mark_computed (const struct attribute *attr,
struct symbol *sym,
struct dwarf2_cu *cu,
int is_block);
}
}
-/* Open the separate '.dwz' debug file, if needed. Error if the file
- cannot be found. */
+/* Open the separate '.dwz' debug file, if needed. Return NULL if
+ there is no .gnu_debugaltlink section in the file. Error if there
+ is such a section but the file cannot be found. */
static struct dwz_file *
dwarf2_get_dwz_file (void)
{
- bfd *abfd, *dwz_bfd;
- asection *section;
- gdb_byte *data;
+ bfd *dwz_bfd;
+ char *data;
struct cleanup *cleanup;
const char *filename;
struct dwz_file *result;
+ unsigned long buildid;
if (dwarf2_per_objfile->dwz_file != NULL)
return dwarf2_per_objfile->dwz_file;
- abfd = dwarf2_per_objfile->objfile->obfd;
- section = bfd_get_section_by_name (abfd, ".gnu_debugaltlink");
- if (section == NULL)
- error (_("could not find '.gnu_debugaltlink' section"));
- if (!bfd_malloc_and_get_section (abfd, section, &data))
- error (_("could not read '.gnu_debugaltlink' section: %s"),
- bfd_errmsg (bfd_get_error ()));
+ bfd_set_error (bfd_error_no_error);
+ data = bfd_get_alt_debug_link_info (dwarf2_per_objfile->objfile->obfd,
+ &buildid);
+ if (data == NULL)
+ {
+ if (bfd_get_error () == bfd_error_no_error)
+ return NULL;
+ error (_("could not read '.gnu_debugaltlink' section: %s"),
+ bfd_errmsg (bfd_get_error ()));
+ }
cleanup = make_cleanup (xfree, data);
filename = (const char *) data;
struct mapped_index local_map, *map;
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;
if (!read_index_from_section (objfile, objfile->name,
use_deprecated_index_sections,
/* If there is a .dwz file, read it so we can get its CU list as
well. */
- if (bfd_get_section_by_name (objfile->obfd, ".gnu_debugaltlink") != NULL)
+ dwz = dwarf2_get_dwz_file ();
+ if (dwz != NULL)
{
- struct dwz_file *dwz = dwarf2_get_dwz_file ();
struct mapped_index dwz_map;
const gdb_byte *dwz_types_ignore;
offset_type dwz_types_elements_ignore;
}
}
-/* A helper function for dw2_find_symbol_file that finds the primary
- file name for a given CU. This is a die_reader_func. */
-
-static void
-dw2_get_primary_filename_reader (const struct die_reader_specs *reader,
- const gdb_byte *info_ptr,
- struct die_info *comp_unit_die,
- int has_children,
- void *data)
-{
- const char **result_ptr = data;
- struct dwarf2_cu *cu = reader->cu;
- struct attribute *attr;
-
- attr = dwarf2_attr (comp_unit_die, DW_AT_name, cu);
- if (attr == NULL)
- *result_ptr = NULL;
- else
- *result_ptr = DW_STRING (attr);
-}
-
-static const char *
-dw2_find_symbol_file (struct objfile *objfile, const char *name)
-{
- struct dwarf2_per_cu_data *per_cu;
- offset_type *vec;
- const char *filename;
-
- dw2_setup (objfile);
-
- /* index_table is NULL if OBJF_READNOW. */
- if (!dwarf2_per_objfile->index_table)
- {
- struct symtab *s;
-
- ALL_OBJFILE_PRIMARY_SYMTABS (objfile, s)
- {
- struct blockvector *bv = BLOCKVECTOR (s);
- const struct block *block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
- struct symbol *sym = lookup_block_symbol (block, name, VAR_DOMAIN);
-
- if (sym)
- {
- /* Only file extension of returned filename is recognized. */
- return SYMBOL_SYMTAB (sym)->filename;
- }
- }
- return NULL;
- }
-
- if (!find_slot_in_mapped_hash (dwarf2_per_objfile->index_table,
- name, &vec))
- return NULL;
-
- /* Note that this just looks at the very first one named NAME -- but
- actually we are looking for a function. find_main_filename
- should be rewritten so that it doesn't require a custom hook. It
- could just use the ordinary symbol tables. */
- /* vec[0] is the length, which must always be >0. */
- per_cu = dw2_get_cu (GDB_INDEX_CU_VALUE (MAYBE_SWAP (vec[1])));
-
- if (per_cu->v.quick->symtab != NULL)
- {
- /* Only file extension of returned filename is recognized. */
- return per_cu->v.quick->symtab->filename;
- }
-
- /* Initialize filename in case there's a problem reading the DWARF,
- dw2_get_primary_filename_reader may not get called. */
- filename = NULL;
- init_cutu_and_read_dies (per_cu, NULL, 0, 0,
- dw2_get_primary_filename_reader, &filename);
-
- /* Only file extension of returned filename is recognized. */
- return filename;
-}
-
static void
dw2_map_matching_symbols (const char * name, domain_enum namespace,
struct objfile *objfile, int global,
dw2_expand_symtabs_for_function,
dw2_expand_all_symtabs,
dw2_expand_symtabs_with_fullname,
- dw2_find_symbol_file,
dw2_map_matching_symbols,
dw2_expand_symtabs_matching,
dw2_find_pc_sect_symtab,
struct signatured_type *sig_entry,
struct dwo_unit *dwo_entry)
{
- sig_entry->per_cu.section = dwo_entry->section;
- sig_entry->per_cu.offset = dwo_entry->offset;
- sig_entry->per_cu.length = dwo_entry->length;
- sig_entry->per_cu.reading_dwo_directly = 1;
- sig_entry->per_cu.objfile = objfile;
+ /* Make sure we're not clobbering something we don't expect to. */
gdb_assert (! sig_entry->per_cu.queued);
gdb_assert (sig_entry->per_cu.cu == NULL);
gdb_assert (sig_entry->per_cu.v.quick != NULL);
gdb_assert (sig_entry->signature == dwo_entry->signature);
gdb_assert (sig_entry->type_offset_in_section.sect_off == 0);
gdb_assert (sig_entry->type_unit_group == NULL);
+ gdb_assert (sig_entry->dwo_unit == NULL);
+
+ sig_entry->per_cu.section = dwo_entry->section;
+ sig_entry->per_cu.offset = dwo_entry->offset;
+ sig_entry->per_cu.length = dwo_entry->length;
+ sig_entry->per_cu.reading_dwo_directly = 1;
+ sig_entry->per_cu.objfile = objfile;
sig_entry->type_offset_in_tu = dwo_entry->type_offset_in_tu;
sig_entry->dwo_unit = dwo_entry;
}
/* Subroutine of lookup_signatured_type.
- Create the signatured_type data structure for a TU to be read in
- directly from a DWO file, bypassing the stub.
- We do this for the case where there is no DWP file and we're using
- .gdb_index: When reading a CU we want to stay in the DWO file containing
- that CU. Otherwise we could end up reading several other DWO files (due
- to comdat folding) to process the transitive closure of all the mentioned
- TUs, and that can be slow. The current DWO file will have every type
- signature that it needs.
+ If we haven't read the TU yet, create the signatured_type data structure
+ for a TU to be read in directly from a DWO file, bypassing the stub.
+ This is the "Stay in DWO Optimization": When there is no DWP file and we're
+ using .gdb_index, then when reading a CU we want to stay in the DWO file
+ containing that CU. Otherwise we could end up reading several other DWO
+ files (due to comdat folding) to process the transitive closure of all the
+ mentioned TUs, and that can be slow. The current DWO file will have every
+ type signature that it needs.
We only do this for .gdb_index because in the psymtab case we already have
to read all the DWOs to build the type unit groups. */
sig_entry = htab_find (dwarf2_per_objfile->signatured_types, &find_sig_entry);
if (sig_entry == NULL)
return NULL;
+
+ /* We can get here with the TU already read, *or* in the process of being
+ read. Don't reassign it if that's the case. Also note that if the TU is
+ already being read, it may not have come from a DWO, the program may be
+ a mix of Fission-compiled code and non-Fission-compiled code. */
/* Have we already tried to read this TU? */
- if (sig_entry->dwo_unit != NULL)
+ if (sig_entry->per_cu.tu_read)
return sig_entry;
/* Ok, this is the first time we're reading this TU. */
STMT_LIST is a DW_AT_stmt_list attribute. */
static struct type_unit_group *
-get_type_unit_group (struct dwarf2_cu *cu, struct attribute *stmt_list)
+get_type_unit_group (struct dwarf2_cu *cu, const struct attribute *stmt_list)
{
struct tu_stats *tu_stats = &dwarf2_per_objfile->tu_stats;
struct type_unit_group *tu_group;
int n_allocated;
int n_comp_units;
struct dwarf2_per_cu_data **all_comp_units;
+ struct dwz_file *dwz;
n_comp_units = 0;
n_allocated = 10;
read_comp_units_from_section (objfile, &dwarf2_per_objfile->info, 0,
&n_allocated, &n_comp_units, &all_comp_units);
- if (bfd_get_section_by_name (objfile->obfd, ".gnu_debugaltlink") != NULL)
- {
- struct dwz_file *dwz = dwarf2_get_dwz_file ();
-
- read_comp_units_from_section (objfile, &dwz->info, 1,
- &n_allocated, &n_comp_units,
- &all_comp_units);
- }
+ dwz = dwarf2_get_dwz_file ();
+ if (dwz != NULL)
+ read_comp_units_from_section (objfile, &dwz->info, 1,
+ &n_allocated, &n_comp_units,
+ &all_comp_units);
dwarf2_per_objfile->all_comp_units
= obstack_alloc (&objfile->objfile_obstack,
: (item->per_cu->v.psymtab && !item->per_cu->v.psymtab->readin))
{
struct dwarf2_per_cu_data *per_cu = item->per_cu;
+ char buf[100];
- if (dwarf2_read_debug)
+ if (per_cu->is_debug_types)
{
- fprintf_unfiltered (gdb_stdlog,
- "Expanding symtab of %s at offset 0x%x\n",
- per_cu->is_debug_types ? "TU" : "CU",
- per_cu->offset.sect_off);
+ struct signatured_type *sig_type =
+ (struct signatured_type *) per_cu;
+
+ sprintf (buf, "TU %s at offset 0x%x",
+ hex_string (sig_type->signature), per_cu->offset.sect_off);
}
+ else
+ sprintf (buf, "CU at offset 0x%x", per_cu->offset.sect_off);
+
+ if (dwarf2_read_debug)
+ fprintf_unfiltered (gdb_stdlog, "Expanding symtab of %s\n", buf);
if (per_cu->is_debug_types)
process_full_type_unit (per_cu, item->pretend_language);
process_full_comp_unit (per_cu, item->pretend_language);
if (dwarf2_read_debug)
- {
- fprintf_unfiltered (gdb_stdlog,
- "Done expanding %s at offset 0x%x\n",
- per_cu->is_debug_types ? "TU" : "CU",
- per_cu->offset.sect_off);
- }
+ fprintf_unfiltered (gdb_stdlog, "Done expanding %s\n", buf);
}
item->per_cu->queued = 0;
included by PER_CU. */
static void
-recursively_compute_inclusions (VEC (dwarf2_per_cu_ptr) **result,
- htab_t all_children,
- struct dwarf2_per_cu_data *per_cu)
+recursively_compute_inclusions (VEC (symtab_ptr) **result,
+ htab_t all_children, htab_t all_type_symtabs,
+ struct dwarf2_per_cu_data *per_cu,
+ struct symtab *immediate_parent)
{
void **slot;
int ix;
+ struct symtab *symtab;
struct dwarf2_per_cu_data *iter;
slot = htab_find_slot (all_children, per_cu, INSERT);
*slot = per_cu;
/* Only add a CU if it has a symbol table. */
- if (get_symtab (per_cu) != NULL)
- VEC_safe_push (dwarf2_per_cu_ptr, *result, per_cu);
+ symtab = get_symtab (per_cu);
+ if (symtab != NULL)
+ {
+ /* If this is a type unit only add its symbol table if we haven't
+ seen it yet (type unit per_cu's can share symtabs). */
+ if (per_cu->is_debug_types)
+ {
+ slot = htab_find_slot (all_type_symtabs, symtab, INSERT);
+ if (*slot == NULL)
+ {
+ *slot = symtab;
+ VEC_safe_push (symtab_ptr, *result, symtab);
+ if (symtab->user == NULL)
+ symtab->user = immediate_parent;
+ }
+ }
+ else
+ {
+ VEC_safe_push (symtab_ptr, *result, symtab);
+ if (symtab->user == NULL)
+ symtab->user = immediate_parent;
+ }
+ }
for (ix = 0;
VEC_iterate (dwarf2_per_cu_ptr, per_cu->imported_symtabs, ix, iter);
++ix)
- recursively_compute_inclusions (result, all_children, iter);
+ {
+ recursively_compute_inclusions (result, all_children,
+ all_type_symtabs, iter, symtab);
+ }
}
/* Compute the symtab 'includes' fields for the symtab related to
if (!VEC_empty (dwarf2_per_cu_ptr, per_cu->imported_symtabs))
{
int ix, len;
- struct dwarf2_per_cu_data *iter;
- VEC (dwarf2_per_cu_ptr) *result_children = NULL;
- htab_t all_children;
+ struct dwarf2_per_cu_data *per_cu_iter;
+ struct symtab *symtab_iter;
+ VEC (symtab_ptr) *result_symtabs = NULL;
+ htab_t all_children, all_type_symtabs;
struct symtab *symtab = get_symtab (per_cu);
/* If we don't have a symtab, we can just skip this case. */
all_children = htab_create_alloc (1, htab_hash_pointer, htab_eq_pointer,
NULL, xcalloc, xfree);
+ all_type_symtabs = htab_create_alloc (1, htab_hash_pointer, htab_eq_pointer,
+ NULL, xcalloc, xfree);
for (ix = 0;
VEC_iterate (dwarf2_per_cu_ptr, per_cu->imported_symtabs,
- ix, iter);
+ ix, per_cu_iter);
++ix)
- recursively_compute_inclusions (&result_children, all_children, iter);
+ {
+ recursively_compute_inclusions (&result_symtabs, all_children,
+ all_type_symtabs, per_cu_iter,
+ symtab);
+ }
- /* Now we have a transitive closure of all the included CUs, and
- for .gdb_index version 7 the included TUs, so we can convert it
- to a list of symtabs. */
- len = VEC_length (dwarf2_per_cu_ptr, result_children);
+ /* Now we have a transitive closure of all the included symtabs. */
+ len = VEC_length (symtab_ptr, result_symtabs);
symtab->includes
= obstack_alloc (&dwarf2_per_objfile->objfile->objfile_obstack,
(len + 1) * sizeof (struct symtab *));
for (ix = 0;
- VEC_iterate (dwarf2_per_cu_ptr, result_children, ix, iter);
+ VEC_iterate (symtab_ptr, result_symtabs, ix, symtab_iter);
++ix)
- symtab->includes[ix] = get_symtab (iter);
+ symtab->includes[ix] = symtab_iter;
symtab->includes[len] = NULL;
- VEC_free (dwarf2_per_cu_ptr, result_children);
+ VEC_free (symtab_ptr, result_symtabs);
htab_delete (all_children);
+ htab_delete (all_type_symtabs);
}
}
preliminary analysis. Return a newly initialized bfd *, which
includes a canonicalized copy of FILE_NAME.
If IS_DWP is TRUE, we're opening a DWP file, otherwise a DWO file.
- In case of trouble, return NULL.
+ SEARCH_CWD is true if the current directory is to be searched.
+ It will be searched before debug-file-directory.
+ If unable to find/open the file, return NULL.
NOTE: This function is derived from symfile_bfd_open. */
static bfd *
-try_open_dwop_file (const char *file_name, int is_dwp)
+try_open_dwop_file (const char *file_name, int is_dwp, int search_cwd)
{
bfd *sym_bfd;
int desc, flags;
char *search_path;
static const char dirname_separator_string[] = { DIRNAME_SEPARATOR, '\0' };
- if (*debug_file_directory != '\0')
- search_path = concat (".", dirname_separator_string, debug_file_directory,
- NULL);
+ if (search_cwd)
+ {
+ if (*debug_file_directory != '\0')
+ search_path = concat (".", dirname_separator_string,
+ debug_file_directory, NULL);
+ else
+ search_path = xstrdup (".");
+ }
else
- search_path = xstrdup (".");
+ search_path = xstrdup (debug_file_directory);
flags = 0;
if (is_dwp)
bfd *abfd;
if (IS_ABSOLUTE_PATH (file_name))
- return try_open_dwop_file (file_name, 0 /*is_dwp*/);
+ return try_open_dwop_file (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. */
- abfd = try_open_dwop_file (path_to_try, 0 /*is_dwp*/);
+ abfd = try_open_dwop_file (path_to_try, 0 /*is_dwp*/, 1 /*search_cwd*/);
xfree (path_to_try);
if (abfd != NULL)
return abfd;
if (*debug_file_directory == '\0')
return NULL;
- return try_open_dwop_file (file_name, 0 /*is_dwp*/);
+ return try_open_dwop_file (file_name, 0 /*is_dwp*/, 1 /*search_cwd*/);
}
/* This function is mapped across the sections and remembers the offset and
static bfd *
open_dwp_file (const char *file_name)
{
- return try_open_dwop_file (file_name, 1 /*is_dwp*/);
+ bfd *abfd;
+
+ abfd = try_open_dwop_file (file_name, 1 /*is_dwp*/, 1 /*search_cwd*/);
+ if (abfd != NULL)
+ return abfd;
+
+ /* Work around upstream bug 15652.
+ http://sourceware.org/bugzilla/show_bug.cgi?id=15652
+ [Whether that's a "bug" is debatable, but it is getting in our way.]
+ We have no real idea where the dwp file is, because gdb's realpath-ing
+ of the executable's path may have discarded the needed info.
+ [IWBN if the dwp file name was recorded in the executable, akin to
+ .gnu_debuglink, but that doesn't exist yet.]
+ Strip the directory from FILE_NAME and search again. */
+ if (*debug_file_directory != '\0')
+ {
+ /* 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*/,
+ 0 /*search_cwd*/);
+ }
+
+ return NULL;
}
/* Initialize the use of the DWP file for the current objfile.
kind, dwo_name, hex_string (signature));
}
- complaint (&symfile_complaints,
- _("Could not find DWO %s %s(%s) referenced by %s at offset 0x%x"
- " [in module %s]"),
- kind, dwo_name, hex_string (signature),
- this_unit->is_debug_types ? "TU" : "CU",
- this_unit->offset.sect_off, objfile->name);
+ /* This is a warning and not a complaint because it can be caused by
+ pilot error (e.g., user accidentally deleting the DWO). */
+ warning (_("Could not find DWO %s %s(%s) referenced by %s at offset 0x%x"
+ " [in module %s]"),
+ kind, dwo_name, hex_string (signature),
+ this_unit->is_debug_types ? "TU" : "CU",
+ this_unit->offset.sect_off, objfile->name);
return NULL;
}
SET_FIELD_DWARF_BLOCK (call_site->target, dlbaton);
}
- else if (is_ref_attr (attr))
+ else if (attr_form_is_ref (attr))
{
struct dwarf2_cu *target_cu = cu;
struct die_info *target_die;
loc = dwarf2_attr (child_die, DW_AT_location, cu);
origin = dwarf2_attr (child_die, DW_AT_abstract_origin, cu);
- if (loc == NULL && origin != NULL && is_ref_attr (origin))
+ if (loc == NULL && origin != NULL && attr_form_is_ref (origin))
{
sect_offset offset;
attr = dwarf2_attr (die, DW_AT_upper_bound, cu);
if (attr)
{
- if (attr_form_is_block (attr) || is_ref_attr (attr))
+ if (attr_form_is_block (attr) || attr_form_is_ref (attr))
{
/* GCC encodes arrays with unspecified or dynamic length
with a DW_FORM_block1 attribute or a reference attribute.
}
/* Super hack. */
- if (cu->per_cu->is_dwz && is_ref_attr (attr))
+ if (cu->per_cu->is_dwz && attr_form_is_ref (attr))
attr->form = DW_FORM_GNU_ref_alt;
/* We have seen instances where the compiler tried to emit a byte
if (line_ptr + lh->total_length > (section->buffer + section->size))
{
dwarf2_statement_list_fits_in_line_number_section_complaint ();
+ do_cleanups (back_to);
return 0;
}
lh->statement_program_end = line_ptr + lh->total_length;
because that is the interpretation long in use by GCC. */
static gdb_byte *
-dwarf2_const_value_data (struct attribute *attr, struct obstack *obstack,
+dwarf2_const_value_data (const struct attribute *attr, struct obstack *obstack,
struct dwarf2_cu *cu, LONGEST *value, int bits)
{
struct objfile *objfile = cu->objfile;
expression. */
static void
-dwarf2_const_value_attr (struct attribute *attr, struct type *type,
+dwarf2_const_value_attr (const struct attribute *attr, struct type *type,
const char *name, struct obstack *obstack,
struct dwarf2_cu *cu,
LONGEST *value, const gdb_byte **bytes,
/* Copy constant value from an attribute to a symbol. */
static void
-dwarf2_const_value (struct attribute *attr, struct symbol *sym,
+dwarf2_const_value (const struct attribute *attr, struct symbol *sym,
struct dwarf2_cu *cu)
{
struct objfile *objfile = cu->objfile;
If there is no type substitute an error marker. */
static struct type *
-lookup_die_type (struct die_info *die, struct attribute *attr,
+lookup_die_type (struct die_info *die, const struct attribute *attr,
struct dwarf2_cu *cu)
{
struct objfile *objfile = cu->objfile;
per_cu = dwarf2_find_containing_comp_unit (offset, 1, cu->objfile);
this_type = get_die_type_at_offset (offset, per_cu);
}
- else if (is_ref_attr (attr))
+ else if (attr_form_is_ref (attr))
{
sect_offset offset = dwarf2_get_ref_die_offset (attr);
struct die_info *type_die = NULL;
struct dwarf2_cu *type_cu = cu;
- if (is_ref_attr (attr))
+ if (attr_form_is_ref (attr))
type_die = follow_die_ref (die, attr, &type_cu);
if (type_die == NULL)
return build_error_marker_type (cu, die);
*slot = die;
}
-/* DW_ADDR is always stored already as sect_offset; despite for the forms
- besides DW_FORM_ref_addr it is stored as cu_offset in the DWARF file. */
-
-static int
-is_ref_attr (struct attribute *attr)
-{
- switch (attr->form)
- {
- case DW_FORM_ref_addr:
- case DW_FORM_ref1:
- case DW_FORM_ref2:
- case DW_FORM_ref4:
- case DW_FORM_ref8:
- case DW_FORM_ref_udata:
- case DW_FORM_GNU_ref_alt:
- return 1;
- default:
- return 0;
- }
-}
-
/* Return DIE offset of ATTR. Return 0 with complaint if ATTR is not of the
required kind. */
static sect_offset
-dwarf2_get_ref_die_offset (struct attribute *attr)
+dwarf2_get_ref_die_offset (const struct attribute *attr)
{
sect_offset retval = { DW_UNSND (attr) };
- if (is_ref_attr (attr))
+ if (attr_form_is_ref (attr))
return retval;
retval.sect_off = 0;
* the value held by the attribute is not constant. */
static LONGEST
-dwarf2_get_attr_constant_value (struct attribute *attr, int default_value)
+dwarf2_get_attr_constant_value (const struct attribute *attr, int default_value)
{
if (attr->form == DW_FORM_sdata)
return DW_SND (attr);
On exit *REF_CU is the CU of the result. */
static struct die_info *
-follow_die_ref_or_sig (struct die_info *src_die, struct attribute *attr,
+follow_die_ref_or_sig (struct die_info *src_die, const struct attribute *attr,
struct dwarf2_cu **ref_cu)
{
struct die_info *die;
- if (is_ref_attr (attr))
+ if (attr_form_is_ref (attr))
die = follow_die_ref (src_die, attr, ref_cu);
else if (attr->form == DW_FORM_ref_sig8)
die = follow_die_sig (src_die, attr, ref_cu);
On exit *REF_CU is the CU of the result. */
static struct die_info *
-follow_die_ref (struct die_info *src_die, struct attribute *attr,
+follow_die_ref (struct die_info *src_die, const struct attribute *attr,
struct dwarf2_cu **ref_cu)
{
sect_offset offset = dwarf2_get_ref_die_offset (attr);
If the referenced type cannot be found an error is thrown. */
static struct die_info *
-follow_die_sig (struct die_info *src_die, struct attribute *attr,
+follow_die_sig (struct die_info *src_die, const struct attribute *attr,
struct dwarf2_cu **ref_cu)
{
ULONGEST signature = DW_SIGNATURE (attr);
reading in and processing the type unit if necessary. */
static struct type *
-get_DW_AT_signature_type (struct die_info *die, struct attribute *attr,
+get_DW_AT_signature_type (struct die_info *die, const struct attribute *attr,
struct dwarf2_cu *cu) /* ARI: editCase function */
{
/* Yes, DW_AT_signature can use a non-ref_sig8 reference. */
- if (is_ref_attr (attr))
+ if (attr_form_is_ref (attr))
{
struct dwarf2_cu *type_cu = cu;
struct die_info *type_die = follow_die_ref (die, attr, &type_cu);
init_cutu_and_read_dies (per_cu, NULL, 0, 1,
read_signatured_type_reader, NULL);
+ sig_type->per_cu.tu_read = 1;
}
/* Decode simple location descriptions.
if so return true else false. */
static int
-attr_form_is_block (struct attribute *attr)
+attr_form_is_block (const struct attribute *attr)
{
return (attr == NULL ? 0 :
attr->form == DW_FORM_block1
of them. */
static int
-attr_form_is_section_offset (struct attribute *attr)
+attr_form_is_section_offset (const struct attribute *attr)
{
return (attr->form == DW_FORM_data4
|| attr->form == DW_FORM_data8
taken as section offsets, not constants. */
static int
-attr_form_is_constant (struct attribute *attr)
+attr_form_is_constant (const struct attribute *attr)
{
switch (attr->form)
{
}
}
+
+/* DW_ADDR is always stored already as sect_offset; despite for the forms
+ besides DW_FORM_ref_addr it is stored as cu_offset in the DWARF file. */
+
+static int
+attr_form_is_ref (const struct attribute *attr)
+{
+ switch (attr->form)
+ {
+ case DW_FORM_ref_addr:
+ case DW_FORM_ref1:
+ case DW_FORM_ref2:
+ case DW_FORM_ref4:
+ case DW_FORM_ref8:
+ case DW_FORM_ref_udata:
+ case DW_FORM_GNU_ref_alt:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
/* Return the .debug_loc section to use for CU.
For DWO files use .debug_loc.dwo. */
static void
fill_in_loclist_baton (struct dwarf2_cu *cu,
struct dwarf2_loclist_baton *baton,
- struct attribute *attr)
+ const struct attribute *attr)
{
struct dwarf2_section_info *section = cu_debug_loc_section (cu);
}
static void
-dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym,
+dwarf2_symbol_mark_computed (const struct attribute *attr, struct symbol *sym,
struct dwarf2_cu *cu, int is_block)
{
struct objfile *objfile = dwarf2_per_objfile->objfile;
struct dwarf2_per_objfile *data = 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);