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 5A6C1385840C for ; Tue, 23 Nov 2021 14:08:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5A6C1385840C 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-552-cu-dbhMcNDWwn96OtkJMBA-1; Tue, 23 Nov 2021 09:08:36 -0500 X-MC-Unique: cu-dbhMcNDWwn96OtkJMBA-1 Received: by mail-wm1-f71.google.com with SMTP id j25-20020a05600c1c1900b00332372c252dso1608938wms.1 for ; Tue, 23 Nov 2021 06:08:35 -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=I4z7/Syp9uaRiNACCAqLv1CDQykoAHCqt6+2Vu7iZrw=; b=pEXOw0zr63cLsTY9icLFTg4HWLAEDmdWiS+TE1r5kWGndu2S5AaiZADRZdN7+jzoUT C36nzg92AFcDhj/dQsYJ/s7+wIhfwQ/qNJoHbPHyXf0AxmS6VGvFJ5aBq+KW1YJWrWdA Na6UZkZnwrzict3YUvKLySlHp/W6SaNokrSksIrzNSr3XiyThcJw0CBk8f/0NbJ17MAA VSCczpkL/ohkL6kALnsURKHFaqhlGAVzDPSpNYqfXfcihS/jrNheE2ilzqyTZOC9Qde3 TIa6uKuvsjtqgCHammxbWjktp4ZF5EagomIvJBkNNoRr8efWdvBBHVFXW43dzmRxulQ7 odEA== X-Gm-Message-State: AOAM530PuXYIeQVlDbCO7xel5cW56mb5nHHX05me9dzojcXHZ6Y6NzKL oe0Uh6S8OUYdP1JoF+EA6V3oUQNFTCDKZ7EJbpekKfGE5tubnj+yxO2zPkbgWg/cZwpPRwN/1hn qraMVui1AjsHjRe1D2EZhe1dXeOG4kTPtuaXdWRXBghu0Ufl9f0pZfWgnemOK8JV4TrT3cFYRpg == X-Received: by 2002:a1c:9a89:: with SMTP id c131mr3389349wme.80.1637676514363; Tue, 23 Nov 2021 06:08:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJwUHlM0Zuwt1hbhgRry45q5WtNJzuALVyLf/8VS5Rd2YRW7m3q83BrqZb6IBsyVkDQHgp9Y4g== X-Received: by 2002:a1c:9a89:: with SMTP id c131mr3389305wme.80.1637676514085; Tue, 23 Nov 2021 06:08:34 -0800 (PST) Received: from localhost (host86-166-129-255.range86-166.btcentralplus.com. [86.166.129.255]) by smtp.gmail.com with ESMTPSA id s63sm1565553wme.22.2021.11.23.06.08.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Nov 2021 06:08:33 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 3/4] gdb: add assert in remote_target::wait relating to async being off Date: Tue, 23 Nov 2021 14:08:22 +0000 Message-Id: <56b13666e9b7e54341aac22da9cfb45986f7f506.1637676250.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=-10.8 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: Tue, 23 Nov 2021 14:08:38 -0000 While working on another patch I ended up in a situation where I had async mode disabled (with 'maint set target-async off'), but the async event token got marked anyway. In this situation GDB was continually calling into remote_target::wait, however, the async token would never become unmarked as the unmarking is guarded by target_is_async_p. We could just unconditionally unmark the token, but that would feel like just ignoring a bug, so, instead, lets assert that if !target_is_async_p, then the async token should not be marked. This assertion would have caught my earlier mistake. There should be no user visible changes with this commit. --- gdb/remote.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gdb/remote.c b/gdb/remote.c index 0c4cc6bad0b..64c4cde436b 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -8312,9 +8312,13 @@ remote_target::wait (ptid_t ptid, struct target_waitstatus *status, remote_state *rs = get_remote_state (); /* Start by clearing the flag that asks for our wait method to be called, - we'll mark it again at the end if needed. */ + we'll mark it again at the end if needed. If the target is not in + async mode then the async token should not be marked. */ if (target_is_async_p ()) clear_async_event_handler (rs->remote_async_inferior_event_token); + else + gdb_assert (!async_event_handler_marked + (rs->remote_async_inferior_event_token)); ptid_t event_ptid; -- 2.25.4