From: Simon Marchi <simark@simark.ca>
To: dark.ryu.550@gmail.com, gdb-patches@sourceware.org
Subject: Re: [PATCH 1/1] Add support for gdb.Type initialization from within the Python API
Date: Fri, 6 Jan 2023 15:00:46 -0500 [thread overview]
Message-ID: <88e10ffd-8e87-b2bf-e6b3-f4567fb50e17@simark.ca> (raw)
In-Reply-To: <5c5201d92161$5908e600$0b1ab200$@gmail.com>
Hi,
Unfortunately, I am unable to apply this patch as well, please send it
using git-send-email.
On 1/5/23 18:56, dark.ryu.550--- via Gdb-patches wrote:
> This patch adds support for creating types from within the Python API. It
> does
>
> so by exposing the `init_*_type` family of functions, defined in
> `gdbtypes.h` to
>
> Python and having them return `gdb.Type` objects connected to the newly
> minted
>
> types.
>
>
>
> These functions are accessible in the root of the gdb module and all require
>
> a reference to a `gdb.Objfile`. Types created from this API are exclusively
>
> objfile-owned.
It would maybe be nice to be able to create arch-owned types too. For
instance, you could create types just after firing up GDB, without even
having an objfile loaded. It's not necessary to implement it at the
same time, but does your approach leave us the option to do that at a
later time?
>
>
>
> This patch also adds an extra type - `gdb.FloatFormat` - to support creation
> of
>
> floating point types by letting users control the format from within Python.
> It
>
> is missing, however, a way to specify half formats and validation functions.
>
>
>
> It is important to note that types created using this interface are not
>
> automatically registered as a symbol, and so, types will become unreachable
>
> unless used to create a value that otherwise references it or saved in some
> way.
>
>
>
> The main drawback of using the `init_*_type` family over implementing type
>
> initialization by hand is that any type that's created gets immediately
>
> allocated on its owner objfile's obstack, regardless of what its real
>
> lifetime requirements are. The main implication of this is that types that
>
> become unreachable will leak their memory for the lifetime of the objfile.
>
> Keeping track of the initialization of the type by hand would require a
>
> deeper change to the existing type object infrastructure. A bit too
> ambitious
>
> for a first patch, I'd say.
>
>
>
> if it were to be done though, we would gain the ability to only keep in the
>
> obstack types that are known to be referenced in some other way - by
> allocating
>
> and copying the data to the obstack as other objects are created that
> reference
>
> it (eg. symbols).
I think how you did it is ok, it's better to keep things simple.
Simon
next prev parent reply other threads:[~2023-01-06 20:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-05 23:56 dark.ryu.550
2023-01-06 20:00 ` Simon Marchi [this message]
2023-01-11 0:58 ` [PATCH] Add support for creating new types from " Matheus Branco Borella
2023-06-27 3:52 ` [PING] " Matheus Branco Borella
2023-05-26 3:30 ` Matheus Branco Borella
2023-08-07 14:53 ` Andrew Burgess
2023-08-08 21:00 ` [PATCH v2] " Matheus Branco Borella
2024-01-13 1:37 ` [PATCH v3] " Matheus Branco Borella
2024-01-13 7:21 ` Eli Zaretskii
2024-01-16 4:55 ` Matheus Branco Borella
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=88e10ffd-8e87-b2bf-e6b3-f4567fb50e17@simark.ca \
--to=simark@simark.ca \
--cc=dark.ryu.550@gmail.com \
--cc=gdb-patches@sourceware.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).