From: Paul Smith <paul@mad-scientist.net>
To: Jonathan Wakely <jwakely.gcc@gmail.com>
Cc: gcc-help <gcc-help@gcc.gnu.org>
Subject: Re: Help using the GDB C++ STL pretty-printers / xmethods
Date: Sun, 08 May 2022 10:09:56 -0400 [thread overview]
Message-ID: <798b5f59f29de856858d0db2104ff21f626e42a0.camel@mad-scientist.net> (raw)
In-Reply-To: <CAH6eHdRvg8FrW9ZSQ9ytd16-VbjDtuzSj8v6gokn59icjp33Lw@mail.gmail.com>
On Sun, 2022-05-08 at 09:16 +0100, Jonathan Wakely wrote:
> > > xmethods don't help me (IIUC) because I'm in the middle of some
> > > Python function and the value I want to retrieve is in a Python
> > > variable, not in a GDB variable, so I can't easily access it with
> > > parse_and_eval().
> >
> > 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')
Yes... this is why I qualified my statement with "easily" :).
Also if I'm doing this as I search through a 700,000 element container,
which is already not super-speedy, the performance is likely not going
to be great.
I imagine the cleanest solution is to have a Python API for STL that
works with and returns gdb.Values, then have the pretty-printers call
that API and format the result. Then others can use that API as well.
I get that the current suite of Python functions are geared
specifically towards using STL objects directly from the GDB UI: both
pretty-printing and accessing them. As someone who's writing my own
Python functions for a complex C++ program, however, an API as above
would be more helpful; we have lots of methods that grovel through
complex structures looking for specific elements, etc.
And, I understand the answer "patches welcome" :). I'm just putting
this out there for people to consider.
next prev parent reply other threads:[~2022-05-08 14:09 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-07 1:23 Paul Smith
2022-05-07 11:19 ` Hannes Domani
2022-05-07 15:07 ` Paul Smith
2022-05-07 15:35 ` Jonathan Wakely
2022-05-07 19:07 ` Paul Smith
2022-05-07 19:51 ` Jonathan Wakely
2022-05-07 23:08 ` Paul Smith
2022-05-08 8:13 ` Jonathan Wakely
2022-05-08 8:16 ` Jonathan Wakely
2022-05-08 14:09 ` Paul Smith [this message]
2022-05-08 14:36 ` Jonathan Wakely
2022-05-08 19:44 ` Paul Smith
2022-05-08 20:26 ` Paul Smith
2022-05-09 10:47 ` Hannes Domani
2022-05-09 10:52 ` Hannes Domani
2022-05-09 9:32 ` Jonathan Wakely
2022-05-09 11:23 ` Jonathan Wakely
2022-05-09 14:05 ` Paul Smith
2022-05-09 14:40 ` Paul Smith
2022-05-07 15:44 ` Hannes Domani
2022-05-07 15:25 ` Jonathan Wakely
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=798b5f59f29de856858d0db2104ff21f626e42a0.camel@mad-scientist.net \
--to=paul@mad-scientist.net \
--cc=gcc-help@gcc.gnu.org \
--cc=jwakely.gcc@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).