From patchwork Thu Feb 6 08:29:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tankut Baris Aktemur X-Patchwork-Id: 37706 Received: (qmail 41285 invoked by alias); 6 Feb 2020 08:30:56 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 40959 invoked by uid 89); 6 Feb 2020 08:30:32 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=H*r:LOCAL X-HELO: mga14.intel.com Received: from mga14.intel.com (HELO mga14.intel.com) (192.55.52.115) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 06 Feb 2020 08:30:31 +0000 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Feb 2020 00:30:16 -0800 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga001.fm.intel.com with ESMTP; 06 Feb 2020 00:30:15 -0800 Received: from ulvlx001.iul.intel.com (ulvlx001.iul.intel.com [172.28.207.17]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id 0168UEU3031733; Thu, 6 Feb 2020 08:30:15 GMT Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id 0168UE6c004717; Thu, 6 Feb 2020 09:30:14 +0100 Received: (from taktemur@localhost) by ulvlx001.iul.intel.com with LOCAL id 0168UEW6004713; Thu, 6 Feb 2020 09:30:14 +0100 From: Tankut Baris Aktemur To: gdb-patches@sourceware.org Cc: palves@redhat.com Subject: [PATCH 1/2] gdb: define convenience function 'exists_non_stop_target' Date: Thu, 6 Feb 2020 09:29:58 +0100 Message-Id: <1580977799-4371-2-git-send-email-tankut.baris.aktemur@intel.com> In-Reply-To: <1580977799-4371-1-git-send-email-tankut.baris.aktemur@intel.com> References: <1580977799-4371-1-git-send-email-tankut.baris.aktemur@intel.com> X-IsSubscribed: yes Define a predicate function that returns true if there exists an inferior with a non-stop target. gdb/ChangeLog: 2020-02-05 Tankut Baris Aktemur * target.h (exists_non_stop_target): New function declaration. * target.c (exists_non_stop_target): New function. --- gdb/target.c | 20 ++++++++++++++++++++ gdb/target.h | 3 +++ 2 files changed, 23 insertions(+) diff --git a/gdb/target.c b/gdb/target.c index 470ef51d69e..a332521af3b 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -3934,6 +3934,26 @@ target_is_non_stop_p (void) && target_always_non_stop_p ())); } +/* See target.h. */ + +bool +exists_non_stop_target () +{ + if (target_is_non_stop_p ()) + return true; + + scoped_restore_current_thread restore_thread; + + for (inferior *inf : all_inferiors ()) + { + switch_to_inferior_no_thread (inf); + if (target_is_non_stop_p ()) + return true; + } + + return false; +} + /* Controls if targets can report that they always run in non-stop mode. This is just for maintainers to use when debugging gdb. */ enum auto_boolean target_non_stop_enabled = AUTO_BOOLEAN_AUTO; diff --git a/gdb/target.h b/gdb/target.h index 26b71cfeb09..40ca5cac8b1 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -1857,6 +1857,9 @@ extern enum auto_boolean target_non_stop_enabled; non-stop" is on. */ extern int target_is_non_stop_p (void); +/* Return true if at least one inferior has a non-stop target. */ +extern bool exists_non_stop_target (); + #define target_execution_direction() \ (current_top_target ()->execution_direction ())