This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 5/6] Simplify minsym iteration
- From: Tom Tromey <tom at tromey dot com>
- To: gdb-patches at sourceware dot org
- Cc: Tom Tromey <tom at tromey dot com>
- Date: Wed, 16 Jan 2019 19:50:31 -0700
- Subject: [PATCH 5/6] Simplify minsym iteration
- References: <20190117025032.9265-1-tom@tromey.com>
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 this iterator
must return pointers rather than references.
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.
---
gdb/ChangeLog | 8 ++++++++
gdb/objfiles.h | 25 ++++++-------------------
2 files changed, 14 insertions(+), 19 deletions(-)
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 4c68430975..f666d558c2 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -591,20 +591,11 @@ public:
typedef std::forward_iterator_tag iterator_category;
typedef int difference_type;
- explicit iterator (struct objfile *objfile)
- : m_msym (objfile->per_bfd->msymbols)
+ explicit iterator (struct minimal_symbol *msym)
+ : m_msym (msym)
{
- /* 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;
@@ -622,12 +613,7 @@ public:
self_type &operator++ ()
{
- if (m_msym != nullptr)
- {
- ++m_msym;
- if (MSYMBOL_LINKAGE_NAME (m_msym) == nullptr)
- m_msym = nullptr;
- }
+ ++m_msym;
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:
--
2.17.2