From patchwork Wed Feb 5 11:54:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Simon Marchi (Code Review)" X-Patchwork-Id: 37691 Received: (qmail 81015 invoked by alias); 5 Feb 2020 11:54:43 -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 80991 invoked by uid 89); 5 Feb 2020 11:54:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.8 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=tankutbarisaktemurintelcom, sk:tankut, nonstop, U*tankut.baris.aktemur X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 05 Feb 2020 11:54:40 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id 8FCA22058E; Wed, 5 Feb 2020 06:54:33 -0500 (EST) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [8.43.85.239]) by mx1.osci.io (Postfix) with ESMTP id 34EEE20198 for ; Wed, 5 Feb 2020 06:54:30 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id 0904F2816C for ; Wed, 5 Feb 2020 06:54:30 -0500 (EST) X-Gerrit-PatchSet: 1 Date: Wed, 5 Feb 2020 06:54:29 -0500 From: "Tankut Baris Aktemur (Code Review)" To: gdb-patches@sourceware.org Message-ID: Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange Subject: [review] gdb: define convenience function 'exists_non_stop_target' X-Gerrit-Change-Id: Ia4db9e33f5cd2d15134d194dadee19ca6853b2d8 X-Gerrit-Change-Number: 765 X-Gerrit-ChangeURL: X-Gerrit-Commit: ae2b8a383bfb143883b600c4d4b964434ef8ec34 References: Reply-To: tankut.baris.aktemur@intel.com, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3-79-g83ff7f88f1 Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/765 ...................................................................... gdb: define convenience function 'exists_non_stop_target' 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. Change-Id: Ia4db9e33f5cd2d15134d194dadee19ca6853b2d8 --- M gdb/target.c M gdb/target.h 2 files changed, 23 insertions(+), 0 deletions(-) diff --git a/gdb/target.c b/gdb/target.c index 470ef51..a332521 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -3934,6 +3934,26 @@ && 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 26b71cf..40ca5ca 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -1857,6 +1857,9 @@ 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 ())