From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id RLAADmu4XGGVJwAAWB0awg (envelope-from ) for ; Tue, 05 Oct 2021 16:41:15 -0400 Received: by simark.ca (Postfix, from userid 112) id 240751EE1B; Tue, 5 Oct 2021 16:41:15 -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.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_DYNAMIC, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.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 38C721E813 for ; Tue, 5 Oct 2021 16:41:14 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ACEFA385BF93 for ; Tue, 5 Oct 2021 20:41:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ACEFA385BF93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1633466473; bh=h/fbX8Z6n6evkjriw+dQJdaQfvnH88Dm86LPHO3uV8E=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=UHo1kE3rnNsQ3rav+flpKMCebX/Kbmk9jy62uLwP6nkNtFqxcoYTActE34y2o8BS4 A/WVikJiKnfL8IXEk9wd5YZKpxVE0BiFQLVBe4xI/sv5ZeFPifvaMB4e8lFTsYOmLZ QHGud62T4mD9SkvxWk6SDlrB07ivylb4mZfiujQ8= Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 6A7FB385802D for ; Tue, 5 Oct 2021 20:40:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6A7FB385802D 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 195KdmFu019689 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 5 Oct 2021 16:39:53 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 195KdmFu019689 Received: from [172.16.0.95] (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id C6BD01E813; Tue, 5 Oct 2021 16:39:47 -0400 (EDT) Subject: Re: [PATCH v4 3/4] gdb: Have setter and getter callbacks for settings To: Lancelot SIX References: <20210929215011.1489639-1-lsix@lancelotsix.com> <20210929215011.1489639-4-lsix@lancelotsix.com> <4909e2ce-64db-525c-0199-458138c32460@polymtl.ca> <20211005201547.wq5za7d2zoswtzyd@ubuntu.lan> Message-ID: <0c7946c4-0a34-3c67-da81-4fdad8208670@polymtl.ca> Date: Tue, 5 Oct 2021 16:39:47 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20211005201547.wq5za7d2zoswtzyd@ubuntu.lan> Content-Type: text/plain; charset=utf-8 Content-Language: tl Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Tue, 5 Oct 2021 20:39:48 +0000 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: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Cc: gdb-patches@sourceware.org Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On 2021-10-05 4:27 p.m., Lancelot SIX wrote: > 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 > Well, since you have the patch already, go ahead and push it. Thanks, Simon