From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id fzx6FWq1XGEFJwAAWB0awg (envelope-from ) for ; Tue, 05 Oct 2021 16:28:26 -0400 Received: by simark.ca (Postfix, from userid 112) id 46D251EE1B; Tue, 5 Oct 2021 16:28:26 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 7CC7A1E813 for ; Tue, 5 Oct 2021 16:28:25 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C7944385B804 for ; Tue, 5 Oct 2021 20:28:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C7944385B804 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1633465704; bh=zi+ER5flNTkH2WKIu7KHcAS/DRz9kE20XMHgsCX6ue0=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=vv+ULi9UYAXXgVsg8DTb1a3Folj7yFTXDbUPsSywaKgXu+2v2w7OalnQYqxnZJ7C2 eHouGEJxwMZiC4KLLtGbwU22dM6ajowhCxa7CjyECL7RHR+cNYIGMRGf4o7dcCJz3d 7aEbMLgPWehkz1wwsAaw1VObG4S0BROHGVlFsvaw= Received: from lndn.lancelotsix.com (lndn.lancelotsix.com [51.195.220.111]) by sourceware.org (Postfix) with ESMTPS id AF918385802D for ; Tue, 5 Oct 2021 20:28:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AF918385802D Received: from ubuntu.lan (unknown [IPv6:2a02:390:9086::635]) by lndn.lancelotsix.com (Postfix) with ESMTPSA id 00CC080D76; Tue, 5 Oct 2021 20:28:03 +0000 (UTC) Date: Tue, 5 Oct 2021 20:27:55 +0000 To: Simon Marchi Subject: Re: [PATCH v4 3/4] gdb: Have setter and getter callbacks for settings Message-ID: <20211005201547.wq5za7d2zoswtzyd@ubuntu.lan> References: <20210929215011.1489639-1-lsix@lancelotsix.com> <20210929215011.1489639-4-lsix@lancelotsix.com> <4909e2ce-64db-525c-0199-458138c32460@polymtl.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4909e2ce-64db-525c-0199-458138c32460@polymtl.ca> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.11 (lndn.lancelotsix.com [0.0.0.0]); Tue, 05 Oct 2021 20:28:04 +0000 (UTC) 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: , From: Lancelot SIX via Gdb-patches Reply-To: Lancelot SIX Cc: gdb-patches@sourceware.org Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On Tue, Oct 05, 2021 at 03:10:55PM -0400, Simon Marchi wrote: > > @@ -241,13 +295,23 @@ struct setting > > gdb_assert (var_type_uses (m_var_type)); > > gdb_assert (m_var != nullptr); > > > > - return *static_cast (m_var); > > + if (m_var == nullptr) > > + { > > + gdb_assert (m_getter != nullptr); > > + auto getter = reinterpret_cast> (m_getter); > > + return getter (); > > + } > > + else > > + return *static_cast (m_var); > > While pulling these upstream changes to the ROCm GDB port, I found that > we forgot to remove the `gdb_assert (m_var != nullptr)` above. > > I can fix that when I send a patch that actually uses the > getters/setters (which would trigger the assert). > > Simon Hi, This is odd, I was sure I did fix this omission, but obviously not. Thanks for spotting this, and my apologies for the inconvenience. Here is a (trivial) patch that fixes that. Best, Lancelot. --- >From 4c5b728046770ef923323162ac48246b947267d2 Mon Sep 17 00:00:00 2001 From: Lancelot SIX Date: Tue, 5 Oct 2021 19:55:19 +0000 Subject: [PATCH] gdb: Remove deprecated assertion in setting::get The commit 702991711a91bd47b209289562843a11e7009396 (gdb: Have setter and getter callbacks for settings) makes it possible for a setting not to be backed by a memory buffer but use callback functions instead to retrieve or set the setting's value. An assertion was not properly updated to take into account that the m_var member (which points to a memory buffer, if used) might be nullptr if the setting uses callback functions. If the setting is backed by a memory buffer, the m_var has to be non nullptr, which is already checked before the pointer is dereferenced. This commit removes this assertion as it is not valid anymore. --- gdb/command.h | 1 - 1 file changed, 1 deletion(-) diff --git a/gdb/command.h b/gdb/command.h index 7c226f193b8..0049ab6ff9e 100644 --- a/gdb/command.h +++ b/gdb/command.h @@ -288,7 +288,6 @@ struct setting const T &get () const { gdb_assert (var_type_uses (m_var_type)); - gdb_assert (m_var != nullptr); if (m_var == nullptr) { -- 2.30.2