From: Paul Smith <psmith@gnu.org>
To: gdb@sourceware.org
Subject: Types prefixed by "class" or "struct" string??
Date: Fri, 21 Feb 2020 14:48:00 -0000 [thread overview]
Message-ID: <ff0ffe8750fdd20fa6fd20127d28d8aa60cd68ad.camel@gnu.org> (raw)
Something very odd is going on. I'm using GCC 8.1 and GDB 8.2.1 with
Python support (GNU/Linux on x86_64), and I've been using them for quite a
while (I've built them myself and put them into a Git repository, along
with binutils 2.33.1 and a sysroot).
I can't say for sure that this is different or has always happened but
certainly I just started noticing it recently and I can't think of anything
that's changed in my environment.
What's happening is that when the GDB Python interface retrieves a type as
a string the name of the type is prefixed by "class " (if it's a class) or
"struct " if it's a struct. So for example if I try to print a
std::list<Foo> variable, I'm getting these exceptions from GDB:
(gdb) p $o->pending
$28 = empty std::__cxx11::listTraceback (most recent call last):
File "/cc/python/libstdcxx/v6/printers.py", line 243, in children
nodetype = find_type(self.val.type, '_Node')
File "/cc/python/libstdcxx/v6/printers.py", line 99, in find_type
raise ValueError("Cannot find type %s::%s" % (str(orig), name))
ValueError: Cannot find type class std::__cxx11::list<Object::Pending, std::allocator<Object::Pending> >::_Node
Look carefully at the message and you'll see that the value of
self.val.type is not just the type, but the type prefixed by "class ".
If I try to look up a type without the "class " prefix it works fine:
(gdb) python
>t = gdb.lookup_type('std::__cxx11::list<Object::Pending, std::allocator<Object::Pending> >::_Node')
>print str(t)
>^D
std::__cxx11::list<Object::Pending, std::allocator<Object::Pending> >::_Node
But, if I try to look up the type including the "class " it definitely
fails:
(gdb) python
>t = gdb.lookup_type('class std::__cxx11::list<Object::Pending, std::allocator<Object::Pending> >::_Node')
>^D
Traceback (most recent call last):
File "<string>", line 1, in <module>
gdb.error: No type named class std::__cxx11::list<Object::Pending, std::allocator<Object::Pending> >::_Node.
Error while executing Python code.
Does anyone know what might be causing this or how to avoid it?
For my own python macros I can strip out the prefix before I look up types,
but obviously I can't do that for the stdcxx printer macros that come with
GCC. And I don't remember needing to do that before. I'm very confused...
next reply other threads:[~2020-02-21 14:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-21 14:48 Paul Smith [this message]
2020-02-21 14:55 ` Paul Koning
2020-02-21 18:16 ` Paul Smith
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=ff0ffe8750fdd20fa6fd20127d28d8aa60cd68ad.camel@gnu.org \
--to=psmith@gnu.org \
--cc=gdb@sourceware.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