From d890404b63b8a0b6c28212388f21421d029f6ad2 Mon Sep 17 00:00:00 2001 From: Tankut Baris Aktemur Date: Thu, 14 May 2020 13:59:54 +0200 Subject: gdb: introduce 'all_non_exited_process_targets' and 'switch_to_target_no_thread' Introduce two new convenience functions: 1. all_non_exited_process_targets: returns a collection of all process stratum targets that have non-exited inferiors on them. Useful for iterating targets. 2. switch_to_target_no_thread: switch the context to the first inferior of the given target, and to no selected thread. gdb/ChangeLog: 2020-05-14 Tankut Baris Aktemur * process-stratum-target.h: Include . (all_non_exited_process_targets, switch_to_target_no_thread): New function declarations. * process-stratum-target.c (all_non_exited_process_targets) (switch_to_target_no_thread): New function implementations. --- gdb/process-stratum-target.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'gdb/process-stratum-target.c') diff --git a/gdb/process-stratum-target.c b/gdb/process-stratum-target.c index f3fd9ee..9eff5ab 100644 --- a/gdb/process-stratum-target.c +++ b/gdb/process-stratum-target.c @@ -83,3 +83,28 @@ process_stratum_target::has_execution (inferior *inf) through hoops. */ return inf->pid != 0; } + +/* See process-stratum-target.h. */ + +std::set +all_non_exited_process_targets () +{ + /* Inferiors may share targets. To eliminate duplicates, use a set. */ + std::set targets; + for (inferior *inf : all_non_exited_inferiors ()) + targets.insert (inf->process_target ()); + + return targets; +} + +/* See process-stratum-target.h. */ + +void +switch_to_target_no_thread (process_stratum_target *target) +{ + for (inferior *inf : all_inferiors (target)) + { + switch_to_inferior_no_thread (inf); + break; + } +} -- cgit v1.1