aboutsummaryrefslogtreecommitdiff
path: root/gdb/objfiles.h
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-01-16 07:18:58 -0700
committerTom Tromey <tom@tromey.com>2019-01-17 15:43:37 -0700
commit7932255de56fb99836b2e712e7dbcfdd5e1f1309 (patch)
tree760e3e52755717ebbe3f4092ff37e425ff062687 /gdb/objfiles.h
parent604b1bfb46e62d561698397cb5499b487eb0db34 (diff)
downloadgdb-7932255de56fb99836b2e712e7dbcfdd5e1f1309.zip
gdb-7932255de56fb99836b2e712e7dbcfdd5e1f1309.tar.gz
gdb-7932255de56fb99836b2e712e7dbcfdd5e1f1309.tar.bz2
Make minimal symbol range adapter a method on objfile
This removes class objfile_msymbols in favor of a method on the objfile. 2019-01-16 Tom Tromey <tom@tromey.com> * objfiles.h (struct minimal_symbol_iterator): Rename. Move earlier. (struct objfile) <msymbols_range>: Move from top level. <msymbols>: New method. (class objfile_msymbols): Remove. * symtab.c (default_collect_symbol_completion_matches_break_on): Update. * symmisc.c (dump_msymbols): Update. * stabsread.c (scan_file_globals): Update. * objc-lang.c (info_selectors_command, info_classes_command) (find_methods): Update. * minsyms.c (find_solib_trampoline_target): Update. * hppa-tdep.c (hppa_lookup_stub_minimal_symbol): Update. * coffread.c (coff_symfile_read): Update. * ada-lang.c (ada_lookup_simple_minsym) (ada_collect_symbol_completion_matches): Update.
Diffstat (limited to 'gdb/objfiles.h')
-rw-r--r--gdb/objfiles.h146
1 files changed, 79 insertions, 67 deletions
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 2e0fad6..5f106d9 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -182,6 +182,47 @@ extern void print_symbol_bcache_statistics (void);
/* Number of entries in the minimal symbol hash table. */
#define MINIMAL_SYMBOL_HASH_SIZE 2039
+/* An iterator for minimal symbols. */
+
+struct minimal_symbol_iterator
+{
+ typedef minimal_symbol_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 minimal_symbol_iterator (struct minimal_symbol *msym)
+ : m_msym (msym)
+ {
+ }
+
+ 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++ ()
+ {
+ ++m_msym;
+ return *this;
+ }
+
+private:
+ struct minimal_symbol *m_msym;
+};
+
/* Some objfile data is hung off the BFD. This enables sharing of the
data across all objfiles using the BFD. The data is stored in an
instance of this structure, and associated with the BFD using the
@@ -319,6 +360,44 @@ struct objfile
return compunits_range (compunit_symtabs);
}
+ /* A range adapter that makes it possible to iterate over all
+ minimal symbols of an objfile. */
+
+ class msymbols_range
+ {
+ public:
+
+ explicit msymbols_range (struct objfile *objfile)
+ : m_objfile (objfile)
+ {
+ }
+
+ minimal_symbol_iterator begin () const
+ {
+ return minimal_symbol_iterator (m_objfile->per_bfd->msymbols);
+ }
+
+ minimal_symbol_iterator end () const
+ {
+ return minimal_symbol_iterator
+ (m_objfile->per_bfd->msymbols
+ + m_objfile->per_bfd->minimal_symbol_count);
+ }
+
+ private:
+
+ struct objfile *m_objfile;
+ };
+
+ /* Return a range adapter for iterating over all minimal
+ symbols. */
+
+ msymbols_range msymbols ()
+ {
+ return msymbols_range (this);
+ }
+
+
/* All struct objfile's are chained together by their next pointers.
The program space field "objfiles" (frequently referenced via
the macro "object_files") points to the first link in this chain. */
@@ -570,73 +649,6 @@ extern void default_iterate_over_objfiles_in_search_order
void *cb_data, struct objfile *current_objfile);
-/* A range adapter that makes it possible to iterate over all
- minimal symbols of an objfile. */
-
-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 minimal_symbol *msym)
- : m_msym (msym)
- {
- }
-
- 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++ ()
- {
- ++m_msym;
- return *this;
- }
-
- private:
- struct minimal_symbol *m_msym;
- };
-
- iterator begin () const
- {
- return iterator (m_objfile->per_bfd->msymbols);
- }
-
- iterator end () const
- {
- return iterator (m_objfile->per_bfd->msymbols
- + m_objfile->per_bfd->minimal_symbol_count);
- }
-
-private:
-
- struct objfile *m_objfile;
-};
-
#define ALL_OBJFILE_OSECTIONS(objfile, osect) \
for (osect = objfile->sections; osect < objfile->sections_end; osect++) \
if (osect->the_bfd_section == NULL) \