From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 83E933858413 for ; Wed, 24 Nov 2021 21:17:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 83E933858413 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca Received: from [172.16.0.95] (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 0576C1E940; Wed, 24 Nov 2021 16:17:15 -0500 (EST) Subject: Re: [PATCHv2 2/6] gdb: hoist target_async_permitted checks into target.c To: Andrew Burgess , gdb-patches@sourceware.org References: From: Simon Marchi Message-ID: <6ce43582-e514-dee6-7aec-c48d702930b5@simark.ca> Date: Wed, 24 Nov 2021 16:17:14 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: tl Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_PASS, SPF_PASS, 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 21:17:17 -0000 On 2021-11-24 7:22 a.m., Andrew Burgess via Gdb-patches wrote: > This commit moves the target_async_permitted check out of each targets > ::can_async_p method and into the two target_can_async_p wrapper > functions. > > I've left some asserts in the two ::can_async_p methods that I > changed, which will hopefully catch any direct calls to these methods > that might be added in the future. > > There should be no user visible changes after this commit. > --- > gdb/linux-nat.c | 5 ++++- > gdb/remote.c | 11 ++++------- > gdb/target.c | 4 ++++ > 3 files changed, 12 insertions(+), 8 deletions(-) > > diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c > index f8f728481ea..3e1d1644d4c 100644 > --- a/gdb/linux-nat.c > +++ b/gdb/linux-nat.c > @@ -4088,9 +4088,12 @@ linux_nat_target::is_async_p () > bool > linux_nat_target::can_async_p () > { > + /* This flag should be checked in the common target.c code. */ > + gdb_assert (target_async_permitted); > + > /* We're always async, unless the user explicitly prevented it with the > "maint set target-async" command. */ > - return target_async_permitted; > + return true; The comment just above that isn't false, but maybe it's not so relevant to have it here anymore. > } > > bool > diff --git a/gdb/remote.c b/gdb/remote.c > index 724386e0916..6ecea5b7fd7 100644 > --- a/gdb/remote.c > +++ b/gdb/remote.c > @@ -14379,14 +14379,11 @@ remote_target::thread_info_to_thread_handle (struct thread_info *tp) > bool > remote_target::can_async_p () > { > - struct remote_state *rs = get_remote_state (); > - > - /* We don't go async if the user has explicitly prevented it with the > - "maint set target-async" command. */ > - if (!target_async_permitted) > - return false; > + /* This flag should be checked in the common target.c code. */ > + gdb_assert (target_async_permitted); > > - /* We're async whenever the serial device is. */ > + /* We're async whenever the serial device can. */ > + struct remote_state *rs = get_remote_state (); > return serial_can_async_p (rs->remote_desc); > } > > diff --git a/gdb/target.c b/gdb/target.c > index c5276ae0fe7..d693b670350 100644 > --- a/gdb/target.c > +++ b/gdb/target.c > @@ -391,6 +391,8 @@ target_can_lock_scheduler () > bool > target_can_async_p () > { > + if (!target_async_permitted) > + return false; > return current_inferior ()->top_target ()->can_async_p (); > } You could make this overload call the other one: return target_can_async_p (current_inferior ()->top_target ()); so that there is really a single point where target_async_permitted is checked. Otherwise, LGTM. Simon