public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: Simon Farre <simon.farre.cx@gmail.com>
Cc: Tom Tromey <tromey@adacore.com>,  gdb-patches@sourceware.org
Subject: Re: [PATCH v1] gdb/DAP Introduce new methods to to Pretty Printers
Date: Wed, 19 Jul 2023 08:41:37 -0600	[thread overview]
Message-ID: <87351km09q.fsf@tromey.com> (raw)
In-Reply-To: <02d2c008-224a-821e-80d4-6f2f9a81e532@gmail.com> (Simon Farre's message of "Mon, 17 Jul 2023 22:52:15 +0200")

Simon> We could go the c++ standard library route here and define silly
Simon> (guard) names for everything we do, going forward.

gdb didn't reserve those, either.

Probably we should just add a second registration approach, one that
allows for future upgrades to the API.  It's just more work.

For DAP we could instead go the other route, and change the fallback
printers to use a fuller API, and then use a shim for existing printers.

>> These are exposed to Python as struct types, but we'd like to present
>> them as array types over DAP -- which is what is done for the CLI (via
>> special cases in the printing code) and also for MI (via varobj, though
>> I haven't actually implemented this for Rust yet).

Simon> I don't understand this part, I wrote a the documentation example,
Simon> that behaves like an dynamic array,
Simon> where pretty printer makes use of it's intimate knowledge of the
Simon> length, because I specifically had languages
Simon> like Rust in mind (or any other type of dynamic data).

Simon> Or do you mean that it should automatically understand when
Simon> it's a built in type, in the language? That would be nice. But would
Simon> that not introduce scope issues, like at what point do we stop?

gdb already does this.  I think the decisions are made per language, but
the general rule is that anything that can be created by the compiler is
normally supported by gdb, but anything in a library is expected to be
described by DWARF.

In Rust this mostly amounts to handling slices, but Ada has more
constructs that need special handling.

Simon> Wouldn't we have to 1st class-implement every language that has a
Simon> novel idea of representing (its own) standard data types? Or are for
Simon> instance
Simon> Rust slices represented specifically as a special type in DWARF that
Simon> we can recognize?

Normally the problem cases here are ones where there is a difference
between their representation in DWARF (e.g., a Rust slice or an Ada
unconstrained array are really struct types) and their meaning in the
language (these are both array-like constructs).

It's important that gdb have access to both of these things.  For
example, for a while GNAT could emit these kinds of arrays using
complicated location expressions -- but that makes it impossible to
create a new instance, because "undoing" the expressions is hard.

Simon> Either way, having a "smart pretty printer" sounds good, for the use
Simon> cases you've described, Ada strings,
Simon> Rust slices, etc - but my biggest question is how would we extend that
Simon> to arbitrary client code?

My thinking for the route forward is:

1. Add a new pretty-printer API that is clearly extensible and change
   the core to use it.  Old pretty-printers can be wrapped in shims.

2. Add support for these array-like objects to gdb.Value or maybe
   gdb.Type.  The idea here is to let Python be able to access the same
   things that gdb already knows.

Tom

  reply	other threads:[~2023-07-19 14:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-25  9:21 Simon Farre
2023-06-25 10:22 ` Eli Zaretskii
2023-07-13 20:38 ` Tom Tromey
2023-07-17 20:52   ` Simon Farre
2023-07-19 14:41     ` Tom Tromey [this message]
2023-07-17 21:53   ` Matt Rice
2023-07-18 18:52     ` Tom Tromey
2023-07-20  9:47       ` Simon Farre
2023-07-21  0:27         ` Matt Rice

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=87351km09q.fsf@tromey.com \
    --to=tromey@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.farre.cx@gmail.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).