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 EC46A385840E for ; Wed, 24 Nov 2021 12:22:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EC46A385840E Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-208-aDmI5Gs6ONeUemIcVKXTYA-1; Wed, 24 Nov 2021 07:22:20 -0500 X-MC-Unique: aDmI5Gs6ONeUemIcVKXTYA-1 Received: by mail-wm1-f71.google.com with SMTP id g80-20020a1c2053000000b003331a764709so2933134wmg.2 for ; Wed, 24 Nov 2021 04:22:20 -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=7FoRxbfr1yhYRscwjzmAbTzdfF1ds4wBvtrCXCCCY9Q=; b=VcsPYBzFsL8dSrb+Df73ZEIS+NKDB8/LSXD2k/3zXRdjjQbwTOcmtJ9wRvl4a8KVbq 26yC8NcjTeH3z6gNP1mkNvUZhw4CTfcg4LzKJFq80MIWFPaQOau/SeysN6Y5RQeQ0l+3 v1jFri/RSECzbBzOXO5KxCaPiIrPe35zOK2j3HqFYxFj0v4wa1E7ab5fd3Lrz2FU3Glo yZ3zaRxElPgpoqXThJkHVP/ylKs9H8b+q44qZPdM9G/xW/l4/jXCPPvIb0LqQ98Nok6c 8NCO9tZ58y/zLZsn22luAwLLKvP1jOyBte/3/THAly2sGe/CtxKmJLP9FwuUamKKjLKu v79g== X-Gm-Message-State: AOAM531p/ne/SJX3QxHqHyYHY2Utb1MOrMTYbam2RY1c4TRDdrVuMAn0 dLVhdoc6EonerDWjzPB2UU4SAiCuIWH2dE3kBHH4vYrqtd5hj0MQ+vj2/OpSSMrwwVLlYPPqqGA Eu243aJQfsqlrQwXPXuRo7WwBCcU6eHpTD4J5MCVtenBqDlSLddKldcC5Yu9T0fmjlAH43hHa/A == X-Received: by 2002:a05:600c:224a:: with SMTP id a10mr14295968wmm.154.1637756539078; Wed, 24 Nov 2021 04:22:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJxxG1pCYRyB1QeZYg+Vysp2C4nZX6GfKDL0grIpEHCbQ19mXSDEjl8R2mMxTIumw46f4BxhCQ== X-Received: by 2002:a05:600c:224a:: with SMTP id a10mr14295931wmm.154.1637756538836; Wed, 24 Nov 2021 04:22:18 -0800 (PST) Received: from localhost (host86-166-129-255.range86-166.btcentralplus.com. [86.166.129.255]) by smtp.gmail.com with ESMTPSA id q8sm14927249wrx.71.2021.11.24.04.22.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Nov 2021 04:22:18 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv2 3/6] gdb: add asserts in target.c for target_async_permitted Date: Wed, 24 Nov 2021 12:22:06 +0000 Message-Id: <3a174872995221e716715f74fc925d8140950398.1637756330.git.aburgess@redhat.com> 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=-11.0 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:23 -0000 The target_async_permitted flag allows a user to override whether a target can act in async mode or not. In previous commits I have moved the checking of this flag out of the various ::can_async_p methods and into the common target.c code. In this commit I will add some additional assertions into target_is_async_p and target_async. The rules these assertions are checking are: 1. A target that returns false for target_can_async_p should never become "async enabled", and so ::is_async_p should always return false. This is being checked in target_is_async_p. 2. GDB should never try to enable async mode for a target that returns false for target_can_async_p, this is checked in target_async. There are a few places where we call the ::is_async_p method directly, in these cases we will obviously not pass through the assert in target_is_async_p, however, there are also plenty of places where we do call target_is_async_p so if GDB starts to misbehave we should catch it quickly enough. There should be no user visible changes after this commit. --- gdb/target.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gdb/target.c b/gdb/target.c index d693b670350..941433f8953 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -411,7 +411,9 @@ target_can_async_p (struct target_ops *target) bool target_is_async_p () { - return current_inferior ()->top_target ()->is_async_p (); + bool result = current_inferior ()->top_target ()->is_async_p (); + gdb_assert (target_async_permitted || !result); + return result; } exec_direction_kind @@ -4340,6 +4342,9 @@ maintenance_print_target_stack (const char *cmd, int from_tty) void target_async (int enable) { + /* If we are trying to enable async mode then it must be the case that + async mode is possible for this target. */ + gdb_assert (!enable || target_can_async_p ()); infrun_async (enable); current_inferior ()->top_target ()->async (enable); } -- 2.25.4