From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by sourceware.org (Postfix) with ESMTP id A330B3959C9D for ; Wed, 13 May 2020 20:53:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A330B3959C9D Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-493-pMzV13vzPheQzwvCUwDnaQ-1; Wed, 13 May 2020 16:53:44 -0400 X-MC-Unique: pMzV13vzPheQzwvCUwDnaQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3C403872FE1 for ; Wed, 13 May 2020 20:53:43 +0000 (UTC) Received: from cascais.Home (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id D1A766154C for ; Wed, 13 May 2020 20:53:42 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH v8 4/6] gdb: introduce 'all_non_exited_process_targets' and 'switch_to_target_no_thread' Date: Wed, 13 May 2020 21:53:36 +0100 Message-Id: <20200513205338.14233-5-palves@redhat.com> In-Reply-To: <20200513205338.14233-1-palves@redhat.com> References: <20200513205338.14233-1-palves@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-17.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 May 2020 20:53:46 -0000 From: Tankut Baris Aktemur 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 * 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 | 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 +all_non_exited_process_targets () +{ + 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; + } +} diff --git a/gdb/process-stratum-target.h b/gdb/process-stratum-target.h index 1be02100dcf..7e7905bf750 100644 --- a/gdb/process-stratum-target.h +++ b/gdb/process-stratum-target.h @@ -21,6 +21,7 @@ #define PROCESS_STRATUM_TARGET_H #include "target.h" +#include /* Abstract base class inherited by all process_stratum targets. */ @@ -82,4 +83,13 @@ as_process_stratum_target (target_ops *target) return static_cast (target); } +/* Return a collection of targets that have non-exited inferiors. */ + +extern std::set all_non_exited_process_targets (); + +/* Switch to the first inferior (and program space) of TARGET, and + switch to no thread selected. */ + +extern void switch_to_target_no_thread (process_stratum_target *target); + #endif /* !defined (PROCESS_STRATUM_TARGET_H) */ -- 2.14.5