From: Paul Smith <psmith@gnu.org>
To: Paul Koning <paulkoning@comcast.net>
Cc: gdb@sourceware.org
Subject: Re: Types prefixed by "class" or "struct" string??
Date: Fri, 21 Feb 2020 18:16:00 -0000 [thread overview]
Message-ID: <846069b1bb0bffa7188666f75077df00fa77a930.camel@gnu.org> (raw)
In-Reply-To: <BDB5F1E4-3BEC-4850-AFEE-6DE6EFCE8733@comcast.net>
On Fri, 2020-02-21 at 09:55 -0500, Paul Koning wrote:
> > But, if I try to look up the type including the "class " it
> > definitely fails:
>
> Well, sure. "class" is not part of the name of the type.
Heh. Well, clearly :). I think I didn't make something clear in my
initial message: it's not *ME* that's providing the "class " prefix:
GDB is doing that itself. That's the problem: it's adding this prefix
to the names of types, then when it tries to look them up it fails.
However I've discovered the culprit, although I still can't understand
why I never saw this before / what could have changed.
Basically, if you evaluate a gdb.Type in a string context GDB adds the
"class" or "struct" prefix; I guess that's part of the __str__
representation for the gdb.Type class?
Example:
(gdb) python
> o = gdb.convenience_variable('o')
> print o['pending'].type
> ^D
class std::__cxx11::list<Object::Pending, std::allocator<Object::Pending> >
But if I use the .name attribute, then I don't get the prefix:
(gdb) python
> o = gdb.convenience_variable('o')
> print o['pending'].type.name
> ^D
std::__cxx11::list<Object::Pending, std::allocator<Object::Pending> >
Unfortunately the Python macros that come with GCC's STL use the string
conversion in the pretty-printer code; for example:
def find_type(orig, name):
typ = orig.strip_typedefs()
while True:
# Strip cv-qualifiers. PR 67440.
search = '%s::%s' % (typ.unqualified(), name)
If this used type.unqualified().name instead it would probably be OK.
But, this kind of thing is done EVERYWHERE in the GCC pretty-printers
so it can't possibly have always been this way or nothing would work!!
I simply don't understand how I could have not run into such a
fundamental issue before: as I said I've been using all these same
versions, built locally and checked into Git, for well over a year now.
Has GDB always provided this "class" / "struct" prefix in the __str__
representation of gdb.Type?
prev parent reply other threads:[~2020-02-21 18:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-21 14:48 Paul Smith
2020-02-21 14:55 ` Paul Koning
2020-02-21 18:16 ` Paul Smith [this message]
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=846069b1bb0bffa7188666f75077df00fa77a930.camel@gnu.org \
--to=psmith@gnu.org \
--cc=gdb@sourceware.org \
--cc=paulkoning@comcast.net \
/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