From: Tom Tromey <tom@tromey.com>
To: Pedro Alves <palves@redhat.com>
Cc: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 00/12] Remove some ALL_* iteration macros
Date: Thu, 10 Jan 2019 18:06:00 -0000 [thread overview]
Message-ID: <87muo8peu8.fsf@tromey.com> (raw)
In-Reply-To: <f509063f-3097-ccc4-7cad-7f89f2b016a5@redhat.com> (Pedro Alves's message of "Thu, 10 Jan 2019 16:44:26 +0000")
>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
>> There are still a few more such macros that could be converted. And,
>> I think inf_threads_iterator could be converted to use next_iterator.
>> I can do some of this if there's interest.
Pedro> If it's a natural fit, then I think it'd be nice. Is there a downside?
I don't think there is one.
What do you think of this?
Tom
commit f4cd9886913b5216ed6073af23d250401f006551
Author: Tom Tromey <tom@tromey.com>
Date: Thu Jan 10 10:50:43 2019 -0700
Replace inf_threads_iterator with next_iterator
This changes inf_threads_iterator and some range adapters in
thread-iter.h to use next_iterator and next_adapter instead.
gdb/ChangeLog
2019-01-10 Tom Tromey <tom@tromey.com>
* thread-iter.h (inf_threads_iterator): Use next_iterator.
(basic_inf_threads_range): Remove.
(inf_threads_range, inf_non_exited_threads_range)
(safe_inf_threads_range): Use next_adapter.
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 32fe0bbe814..ac1dd540ef7 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2019-01-10 Tom Tromey <tom@tromey.com>
+
+ * thread-iter.h (inf_threads_iterator): Use next_iterator.
+ (basic_inf_threads_range): Remove.
+ (inf_threads_range, inf_non_exited_threads_range)
+ (safe_inf_threads_range): Use next_adapter.
+
2019-01-10 Tom Tromey <tom@tromey.com>
* objfiles.h (objfile::reset_psymtabs): Update.
diff --git a/gdb/thread-iter.h b/gdb/thread-iter.h
index a1145d4938a..be6ab73c686 100644
--- a/gdb/thread-iter.h
+++ b/gdb/thread-iter.h
@@ -20,68 +20,13 @@
#define THREAD_ITER_H
#include "common/filtered-iterator.h"
+#include "common/next-iterator.h"
#include "common/safe-iterator.h"
/* A forward iterator that iterates over a given inferior's
threads. */
-class inf_threads_iterator
-{
-public:
- typedef inf_threads_iterator self_type;
- typedef struct thread_info *value_type;
- typedef struct thread_info *&reference;
- typedef struct thread_info **pointer;
- typedef std::forward_iterator_tag iterator_category;
- typedef int difference_type;
-
- /* Create an iterator pointing at HEAD. This takes a thread pointer
- instead of an inferior pointer to avoid circular dependencies
- between the thread and inferior header files. */
- explicit inf_threads_iterator (struct thread_info *head)
- : m_thr (head)
- {}
-
- /* Create a one-past-end iterator. */
- inf_threads_iterator ()
- : m_thr (nullptr)
- {}
-
- inf_threads_iterator& operator++ ()
- {
- m_thr = m_thr->next;
- return *this;
- }
-
- thread_info *operator* () const { return m_thr; }
-
- bool operator!= (const inf_threads_iterator &other) const
- { return m_thr != other.m_thr; }
-
-private:
- /* The currently-iterated thread. NULL if we reached the end of the
- list. */
- thread_info *m_thr;
-};
-
-/* A range adapter that makes it possible to iterate over an
- inferior's thread list with range-for. */
-template<typename Iterator>
-struct basic_inf_threads_range
-{
- friend struct inferior;
-private:
- explicit basic_inf_threads_range (struct thread_info *head)
- : m_head (head)
- {}
-
-public:
- Iterator begin () const { return Iterator (m_head); }
- Iterator end () const { return Iterator (); }
-
-private:
- thread_info *m_head;
-};
+using inf_threads_iterator = next_iterator<thread_info>;
/* A forward iterator that iterates over all threads of all
inferiors. */
@@ -223,19 +168,19 @@ using safe_inf_threads_iterator
of an inferior with range-for. */
using inf_threads_range
- = basic_inf_threads_range<inf_threads_iterator>;
+ = next_adapter<thread_info, inf_threads_iterator>;
/* A range adapter that makes it possible to iterate over all
non-exited threads of an inferior with range-for. */
using inf_non_exited_threads_range
- = basic_inf_threads_range<inf_non_exited_threads_iterator>;
+ = next_adapter<thread_info, inf_non_exited_threads_iterator>;
/* A range adapter that makes it possible to iterate over all threads
of an inferior with range-for, safely. */
using safe_inf_threads_range
- = basic_inf_threads_range<safe_inf_threads_iterator>;
+ = next_adapter<thread_info, safe_inf_threads_iterator>;
/* A range adapter that makes it possible to iterate over all threads
of all inferiors with range-for. */
next prev parent reply other threads:[~2019-01-10 18:06 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-25 16:54 Tom Tromey
2018-11-25 16:54 ` [PATCH 11/12] Remove ALL_OBJSECTIONS Tom Tromey
2018-11-25 16:54 ` [PATCH 07/12] Remove ALL_COMPUNITS Tom Tromey
2018-11-25 16:54 ` [PATCH 10/12] Remove ALL_OBJFILES and ALL_FILETABS Tom Tromey
2018-11-25 16:54 ` [PATCH 05/12] Remove ALL_MSYMBOLS and ALL_OBJFILE_MSYMBOLS Tom Tromey
2018-11-25 16:54 ` [PATCH 04/12] Remove ALL_OBJFILES_SAFE Tom Tromey
2018-11-25 16:54 ` [PATCH 12/12] Remove ALL_OBJFILE_PSYMTABS Tom Tromey
2018-11-25 16:54 ` [PATCH 01/12] Introduce all_objfiles and next_iterator Tom Tromey
2018-11-25 16:54 ` [PATCH 08/12] Remove ALL_COMPUNIT_FILETABS Tom Tromey
2018-11-25 16:54 ` [PATCH 09/12] Remove ALL_OBJFILE_FILETABS Tom Tromey
2018-11-25 16:54 ` [PATCH 03/12] Remove most uses of ALL_OBJFILES Tom Tromey
2018-11-25 16:55 ` [PATCH 06/12] Remove ALL_OBJFILE_COMPUNITS Tom Tromey
2018-11-25 16:55 ` [PATCH 02/12] Remove ALL_PSPACE_OBJFILES Tom Tromey
2018-12-23 7:00 ` [PATCH 00/12] Remove some ALL_* iteration macros Joel Brobecker
2018-12-24 20:54 ` Tom Tromey
2018-12-26 17:30 ` Simon Marchi
2018-12-26 22:28 ` Tom Tromey
2018-12-26 22:32 ` Tom Tromey
2018-12-26 22:35 ` Simon Marchi
2018-12-26 22:52 ` Tom Tromey
2018-12-26 23:45 ` Tom Tromey
2018-12-27 0:46 ` Simon Marchi
2018-12-27 6:22 ` Tom Tromey
2018-12-27 1:52 ` Simon Marchi
2019-01-03 21:46 ` Tom Tromey
2019-01-03 22:45 ` Simon Marchi
2019-01-06 20:10 ` Tom Tromey
2019-01-09 19:49 ` Simon Marchi
2019-01-10 1:29 ` Tom Tromey
2019-01-10 16:45 ` Pedro Alves
2019-01-10 18:10 ` Tom Tromey
2019-01-10 19:58 ` Pedro Alves
2019-01-10 16:44 ` Pedro Alves
2019-01-10 18:06 ` Tom Tromey [this message]
2019-01-10 18:09 ` Pedro Alves
2019-01-10 22:53 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87muo8peu8.fsf@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).