#include "buildsym.h"
#include "demangle.h"
#include "gdb-demangle.h"
-#include "expression.h"
#include "filenames.h" /* for DOSish file names */
#include "macrotab.h"
#include "language.h"
#include "addrmap.h"
#include "typeprint.h"
#include "psympriv.h"
-#include <sys/stat.h>
-#include "completer.h"
-#include "gdbsupport/vec.h"
#include "c-lang.h"
#include "go-lang.h"
#include "valprint.h"
#include "gdbcore.h" /* for gnutarget */
#include "gdb/gdb-index.h"
-#include <ctype.h>
#include "gdb_bfd.h"
#include "f-lang.h"
#include "source.h"
-#include "gdbsupport/filestuff.h"
#include "build-id.h"
#include "namespace.h"
-#include "gdbsupport/gdb_unlinker.h"
#include "gdbsupport/function-view.h"
#include "gdbsupport/gdb_optional.h"
#include "gdbsupport/underlying.h"
-#include "gdbsupport/byte-vector.h"
#include "gdbsupport/hash_enum.h"
#include "filename-seen-cache.h"
#include "producer.h"
#include <fcntl.h>
-#include <sys/types.h>
#include <algorithm>
-#include <unordered_set>
#include <unordered_map>
#include "gdbsupport/selftest.h"
-#include <cmath>
-#include <set>
-#include <forward_list>
#include "rust-lang.h"
#include "gdbsupport/pathstuff.h"
/* When non-zero, dump line number entries as they are read in. */
static unsigned int dwarf_line_debug = 0;
-/* When non-zero, cross-check physname against demangler. */
-static int check_physname = 0;
+/* When true, cross-check physname against demangler. */
+static bool check_physname = false;
-/* When non-zero, do not reject deprecated .gdb_index sections. */
-static int use_deprecated_index_sections = 0;
+/* When true, do not reject deprecated .gdb_index sections. */
+static bool use_deprecated_index_sections = false;
static const struct objfile_key<dwarf2_per_objfile> dwarf2_objfile_data_key;
vector. */
std::pair<std::vector<name_component>::const_iterator,
std::vector<name_component>::const_iterator>
- find_name_components_bounds (const lookup_name_info &ln_no_params) const;
+ find_name_components_bounds (const lookup_name_info &ln_no_params,
+ enum language lang) const;
/* Prevent deleting/destroying via a base class pointer. */
protected:
This will be the first byte following the compilation unit header. */
cu_offset first_die_cu_offset;
- /* 64-bit signature of this type unit - it is valid only for
- UNIT_TYPE DW_UT_type. */
+
+ /* 64-bit signature of this unit. For type units, it denotes the signature of
+ the type (DW_UT_type in DWARF 4, additionally DW_UT_split_type in DWARF 5).
+ Also used in DWARF 5, to denote the dwo id when the unit type is
+ DW_UT_skeleton or DW_UT_split_compile. */
ULONGEST signature;
/* For types, offset in the type's DIE of the type defined by this TU. */
/* The TUs that share this DW_AT_stmt_list entry.
This is added to while parsing type units to build partial symtabs,
and is deleted afterwards and not used again. */
- VEC (sig_type_ptr) *tus;
+ std::vector<signatured_type *> *tus;
/* The compunit symtab.
Type units in a group needn't all be defined in the same source file,
cu_partial_die_info (struct dwarf2_cu *cu, struct partial_die_info *pdi)
: cu (cu),
pdi (pdi)
- { /* Nothhing. */ }
+ { /* Nothing. */ }
private:
cu_partial_die_info () = delete;
static const char *dwarf2_string_attr (struct die_info *die, unsigned int name,
struct dwarf2_cu *cu);
+static const char *dwarf2_dwo_name (struct die_info *die, struct dwarf2_cu *cu);
+
static int dwarf2_flag_true_p (struct die_info *die, unsigned name,
struct dwarf2_cu *cu);
static const char *dwarf_attr_name (unsigned int);
+static const char *dwarf_unit_type_name (int unit_type);
+
static const char *dwarf_form_name (unsigned int);
static const char *dwarf_bool_name (unsigned int);
/* See declaration. */
dwarf2_per_objfile::dwarf2_per_objfile (struct objfile *objfile_,
- const dwarf2_debug_sections *names)
- : objfile (objfile_)
+ const dwarf2_debug_sections *names,
+ bool can_copy_)
+ : objfile (objfile_),
+ can_copy (can_copy_)
{
if (names == NULL)
names = &dwarf2_elf_names;
htab_delete (line_header_hash);
for (dwarf2_per_cu_data *per_cu : all_comp_units)
- VEC_free (dwarf2_per_cu_ptr, per_cu->imported_symtabs);
+ per_cu->imported_symtabs_free ();
for (signatured_type *sig_type : all_type_units)
- VEC_free (dwarf2_per_cu_ptr, sig_type->per_cu.imported_symtabs);
+ sig_type->per_cu.imported_symtabs_free ();
/* Everything else should be on the objfile obstack. */
}
/* Try to locate the sections we need for DWARF 2 debugging
information and return true if we have enough to do something.
NAMES points to the dwarf2 section names, or is NULL if the standard
- ELF names are used. */
+ ELF names are used. CAN_COPY is true for formats where symbol
+ interposition is possible and so symbol values must follow copy
+ relocation rules. */
int
dwarf2_has_info (struct objfile *objfile,
- const struct dwarf2_debug_sections *names)
+ const struct dwarf2_debug_sections *names,
+ bool can_copy)
{
if (objfile->flags & OBJF_READNEVER)
return 0;
if (dwarf2_per_objfile == NULL)
dwarf2_per_objfile = dwarf2_objfile_data_key.emplace (objfile, objfile,
- names);
+ names,
+ can_copy);
return (!dwarf2_per_objfile->info.is_virtual
&& dwarf2_per_objfile->info.s.section != NULL
asection *sectp = get_section_bfd_section (section);
gdb_assert (sectp != NULL);
- return bfd_section_name (get_section_bfd_owner (section), sectp);
+ return bfd_section_name (sectp);
}
/* Return the name of the file SECTION is in. */
asection *sectp = get_section_bfd_section (section);
gdb_assert (sectp != NULL);
- return bfd_get_section_flags (sectp->owner, sectp);
+ return bfd_section_flags (sectp);
}
/* When loading sections, we look either for uncompressed section or for
dwarf2_per_objfile::locate_sections (bfd *abfd, asection *sectp,
const dwarf2_debug_sections &names)
{
- flagword aflag = bfd_get_section_flags (abfd, sectp);
+ flagword aflag = bfd_section_flags (sectp);
if ((aflag & SEC_HAS_CONTENTS) == 0)
{
}
+ else if (elf_section_data (sectp)->this_hdr.sh_size
+ > bfd_get_file_size (abfd))
+ {
+ bfd_size_type size = elf_section_data (sectp)->this_hdr.sh_size;
+ warning (_("Discarding section %s which has a section size (%s"
+ ") larger than the file size [in module %s]"),
+ bfd_section_name (sectp), phex_nz (size, sizeof (size)),
+ bfd_get_filename (abfd));
+ }
else if (section_is_p (sectp->name, &names.info))
{
this->info.s.section = sectp;
- this->info.size = bfd_get_section_size (sectp);
+ this->info.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names.abbrev))
{
this->abbrev.s.section = sectp;
- this->abbrev.size = bfd_get_section_size (sectp);
+ this->abbrev.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names.line))
{
this->line.s.section = sectp;
- this->line.size = bfd_get_section_size (sectp);
+ this->line.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names.loc))
{
this->loc.s.section = sectp;
- this->loc.size = bfd_get_section_size (sectp);
+ this->loc.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names.loclists))
{
this->loclists.s.section = sectp;
- this->loclists.size = bfd_get_section_size (sectp);
+ this->loclists.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names.macinfo))
{
this->macinfo.s.section = sectp;
- this->macinfo.size = bfd_get_section_size (sectp);
+ this->macinfo.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names.macro))
{
this->macro.s.section = sectp;
- this->macro.size = bfd_get_section_size (sectp);
+ this->macro.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names.str))
{
this->str.s.section = sectp;
- this->str.size = bfd_get_section_size (sectp);
+ this->str.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names.line_str))
{
this->line_str.s.section = sectp;
- this->line_str.size = bfd_get_section_size (sectp);
+ this->line_str.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names.addr))
{
this->addr.s.section = sectp;
- this->addr.size = bfd_get_section_size (sectp);
+ this->addr.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names.frame))
{
this->frame.s.section = sectp;
- this->frame.size = bfd_get_section_size (sectp);
+ this->frame.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names.eh_frame))
{
this->eh_frame.s.section = sectp;
- this->eh_frame.size = bfd_get_section_size (sectp);
+ this->eh_frame.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names.ranges))
{
this->ranges.s.section = sectp;
- this->ranges.size = bfd_get_section_size (sectp);
+ this->ranges.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names.rnglists))
{
this->rnglists.s.section = sectp;
- this->rnglists.size = bfd_get_section_size (sectp);
+ this->rnglists.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names.types))
{
memset (&type_section, 0, sizeof (type_section));
type_section.s.section = sectp;
- type_section.size = bfd_get_section_size (sectp);
+ type_section.size = bfd_section_size (sectp);
this->types.push_back (type_section);
}
else if (section_is_p (sectp->name, &names.gdb_index))
{
this->gdb_index.s.section = sectp;
- this->gdb_index.size = bfd_get_section_size (sectp);
+ this->gdb_index.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names.debug_names))
{
this->debug_names.s.section = sectp;
- this->debug_names.size = bfd_get_section_size (sectp);
+ this->debug_names.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names.debug_aranges))
{
this->debug_aranges.s.section = sectp;
- this->debug_aranges.size = bfd_get_section_size (sectp);
+ this->debug_aranges.size = bfd_section_size (sectp);
}
- if ((bfd_get_section_flags (abfd, sectp) & (SEC_LOAD | SEC_ALLOC))
- && bfd_section_vma (abfd, sectp) == 0)
+ if ((bfd_section_flags (sectp) & (SEC_LOAD | SEC_ALLOC))
+ && bfd_section_vma (sectp) == 0)
this->has_section_at_zero = true;
}
{
error (_("Dwarf Error: Can't read DWARF data"
" in section %s [in module %s]"),
- bfd_section_name (abfd, sectp), bfd_get_filename (abfd));
+ bfd_section_name (sectp), bfd_get_filename (abfd));
}
}
if (section_is_p (sectp->name, &dwarf2_elf_names.abbrev))
{
dwz_file->abbrev.s.section = sectp;
- dwz_file->abbrev.size = bfd_get_section_size (sectp);
+ dwz_file->abbrev.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &dwarf2_elf_names.info))
{
dwz_file->info.s.section = sectp;
- dwz_file->info.size = bfd_get_section_size (sectp);
+ dwz_file->info.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &dwarf2_elf_names.str))
{
dwz_file->str.s.section = sectp;
- dwz_file->str.size = bfd_get_section_size (sectp);
+ dwz_file->str.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &dwarf2_elf_names.line))
{
dwz_file->line.s.section = sectp;
- dwz_file->line.size = bfd_get_section_size (sectp);
+ dwz_file->line.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &dwarf2_elf_names.macro))
{
dwz_file->macro.s.section = sectp;
- dwz_file->macro.size = bfd_get_section_size (sectp);
+ dwz_file->macro.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &dwarf2_elf_names.gdb_index))
{
dwz_file->gdb_index.s.section = sectp;
- dwz_file->gdb_index.size = bfd_get_section_size (sectp);
+ dwz_file->gdb_index.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &dwarf2_elf_names.debug_names))
{
dwz_file->debug_names.s.section = sectp;
- dwz_file->debug_names.size = bfd_get_section_size (sectp);
+ dwz_file->debug_names.size = bfd_section_size (sectp);
}
}
return 0;
if (!read_gdb_index_from_buffer (objfile,
- bfd_get_filename (dwz->dwz_bfd), 1,
- dwz_index_content, &dwz_map,
+ bfd_get_filename (dwz->dwz_bfd.get ()),
+ 1, dwz_index_content, &dwz_map,
&dwz_list, &dwz_list_elements,
&dwz_types_ignore,
&dwz_types_elements_ignore))
{
warning (_("could not read '.gdb_index' section from %s; skipping"),
- bfd_get_filename (dwz->dwz_bfd));
+ bfd_get_filename (dwz->dwz_bfd.get ()));
return 0;
}
}
file_and_directory fnd = find_file_and_directory (comp_unit_die, cu);
- qfn->num_file_names = lh->file_names.size ();
+ int offset = 0;
+ if (strcmp (fnd.name, "<unknown>") != 0)
+ ++offset;
+
+ qfn->num_file_names = offset + lh->file_names.size ();
qfn->file_names =
- XOBNEWVEC (&objfile->objfile_obstack, const char *, lh->file_names.size ());
+ XOBNEWVEC (&objfile->objfile_obstack, const char *, qfn->num_file_names);
+ if (offset != 0)
+ qfn->file_names[0] = xstrdup (fnd.name);
for (i = 0; i < lh->file_names.size (); ++i)
- qfn->file_names[i] = file_full_name (i + 1, lh.get (), fnd.comp_dir);
+ qfn->file_names[i + offset] = file_full_name (i + 1, lh.get (), fnd.comp_dir);
qfn->real_names = NULL;
lh_cu->v.quick->file_names = qfn;
{
/* 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.
- Unused if !WANT_SPECIFIC_BLOCK. */
- int block_index;
+ /* If set, only look for symbols that match that block. Valid values are
+ GLOBAL_BLOCK and STATIC_BLOCK. */
+ gdb::optional<block_enum> block_index;
/* The kind of symbol we're looking for. */
domain_enum domain;
/* The list of CUs from the index entry of the symbol,
int global_seen;
};
-/* Initialize the index symtab iterator ITER.
- If WANT_SPECIFIC_BLOCK is non-zero, only look for symbols
- in block BLOCK_INDEX. Otherwise BLOCK_INDEX is ignored. */
+/* Initialize the index symtab iterator ITER. */
static void
dw2_symtab_iter_init (struct dw2_symtab_iterator *iter,
struct dwarf2_per_objfile *dwarf2_per_objfile,
- int want_specific_block,
- int block_index,
+ gdb::optional<block_enum> block_index,
domain_enum domain,
const char *name)
{
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;
offset_type cu_index_and_attrs =
MAYBE_SWAP (iter->vec[iter->next + 1]);
offset_type cu_index = GDB_INDEX_CU_VALUE (cu_index_and_attrs);
- int want_static = iter->block_index != GLOBAL_BLOCK;
- /* This value is only valid for index versions >= 7. */
- int is_static = GDB_INDEX_SYMBOL_STATIC_VALUE (cu_index_and_attrs);
gdb_index_symbol_kind symbol_kind =
GDB_INDEX_SYMBOL_KIND_VALUE (cu_index_and_attrs);
/* Only check the symbol attributes if they're present.
/* Check static vs global. */
if (attrs_valid)
{
- if (iter->want_specific_block
- && want_static != is_static)
- continue;
+ bool is_static = GDB_INDEX_SYMBOL_STATIC_VALUE (cu_index_and_attrs);
+
+ if (iter->block_index.has_value ())
+ {
+ bool want_static = *iter->block_index == STATIC_BLOCK;
+
+ if (is_static != want_static)
+ continue;
+ }
+
/* Work around gold/15646. */
if (!is_static && iter->global_seen)
continue;
}
static struct compunit_symtab *
-dw2_lookup_symbol (struct objfile *objfile, int block_index,
+dw2_lookup_symbol (struct objfile *objfile, block_enum block_index,
const char *name, domain_enum domain)
{
struct compunit_symtab *stab_best = NULL;
struct dw2_symtab_iterator iter;
struct dwarf2_per_cu_data *per_cu;
- dw2_symtab_iter_init (&iter, dwarf2_per_objfile, 1, block_index, domain, name);
+ dw2_symtab_iter_init (&iter, dwarf2_per_objfile, block_index, domain, name);
while ((per_cu = dw2_symtab_iter_next (&iter)) != NULL)
{
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);
+ dw2_symtab_iter_init (&iter, dwarf2_per_objfile, {}, VAR_DOMAIN, func_name);
while ((per_cu = dw2_symtab_iter_next (&iter)) != NULL)
dw2_instantiate_symtab (per_cu, false);
}
static void
-dw2_map_matching_symbols (struct objfile *objfile,
- const char * name, domain_enum domain,
- int global,
- int (*callback) (const struct block *,
- struct symbol *, void *),
- void *data, symbol_name_match_type match,
- symbol_compare_ftype *ordered_compare)
+dw2_map_matching_symbols
+ (struct objfile *objfile,
+ const lookup_name_info &name, domain_enum domain,
+ int global,
+ gdb::function_view<symbol_found_callback_ftype> callback,
+ symbol_compare_ftype *ordered_compare)
{
/* Currently unimplemented; used for Ada. The function can be called if the
current language is Ada for a non-Ada objfile using GNU index. As Ada
does not look for non-Ada symbols this function should just return. */
}
-/* Symbol name matcher for .gdb_index names.
-
- Symbol names in .gdb_index have a few particularities:
-
- - There's no indication of which is the language of each symbol.
-
- Since each language has its own symbol name matching algorithm,
- and we don't know which language is the right one, we must match
- each symbol against all languages. This would be a potential
- performance problem if it were not mitigated by the
- mapped_index::name_components lookup table, which significantly
- reduces the number of times we need to call into this matcher,
- making it a non-issue.
-
- - Symbol names in the index have no overload (parameter)
- information. I.e., in C++, "foo(int)" and "foo(long)" both
- appear as "foo" in the index, for example.
-
- This means that the lookup names passed to the symbol name
- matcher functions must have no parameter information either
- because (e.g.) symbol search name "foo" does not match
- lookup-name "foo(int)" [while swapping search name for lookup
- name would match].
-*/
-class gdb_index_symbol_name_matcher
-{
-public:
- /* Prepares the vector of comparison functions for LOOKUP_NAME. */
- gdb_index_symbol_name_matcher (const lookup_name_info &lookup_name);
-
- /* Walk all the matcher routines and match SYMBOL_NAME against them.
- Returns true if any matcher matches. */
- bool matches (const char *symbol_name);
-
-private:
- /* A reference to the lookup name we're matching against. */
- const lookup_name_info &m_lookup_name;
-
- /* A vector holding all the different symbol name matchers, for all
- languages. */
- std::vector<symbol_name_matcher_ftype *> m_symbol_name_matcher_funcs;
-};
-
-gdb_index_symbol_name_matcher::gdb_index_symbol_name_matcher
- (const lookup_name_info &lookup_name)
- : m_lookup_name (lookup_name)
-{
- /* Prepare the vector of comparison functions upfront, to avoid
- doing the same work for each symbol. Care is taken to avoid
- matching with the same matcher more than once if/when multiple
- languages use the same matcher function. */
- auto &matchers = m_symbol_name_matcher_funcs;
- matchers.reserve (nr_languages);
-
- matchers.push_back (default_symbol_name_matcher);
-
- for (int i = 0; i < nr_languages; i++)
- {
- const language_defn *lang = language_def ((enum language) i);
- symbol_name_matcher_ftype *name_matcher
- = get_symbol_name_matcher (lang, m_lookup_name);
-
- /* Don't insert the same comparison routine more than once.
- Note that we do this linear walk instead of a seemingly
- cheaper sorted insert, or use a std::set or something like
- that, because relative order of function addresses is not
- stable. This is not a problem in practice because the number
- of supported languages is low, and the cost here is tiny
- compared to the number of searches we'll do afterwards using
- this object. */
- if (name_matcher != default_symbol_name_matcher
- && (std::find (matchers.begin (), matchers.end (), name_matcher)
- == matchers.end ()))
- matchers.push_back (name_matcher);
- }
-}
-
-bool
-gdb_index_symbol_name_matcher::matches (const char *symbol_name)
-{
- for (auto matches_name : m_symbol_name_matcher_funcs)
- if (matches_name (symbol_name, m_lookup_name, NULL))
- return true;
-
- return false;
-}
-
/* Starting from a search name, return the string that finds the upper
bound of all strings that start with SEARCH_NAME in a sorted name
list. Returns the empty string to indicate that the upper bound is
std::pair<std::vector<name_component>::const_iterator,
std::vector<name_component>::const_iterator>
mapped_index_base::find_name_components_bounds
- (const lookup_name_info &lookup_name_without_params) const
+ (const lookup_name_info &lookup_name_without_params, language lang) const
{
auto *name_cmp
= this->name_components_casing == case_sensitive_on ? strcmp : strcasecmp;
- const char *cplus
- = lookup_name_without_params.cplus ().lookup_name ().c_str ();
+ const char *lang_name
+ = lookup_name_without_params.language_lookup_name (lang).c_str ();
/* Comparison function object for lower_bound that matches against a
given symbol name. */
/* Find the lower bound. */
auto lower = [&] ()
{
- if (lookup_name_without_params.completion_mode () && cplus[0] == '\0')
+ if (lookup_name_without_params.completion_mode () && lang_name[0] == '\0')
return begin;
else
- return std::lower_bound (begin, end, cplus, lookup_compare_lower);
+ return std::lower_bound (begin, end, lang_name, lookup_compare_lower);
} ();
/* Find the upper bound. */
We find the upper bound by looking for the insertion
point of "func"-with-last-character-incremented,
i.e. "fund". */
- std::string after = make_sort_after_prefix_name (cplus);
+ std::string after = make_sort_after_prefix_name (lang_name);
if (after.empty ())
return end;
return std::lower_bound (lower, end, after.c_str (),
lookup_compare_lower);
}
else
- return std::upper_bound (lower, end, cplus, lookup_compare_upper);
+ return std::upper_bound (lower, end, lang_name, lookup_compare_upper);
} ();
return {lower, upper};
/* The code below only knows how to break apart components of C++
symbol names (and other languages that use '::' as
- namespace/module separator). If we add support for wild matching
- to some language that uses some other operator (E.g., Ada, Go and
- D use '.'), then we'll need to try splitting the symbol name
- according to that language too. Note that Ada does support wild
- matching, but doesn't currently support .gdb_index. */
+ namespace/module separator) and Ada symbol names. */
auto count = this->symbol_name_count ();
for (offset_type idx = 0; idx < count; idx++)
{
/* Add each name component to the name component table. */
unsigned int previous_len = 0;
- for (unsigned int current_len = cp_find_first_component (name);
- name[current_len] != '\0';
- current_len += cp_find_first_component (name + current_len))
+
+ if (strstr (name, "::") != nullptr)
+ {
+ for (unsigned int current_len = cp_find_first_component (name);
+ name[current_len] != '\0';
+ current_len += cp_find_first_component (name + current_len))
+ {
+ gdb_assert (name[current_len] == ':');
+ this->name_components.push_back ({previous_len, idx});
+ /* Skip the '::'. */
+ current_len += 2;
+ previous_len = current_len;
+ }
+ }
+ else
{
- gdb_assert (name[current_len] == ':');
- this->name_components.push_back ({previous_len, idx});
- /* Skip the '::'. */
- current_len += 2;
- previous_len = current_len;
+ /* Handle the Ada encoded (aka mangled) form here. */
+ for (const char *iter = strstr (name, "__");
+ iter != nullptr;
+ iter = strstr (iter, "__"))
+ {
+ this->name_components.push_back ({previous_len, idx});
+ iter += 2;
+ previous_len = iter - name;
+ }
}
+
this->name_components.push_back ({previous_len, idx});
}
const lookup_name_info &lookup_name_in,
gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
enum search_domain kind,
- gdb::function_view<void (offset_type)> match_callback)
+ gdb::function_view<bool (offset_type)> match_callback)
{
lookup_name_info lookup_name_without_params
= lookup_name_in.make_ignore_params ();
- gdb_index_symbol_name_matcher lookup_name_matcher
- (lookup_name_without_params);
/* Build the symbol name component sorted vector, if we haven't
yet. */
index.build_name_components ();
- auto bounds = index.find_name_components_bounds (lookup_name_without_params);
-
- /* Now for each symbol name in range, check to see if we have a name
- match, and if so, call the MATCH_CALLBACK callback. */
-
/* The same symbol may appear more than once in the range though.
E.g., if we're looking for symbols that complete "w", and we have
a symbol named "w1::w2", we'll find the two name components for
indexes that matched in a temporary vector and ignore
duplicates. */
std::vector<offset_type> matches;
- matches.reserve (std::distance (bounds.first, bounds.second));
- for (; bounds.first != bounds.second; ++bounds.first)
+ struct name_and_matcher
+ {
+ symbol_name_matcher_ftype *matcher;
+ const std::string &name;
+
+ bool operator== (const name_and_matcher &other) const
{
- const char *qualified = index.symbol_name_at (bounds.first->idx);
+ return matcher == other.matcher && name == other.name;
+ }
+ };
- if (!lookup_name_matcher.matches (qualified)
- || (symbol_matcher != NULL && !symbol_matcher (qualified)))
+ /* A vector holding all the different symbol name matchers, for all
+ languages. */
+ std::vector<name_and_matcher> matchers;
+
+ for (int i = 0; i < nr_languages; i++)
+ {
+ enum language lang_e = (enum language) i;
+
+ const language_defn *lang = language_def (lang_e);
+ symbol_name_matcher_ftype *name_matcher
+ = get_symbol_name_matcher (lang, lookup_name_without_params);
+
+ name_and_matcher key {
+ name_matcher,
+ lookup_name_without_params.language_lookup_name (lang_e)
+ };
+
+ /* Don't insert the same comparison routine more than once.
+ Note that we do this linear walk. This is not a problem in
+ practice because the number of supported languages is
+ low. */
+ if (std::find (matchers.begin (), matchers.end (), key)
+ != matchers.end ())
continue;
+ matchers.push_back (std::move (key));
+
+ auto bounds
+ = index.find_name_components_bounds (lookup_name_without_params,
+ lang_e);
+
+ /* Now for each symbol name in range, check to see if we have a name
+ match, and if so, call the MATCH_CALLBACK callback. */
+
+ for (; bounds.first != bounds.second; ++bounds.first)
+ {
+ const char *qualified = index.symbol_name_at (bounds.first->idx);
+
+ if (!name_matcher (qualified, lookup_name_without_params, NULL)
+ || (symbol_matcher != NULL && !symbol_matcher (qualified)))
+ continue;
- matches.push_back (bounds.first->idx);
+ matches.push_back (bounds.first->idx);
+ }
}
std::sort (matches.begin (), matches.end ());
{
if (prev != idx)
{
- match_callback (idx);
+ if (!match_callback (idx))
+ break;
prev = idx;
}
}
if (expected_str == NULL || strcmp (expected_str, matched_name) != 0)
mismatch (expected_str, matched_name);
+ return true;
});
const char *expected_str
lookup_name_info lookup_name (search_name,
symbol_name_match_type::FULL, true);
- auto bounds = index.find_name_components_bounds (lookup_name);
+ auto bounds = index.find_name_components_bounds (lookup_name,
+ language_cplus);
size_t distance = std::distance (bounds.first, bounds.second);
if (distance != expected_syms.size ())
{
dw2_expand_marked_cus (dwarf2_per_objfile, idx, file_matcher,
expansion_notify, kind);
+ return true;
});
}
if (dwz != NULL)
{
if (!read_debug_names_from_section (objfile,
- bfd_get_filename (dwz->dwz_bfd),
+ bfd_get_filename (dwz->dwz_bfd.get ()),
&dwz->debug_names, dwz_map))
{
warning (_("could not read '.debug_names' section from %s; skipping"),
- bfd_get_filename (dwz->dwz_bfd));
+ bfd_get_filename (dwz->dwz_bfd.get ()));
return false;
}
}
class dw2_debug_names_iterator
{
public:
- /* If WANT_SPECIFIC_BLOCK is true, only look for symbols in block
- BLOCK_INDEX. Otherwise BLOCK_INDEX is ignored. */
dw2_debug_names_iterator (const mapped_debug_names &map,
- bool want_specific_block,
- block_enum block_index, domain_enum domain,
+ gdb::optional<block_enum> block_index,
+ domain_enum domain,
const char *name)
- : m_map (map), m_want_specific_block (want_specific_block),
- m_block_index (block_index), m_domain (domain),
+ : m_map (map), m_block_index (block_index), m_domain (domain),
m_addr (find_vec_in_debug_names (map, name))
{}
m_addr (find_vec_in_debug_names (map, namei))
{}
+ dw2_debug_names_iterator (const mapped_debug_names &map,
+ block_enum block_index, domain_enum domain,
+ uint32_t namei)
+ : m_map (map), m_block_index (block_index), m_domain (domain),
+ m_addr (find_vec_in_debug_names (map, namei))
+ {}
+
/* Return the next matching CU or NULL if there are no more. */
dwarf2_per_cu_data *next ();
/* The internalized form of .debug_names. */
const mapped_debug_names &m_map;
- /* If true, only look for symbols that match BLOCK_INDEX. */
- const bool m_want_specific_block = false;
-
- /* One of GLOBAL_BLOCK or STATIC_BLOCK.
- Unused if !WANT_SPECIFIC_BLOCK - FIRST_LOCAL_BLOCK is an invalid
- value. */
- const block_enum m_block_index = FIRST_LOCAL_BLOCK;
+ /* If set, only look for symbols that match that block. Valid values are
+ GLOBAL_BLOCK and STATIC_BLOCK. */
+ const gdb::optional<block_enum> m_block_index;
/* The kind of symbol we're looking for. */
const domain_enum m_domain = UNDEF_DOMAIN;
return NULL;
}
const mapped_debug_names::index_val &indexval = indexval_it->second;
- bool have_is_static = false;
- bool is_static;
+ enum class symbol_linkage {
+ unknown,
+ static_,
+ extern_,
+ } symbol_linkage_ = symbol_linkage::unknown;
dwarf2_per_cu_data *per_cu = NULL;
for (const mapped_debug_names::index_val::attr &attr : indexval.attr_vec)
{
case DW_IDX_GNU_internal:
if (!m_map.augmentation_is_gdb)
break;
- have_is_static = true;
- is_static = true;
+ symbol_linkage_ = symbol_linkage::static_;
break;
case DW_IDX_GNU_external:
if (!m_map.augmentation_is_gdb)
break;
- have_is_static = true;
- is_static = false;
+ symbol_linkage_ = symbol_linkage::extern_;
break;
}
}
goto again;
/* Check static vs global. */
- if (have_is_static)
+ if (symbol_linkage_ != symbol_linkage::unknown && m_block_index.has_value ())
{
- const bool want_static = m_block_index != GLOBAL_BLOCK;
- if (m_want_specific_block && want_static != is_static)
- goto again;
+ const bool want_static = *m_block_index == STATIC_BLOCK;
+ const bool symbol_is_static =
+ symbol_linkage_ == symbol_linkage::static_;
+ if (want_static != symbol_is_static)
+ goto again;
}
/* Match dw2_symtab_iter_next, symbol_kind
}
static struct compunit_symtab *
-dw2_debug_names_lookup_symbol (struct objfile *objfile, int block_index_int,
+dw2_debug_names_lookup_symbol (struct objfile *objfile, block_enum block_index,
const char *name, domain_enum domain)
{
- const block_enum block_index = static_cast<block_enum> (block_index_int);
struct dwarf2_per_objfile *dwarf2_per_objfile
= get_dwarf2_per_objfile (objfile);
}
const auto &map = *mapp;
- dw2_debug_names_iterator iter (map, true /* want_specific_block */,
- block_index, domain, name);
+ dw2_debug_names_iterator iter (map, block_index, domain, name);
struct compunit_symtab *stab_best = NULL;
struct dwarf2_per_cu_data *per_cu;
{
const mapped_debug_names &map = *dwarf2_per_objfile->debug_names_table;
- /* Note: It doesn't matter what we pass for block_index here. */
- dw2_debug_names_iterator iter (map, false /* want_specific_block */,
- GLOBAL_BLOCK, VAR_DOMAIN, func_name);
+ dw2_debug_names_iterator iter (map, {}, VAR_DOMAIN, func_name);
struct dwarf2_per_cu_data *per_cu;
while ((per_cu = iter.next ()) != NULL)
}
}
+static void
+dw2_debug_names_map_matching_symbols
+ (struct objfile *objfile,
+ const lookup_name_info &name, domain_enum domain,
+ int global,
+ gdb::function_view<symbol_found_callback_ftype> callback,
+ symbol_compare_ftype *ordered_compare)
+{
+ 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;
+
+ mapped_debug_names &map = *dwarf2_per_objfile->debug_names_table;
+ const block_enum block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK;
+
+ const char *match_name = name.ada ().lookup_name ().c_str ();
+ auto matcher = [&] (const char *symname)
+ {
+ if (ordered_compare == nullptr)
+ return true;
+ return ordered_compare (symname, match_name) == 0;
+ };
+
+ dw2_expand_symtabs_matching_symbol (map, name, matcher, ALL_DOMAIN,
+ [&] (offset_type namei)
+ {
+ /* The name was matched, now expand corresponding CUs that were
+ marked. */
+ dw2_debug_names_iterator iter (map, block_kind, domain, namei);
+
+ struct dwarf2_per_cu_data *per_cu;
+ while ((per_cu = iter.next ()) != NULL)
+ dw2_expand_symtabs_matching_one (per_cu, nullptr, nullptr);
+ return true;
+ });
+
+ /* It's a shame we couldn't do this inside the
+ dw2_expand_symtabs_matching_symbol callback, but that skips CUs
+ that have already been expanded. Instead, this loop matches what
+ the psymtab code does. */
+ for (dwarf2_per_cu_data *per_cu : dwarf2_per_objfile->all_comp_units)
+ {
+ struct compunit_symtab *cust = per_cu->v.quick->compunit_symtab;
+ if (cust != nullptr)
+ {
+ const struct block *block
+ = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), block_kind);
+ if (!iterate_over_symbols_terminated (block, name,
+ domain, callback))
+ break;
+ }
+ }
+}
+
static void
dw2_debug_names_expand_symtabs_matching
(struct objfile *objfile,
while ((per_cu = iter.next ()) != NULL)
dw2_expand_symtabs_matching_one (per_cu, file_matcher,
expansion_notify);
+ return true;
});
}
dw2_debug_names_expand_symtabs_for_function,
dw2_expand_all_symtabs,
dw2_expand_symtabs_with_fullname,
- dw2_map_matching_symbols,
+ dw2_debug_names_map_matching_symbols,
dw2_debug_names_expand_symtabs_matching,
dw2_find_pc_sect_compunit_symtab,
NULL,
switch (cu_header->unit_type)
{
case DW_UT_compile:
+ case DW_UT_partial:
+ case DW_UT_skeleton:
+ case DW_UT_split_compile:
if (section_kind != rcuh_kind::COMPILE)
error (_("Dwarf Error: wrong unit_type in compilation unit header "
- "(is DW_UT_compile, should be DW_UT_type) [in module %s]"),
- filename);
+ "(is %s, should be %s) [in module %s]"),
+ dwarf_unit_type_name (cu_header->unit_type),
+ dwarf_unit_type_name (DW_UT_type), filename);
break;
case DW_UT_type:
+ case DW_UT_split_type:
section_kind = rcuh_kind::TYPE;
break;
default:
error (_("Dwarf Error: wrong unit_type in compilation unit header "
- "(is %d, should be %d or %d) [in module %s]"),
- cu_header->unit_type, DW_UT_compile, DW_UT_type, filename);
+ "(is %#04x, should be one of: %s, %s, %s, %s or %s) "
+ "[in module %s]"), cu_header->unit_type,
+ dwarf_unit_type_name (DW_UT_compile),
+ dwarf_unit_type_name (DW_UT_skeleton),
+ dwarf_unit_type_name (DW_UT_split_compile),
+ dwarf_unit_type_name (DW_UT_type),
+ dwarf_unit_type_name (DW_UT_split_type), filename);
}
cu_header->addr_size = read_1_byte (abfd, info_ptr);
_("read_comp_unit_head: dwarf from non elf file"));
cu_header->signed_addr_p = signed_addr;
- if (section_kind == rcuh_kind::TYPE)
- {
- LONGEST type_offset;
+ bool header_has_signature = section_kind == rcuh_kind::TYPE
+ || cu_header->unit_type == DW_UT_skeleton
+ || cu_header->unit_type == DW_UT_split_compile;
+ if (header_has_signature)
+ {
cu_header->signature = read_8_bytes (abfd, info_ptr);
info_ptr += 8;
+ }
+ if (section_kind == rcuh_kind::TYPE)
+ {
+ LONGEST type_offset;
type_offset = read_offset (abfd, info_ptr, cu_header, &bytes_read);
info_ptr += bytes_read;
cu_header->type_cu_offset_in_tu = (cu_offset) type_offset;
return 1;
}
+/* Return the signature of the compile unit, if found. In DWARF 4 and before,
+ the signature is in the DW_AT_GNU_dwo_id attribute. In DWARF 5 and later, the
+ signature is part of the header. */
+static gdb::optional<ULONGEST>
+lookup_dwo_id (struct dwarf2_cu *cu, struct die_info* comp_unit_die)
+{
+ if (cu->header.version >= 5)
+ return cu->header.signature;
+ struct attribute *attr;
+ attr = dwarf2_attr (comp_unit_die, DW_AT_GNU_dwo_id, cu);
+ if (attr == nullptr)
+ return gdb::optional<ULONGEST> ();
+ return DW_UNSND (attr);
+}
+
/* Subroutine of init_cutu_and_read_dies to simplify it.
Look up the DWO unit specified by COMP_UNIT_DIE of THIS_CU.
Returns NULL if the specified DWO unit cannot be found. */
struct die_info *comp_unit_die)
{
struct dwarf2_cu *cu = this_cu->cu;
- ULONGEST signature;
struct dwo_unit *dwo_unit;
const char *comp_dir, *dwo_name;
gdb_assert (cu != NULL);
/* Yeah, we look dwo_name up again, but it simplifies the code. */
- dwo_name = dwarf2_string_attr (comp_unit_die, DW_AT_GNU_dwo_name, cu);
+ dwo_name = dwarf2_dwo_name (comp_unit_die, cu);
comp_dir = dwarf2_string_attr (comp_unit_die, DW_AT_comp_dir, cu);
if (this_cu->is_debug_types)
/* Since this_cu is the first member of struct signatured_type,
we can go from a pointer to one to a pointer to the other. */
sig_type = (struct signatured_type *) this_cu;
- signature = sig_type->signature;
dwo_unit = lookup_dwo_type_unit (sig_type, dwo_name, comp_dir);
}
else
{
- struct attribute *attr;
-
- attr = dwarf2_attr (comp_unit_die, DW_AT_GNU_dwo_id, cu);
- if (! attr)
+ gdb::optional<ULONGEST> signature = lookup_dwo_id (cu, comp_unit_die);
+ if (!signature.has_value ())
error (_("Dwarf Error: missing dwo_id for dwo_name %s"
" [in module %s]"),
dwo_name, objfile_name (this_cu->dwarf2_per_objfile->objfile));
- signature = DW_UNSND (attr);
dwo_unit = lookup_dwo_comp_unit (this_cu, dwo_name, comp_dir,
- signature);
+ *signature);
}
return dwo_unit;
struct die_reader_specs reader;
struct die_info *comp_unit_die;
int has_children;
- struct attribute *attr;
struct signatured_type *sig_type = NULL;
struct dwarf2_section_info *abbrev_section;
/* Non-zero if CU currently points to a DWO file and we need to
Note that if USE_EXISTING_OK != 0, and THIS_CU->cu already contains a
DWO CU, that this test will fail (the attribute will not be present). */
- attr = dwarf2_attr (comp_unit_die, DW_AT_GNU_dwo_name, cu);
+ const char *dwo_name = dwarf2_dwo_name (comp_unit_die, cu);
abbrev_table_up dwo_abbrev_table;
- if (attr)
+ if (dwo_name != nullptr)
{
struct dwo_unit *dwo_unit;
struct die_info *dwo_comp_unit_die;
end_psymtab_common (objfile, pst);
- if (!VEC_empty (dwarf2_per_cu_ptr, cu->per_cu->imported_symtabs))
+ if (!cu->per_cu->imported_symtabs_empty ())
{
int i;
- int len = VEC_length (dwarf2_per_cu_ptr, cu->per_cu->imported_symtabs);
- struct dwarf2_per_cu_data *iter;
+ int len = cu->per_cu->imported_symtabs_size ();
/* Fill in 'dependencies' here; we fill in 'users' in a
post-pass. */
pst->number_of_dependencies = len;
pst->dependencies
= objfile->partial_symtabs->allocate_dependencies (len);
- for (i = 0;
- VEC_iterate (dwarf2_per_cu_ptr, cu->per_cu->imported_symtabs,
- i, iter);
- ++i)
- pst->dependencies[i] = iter->v.psymtab;
+ for (i = 0; i < len; ++i)
+ {
+ pst->dependencies[i]
+ = cu->per_cu->imported_symtabs->at (i)->v.psymtab;
+ }
- VEC_free (dwarf2_per_cu_ptr, cu->per_cu->imported_symtabs);
+ cu->per_cu->imported_symtabs_free ();
}
/* Get the list of files included in the current compilation unit,
attr = dwarf2_attr_no_follow (type_unit_die, DW_AT_stmt_list);
tu_group = get_type_unit_group (cu, attr);
- VEC_safe_push (sig_type_ptr, tu_group->tus, sig_type);
+ if (tu_group->tus == nullptr)
+ tu_group->tus = new std::vector<signatured_type *>;
+ tu_group->tus->push_back (sig_type);
prepare_one_comp_unit (cu, type_unit_die, language_minimal);
pst = create_partial_symtab (per_cu, "");
struct type_unit_group *tu_group = (struct type_unit_group *) *slot;
struct dwarf2_per_cu_data *per_cu = &tu_group->per_cu;
struct partial_symtab *pst = per_cu->v.psymtab;
- int len = VEC_length (sig_type_ptr, tu_group->tus);
- struct signatured_type *iter;
+ int len = (tu_group->tus == nullptr) ? 0 : tu_group->tus->size ();
int i;
gdb_assert (len > 0);
pst->number_of_dependencies = len;
pst->dependencies = objfile->partial_symtabs->allocate_dependencies (len);
- for (i = 0;
- VEC_iterate (sig_type_ptr, tu_group->tus, i, iter);
- ++i)
+ for (i = 0; i < len; ++i)
{
+ struct signatured_type *iter = tu_group->tus->at (i);
gdb_assert (iter->per_cu.is_debug_types);
pst->dependencies[i] = iter->per_cu.v.psymtab;
iter->type_unit_group = tu_group;
}
- VEC_free (sig_type_ptr, tu_group->tus);
+ delete tu_group->tus;
+ tu_group->tus = nullptr;
return 1;
}
if (per_cu->v.psymtab == NULL)
process_psymtab_comp_unit (per_cu, 1, cu->language);
- VEC_safe_push (dwarf2_per_cu_ptr,
- cu->per_cu->imported_symtabs, per_cu);
+ cu->per_cu->imported_symtabs_push (per_cu);
}
break;
case DW_TAG_imported_declaration:
return NULL;
}
+ /* Nested subroutines in Fortran get a prefix. */
if (pdi->tag == DW_TAG_enumerator)
/* Enumerators should not get the name of the enumeration as a prefix. */
parent->scope = grandparent_scope;
|| parent->tag == DW_TAG_class_type
|| parent->tag == DW_TAG_interface_type
|| parent->tag == DW_TAG_union_type
- || parent->tag == DW_TAG_enumeration_type)
+ || parent->tag == DW_TAG_enumeration_type
+ || (cu->language == language_fortran
+ && parent->tag == DW_TAG_subprogram
+ && pdi->tag == DW_TAG_subprogram))
{
if (grandparent_scope == NULL)
parent->scope = parent->name;
case DW_TAG_subprogram:
addr = (gdbarch_adjust_dwarf2_addr (gdbarch, pdi->lowpc + baseaddr)
- baseaddr);
- if (pdi->is_external || cu->language == language_ada)
- {
- /* brobecker/2007-12-26: Normally, only "external" DIEs are part
- of the global scope. But in Ada, we want to be able to access
- nested procedures globally. So all Ada subprograms are stored
- in the global scope. */
+ if (pdi->is_external
+ || cu->language == language_ada
+ || (cu->language == language_fortran
+ && pdi->die_parent != NULL
+ && pdi->die_parent->tag == DW_TAG_subprogram))
+ {
+ /* Normally, only "external" DIEs are part of the global scope.
+ But in Ada and Fortran, we want to be able to access nested
+ procedures globally. So all Ada and Fortran subprograms are
+ stored in the global scope. */
add_psymbol_to_list (actual_name, strlen (actual_name),
built_actual_name != NULL,
VAR_DOMAIN, LOC_BLOCK,
if (! pdi->has_children)
return;
- if (cu->language == language_ada)
+ if (cu->language == language_ada || cu->language == language_fortran)
{
pdi = pdi->die_child;
while (pdi != NULL)
case DW_FORM_data1:
case DW_FORM_ref1:
case DW_FORM_flag:
+ case DW_FORM_strx1:
info_ptr += 1;
break;
case DW_FORM_flag_present:
break;
case DW_FORM_data2:
case DW_FORM_ref2:
+ case DW_FORM_strx2:
info_ptr += 2;
break;
+ case DW_FORM_strx3:
+ info_ptr += 3;
+ break;
case DW_FORM_data4:
case DW_FORM_ref4:
+ case DW_FORM_strx4:
info_ptr += 4;
break;
case DW_FORM_data8:
{
struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile;
const char *saved_package_name
- = (const char *) obstack_copy0 (&objfile->per_bfd->storage_obstack,
- package_name,
- strlen (package_name));
+ = obstack_strdup (&objfile->per_bfd->storage_obstack, package_name);
struct type *type = init_type (objfile, TYPE_CODE_MODULE, 0,
saved_package_name);
struct symbol *sym;
SET_FIELD_BITPOS (TYPE_FIELD (type, 0), 0);
TYPE_FIELD_NAME (type, 0) = "<<variants>>";
}
- else if (TYPE_NFIELDS (type) == 1)
+ /* A union with a single anonymous field is probably an old-style
+ univariant enum. */
+ else if (TYPE_NFIELDS (type) == 1 && streq (TYPE_FIELD_NAME (type, 0), ""))
{
- /* We assume that a union with a single field is a univariant
- enum. */
/* Smash this type to be a structure type. We have to do this
because the type has already been recorded. */
TYPE_CODE (type) = TYPE_CODE_STRUCT;
struct compunit_symtab *immediate_parent)
{
void **slot;
- int ix;
struct compunit_symtab *cust;
- struct dwarf2_per_cu_data *iter;
slot = htab_find_slot (all_children, per_cu, INSERT);
if (*slot != NULL)
}
}
- for (ix = 0;
- VEC_iterate (dwarf2_per_cu_ptr, per_cu->imported_symtabs, ix, iter);
- ++ix)
- {
- recursively_compute_inclusions (result, all_children,
- all_type_symtabs, iter, cust);
- }
+ if (!per_cu->imported_symtabs_empty ())
+ for (dwarf2_per_cu_data *ptr : *per_cu->imported_symtabs)
+ {
+ recursively_compute_inclusions (result, all_children,
+ all_type_symtabs, ptr, cust);
+ }
}
/* Compute the compunit_symtab 'includes' fields for the compunit_symtab of
{
gdb_assert (! per_cu->is_debug_types);
- if (!VEC_empty (dwarf2_per_cu_ptr, per_cu->imported_symtabs))
+ if (!per_cu->imported_symtabs_empty ())
{
- int ix, len;
- struct dwarf2_per_cu_data *per_cu_iter;
+ int len;
std::vector<compunit_symtab *> result_symtabs;
htab_t all_children, all_type_symtabs;
struct compunit_symtab *cust = get_compunit_symtab (per_cu);
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, per_cu_iter);
- ++ix)
+ for (dwarf2_per_cu_data *ptr : *per_cu->imported_symtabs)
{
recursively_compute_inclusions (&result_symtabs, all_children,
- all_type_symtabs, per_cu_iter,
- cust);
+ all_type_symtabs, ptr, cust);
}
/* Now we have a transitive closure of all the included symtabs. */
if (cu->language == language_go)
fixup_go_packaging (cu);
- /* Now that we have processed all the DIEs in the CU, all the types
+ /* Now that we have processed all the DIEs in the CU, all the types
should be complete, and it should now be safe to compute all of the
physnames. */
compute_delayed_physnames (cu);
Still one can confuse GDB by using non-standard GCC compilation
options - this waits on GCC PR other/32998 (-frecord-gcc-switches).
- */
+ */
if (cu->has_loclist && gcc_4_minor >= 5)
cust->locations_valid = 1;
if (cu->language == language_go)
fixup_go_packaging (cu);
- /* Now that we have processed all the DIEs in the CU, all the types
+ /* Now that we have processed all the DIEs in the CU, all the types
should be complete, and it should now be safe to compute all of the
physnames. */
compute_delayed_physnames (cu);
if (maybe_queue_comp_unit (cu, per_cu, cu->language))
load_full_comp_unit (per_cu, false, cu->language);
- VEC_safe_push (dwarf2_per_cu_ptr, cu->per_cu->imported_symtabs,
- per_cu);
+ cu->per_cu->imported_symtabs_push (per_cu);
}
}
read_type_unit_scope (die, cu);
break;
case DW_TAG_subprogram:
+ /* Nested subprograms in Fortran get a prefix. */
+ if (cu->language == language_fortran
+ && die->parent != NULL
+ && die->parent->tag == DW_TAG_subprogram)
+ cu->processing_has_namespace_info = true;
+ /* Fall through. */
case DW_TAG_inlined_subroutine:
read_func_scope (die, cu);
break;
INTERMEDIATE_NAME is already canonical, then we need to
copy it to the appropriate obstack. */
if (canonical_name == NULL || canonical_name == intermediate_name.c_str ())
- name = ((const char *)
- obstack_copy0 (&objfile->per_bfd->storage_obstack,
- intermediate_name.c_str (),
- intermediate_name.length ()));
+ name = obstack_strdup (&objfile->per_bfd->storage_obstack,
+ intermediate_name);
else
name = canonical_name;
}
retval = canon;
if (need_copy)
- retval = ((const char *)
- obstack_copy0 (&objfile->per_bfd->storage_obstack,
- retval, strlen (retval)));
+ retval = obstack_strdup (&objfile->per_bfd->storage_obstack, retval);
return retval;
}
struct create_dwo_cu_data *data = (struct create_dwo_cu_data *) datap;
struct dwo_file *dwo_file = data->dwo_file;
struct dwo_unit *dwo_unit = &data->dwo_unit;
- struct attribute *attr;
- attr = dwarf2_attr (comp_unit_die, DW_AT_GNU_dwo_id, cu);
- if (attr == NULL)
+ gdb::optional<ULONGEST> signature = lookup_dwo_id (cu, comp_unit_die);
+ if (!signature.has_value ())
{
complaint (_("Dwarf Error: debug entry at offset %s is missing"
" its dwo_id [in module %s]"),
}
dwo_unit->dwo_file = dwo_file;
- dwo_unit->signature = DW_UNSND (attr);
+ dwo_unit->signature = *signature;
dwo_unit->section = section;
dwo_unit->sect_off = sect_off;
dwo_unit->length = cu->per_cu->length;
if (sections->abbrev.s.section != NULL)
return 0;
sections->abbrev.s.section = sectp;
- sections->abbrev.size = bfd_get_section_size (sectp);
+ sections->abbrev.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->info_dwo)
|| section_is_p (sectp->name, &names->types_dwo))
if (sections->info_or_types.s.section != NULL)
return 0;
sections->info_or_types.s.section = sectp;
- sections->info_or_types.size = bfd_get_section_size (sectp);
+ sections->info_or_types.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->line_dwo))
{
if (sections->line.s.section != NULL)
return 0;
sections->line.s.section = sectp;
- sections->line.size = bfd_get_section_size (sectp);
+ sections->line.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->loc_dwo))
{
if (sections->loc.s.section != NULL)
return 0;
sections->loc.s.section = sectp;
- sections->loc.size = bfd_get_section_size (sectp);
+ sections->loc.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->macinfo_dwo))
{
if (sections->macinfo.s.section != NULL)
return 0;
sections->macinfo.s.section = sectp;
- sections->macinfo.size = bfd_get_section_size (sectp);
+ sections->macinfo.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->macro_dwo))
{
if (sections->macro.s.section != NULL)
return 0;
sections->macro.s.section = sectp;
- sections->macro.size = bfd_get_section_size (sectp);
+ sections->macro.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->str_offsets_dwo))
{
if (sections->str_offsets.s.section != NULL)
return 0;
sections->str_offsets.s.section = sectp;
- sections->str_offsets.size = bfd_get_section_size (sectp);
+ sections->str_offsets.size = bfd_section_size (sectp);
}
else
{
virtual_dwo_name.c_str ());
}
dwo_file = new struct dwo_file;
- dwo_file->dwo_name
- = (const char *) obstack_copy0 (&objfile->objfile_obstack,
- virtual_dwo_name.c_str (),
- virtual_dwo_name.size ());
+ dwo_file->dwo_name = obstack_strdup (&objfile->objfile_obstack,
+ virtual_dwo_name);
dwo_file->comp_dir = comp_dir;
dwo_file->sections.abbrev = sections.abbrev;
dwo_file->sections.line = sections.line;
bounds of the real section. This is a pretty-rare event, so just
flag an error (easier) instead of a warning and trying to cope. */
if (sectp == NULL
- || offset + size > bfd_get_section_size (sectp))
+ || offset + size > bfd_section_size (sectp))
{
error (_("Dwarf Error: Bad DWP V2 section info, doesn't fit"
" in section %s [in module %s]"),
- sectp ? bfd_section_name (abfd, sectp) : "<unknown>",
+ sectp ? bfd_section_name (sectp) : "<unknown>",
objfile_name (dwarf2_per_objfile->objfile));
}
virtual_dwo_name.c_str ());
}
dwo_file = new struct dwo_file;
- dwo_file->dwo_name
- = (const char *) obstack_copy0 (&objfile->objfile_obstack,
- virtual_dwo_name.c_str (),
- virtual_dwo_name.size ());
+ dwo_file->dwo_name = obstack_strdup (&objfile->objfile_obstack,
+ virtual_dwo_name);
dwo_file->comp_dir = comp_dir;
dwo_file->sections.abbrev =
create_dwp_v2_section (dwarf2_per_objfile, &dwp_file->sections.abbrev,
if (section_is_p (sectp->name, &names->abbrev_dwo))
{
dwo_sections->abbrev.s.section = sectp;
- dwo_sections->abbrev.size = bfd_get_section_size (sectp);
+ dwo_sections->abbrev.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->info_dwo))
{
dwo_sections->info.s.section = sectp;
- dwo_sections->info.size = bfd_get_section_size (sectp);
+ dwo_sections->info.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->line_dwo))
{
dwo_sections->line.s.section = sectp;
- dwo_sections->line.size = bfd_get_section_size (sectp);
+ dwo_sections->line.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->loc_dwo))
{
dwo_sections->loc.s.section = sectp;
- dwo_sections->loc.size = bfd_get_section_size (sectp);
+ dwo_sections->loc.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->macinfo_dwo))
{
dwo_sections->macinfo.s.section = sectp;
- dwo_sections->macinfo.size = bfd_get_section_size (sectp);
+ dwo_sections->macinfo.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->macro_dwo))
{
dwo_sections->macro.s.section = sectp;
- dwo_sections->macro.size = bfd_get_section_size (sectp);
+ dwo_sections->macro.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->str_dwo))
{
dwo_sections->str.s.section = sectp;
- dwo_sections->str.size = bfd_get_section_size (sectp);
+ dwo_sections->str.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->str_offsets_dwo))
{
dwo_sections->str_offsets.s.section = sectp;
- dwo_sections->str_offsets.size = bfd_get_section_size (sectp);
+ dwo_sections->str_offsets.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->types_dwo))
{
memset (&type_section, 0, sizeof (type_section));
type_section.s.section = sectp;
- type_section.size = bfd_get_section_size (sectp);
+ type_section.size = bfd_section_size (sectp);
dwo_sections->types.push_back (type_section);
}
}
if (section_is_p (sectp->name, &names->str_dwo))
{
dwp_file->sections.str.s.section = sectp;
- dwp_file->sections.str.size = bfd_get_section_size (sectp);
+ dwp_file->sections.str.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->cu_index))
{
dwp_file->sections.cu_index.s.section = sectp;
- dwp_file->sections.cu_index.size = bfd_get_section_size (sectp);
+ dwp_file->sections.cu_index.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->tu_index))
{
dwp_file->sections.tu_index.s.section = sectp;
- dwp_file->sections.tu_index.size = bfd_get_section_size (sectp);
+ dwp_file->sections.tu_index.size = bfd_section_size (sectp);
}
}
if (section_is_p (sectp->name, &names->abbrev_dwo))
{
dwp_file->sections.abbrev.s.section = sectp;
- dwp_file->sections.abbrev.size = bfd_get_section_size (sectp);
+ dwp_file->sections.abbrev.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->info_dwo))
{
dwp_file->sections.info.s.section = sectp;
- dwp_file->sections.info.size = bfd_get_section_size (sectp);
+ dwp_file->sections.info.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->line_dwo))
{
dwp_file->sections.line.s.section = sectp;
- dwp_file->sections.line.size = bfd_get_section_size (sectp);
+ dwp_file->sections.line.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->loc_dwo))
{
dwp_file->sections.loc.s.section = sectp;
- dwp_file->sections.loc.size = bfd_get_section_size (sectp);
+ dwp_file->sections.loc.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->macinfo_dwo))
{
dwp_file->sections.macinfo.s.section = sectp;
- dwp_file->sections.macinfo.size = bfd_get_section_size (sectp);
+ dwp_file->sections.macinfo.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->macro_dwo))
{
dwp_file->sections.macro.s.section = sectp;
- dwp_file->sections.macro.size = bfd_get_section_size (sectp);
+ dwp_file->sections.macro.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->str_offsets_dwo))
{
dwp_file->sections.str_offsets.s.section = sectp;
- dwp_file->sections.str_offsets.size = bfd_get_section_size (sectp);
+ dwp_file->sections.str_offsets.size = bfd_section_size (sectp);
}
else if (section_is_p (sectp->name, &names->types_dwo))
{
dwp_file->sections.types.s.section = sectp;
- dwp_file->sections.types.size = bfd_get_section_size (sectp);
+ dwp_file->sections.types.size = bfd_section_size (sectp);
}
}
while processing PER_CU. */
if (maybe_queue_comp_unit (NULL, sig_cu, per_cu->cu->language))
load_full_type_unit (sig_cu);
- VEC_safe_push (dwarf2_per_cu_ptr, per_cu->imported_symtabs, sig_cu);
+ per_cu->imported_symtabs_push (sig_cu);
}
return 1;
return cu->producer_is_codewarrior;
}
-/* Return the default accessibility type if it is not overriden by
+/* Return the default accessibility type if it is not overridden by
DW_AT_accessibility. */
static enum dwarf_access_attribute
}
}
+ LONGEST bias = 0;
+ struct attribute *bias_attr = dwarf2_attr (die, DW_AT_GNU_bias, cu);
+ if (bias_attr != nullptr && attr_form_is_constant (bias_attr))
+ bias = dwarf2_get_attr_constant_value (bias_attr, 0);
+
/* Normally, the DWARF producers are expected to use a signed
constant form (Eg. DW_FORM_sdata) to express negative bounds.
But this is unfortunately not always the case, as witnessed
&& !TYPE_UNSIGNED (base_type) && (high.data.const_val & negative_mask))
high.data.const_val |= negative_mask;
- range_type = create_range_type (NULL, orig_base_type, &low, &high);
+ range_type = create_range_type (NULL, orig_base_type, &low, &high, bias);
if (high_bound_is_count)
TYPE_RANGE_DATA (range_type)->flag_upper_bound_is_count = 1;
|| pdi.tag == DW_TAG_subrange_type))
{
if (building_psymtab && pdi.name != NULL)
- add_psymbol_to_list (pdi.name, strlen (pdi.name), 0,
+ add_psymbol_to_list (pdi.name, strlen (pdi.name), false,
VAR_DOMAIN, LOC_TYPEDEF, -1,
psymbol_placement::STATIC,
0, cu->language, objfile);
if (pdi.name == NULL)
complaint (_("malformed enumerator DIE ignored"));
else if (building_psymtab)
- add_psymbol_to_list (pdi.name, strlen (pdi.name), 0,
+ add_psymbol_to_list (pdi.name, strlen (pdi.name), false,
VAR_DOMAIN, LOC_CONST, -1,
cu->language == language_cplus
? psymbol_placement::GLOBAL
inside functions to find template arguments (if the name of the
function does not already contain the template arguments).
- For Ada, we need to scan the children of subprograms and lexical
- blocks as well because Ada allows the definition of nested
- entities that could be interesting for the debugger, such as
- nested subprograms for instance. */
+ For Ada and Fortran, we need to scan the children of subprograms
+ and lexical blocks as well because these languages allow the
+ definition of nested entities that could be interesting for the
+ debugger, such as nested subprograms for instance. */
if (last_die->has_children
&& (load_all
|| last_die->tag == DW_TAG_namespace
|| last_die->tag == DW_TAG_interface_type
|| last_die->tag == DW_TAG_structure_type
|| last_die->tag == DW_TAG_union_type))
- || (cu->language == language_ada
+ || ((cu->language == language_ada
+ || cu->language == language_fortran)
&& (last_die->tag == DW_TAG_subprogram
|| last_die->tag == DW_TAG_lexical_block))))
{
{
struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile;
struct_pdi->name
- = ((const char *)
- obstack_copy0 (&objfile->per_bfd->storage_obstack,
- actual_class_name,
- strlen (actual_class_name)));
+ = obstack_strdup (&objfile->per_bfd->storage_obstack,
+ actual_class_name);
xfree (actual_class_name);
}
break;
base = demangled;
struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile;
- name
- = ((const char *)
- obstack_copy0 (&objfile->per_bfd->storage_obstack,
- base, strlen (base)));
+ name = obstack_strdup (&objfile->per_bfd->storage_obstack, base);
xfree (demangled);
}
}
if (dwz->str.buffer == NULL)
error (_("DW_FORM_GNU_strp_alt used without .debug_str "
"section [in module %s]"),
- bfd_get_filename (dwz->dwz_bfd));
+ bfd_get_filename (dwz->dwz_bfd.get ()));
if (str_offset >= dwz->str.size)
error (_("DW_FORM_GNU_strp_alt pointing outside of "
".debug_str section [in module %s]"),
- bfd_get_filename (dwz->dwz_bfd));
+ bfd_get_filename (dwz->dwz_bfd.get ()));
gdb_assert (HOST_CHAR_BIT == 8);
if (dwz->str.buffer[str_offset] == '\0')
return NULL;
if (attr->form == DW_FORM_strp || attr->form == DW_FORM_line_strp
|| attr->form == DW_FORM_string
|| attr->form == DW_FORM_strx
+ || attr->form == DW_FORM_strx1
+ || attr->form == DW_FORM_strx2
+ || attr->form == DW_FORM_strx3
+ || attr->form == DW_FORM_strx4
|| attr->form == DW_FORM_GNU_str_index
|| attr->form == DW_FORM_GNU_strp_alt)
str = DW_STRING (attr);
return str;
}
+/* Return the dwo name or NULL if not present. If present, it is in either
+ DW_AT_GNU_dwo_name or DW_AT_dwo_name atrribute. */
+static const char *
+dwarf2_dwo_name (struct die_info *die, struct dwarf2_cu *cu)
+{
+ const char *dwo_name = dwarf2_string_attr (die, DW_AT_GNU_dwo_name, cu);
+ if (dwo_name == nullptr)
+ dwo_name = dwarf2_string_attr (die, DW_AT_dwo_name, cu);
+ return dwo_name;
+}
+
/* Return non-zero iff the attribute NAME is defined for the given DIE,
and holds a non-zero value. This function should only be used for
DW_FORM_flag or DW_FORM_flag_present attributes. */
unsigned int dummy;
if (DW_BLOCK (attr)->data[0] == DW_OP_addr)
- SYMBOL_VALUE_ADDRESS (sym) =
- read_address (objfile->obfd, DW_BLOCK (attr)->data + 1, cu, &dummy);
+ SET_SYMBOL_VALUE_ADDRESS (sym,
+ read_address (objfile->obfd,
+ DW_BLOCK (attr)->data + 1,
+ cu, &dummy));
else
- SYMBOL_VALUE_ADDRESS (sym) =
- read_addr_index_from_leb128 (cu, DW_BLOCK (attr)->data + 1, &dummy);
+ SET_SYMBOL_VALUE_ADDRESS
+ (sym, read_addr_index_from_leb128 (cu, DW_BLOCK (attr)->data + 1,
+ &dummy));
SYMBOL_ACLASS_INDEX (sym) = LOC_STATIC;
fixup_symbol_section (sym, objfile);
- SYMBOL_VALUE_ADDRESS (sym) += ANOFFSET (objfile->section_offsets,
- SYMBOL_SECTION (sym));
+ SET_SYMBOL_VALUE_ADDRESS (sym,
+ SYMBOL_VALUE_ADDRESS (sym)
+ + ANOFFSET (objfile->section_offsets,
+ SYMBOL_SECTION (sym)));
return;
}
addr = attr_value_as_address (attr);
addr = gdbarch_adjust_dwarf2_addr (gdbarch, addr + baseaddr);
- SYMBOL_VALUE_ADDRESS (sym) = addr;
+ SET_SYMBOL_VALUE_ADDRESS (sym, addr);
}
SYMBOL_TYPE (sym) = objfile_type (objfile)->builtin_core_addr;
SYMBOL_DOMAIN (sym) = LABEL_DOMAIN;
SYMBOL_ACLASS_INDEX (sym) = LOC_BLOCK;
attr2 = dwarf2_attr (die, DW_AT_external, cu);
if ((attr2 && (DW_UNSND (attr2) != 0))
- || cu->language == language_ada)
+ || cu->language == language_ada
+ || cu->language == language_fortran)
{
/* Subprograms marked external are stored as a global symbol.
- Ada subprograms, whether marked external or not, are always
- stored as a global symbol, because we want to be able to
- access them globally. For instance, we want to be able
- to break on a nested subprogram without having to
- specify the context. */
+ Ada and Fortran subprograms, whether marked external or
+ not, are always stored as a global symbol, because we want
+ to be able to access them globally. For instance, we want
+ to be able to break on a nested subprogram without having
+ to specify the context. */
list_to_add = cu->get_builder ()->get_global_symbols ();
}
else
}
else if (attr2 && (DW_UNSND (attr2) != 0))
{
- /* Workaround gfortran PR debug/40040 - it uses
- DW_AT_location for variables in -fPIC libraries which may
- get overriden by other libraries/executable and get
- a different address. Resolve it by the minimal symbol
- which may come from inferior's executable using copy
- relocation. Make this workaround only for gfortran as for
- other compilers GDB cannot guess the minimal symbol
- Fortran mangling kind. */
- if (cu->language == language_fortran && die->parent
- && die->parent->tag == DW_TAG_module
- && cu->producer
- && startswith (cu->producer, "GNU Fortran"))
- SYMBOL_ACLASS_INDEX (sym) = LOC_UNRESOLVED;
+ if (SYMBOL_CLASS (sym) == LOC_STATIC
+ && (objfile->flags & OBJF_MAINLINE) == 0
+ && dwarf2_per_objfile->can_copy)
+ {
+ /* A global static variable might be subject to
+ copy relocation. We first check for a local
+ minsym, though, because maybe the symbol was
+ marked hidden, in which case this would not
+ apply. */
+ bound_minimal_symbol found
+ = (lookup_minimal_symbol_linkage
+ (SYMBOL_LINKAGE_NAME (sym), objfile));
+ if (found.minsym != nullptr)
+ sym->maybe_copied = 1;
+ }
/* A variable with DW_AT_external is never static,
but it may be block-scoped. */
objfile_name (objfile),
sect_offset_str (cu->header.sect_off),
sect_offset_str (die->sect_off));
- saved = (char *) obstack_copy0 (&objfile->objfile_obstack,
- message.c_str (), message.length ());
+ saved = obstack_strdup (&objfile->objfile_obstack, message);
return init_type (objfile, TYPE_CODE_ERROR, 0, saved);
}
if (actual_name_len > die_name_len + 2
&& actual_name[actual_name_len
- die_name_len - 1] == ':')
- name = (char *) obstack_copy0 (
+ name = obstack_strndup (
&objfile->per_bfd->storage_obstack,
actual_name, actual_name_len - die_name_len - 2);
}
return "";
struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile;
- return (char *) obstack_copy0 (&objfile->per_bfd->storage_obstack,
- DW_STRING (attr),
- &base[-1] - DW_STRING (attr));
+ return obstack_strndup (&objfile->per_bfd->storage_obstack,
+ DW_STRING (attr),
+ &base[-1] - DW_STRING (attr));
}
/* Return the name of the namespace/class that DIE is defined within,
return name;
}
return "";
+ case DW_TAG_subprogram:
+ /* Nested subroutines in Fortran get a prefix with the name
+ of the parent's subroutine. */
+ if (cu->language == language_fortran)
+ {
+ if ((die->tag == DW_TAG_subprogram)
+ && (dwarf2_name (parent, cu) != NULL))
+ return dwarf2_name (parent, cu);
+ }
+ return determine_prefix (parent, cu);
case DW_TAG_enumeration_type:
parent_type = read_type_die (parent, cu);
if (TYPE_DECLARED_CLASS (parent_type))
if (!canon_name.empty ())
{
if (canon_name != name)
- name = (const char *) obstack_copy0 (obstack,
- canon_name.c_str (),
- canon_name.length ());
+ name = obstack_strdup (obstack, canon_name);
}
}
/* FIXME: we already did this for the partial symbol... */
DW_STRING (attr)
- = ((const char *)
- obstack_copy0 (&objfile->per_bfd->storage_obstack,
- demangled, strlen (demangled)));
+ = obstack_strdup (&objfile->per_bfd->storage_obstack,
+ demangled);
DW_STRING_IS_CANONICAL (attr) = 1;
xfree (demangled);
return name;
}
+/* Convert a unit type to corresponding DW_UT name. */
+
+static const char *
+dwarf_unit_type_name (int unit_type) {
+ switch (unit_type)
+ {
+ case 0x01:
+ return "DW_UT_compile (0x01)";
+ case 0x02:
+ return "DW_UT_type (0x02)";
+ case 0x03:
+ return "DW_UT_partial (0x03)";
+ case 0x04:
+ return "DW_UT_skeleton (0x04)";
+ case 0x05:
+ return "DW_UT_split_compile (0x05)";
+ case 0x06:
+ return "DW_UT_split_type (0x06)";
+ case 0x80:
+ return "DW_UT_lo_user (0x80)";
+ case 0xff:
+ return "DW_UT_hi_user (0xff)";
+ default:
+ return nullptr;
+ }
+}
+
/* Convert a DWARF value form code into its string name. */
static const char *
case DW_FORM_indirect:
/* The reader will have reduced the indirect form to
the "base form" so this form should not occur. */
- fprintf_unfiltered (f,
+ fprintf_unfiltered (f,
"unexpected attribute form: DW_FORM_indirect");
break;
case DW_FORM_implicit_const:
!= dwarf2_per_objfile->abstract_to_concrete.end ()))
{
CORE_ADDR pc = (*get_frame_pc) (baton);
+ CORE_ADDR baseaddr
+ = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
for (const auto &cand_off
: dwarf2_per_objfile->abstract_to_concrete[die->sect_off])
CORE_ADDR pc_low, pc_high;
get_scope_pc_bounds (cand->parent, &pc_low, &pc_high, cu);
- if (pc_low == ((CORE_ADDR) -1)
- || !(pc_low <= pc && pc < pc_high))
+ if (pc_low == ((CORE_ADDR) -1))
+ continue;
+ pc_low = gdbarch_adjust_dwarf2_addr (gdbarch, pc_low + baseaddr);
+ pc_high = gdbarch_adjust_dwarf2_addr (gdbarch, pc_high + baseaddr);
+ if (!(pc_low <= pc && pc < pc_high))
continue;
die = cand;
if (dwarf2_per_objfile->index_table != NULL
&& dwarf2_per_objfile->index_table->version <= 7)
{
- VEC_safe_push (dwarf2_per_cu_ptr,
- (*ref_cu)->per_cu->imported_symtabs,
- sig_cu->per_cu);
+ (*ref_cu)->per_cu->imported_symtabs_push (sig_cu->per_cu);
}
*ref_cu = sig_cu;
if (cu->dwo_unit)
{
struct dwo_sections *sections = &cu->dwo_unit->dwo_file->sections;
-
+
return cu->header.version >= 5 ? §ions->loclists : §ions->loc;
}
return (cu->header.version >= 5 ? &dwarf2_per_objfile->loclists
cmd_show_list (show_dwarf_cmdlist, from_tty, "");
}
-int dwarf_always_disassemble;
+bool dwarf_always_disassemble;
static void
show_dwarf_always_disassemble (struct ui_file *file, int from_tty,
{
add_prefix_cmd ("dwarf", class_maintenance, set_dwarf_cmd, _("\
Set DWARF specific variables.\n\
-Configure DWARF variables such as the cache size"),
+Configure DWARF variables such as the cache size."),
&set_dwarf_cmdlist, "maintenance set dwarf ",
0/*allow-unknown*/, &maintenance_set_cmdlist);
add_prefix_cmd ("dwarf", class_maintenance, show_dwarf_cmd, _("\
-Show DWARF specific variables\n\
-Show DWARF variables such as the cache size"),
+Show DWARF specific variables.\n\
+Show DWARF variables such as the cache size."),
&show_dwarf_cmdlist, "maintenance show dwarf ",
0/*allow-unknown*/, &maintenance_show_cmdlist);