From: John Baldwin <jhb@FreeBSD.org>
To: Simon Marchi <simon.marchi@efficios.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb: fix gdbarch_tdep ODR violation
Date: Fri, 12 Nov 2021 13:55:57 -0800 [thread overview]
Message-ID: <d0a9cb40-3998-5d08-c7a3-8d8ca8167eb0@FreeBSD.org> (raw)
In-Reply-To: <20211112204233.4108340-1-simon.marchi@efficios.com>
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 <arch>_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 <arch>_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
next prev parent reply other threads:[~2021-11-12 21:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-12 20:42 Simon Marchi via Gdb-patches
2021-11-12 21:55 ` John Baldwin [this message]
2021-11-15 10:45 ` Luis Machado via Gdb-patches
2021-11-15 16:29 ` Simon Marchi
2021-11-15 20:42 ` will schmidt via Gdb-patches
2021-11-15 20:43 ` Simon Marchi via Gdb-patches
2021-11-15 23:19 ` Luis Machado via Gdb-patches
2021-11-16 2:02 ` Simon Marchi via Gdb-patches
2021-11-15 16:47 ` Pedro Alves
2021-11-15 16:53 ` Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d0a9cb40-3998-5d08-c7a3-8d8ca8167eb0@FreeBSD.org \
--to=jhb@freebsd.org \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@efficios.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox