[PATCH 1/2] gdb: use inferior::threads instead of all_threads and a PID filter
Andrew Burgess <[email protected]>
| Newsgroups | gmane.comp.gdb.patches |
|---|---|
| Message-ID | <2dbabbed902e38a1d4534fd7ecd3362331f71ea8.1786049312.git.aburgess@redhat.com> |
I noticed a few places where we iterated over `all_threads ()` but
then immediately filtered by PID. It would be better to instead
iterate over `inferior::threads ()` and remove the PID filtering.
These should be equivalent as a single inferior should contain every
thread with a given PID, and should only contain threads with that
given PID.
While editing the `for (...)` loops I have replaced 'auto' with
'thread_info' for additional type clarity.
There should be no user visible changes after this commit.
---
gdb/mi/mi-main.c | 18 +++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 8b6da41ffeb..903c6a5f411 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -359,14 +359,11 @@ mi_cmd_exec_interrupt (const char *command, const char *const *argv, int argc)
scoped_disable_commit_resumed disable_commit_resumed
("interrupting all threads of thread group");
- for (auto &thread : all_threads ())
+ for (thread_info &thread : inf->threads ())
{
if (thread.state () != THREAD_RUNNING)
continue;
- if (thread.ptid.pid () != inf->pid)
- continue;
-
target_stop (thread.ptid);
}
}
@@ -603,14 +600,13 @@ print_one_inferior (struct inferior *inferior, bool recurse,
if (inferior->pid != 0)
{
- for (auto &ti : all_threads ())
- if (ti.ptid.pid () == inferior->pid)
- {
- int core = target_core_of_thread (ti.ptid);
+ for (thread_info &ti : inferior->threads ())
+ {
+ int core = target_core_of_thread (ti.ptid);
- if (core != -1)
- cores.insert (core);
- }
+ if (core != -1)
+ cores.insert (core);
+ }
}
if (!cores.empty ())
--
2.25.4