aboutsummaryrefslogtreecommitdiff
path: root/gdb/objfiles.h
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/objfiles.h')
-rw-r--r--gdb/objfiles.h133
1 files changed, 53 insertions, 80 deletions
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index bb2f05d..9566acf 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -33,6 +33,7 @@
#include "quick-symbol.h"
#include <forward_list>
#include "gdbsupport/unordered_map.h"
+#include "gdbsupport/owning_intrusive_list.h"
struct htab;
struct objfile_data;
@@ -382,6 +383,12 @@ struct obj_section
return bfd_section_vma (this->the_bfd_section) + this->offset ();
}
+ /* As addr, but returns an unrelocated address. */
+ unrelocated_addr addr_unrel () const
+ {
+ return unrelocated_addr (bfd_section_vma (this->the_bfd_section));
+ }
+
/* The one-passed-the-end memory address of the section
(vma + size + offset). */
CORE_ADDR endaddr () const
@@ -389,13 +396,27 @@ struct obj_section
return this->addr () + bfd_section_size (this->the_bfd_section);
}
+ /* As endaddr, but returns an unrelocated address. */
+ unrelocated_addr endaddr_unrel () const
+ {
+ return this->addr_unrel () + bfd_section_size (this->the_bfd_section);
+ }
+
/* True if ADDR is in this obj_section, false otherwise. */
bool contains (CORE_ADDR addr) const
{
return addr >= this->addr () && addr < endaddr ();
}
- /* BFD section pointer */
+ /* As contains (CORE_ADDR), but for an unrelocated address. */
+ bool contains (unrelocated_addr addr) const
+ {
+ return addr >= this->addr_unrel () && addr < endaddr_unrel ();
+ }
+
+ /* BFD section pointer. This is nullptr if the corresponding BFD section is
+ not allocatable (!SEC_ALLOC), in which case this obj_section can be
+ considered NULL / empty. */
struct bfd_section *the_bfd_section;
/* Objfile this section is part of. */
@@ -451,12 +472,18 @@ public:
/* Return the program space associated with this objfile. */
program_space *pspace () { return m_pspace; }
+ using compunit_symtab_iterator
+ = owning_intrusive_list<compunit_symtab>::iterator;
+ using compunit_symtab_range = iterator_range<compunit_symtab_iterator>;
+
/* A range adapter that makes it possible to iterate over all
compunits in one objfile. */
compunit_symtab_range compunits ()
{
- return compunit_symtab_range (compunit_symtabs);
+ auto begin = compunit_symtab_iterator (compunit_symtabs.begin ());
+ auto end = compunit_symtab_iterator (compunit_symtabs.end ());
+ return compunit_symtab_range (std::move (begin), std::move (end));
}
/* A range adapter that makes it possible to iterate over all
@@ -515,10 +542,16 @@ public:
return per_bfd->gdbarch;
}
- /* Return true if OBJFILE has partial symbols. */
-
+ /* Return true if this objfile has partial symbols. */
bool has_partial_symbols ();
+ /* Return true if this objfile has full symbols. */
+ bool has_full_symbols ();
+
+ /* Return true if this objfile has full or partial symbols, either directly
+ or through a separate debug file. */
+ bool has_symbols ();
+
/* Look for a separate debug symbol file for this objfile, make use of
build-id, debug-link, and debuginfod as necessary. If a suitable
separate debug symbol file is found then it is loaded using a call to
@@ -577,10 +610,6 @@ public:
/* See quick_symbol_functions. */
void dump ();
- /* Find all the symbols in OBJFILE named FUNC_NAME, and ensure that
- the corresponding symbol tables are loaded. */
- void expand_symtabs_for_function (const char *func_name);
-
/* See quick_symbol_functions. */
void expand_all_symtabs ();
@@ -592,14 +621,14 @@ public:
void expand_symtabs_with_fullname (const char *fullname);
/* See quick_symbol_functions. */
- bool expand_symtabs_matching
- (expand_symtabs_file_matcher file_matcher,
+ bool search
+ (search_symtabs_file_matcher file_matcher,
const lookup_name_info *lookup_name,
- expand_symtabs_symbol_matcher symbol_matcher,
- expand_symtabs_expansion_listener expansion_notify,
+ search_symtabs_symbol_matcher symbol_matcher,
+ search_symtabs_expansion_listener listener,
block_search_flags search_flags,
domain_search_flags domain,
- expand_symtabs_lang_matcher lang_matcher = nullptr);
+ search_symtabs_lang_matcher lang_matcher = nullptr);
/* See quick_symbol_functions. */
struct compunit_symtab *
@@ -649,61 +678,18 @@ public:
this->section_offsets[idx] = offset;
}
- class section_iterator
+ /* Filter function for section_iterator. */
+ struct filter_out_null_bfd_section
{
- public:
- section_iterator (const section_iterator &) = default;
- section_iterator (section_iterator &&) = default;
- section_iterator &operator= (const section_iterator &) = default;
- section_iterator &operator= (section_iterator &&) = default;
-
- typedef section_iterator self_type;
- typedef obj_section *value_type;
-
- value_type operator* ()
- { return m_iter; }
-
- section_iterator &operator++ ()
- {
- ++m_iter;
- skip_null ();
- return *this;
- }
-
- bool operator== (const section_iterator &other) const
- { return m_iter == other.m_iter && m_end == other.m_end; }
-
- bool operator!= (const section_iterator &other) const
- { return !(*this == other); }
-
- private:
-
- friend class objfile;
-
- section_iterator (obj_section *iter, obj_section *end)
- : m_iter (iter),
- m_end (end)
- {
- skip_null ();
- }
-
- void skip_null ()
- {
- while (m_iter < m_end && m_iter->the_bfd_section == nullptr)
- ++m_iter;
- }
-
- value_type m_iter;
- value_type m_end;
+ bool operator() (const obj_section &sec) const noexcept
+ { return sec.the_bfd_section != nullptr; }
};
- iterator_range<section_iterator> sections ()
- {
- return (iterator_range<section_iterator>
- (section_iterator (sections_start, sections_end),
- section_iterator (sections_end, sections_end)));
- }
+ using section_iterator = filtered_iterator<obj_section *, filter_out_null_bfd_section>;
+ /* Return an iterable that yields the "non-null" sections of this objfile.
+ That is, the sections for which obj_section::the_bfd_section is
+ non-nullptr. */
iterator_range<section_iterator> sections () const
{
return (iterator_range<section_iterator>
@@ -736,7 +722,7 @@ public:
/* List of compunits.
These are used to do symbol lookups and file/line-number lookups. */
- struct compunit_symtab *compunit_symtabs = nullptr;
+ owning_intrusive_list<compunit_symtab> compunit_symtabs;
/* The object file's BFD. Can be null if the objfile contains only
minimal symbols (e.g. the run time common symbols for SunOS4) or
@@ -938,15 +924,6 @@ extern void free_objfile_separate_debug (struct objfile *);
extern void objfile_relocate (struct objfile *, const section_offsets &);
extern void objfile_rebase (struct objfile *, CORE_ADDR);
-/* Return true if OBJFILE has full symbols. */
-
-extern bool objfile_has_full_symbols (objfile *objfile);
-
-/* Return true if OBJFILE has full or partial symbols, either directly
- or through a separate debug file. */
-
-extern bool objfile_has_symbols (objfile *objfile);
-
/* Return true if any objfile of PSPACE has partial symbols. */
extern bool have_partial_symbols (program_space *pspace);
@@ -992,10 +969,10 @@ extern struct obj_section *find_pc_section (CORE_ADDR pc);
/* Return true if PC is in a section called NAME. */
extern bool pc_in_section (CORE_ADDR, const char *);
-/* Return non-zero if PC is in a SVR4-style procedure linkage table
+/* Return true if PC is in a SVR4-style procedure linkage table
section. */
-static inline int
+static inline bool
in_plt_section (CORE_ADDR pc)
{
return (pc_in_section (pc, ".plt")
@@ -1013,10 +990,6 @@ in_plt_section (CORE_ADDR pc)
extern scoped_restore_tmpl<int> inhibit_section_map_updates
(struct program_space *pspace);
-extern void default_iterate_over_objfiles_in_search_order
- (gdbarch *gdbarch, iterate_over_objfiles_in_search_order_cb_ftype cb,
- objfile *current_objfile);
-
/* Reset the per-BFD storage area on OBJ. */
void set_objfile_per_bfd (struct objfile *obj);