Re: GDB variants accepting plugins (to the debugger) ?

Tom Tromey <[email protected]> Fri, 30 Jan 2026 13:12:10 -0700
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
>>>>> "Basile" == Basile Starynkevitch <[email protected]> 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