From: Tom Tromey <tom@tromey.com>
To: Basile Starynkevitch <basile@starynkevitch.net>
Cc: gdb@sourceware.org, team@refpersys.org
Subject: Re: GDB variants accepting plugins (to the debugger) ?
Date: Fri, 30 Jan 2026 13:12:10 -0700 [thread overview]
Message-ID: <87ikci97xh.fsf@tromey.com> (raw)
In-Reply-To: <06d90d0ef774cf4ffd69a675a9092afee18a3446.camel@starynkevitch.net> (Basile Starynkevitch's message of "Fri, 30 Jan 2026 14:13:51 +0100")
>>>>> "Basile" == Basile Starynkevitch <basile@starynkevitch.net> writes:
Basile> But coding manually a Python or Guile function for every
Basile> important C++ classes of a software is very time consuming
People often bring up the idea of using helper functions from the
inferior for pretty-printing. And maybe it can be done, kind of.
But normally I push back against this idea for a few reasons.
Internally this means making an inferior call in gdb. But, gdb will use
pretty-printers in all situations, including when unwinding the stack.
This might work but its somewhat problematic to modify the stack while
unwinding it.
A related thing is that infcalls are sometimes very surprising. For
instance unless you mess with scheduler-locking, they cause other
threads to run. So, e.g., you could easily hit a breakpoint when
printing a variable.
Finally, this approach doesn't work at all for core files.
A somewhat better idea is to have the compiler spit out some IR (wasm is
often suggested) for these pretty-printers (and accessor functions and
whatever else) and then have gdb run this. This would be great but
nobody has ever done the work... I did once consider doing this with a
gcc plugin and having it generate Python but time is kind of short.
Basile> I regret that GDB 17.1 has not evolved into something similar to
Basile> the old and unmaintained UPS open source debugger
Basile> https://ups.sourceforge.net/ which sadly is not working on
Basile> Linux/AMD-64 computers running a recent kernel 6.17 and and
Basile> using recent libc and libstdc++
I don't have much to suggest other than you can already do a lot with
Python in gdb. For instance I wrote a gdb GUI that runs in-process.
Most of the gdb Python code you'll find in the wild will be
pretty-printers; gdb has some of these for itself. libstdc++ has some
xmethods and sometimes you'll stumble across a frame filter; and there's
at least one unwinder out there.
There's some links here
https://sourceware.org/gdb/wiki/ExtensionsInPython
Tom
next prev parent reply other threads:[~2026-01-30 20:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-30 13:13 Basile Starynkevitch
2026-01-30 13:33 ` Eli Zaretskii via Gdb
2026-01-30 15:35 ` Simon Marchi via Gdb
2026-01-30 17:03 ` Basile Starynkevitch
2026-01-30 17:16 ` Simon Marchi via Gdb
2026-01-30 20:12 ` Tom Tromey [this message]
2026-01-31 2:36 ` Matt Rice via Gdb
2026-01-31 17:00 ` Tom Tromey
2026-02-02 13:49 ` Jan Vrany via Gdb
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=87ikci97xh.fsf@tromey.com \
--to=tom@tromey.com \
--cc=basile@starynkevitch.net \
--cc=gdb@sourceware.org \
--cc=team@refpersys.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