From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 089673858025 for ; Wed, 4 Oct 2023 02:07:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 089673858025 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 394274wA018720 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 3 Oct 2023 22:07:08 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 394274wA018720 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=default; t=1696385228; bh=DMGtDh9Ma0iaTZ4bwyiTuU+U9SYsr6UhJH1zGGFSTR4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l3FxPOhtHs+5KwYMppLWFImP1J4VYYDfLpsKCZVS61HQs0pzJdA+uuPYpXmjghxwW xQXM7lxaKRxLELKJOCwSf/4JKFxjElbWPd4fz1efpGk/pY3bPQVLYLC0nMiL2Dg/Tv NkjXKpmycpV3cTSPuRPlMrDdH+CVMkRx3bJH8lyg= Received: from simark.localdomain (modemcable238.237-201-24.mc.videotron.ca [24.201.237.238]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id DF2DB1E0D0; Tue, 3 Oct 2023 22:07:03 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 3/3] gdb: add assertion when marking the remote async flag Date: Tue, 3 Oct 2023 22:04:01 -0400 Message-ID: <20231004020701.260411-4-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231004020701.260411-1-simon.marchi@polymtl.ca> References: <20231004020701.260411-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Wed, 4 Oct 2023 02:07:04 +0000 X-Spam-Status: No, score=-3188.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: From: Simon Marchi As reported in bug 30630 [1], we hit a case where the remote target's async flag is marked while the target is not configured (yet) to work async. This should not happen. It is caught thanks to this assert in remote_target::wait: /* Start by clearing the flag that asks for our wait method to be called, 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 ()) rs->clear_async_event_handler (); else gdb_assert (!rs->async_event_handler_marked ()); This is helpful, but I think that we could have caught the problem earlier than that, at the moment we marked the handler. Catching problems earlier makes them easier to debug. [1] https://sourceware.org/bugzilla/show_bug.cgi?id=30630 Change-Id: I7e229c74b04da82bef6a817d5a676be5cf52e833 --- gdb/remote.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gdb/remote.c b/gdb/remote.c index 38d0027dbf9e..7830b5cec33f 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -424,7 +424,10 @@ class remote_state } void mark_async_event_handler () - { ::mark_async_event_handler (m_async_event_handler_token); } + { + gdb_assert (this->is_async_p ()); + ::mark_async_event_handler (m_async_event_handler_token); + } void clear_async_event_handler () { ::clear_async_event_handler (m_async_event_handler_token); } -- 2.42.0