From: Daniel Jacobowitz <dan@codesourcery.com>
To: Chris Moller <cmoller@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: beta patch for PR 9065
Date: Tue, 16 Feb 2010 21:53:00 -0000 [thread overview]
Message-ID: <20100216215313.GA4858@caradoc.them.org> (raw)
In-Reply-To: <4B7AE477.9060606@redhat.com>
On Tue, Feb 16, 2010 at 01:31:19PM -0500, Chris Moller wrote:
> [Question: Internally, this patch is based on "sizeof" which actually
> creates an int type that, in addition to just being printed, can be
> used for stuff like "set <var> = sizeof(<whatever>)". The gdb typeid
> doesn't even try to create an analogue to a type_info class, it just
> extracts the name from the appropriate type struct and creates a
> cstring type from it. Would it be good/essential for the
> implementation to instantiate a real type_info class? (That, I
> suspect, will be a lot more work...)]
What do folks use typeid for, in the wild? IMO, "ptype typeid(int)"
giving you a string would be very surprising.
It's been a while since I looked at this, but the typeinfo for a class
with RTTI should be available in the symbol table (_ZTI symbols). The
others might be available or not; we could look them up in the symbol
table, or allocate them dynamically.
We could synthesize a type_info object; the Itanium C++ ABI defines
the layout (section 2.9.5). But we might also have to synthesize its
name() method, as it is unlikely to be emitted out of line.
name() is supposed to return a mangled type name, too. I'm not sure
how able GDB is going to be to mangle type names; it's a very hard
problem w.r.t. templates.
The appliction or libstdc++ should have the typeinfos for anything
whose typeinfo was referenced...
> @@ -1897,6 +1923,8 @@
> {"struct", STRUCT, OP_NULL, 0},
> {"signed", SIGNED_KEYWORD, OP_NULL, 0},
> {"sizeof", SIZEOF, OP_NULL, 0},
> + {"typeid", TYPEID, OP_NULL, 0},
> + {"name", NAMELIT, OP_NULL, 0},
> {"double", DOUBLE_KEYWORD, OP_NULL, 0},
> {"false", FALSEKEYWORD, OP_NULL, 1},
> {"class", CLASS, OP_NULL, 1},
I bet adding "name" to this list will break any expression with "name"
in it, like "print name".
--
Daniel Jacobowitz
CodeSourcery
next prev parent reply other threads:[~2010-02-16 21:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-16 18:31 Chris Moller
2010-02-16 21:53 ` Daniel Jacobowitz [this message]
2010-02-16 22:02 ` Chris Moller
2010-02-16 22:27 ` Tom Tromey
2010-02-16 22:57 ` Daniel Jacobowitz
2010-02-16 22:25 ` Tom Tromey
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=20100216215313.GA4858@caradoc.them.org \
--to=dan@codesourcery.com \
--cc=cmoller@redhat.com \
--cc=gdb-patches@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