From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29172 invoked by alias); 16 Feb 2010 21:53:26 -0000 Received: (qmail 29161 invoked by uid 22791); 16 Feb 2010 21:53:25 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 16 Feb 2010 21:53:21 +0000 Received: (qmail 20614 invoked from network); 16 Feb 2010 21:53:20 -0000 Received: from unknown (HELO caradoc.them.org) (dan@127.0.0.2) by mail.codesourcery.com with ESMTPA; 16 Feb 2010 21:53:20 -0000 Date: Tue, 16 Feb 2010 21:53:00 -0000 From: Daniel Jacobowitz To: Chris Moller Cc: gdb-patches@sourceware.org Subject: Re: beta patch for PR 9065 Message-ID: <20100216215313.GA4858@caradoc.them.org> Mail-Followup-To: Chris Moller , gdb-patches@sourceware.org References: <4B7AE477.9060606@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4B7AE477.9060606@redhat.com> User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-02/txt/msg00403.txt.bz2 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 = sizeof()". 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