[binutils-gdb] gdb: use inferior::threads instead of all_threads and a PID filter
Andrew Burgess via Gdb-cvs <[email protected]>
| Newsgroups | gmane.comp.gdb.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=596ff0647b07ba9ada27795207adad36d9d7cd24 commit 596ff0647b07ba9ada27795207adad36d9d7cd24 Author: Andrew Burgess <[email protected]> Date: Thu Aug 6 11:35:20 2026 +0100 gdb: use inferior::threads instead of all_threads and a PID filter 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. Approved-By: Tom de Vries <[email protected]> Diff: --- 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 4d93859f38e..5d1aeb87d43 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 ())