From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id 0A9AB385840B for ; Thu, 22 Feb 2024 12:07:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0A9AB385840B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0A9AB385840B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708603664; cv=none; b=WCCTYtpI0jO7rTyvTn4SosMxgNfljXQVFWaksmGbRhOv0yNoBaYd4T0W7TlwNwpADoN5mi9qVsPbjwXy9TevYCOnL7E+5dpvi+KrA890zb333jo4wBQ8rehLfha4p3oDNMyiGRrqxkw48XjTvBw2e8Ni6IEneuIWNAIaTiBPXp0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708603664; c=relaxed/simple; bh=gtQaOQZ9yrvBydgmisaMErps+n1/n8wb8o+Mk87IlKY=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature: Message-ID:Date:MIME-Version:Subject:To:From; b=vB8XqRo8OHC0MTMDorzXe2gn9Vm3u0l74dQX2+kHF1SxCU+m3C7mduhuXF4fKLUCiL1EU3Nz6knQzW5k4ZNp4tDSun/PB/vMxkrkABh2RAv43yIlXe8jd8oHTgrswA10Q6AIfC5x2a/KRQCoS1XlJ4sARIxEAzQWmyeh6gYhSxc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 21B6D2123F; Thu, 22 Feb 2024 12:07:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708603658; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WrOIT5p332Pzgo2LftAXJuJ8tA7l+h3Jv1GLtBKTGaA=; b=qL/0eVgWw/jw/2ooabYXz1x1qNh1CkkA+syXtpmcLw540CuNC7yWFcT5R0VSB5NWJih0UE dk+O6zbvDggbXqVXN8O+I38cGx2E3m/lnwAN6EzSSgXh0TixHeAuKCmXUozLJWMsOBTfzL q4FrptGkn4nxpU0RVvRUXhGGND0Lh10= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708603658; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WrOIT5p332Pzgo2LftAXJuJ8tA7l+h3Jv1GLtBKTGaA=; b=dwKyeicJZjQMMW+0YsHnTNnOMB1T4yUGFVMekQS/dGpZ3d0g3NbFgbquxZwTxAWjF06aPB YGDPk4Lrwk4TvNCg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708603658; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WrOIT5p332Pzgo2LftAXJuJ8tA7l+h3Jv1GLtBKTGaA=; b=qL/0eVgWw/jw/2ooabYXz1x1qNh1CkkA+syXtpmcLw540CuNC7yWFcT5R0VSB5NWJih0UE dk+O6zbvDggbXqVXN8O+I38cGx2E3m/lnwAN6EzSSgXh0TixHeAuKCmXUozLJWMsOBTfzL q4FrptGkn4nxpU0RVvRUXhGGND0Lh10= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708603658; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WrOIT5p332Pzgo2LftAXJuJ8tA7l+h3Jv1GLtBKTGaA=; b=dwKyeicJZjQMMW+0YsHnTNnOMB1T4yUGFVMekQS/dGpZ3d0g3NbFgbquxZwTxAWjF06aPB YGDPk4Lrwk4TvNCg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 06C93133DC; Thu, 22 Feb 2024 12:07:38 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id nnlPAAo512VJJgAAD6G6ig (envelope-from ); Thu, 22 Feb 2024 12:07:38 +0000 Message-ID: <549c2044-4ec2-4072-a554-6a66e7ddee1d@suse.de> Date: Thu, 22 Feb 2024 13:07:35 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] [gdb/tui] Factor out tui_noscroll_window et al Content-Language: en-US To: Simon Marchi , Tom Tromey Cc: gdb-patches@sourceware.org References: <20231112150601.25484-1-tdevries@suse.de> <87r0kttwba.fsf@tromey.com> <24af4ea8-5426-4ce4-b1c5-12858b38a952@simark.ca> From: Tom de Vries In-Reply-To: <24af4ea8-5426-4ce4-b1c5-12858b38a952@simark.ca> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: X-Spam-Score: -4.29 X-Spamd-Result: default: False [-4.29 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; XM_UA_NO_VERSION(0.01)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; NEURAL_HAM_LONG(-1.00)[-1.000]; BAYES_HAM(-3.00)[100.00%]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.995]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; MID_RHS_MATCH_FROM(0.00)[] X-Spam-Status: No, score=-12.3 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,T_SCC_BODY_TEXT_LINE 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: On 2/21/24 18:32, Simon Marchi wrote: > On 11/13/23 12:08, Tom Tromey wrote: >>>>>>> "Tom" == Tom de Vries writes: >> >> Tom> +/* A TUI window that doesn't scroll. */ >> Tom> + >> Tom> +struct tui_noscroll_window : public virtual tui_win_info { >> >> The "{" should be on the next line. >> >> Tom> +/* A TUI window that occupies a single line. */ >> Tom> + >> Tom> +struct tui_oneline_window : public virtual tui_win_info { >> >> Some of these only have a single use. That seems like overkill to me, >> unless we're introducing another use someday. >> >> Tom> +#define TUI_SRC_WIN \ >> Tom> + (dynamic_cast (tui_win_list[SRC_WIN])) >> Tom> +#define TUI_DISASM_WIN \ >> Tom> + (dynamic_cast (tui_win_list[DISASSEM_WIN])) >> >> I think these should use gdb::checked_static_cast. > > Actually, since the base is virtual, dynamic_cast is needed. Try > changing development to false in bfd/development.sh, you'll get: > > CXX tui/tui-layout.o > In file included from /home/smarchi/src/binutils-gdb/gdb/tui/tui-data.h:31, > from /home/smarchi/src/binutils-gdb/gdb/tui/tui-command.h:25, > from /home/smarchi/src/binutils-gdb/gdb/tui/tui-layout.c:31: > /home/smarchi/src/binutils-gdb/gdb/../gdbsupport/gdb-checked-static-cast.h: In instantiation of ‘T gdb::checked_static_cast(V*) [with T = tui_cmd_window*; V = tui_win_info]’: > /home/smarchi/src/binutils-gdb/gdb/tui/tui-layout.c:79:3: required from here > /home/smarchi/src/binutils-gdb/gdb/../gdbsupport/gdb-checked-static-cast.h:64:14: error: cannot convert from pointer to base class ‘tui_win_info’ to pointer to derived class ‘tui_cmd_window’ because the base is virtual > 64 | T result = static_cast (v); > | ^~~~~~~~~~~~~~~~~~ > > It might be a good idea to add a static_cast in the DEVELOPMENT branch > of checked_static_cast to catch this kind of mistake. I think it could > be written this way to be succinct (but untested): > > > T result = static_cast (v); > #ifdef DEVELOPMENT > gdb_assert (result == dynamic_cast (v)); > #endif > > return result; > > IOW, this patch: > Hi Simon, LGTM. Also I can confirm that the patch catches the problem show above (which was reported as PR31399). I'll write a fix for that PR, and test with your patch applied as well. Thanks, - Tom > diff --git a/gdbsupport/gdb-checked-static-cast.h b/gdbsupport/gdb-checked-static-cast.h > index b6ce8c8bb04..e935bb359f0 100644 > --- a/gdbsupport/gdb-checked-static-cast.h > +++ b/gdbsupport/gdb-checked-static-cast.h > @@ -54,14 +54,9 @@ checked_static_cast (V *v) > || std::is_base_of::value, > "types must be related"); > > -#ifdef DEVELOPMENT > - if (v == nullptr) > - return nullptr; > - > - T result = dynamic_cast (v); > - gdb_assert (result != nullptr); > -#else > T result = static_cast (v); > +#ifdef DEVELOPMENT > + gdb_assert (result == dynamic_cast (v)); > #endif > > return result; > > Simon