Simplify minsym iteration
This simplifies the minimal symbol iterator, by using minimal_symbol_count and just doing a somewhat ordinary array-like iteration. array_view is nearly usable, except that it is more convenient for this iterator to return pointers rather than references. gdb/ChangeLog 2019-01-16 Tom Tromey <tom@tromey.com> * objfiles.h (class objfile_msymbols) <iterator>: Change argument type. Remove no-argument constructor. <iterator::operator++>: Simplify. <begin>: Update. <end>: Use minimal_symbol_count.
This commit is contained in:
parent
f252c6d5dc
commit
604b1bfb46
|
@ -1,3 +1,11 @@
|
|||
2019-01-16 Tom Tromey <tom@tromey.com>
|
||||
|
||||
* objfiles.h (class objfile_msymbols) <iterator>: Change argument
|
||||
type. Remove no-argument constructor.
|
||||
<iterator::operator++>: Simplify.
|
||||
<begin>: Update.
|
||||
<end>: Use minimal_symbol_count.
|
||||
|
||||
2019-01-16 Tom Tromey <tom@tromey.com>
|
||||
|
||||
* objfiles.h (struct objfile) <psymtabs>: New method.
|
||||
|
|
|
@ -591,17 +591,8 @@ public:
|
|||
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)
|
||||
explicit iterator (struct minimal_symbol *msym)
|
||||
: m_msym (msym)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -621,13 +612,8 @@ public:
|
|||
}
|
||||
|
||||
self_type &operator++ ()
|
||||
{
|
||||
if (m_msym != nullptr)
|
||||
{
|
||||
++m_msym;
|
||||
if (MSYMBOL_LINKAGE_NAME (m_msym) == nullptr)
|
||||
m_msym = nullptr;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -637,12 +623,13 @@ public:
|
|||
|
||||
iterator begin () const
|
||||
{
|
||||
return iterator (m_objfile);
|
||||
return iterator (m_objfile->per_bfd->msymbols);
|
||||
}
|
||||
|
||||
iterator end () const
|
||||
{
|
||||
return iterator ();
|
||||
return iterator (m_objfile->per_bfd->msymbols
|
||||
+ m_objfile->per_bfd->minimal_symbol_count);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue