-/* An iterarable object that can be used to iterate over all
- objfiles. The basic use is in a foreach, like:
-
- for (objfile *objf : all_objfiles (pspace)) { ... } */
-
-class all_objfiles : public next_adapter<struct objfile>
-{
-public:
-
- explicit all_objfiles (struct program_space *pspace)
- : next_adapter<struct objfile> (pspace->objfiles)
- {
- }
-};
-
-/* An iterarable object that can be used to iterate over all
- objfiles. The basic use is in a foreach, like:
-
- for (objfile *objf : all_objfiles_safe (pspace)) { ... }
-
- This variant uses a basic_safe_iterator so that objfiles can be
- deleted during iteration. */
-
-class all_objfiles_safe
- : public next_adapter<struct objfile,
- basic_safe_iterator<next_iterator<objfile>>>
-{
-public:
-
- explicit all_objfiles_safe (struct program_space *pspace)
- : next_adapter<struct objfile,
- basic_safe_iterator<next_iterator<objfile>>>
- (pspace->objfiles)
- {
- }
-};
-
-/* A range adapter that makes it possible to iterate over all
- compunits in one objfile. */
-
-class objfile_compunits : public next_adapter<struct compunit_symtab>
-{
-public:
-
- explicit objfile_compunits (struct objfile *objfile)
- : next_adapter<struct compunit_symtab> (objfile->compunit_symtabs)
- {
- }
-};
-
-/* 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 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;
-};
-