From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH 1/4] gdb: remove use of iterate_over_inferiors in py-inferior.c
Date: Wed, 15 Jan 2020 19:18:00 -0000 [thread overview]
Message-ID: <20200115191222.28208-2-simon.marchi@efficios.com> (raw)
In-Reply-To: <20200115191222.28208-1-simon.marchi@efficios.com>
Use range-based for instead of iterate_over_inferiors in one spot in the Python
code.
gdb/ChangeLog:
* python/py-inferior.c (build_inferior_list): Remove.
(gdbpy_ref): Use range-based for loop to iterate over inferiors.
---
gdb/python/py-inferior.c | 24 ++++++++++--------------
1 file changed, 10 insertions(+), 14 deletions(-)
diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c
index 4adc5d6f9988..fd7d8a8aa709 100644
--- a/gdb/python/py-inferior.c
+++ b/gdb/python/py-inferior.c
@@ -462,18 +462,6 @@ infpy_get_progspace (PyObject *self, void *closure)
return pspace_to_pspace_object (pspace).release ();
}
-static int
-build_inferior_list (struct inferior *inf, void *arg)
-{
- PyObject *list = (PyObject *) arg;
- gdbpy_ref<inferior_object> inferior = inferior_to_inferior_object (inf);
-
- if (inferior == NULL)
- return 0;
-
- return PyList_Append (list, (PyObject *) inferior.get ()) ? 1 : 0;
-}
-
/* Implementation of gdb.inferiors () -> (gdb.Inferior, ...).
Returns a tuple of all inferiors. */
PyObject *
@@ -483,8 +471,16 @@ gdbpy_inferiors (PyObject *unused, PyObject *unused2)
if (list == NULL)
return NULL;
- if (iterate_over_inferiors (build_inferior_list, list.get ()))
- return NULL;
+ for (inferior *inf : all_inferiors ())
+ {
+ gdbpy_ref<inferior_object> inferior = inferior_to_inferior_object (inf);
+
+ if (inferior == NULL)
+ continue;
+
+ if (PyList_Append (list.get (), (PyObject *) inferior.get ()) != 0)
+ return NULL;
+ }
return PyList_AsTuple (list.get ());
}
--
2.25.0
next prev parent reply other threads:[~2020-01-15 19:12 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-15 19:12 [PATCH 0/4] Remove some uses of iterate_over_inferiors Simon Marchi
2020-01-15 19:12 ` [PATCH 4/4] gdb: remove uses of iterate_over_inferiors in top.c Simon Marchi
2020-01-15 19:12 ` [PATCH 2/4] gdb: remove use of iterate_over_inferiors in mi/mi-interp.c Simon Marchi
2020-01-16 11:29 ` Aktemur, Tankut Baris
2020-01-16 15:31 ` Simon Marchi
2020-01-17 7:52 ` Aktemur, Tankut Baris
2020-01-17 15:14 ` Simon Marchi
2020-01-15 19:18 ` Simon Marchi [this message]
2020-01-15 19:50 ` [PATCH 3/4] gdb: remove uses of iterate_over_inferiors in mi/mi-main.c Simon Marchi
2020-01-16 16:23 ` [PATCH 0/4] Remove some uses of iterate_over_inferiors Tom Tromey
2020-01-16 22:46 ` Simon Marchi
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=20200115191222.28208-2-simon.marchi@efficios.com \
--to=simon.marchi@efficios.com \
--cc=gdb-patches@sourceware.org \
/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