Help using the GDB C++ STL pretty-printers / xmethods

Jonathan Wakely jwakely.gcc@gmail.com
Mon May 9 09:32:17 GMT 2022


On Sun, 8 May 2022 at 20:44, Paul Smith <paul@mad-scientist.net> wrote:
>
> On Sun, 2022-05-08 at 09:16 +0100, Jonathan Wakely wrote:
> > > gdb.set_convenience_variable('mgr', val['mgr'])
> > > init = gdb.parse_and_eval('$mgr->initialized')
> > >
> > > This will use the xmethod to evaluate the expression.
> >
> > And then:
> >
> > if init:
> >     return gdb.parse_and_eval('*$mgr')
>
> Unfortunately, this doesn't work :(.  I can't do it from the GDB
> command line or python (I have tried both with the same results).
> Something about convenience variables doesn't play well with xmethods
> (or maybe this xmethod implementation specifically?)

You're right, sorry. It doesn't work for me with a convenience variable.

But since what you want is something that works in arbitrary Python
code, not just within GDB, doesn't pybind11 already do everything you
want?
https://github.com/pybind/pybind11


More information about the Gcc-help mailing list