From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 731DC3858412 for ; Wed, 24 Nov 2021 12:22:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 731DC3858412 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-498-_8Q8hV7iO_yCSL2lgWLV6g-1; Wed, 24 Nov 2021 07:22:18 -0500 X-MC-Unique: _8Q8hV7iO_yCSL2lgWLV6g-1 Received: by mail-wm1-f69.google.com with SMTP id bg20-20020a05600c3c9400b0033a9300b44bso1355198wmb.2 for ; Wed, 24 Nov 2021 04:22:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6D8I4/Nm+EtHZTGJVKANJB7Q8X6PGdBfdSIlNTaMjms=; b=S45PXHghz21Dya4wLiWpMa70p/4PtKUwMM0N20FF9+Ws8Ehp25/NVbVi33OWzhQtYN R9Ph1POdpjcFQxAvar5FUZxLpIJDxZQ4LXZFlyj2oN2l+z1lFPAo184astSc9TViTcfP 5eEynrq7gWxsZ3kHlrjomODqTDkd7UEsHsvH1ko42CdRqgDB9lbZ3Vy9bFyiIKaunGNq /fVqiS7V79AGDEuQvydPH0tcgH28ZDDNy/kFnwbrLRupcJRxrjVOqchne5L/dJxmC+QE oYCo6vEc3wPpY6LjxIIJKWOg8fOD1R+SkLcA9VuzX0lGTw8QKkB+1m+Udof56c4l8IZ+ IuNw== X-Gm-Message-State: AOAM531yijBrv38dNzcgsJb5xuBxz8WTY3MlE3zKVblG9DlJ0MuC8MtK /NnclEjSOB1Ac/VJOXRoxBz37R4C85NWMsSoILvUvfn1FfD859XEFR6A+I4IPgfgPgLQD5YBdO5 vl90PTe8I7dfff5WN/n2otGA/cKIHgyRGO9nSZC+vToc3gEVdeIQJBzoyMN1jttap4sdOOfrreQ == X-Received: by 2002:a1c:f70c:: with SMTP id v12mr14361832wmh.18.1637756536581; Wed, 24 Nov 2021 04:22:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJxosdHNtIE4GoIT3qg1OgdW6rAnSoHx2eLLFHkXijOk/E/yDVsKkjKwWCd/8P5UTrcEDXJvMA== X-Received: by 2002:a1c:f70c:: with SMTP id v12mr14361776wmh.18.1637756536286; Wed, 24 Nov 2021 04:22:16 -0800 (PST) Received: from localhost (host86-166-129-255.range86-166.btcentralplus.com. [86.166.129.255]) by smtp.gmail.com with ESMTPSA id t1sm17638322wre.32.2021.11.24.04.22.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Nov 2021 04:22:15 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv2 1/6] gdb: introduce a new overload of target_can_async_p Date: Wed, 24 Nov 2021 12:22:04 +0000 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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, 24 Nov 2021 12:22:21 -0000 There are a few places where we call the target_ops::can_async_p member function directly, instead of using the target_can_async_p wrapper. In some of these places this is because we need to ask before the target has been pushed, and in another location (in target.c) it seems unnecessary to go through the wrapper when we are already in target.c code. However, in the next commit I'd like to hoist some common checks out of target specific code into target.c. To achieve this, in this commit I introduce a new overload of target_can_async_p which takes a target_ops pointer, and calls the ::can_async_p method directly. This commit adds the new overload, and has everyone call though it. There should be no user visible changes after this commit. --- gdb/infcmd.c | 2 +- gdb/mi/mi-main.c | 4 ++-- gdb/target.c | 10 +++++++++- gdb/target.h | 4 ++++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 6bbd45618eb..984ce4e042b 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -336,7 +336,7 @@ prepare_execution_command (struct target_ops *target, int background) { /* If we get a request for running in the bg but the target doesn't support it, error out. */ - if (background && !target->can_async_p ()) + if (background && !target_can_async_p (target)) error (_("Asynchronous execution not supported on this target.")); if (!background) diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index e28fae0cc6c..311697b2d58 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -408,7 +408,7 @@ run_one_inferior (inferior *inf, bool start_p) { const char *run_cmd = start_p ? "start" : "run"; struct target_ops *run_target = find_run_target (); - int async_p = mi_async && run_target->can_async_p (); + int async_p = mi_async && target_can_async_p (run_target); if (inf->pid != 0) { @@ -473,7 +473,7 @@ mi_cmd_exec_run (const char *command, char **argv, int argc) { const char *run_cmd = start_p ? "start" : "run"; struct target_ops *run_target = find_run_target (); - int async_p = mi_async && run_target->can_async_p (); + int async_p = mi_async && target_can_async_p (run_target); mi_execute_cli_command (run_cmd, async_p, async_p ? "&" : NULL); diff --git a/gdb/target.c b/gdb/target.c index 8fe27c775ea..c5276ae0fe7 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -396,6 +396,14 @@ target_can_async_p () /* See target.h. */ +bool +target_can_async_p (struct target_ops *target) +{ + return target->can_async_p (); +} + +/* See target.h. */ + bool target_is_async_p () { @@ -2602,7 +2610,7 @@ target_wait (ptid_t ptid, struct target_waitstatus *status, gdb_assert (!proc_target->commit_resumed_state); - if (!target->can_async_p ()) + if (!target_can_async_p (target)) gdb_assert ((options & TARGET_WNOHANG) == 0); return target->wait (ptid, status, options); diff --git a/gdb/target.h b/gdb/target.h index 4dc17fd4806..e709b7d7cfd 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -1886,6 +1886,10 @@ extern bool target_async_permitted; /* Can the target support asynchronous execution? */ extern bool target_can_async_p (); +/* An overload of the above that can be called when the target is not yet + pushed, this calls TARGET::can_async_p directly. */ +extern bool target_can_async_p (struct target_ops *target); + /* Is the target in asynchronous execution mode? */ extern bool target_is_async_p (); -- 2.25.4