aboutsummaryrefslogtreecommitdiff
path: root/gdb/objfiles.h
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-11-23 17:32:08 -0700
committerTom Tromey <tom@tromey.com>2019-01-09 18:28:15 -0700
commit5325b9bf1ee283c40f076334eb3ea66e1f0a6ade (patch)
tree4964d0282ac4cb82ed0a6691cbccf4062c3799d8 /gdb/objfiles.h
parentcac85af2467c9bac326b397b150274d95d2916a5 (diff)
downloadgdb-5325b9bf1ee283c40f076334eb3ea66e1f0a6ade.zip
gdb-5325b9bf1ee283c40f076334eb3ea66e1f0a6ade.tar.gz
gdb-5325b9bf1ee283c40f076334eb3ea66e1f0a6ade.tar.bz2
Remove ALL_MSYMBOLS and ALL_OBJFILE_MSYMBOLS
This removes the ALL_MSYMBOLS and ALL_OBJFILE_MSYMBOLS macros, replacing their uses with ranged for loops. In a couple of spots, a new declaration was needed in order to work around shadowing; these are just temporary and are removed in a subsequent patch. gdb/ChangeLog 2019-01-09 Tom Tromey <tom@tromey.com> * symtab.c (search_symbols) (default_collect_symbol_completion_matches_break_on): Use objfile_msymbols. * ada-lang.c (ada_lookup_simple_minsym) (ada_collect_symbol_completion_matches): Use objfile_msymbols. * minsyms.c (find_solib_trampoline_target): Use objfile_msymbols. * hppa-tdep.c (hppa_lookup_stub_minimal_symbol): Use objfile_msymbols. * coffread.c (coff_symfile_read): Use objfile_msymbols. * symmisc.c (dump_msymbols): Use objfile_msymbols. * objc-lang.c (find_methods): Use objfile_msymbols. (info_selectors_command, info_classes_command): Likewise. * stabsread.c (scan_file_globals): Use objfile_msymbols. * objfiles.h (class objfile_msymbols): New. (ALL_OBJFILE_MSYMBOLS): Remove. (ALL_MSYMBOLS): Remove.
Diffstat (limited to 'gdb/objfiles.h')
-rw-r--r--gdb/objfiles.h90
1 files changed, 78 insertions, 12 deletions
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index cb3668a..a3b0e92 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -623,12 +623,85 @@ public:
#define ALL_OBJFILE_COMPUNITS(objfile, cu) \
for ((cu) = (objfile) -> compunit_symtabs; (cu) != NULL; (cu) = (cu) -> next)
-/* Traverse all minimal symbols in one objfile. */
+/* A range adapter that makes it possible to iterate over all
+ minimal symbols of an objfile. */
-#define ALL_OBJFILE_MSYMBOLS(objfile, m) \
- for ((m) = (objfile)->per_bfd->msymbols; \
- MSYMBOL_LINKAGE_NAME (m) != NULL; \
- (m)++)
+class objfile_msymbols
+{
+public:
+
+ explicit objfile_msymbols (struct objfile *objfile)
+ : m_objfile (objfile)
+ {
+ }
+
+ struct iterator
+ {
+ typedef iterator self_type;
+ typedef struct minimal_symbol *value_type;
+ typedef struct minimal_symbol *&reference;
+ typedef struct minimal_symbol **pointer;
+ typedef std::forward_iterator_tag iterator_category;
+ typedef int difference_type;
+
+ explicit iterator (struct objfile *objfile)
+ : m_msym (objfile->per_bfd->msymbols)
+ {
+ /* Make sure to properly handle the case where there are no
+ minsyms. */
+ if (MSYMBOL_LINKAGE_NAME (m_msym) == nullptr)
+ m_msym = nullptr;
+ }
+
+ iterator ()
+ : m_msym (nullptr)
+ {
+ }
+
+ value_type operator* () const
+ {
+ return m_msym;
+ }
+
+ bool operator== (const self_type &other) const
+ {
+ return m_msym == other.m_msym;
+ }
+
+ bool operator!= (const self_type &other) const
+ {
+ return m_msym != other.m_msym;
+ }
+
+ self_type &operator++ ()
+ {
+ if (m_msym != nullptr)
+ {
+ ++m_msym;
+ if (MSYMBOL_LINKAGE_NAME (m_msym) == nullptr)
+ m_msym = nullptr;
+ }
+ return *this;
+ }
+
+ private:
+ struct minimal_symbol *m_msym;
+ };
+
+ iterator begin () const
+ {
+ return iterator (m_objfile);
+ }
+
+ iterator end () const
+ {
+ return iterator ();
+ }
+
+private:
+
+ struct objfile *m_objfile;
+};
/* Traverse all symtabs in all objfiles in the current symbol
space. */
@@ -643,13 +716,6 @@ public:
ALL_OBJFILES (objfile) \
ALL_OBJFILE_COMPUNITS (objfile, cu)
-/* Traverse all minimal symbols in all objfiles in the current symbol
- space. */
-
-#define ALL_MSYMBOLS(objfile, m) \
- ALL_OBJFILES (objfile) \
- ALL_OBJFILE_MSYMBOLS (objfile, m)
-
#define ALL_OBJFILE_OSECTIONS(objfile, osect) \
for (osect = objfile->sections; osect < objfile->sections_end; osect++) \
if (osect->the_bfd_section == NULL) \