aboutsummaryrefslogtreecommitdiff
path: root/gdb/objfiles.h
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-03-10 15:37:20 -0600
committerTom Tromey <tom@tromey.com>2019-04-10 08:05:17 -0600
commite9ad22ee5f0a40dfa1182ee68e3349dd72a42afe (patch)
tree5500e93752b2711677dbcd2524e1d91f067bd680 /gdb/objfiles.h
parentee3711344b6e0cffeb237fa6889aab04853f9004 (diff)
downloadgdb-e9ad22ee5f0a40dfa1182ee68e3349dd72a42afe.zip
gdb-e9ad22ee5f0a40dfa1182ee68e3349dd72a42afe.tar.gz
gdb-e9ad22ee5f0a40dfa1182ee68e3349dd72a42afe.tar.bz2
Introduce a separate debug objfile iterator
This introduces a new iterator and range adapter for iteration over the separate debug files of a given objfile. As in the current approach, the requested objfile is returned first, followed by the separate debug objfiles. gdb/ChangeLog 2019-04-10 Tom Tromey <tom@tromey.com> * symtab.c (lookup_global_symbol_from_objfile) (lookup_symbol_in_objfile_from_linkage_name): Use the iterator. * objfiles.h (class separate_debug_iterator): New. (class separate_debug_range): New. (struct objfile) <separate_debug_objfiles>: New method. (objfile_separate_debug_iterate): Don't declare. * objfiles.c (separate_debug_iterator::operator++): Rename from objfile_separate_debug_iterate. (objfile_relocate, objfile_rebase, objfile_has_symbols): Use the iterator. * minsyms.c (lookup_minimal_symbol_by_pc_section): Use the iterator.
Diffstat (limited to 'gdb/objfiles.h')
-rw-r--r--gdb/objfiles.h68
1 files changed, 65 insertions, 3 deletions
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 368d9f3..168f7fc 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -318,6 +318,63 @@ struct objfile_per_bfd_storage
std::bitset<nr_languages> demangled_hash_languages;
};
+/* An iterator that first returns a parent objfile, and then each
+ separate debug objfile. */
+
+class separate_debug_iterator
+{
+public:
+
+ explicit separate_debug_iterator (struct objfile *objfile)
+ : m_objfile (objfile),
+ m_parent (objfile)
+ {
+ }
+
+ bool operator!= (const separate_debug_iterator &other)
+ {
+ return m_objfile != other.m_objfile;
+ }
+
+ separate_debug_iterator &operator++ ();
+
+ struct objfile *operator* ()
+ {
+ return m_objfile;
+ }
+
+private:
+
+ struct objfile *m_objfile;
+ struct objfile *m_parent;
+};
+
+/* A range adapter wrapping separate_debug_iterator. */
+
+class separate_debug_range
+{
+public:
+
+ explicit separate_debug_range (struct objfile *objfile)
+ : m_objfile (objfile)
+ {
+ }
+
+ separate_debug_iterator begin ()
+ {
+ return separate_debug_iterator (m_objfile);
+ }
+
+ separate_debug_iterator end ()
+ {
+ return separate_debug_iterator (nullptr);
+ }
+
+private:
+
+ struct objfile *m_objfile;
+};
+
/* Master structure for keeping track of each file from which
gdb reads symbols. There are several ways these get allocated: 1.
The main symbol file, symfile_objfile, set by the symbol-file command,
@@ -396,6 +453,14 @@ struct objfile
return msymbols_range (this);
}
+ /* Return a range adapter for iterating over all the separate debug
+ objfiles of this objfile. */
+
+ separate_debug_range separate_debug_objfiles ()
+ {
+ return separate_debug_range (this);
+ }
+
/* All struct objfile's are chained together by their next pointers.
The program space field "objfiles" (frequently referenced via
@@ -563,9 +628,6 @@ extern CORE_ADDR entry_point_address (void);
extern void build_objfile_section_table (struct objfile *);
-extern struct objfile *objfile_separate_debug_iterate (const struct objfile *,
- const struct objfile *);
-
extern void put_objfile_before (struct objfile *, struct objfile *);
extern void add_separate_debug_objfile (struct objfile *, struct objfile *);