From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 From: Lancelot SIX To: Simon Marchi Cc: gdb-patches@sourceware.org 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-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, 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, 05 Oct 2021 20:28:07 -0000 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