[PATCH v8 4/6] gdb: introduce 'all_non_exited_process_targets' and 'switch_to_target_no_thread'

Aktemur, Tankut Baris tankut.baris.aktemur@intel.com
Thu May 14 08:44:12 GMT 2020


On Wednesday, May 13, 2020 10:54 PM, Pedro Alves wrote:
> 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-04-30  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>
> 
> 	* process-stratum-target.h: Include <set>.
> 	(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 | 24 ++++++++++++++++++++++++
>  gdb/process-stratum-target.h | 10 ++++++++++
>  2 files changed, 34 insertions(+)
> 
> diff --git a/gdb/process-stratum-target.c b/gdb/process-stratum-target.c
> index f3fd9ee905d..9fb358a6a9f 100644
> --- a/gdb/process-stratum-target.c
> +++ b/gdb/process-stratum-target.c
> @@ -83,3 +83,27 @@ process_stratum_target::has_execution (inferior *inf)
>       through hoops.  */
>    return inf->pid != 0;
>  }
> +
> +/* See process-stratum-target.h.  */
> +
> +std::set<process_stratum_target *>
> +all_non_exited_process_targets ()
> +{

Christian suggested adding a comment here to state why a set was needed.
I thought about this:

/* Inferiors may share targets.  To eliminate duplicates, use a set.  */

> +  std::set<process_stratum_target *> targets;
> +  for (inferior *inf : all_non_exited_inferiors ())
> +    targets.insert (inf->process_target ());
> +
> +  return targets;
> +}

Thanks.
-Baris


Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Gary Kershaw
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


More information about the Gdb-patches mailing list