This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Simplify minsym iteration
- From: Tom Tromey <tromey at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 17 Jan 2019 23:23:07 -0000
- Subject: [binutils-gdb] Simplify minsym iteration
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=604b1bfb46e62d561698397cb5499b487eb0db34
commit 604b1bfb46e62d561698397cb5499b487eb0db34
Author: Tom Tromey <tom@tromey.com>
Date: Wed Jan 16 07:09:55 2019 -0700
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.
Diff:
---
gdb/ChangeLog | 8 ++++++++
gdb/objfiles.h | 25 ++++++-------------------
2 files changed, 14 insertions(+), 19 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 4e562fc..7d1ed3f 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,13 @@
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.
(class objfile_psymtabs): Remove.
* psymtab.h (class psymtab_storage) <partial_symtab_range>: New
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 5299a3c..2e0fad6 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: