public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Matheus Branco Borella <dark.ryu.550@gmail.com>
To: gdb-patches@sourceware.org
Cc: eli@gnu.org
Subject: Re: [PATCH v4] Add support for creating new types from the Python API
Date: Tue, 16 Jan 2024 18:27:23 -0300	[thread overview]
Message-ID: <20240116212722.10251-1-dark.ryu.550@gmail.com> (raw)
In-Reply-To: <83v87taz0f.fsf@gnu.org>

> How can that work?  AFAIU, most architectures only allow pointers of
> certain sizes, some allow pointers of just one size.  E.g., what
> happens if I create a 16-bit pointer on a 64-bit target?

My intention is primarily to make it possible to construct such types,
assuming the given configuration is valid. In this case it would be the
consumer of the API who would be responsible for guaranteeing what they
are doing is valid.

Regardless, as far as I could gather, GDB doesn't really seem to care
if values whose types have TYPE_CODE_PTR have sizes that are valid in
the target architecture. `unsigned_pointer_to_address`, as well as all
the `*_pointer_to_address` functions I could find by grepping for uses
of `set_gdbarch_pointer_to_address` in the code are perfectly fine just
reading the data in the pointers as if they were type->length()-sized
integers. And mostly the same goes for their `*_address_to_pointer`
counterparts, except for large values being clipped (including extra
function pointer information). But I believe that behavior should be
fairly unsurprising if you're creating a pointer with the wrong size.

So, to answer your question, AFAICT it would just treat it as an
address stored in an (u)int16_t.

  reply	other threads:[~2024-01-16 22:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-16  4:54 Matheus Branco Borella
2024-01-16 12:45 ` Eli Zaretskii
2024-01-16 17:50   ` Matheus Branco Borella
2024-01-16 18:20   ` [PATCH v4] Add support for creating new types from the Python API Matheus Branco Borella
2024-01-16 18:56     ` Eli Zaretskii
2024-01-16 21:27       ` Matheus Branco Borella [this message]
2024-02-06 18:20 ` Tom Tromey
2024-02-21 18:11   ` 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=20240116212722.10251-1-dark.ryu.550@gmail.com \
    --to=dark.ryu.550@gmail.com \
    --cc=eli@gnu.org \
    --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).