From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id TrkpFAXjjmEXcwAAWB0awg (envelope-from ) for ; Fri, 12 Nov 2021 16:56:21 -0500 Received: by simark.ca (Postfix, from userid 112) id 41DEC1F0C1; Fri, 12 Nov 2021 16:56:21 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, NICE_REPLY_A 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 A30FC1E940 for ; Fri, 12 Nov 2021 16:56:20 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 93AA5385841B for ; Fri, 12 Nov 2021 21:56:19 +0000 (GMT) Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2610:1c1:1:606c::19:2]) by sourceware.org (Postfix) with ESMTPS id AEA7D385840F for ; Fri, 12 Nov 2021 21:56:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AEA7D385840F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [96.47.72.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits)) (Client CN "mx1.freebsd.org", Issuer "R3" (verified OK)) by mx2.freebsd.org (Postfix) with ESMTPS id DC6A79AB94; Fri, 12 Nov 2021 21:55:58 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HrXTV56RRz3Kjf; Fri, 12 Nov 2021 21:55:58 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from John-Baldwins-MacBook-Pro.local (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 4593424C44; Fri, 12 Nov 2021 21:55:58 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Subject: Re: [PATCH] gdb: fix gdbarch_tdep ODR violation To: Simon Marchi , gdb-patches@sourceware.org References: <20211112204233.4108340-1-simon.marchi@efficios.com> From: John Baldwin Message-ID: Date: Fri, 12 Nov 2021 13:55:57 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <20211112204233.4108340-1-simon.marchi@efficios.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On 11/12/21 12:42 PM, Simon Marchi via Gdb-patches wrote: > I would like to be able to use non-trivial types in gdbarch_tdep types. > This is not possible at the moment (in theory), because of the one > definition rule. > > To allow it, rename all gdbarch_tdep types to _gdbarch_tdep, and > make them inherit from a gdbarch_tdep base class. The inheritance is > necessary to be able to pass pointers to all these _gdbarch_tdep > objects to gdbarch_alloc, which takes a pointer to gdbarch_tdep. > > These objects are never deleted through a base class pointer, so I > didn't include a virtual destructor. In the future, if gdbarch objects > deletable, I could imagine that the gdbarch_tdep objects could become > owned by the gdbarch objects, and then it would become useful to have a > virtual destructor (so that the gdbarch object can delete the owned > gdbarch_tdep object). But that's not necessary right now. > > It turns out that RISC-V already has a gdbarch_tdep that is > non-default-constructible, so that provides a good motivation for this > change. > > Most changes are fairly straightforward, mostly needing to add some > casts all over the place. There is however the xtensa architecture, > doing its own little weird thing to define its gdbarch_tdep. I did my > best to adapt it, but I can't test those changes. I haven't reviewed in detail, but I'm a big fan of this change. If nothign else it makes it easier to debug gdb itself since 'p (gdbarch_tdep *)foo' will no longer be ambiguous. -- John Baldwin