diff options
author | Tom Tromey <tom@tromey.com> | 2018-06-14 22:12:16 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2019-01-09 18:28:14 -0700 |
commit | 217083254a26b9e1dc42c43f573054740988c2cf (patch) | |
tree | f1f71ece7cdd6a3e533ddc276bf9ec79c0096283 /gdb/objfiles.h | |
parent | d30e1903399c32605d38b8d75a612c0d5d3d18b5 (diff) | |
download | gdb-217083254a26b9e1dc42c43f573054740988c2cf.zip gdb-217083254a26b9e1dc42c43f573054740988c2cf.tar.gz gdb-217083254a26b9e1dc42c43f573054740988c2cf.tar.bz2 |
Introduce all_objfiles and next_iterator
This introduces an iterable object which can be used to iterate over
objfiles. It also introduces a generic "next_iterator", which can be
used to iterate over types that have a "next" field.
gdb/ChangeLog
2019-01-09 Tom Tromey <tom@tromey.com>
* common/next-iterator.h: New file.
* objfiles.h (class all_objfiles): New.
(struct objfile_iterator): New.
Diffstat (limited to 'gdb/objfiles.h')
-rw-r--r-- | gdb/objfiles.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/gdb/objfiles.h b/gdb/objfiles.h index b3ceb8c..8d7a3c3 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -28,6 +28,7 @@ #include "registry.h" #include "gdb_bfd.h" #include <vector> +#include "common/next-iterator.h" struct bcache; struct htab; @@ -565,6 +566,22 @@ extern void default_iterate_over_objfiles_in_search_order void *cb_data, struct objfile *current_objfile); +/* 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) + { + } +}; + + /* Traverse all object files in the current program space. ALL_OBJFILES_SAFE works even if you delete the objfile during the traversal. */ |