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 311513858023 for ; Wed, 24 Nov 2021 12:22:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 311513858023 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-148-dleWYa-GPhSsBOvf6citvQ-1; Wed, 24 Nov 2021 07:22:19 -0500 X-MC-Unique: dleWYa-GPhSsBOvf6citvQ-1 Received: by mail-wm1-f72.google.com with SMTP id p12-20020a05600c1d8c00b0033a22e48203so1341583wms.6 for ; Wed, 24 Nov 2021 04:22:19 -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=yz3OVeoJrkf56eWcpG+tkQI3NltpmXASjE6wyQ5o4bI=; b=yJHv/bkoxvT03RrKCXsz103/SCHqFJ+6TLli/5Pd4j8SiWTAalHUs/dMpqX6Q6OTfm 9CLQEnuOl72GR9htcX5XaB21izRG9AWF8jQtiV45/edHnJt7hl9zFBLiX8T2jkp3Qkfi 4G2tJvMMN7c13M/N9t7eHmMCyX3TlNVZmdRtN5VuDIoVV/ZmCEAoRT5eOwGEGGVgp5fO xd2WXZY3ffA4Qr5u6NcztTcuaY027r+VLhaPnMpmjOYTQC2lsRpLEvKhSzYfQAf7eV80 OWm9NA9NBhjO6BJnyGED7Ltl6tNFt1vTBcsgqYZHPtrDujv4ro1FsL4eJAvwbouFwiUz 66aw== X-Gm-Message-State: AOAM53088Jd0SrKu5osJN2oia10pKMxl1sOxhEOBb38zvMbWA7lT2iKz JNoOXGQ8rR4Hrzz2spwbC3o0ru64f3mlaKOcIR9ApFnmJrnk62+2CnJE57O23T6QvvW2KRUUaDl E2ByOsjjtjet/zkcZOUOZyrTE7FVMBNU/Zk2BKVsBnTMCifDfyfDIvj4DjK2ax9GpuzU+ecOgqg == X-Received: by 2002:a5d:550c:: with SMTP id b12mr18176017wrv.427.1637756537764; Wed, 24 Nov 2021 04:22:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJwg0kn+9w0dILTdgMca6oJhBn8hDADTNPVLqumZH/G+wL9iWEH/0sPNjuXDoCXLB86pZAypJQ== X-Received: by 2002:a5d:550c:: with SMTP id b12mr18175991wrv.427.1637756537532; Wed, 24 Nov 2021 04:22:17 -0800 (PST) Received: from localhost (host86-166-129-255.range86-166.btcentralplus.com. [86.166.129.255]) by smtp.gmail.com with ESMTPSA id v8sm14835717wrd.84.2021.11.24.04.22.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Nov 2021 04:22:17 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv2 2/6] gdb: hoist target_async_permitted checks into target.c Date: Wed, 24 Nov 2021 12:22:05 +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:22 -0000 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; } 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 (); } @@ -399,6 +401,8 @@ target_can_async_p () bool target_can_async_p (struct target_ops *target) { + if (!target_async_permitted) + return false; return target->can_async_p (); } -- 2.25.4