From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10461 invoked by alias); 7 Sep 2010 22:16:56 -0000 Received: (qmail 10451 invoked by uid 22791); 7 Sep 2010 22:16:55 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 07 Sep 2010 22:16:51 +0000 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o87MGm4O013382 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 7 Sep 2010 18:16:48 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o87MGmSw027454; Tue, 7 Sep 2010 18:16:48 -0400 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o87MGlJN005387; Tue, 7 Sep 2010 18:16:47 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 8C9523792BD; Tue, 7 Sep 2010 16:16:46 -0600 (MDT) From: Tom Tromey To: "Kenneth Rose" Cc: gdb@sourceware.org Subject: Re: Cast to result of whatis expression References: <784f56871ebbe612785c8be91771a9a5.squirrel@webmail.kenrose.org> Date: Tue, 07 Sep 2010 22:16:00 -0000 In-Reply-To: <784f56871ebbe612785c8be91771a9a5.squirrel@webmail.kenrose.org> (Kenneth Rose's message of "Tue, 7 Sep 2010 18:03:41 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2010-09/txt/msg00052.txt.bz2 >>>>> "Kenneth" == Kenneth Rose writes: Kenneth> I'm writing something similar to gdb-stl-views for some custom Kenneth> container classes that we have. I think that these days it is better to use the Python pretty-printing infrastructure instead. It has a number of advantages -- it works no matter how the object is printed (in a stack trace, embedded in some other structure), and it works with MI. Kenneth> I need to explicitly cast foo.m_x to the appropriate type, but Kenneth> I'm at a loss as to how to get that type from gdb. "whatis Kenneth> foo" gives me back "Container". Is there anyway of Kenneth> extracting the "int" part of that result and using that as the Kenneth> type to cast to? You can do this in Python :-) You could probably do it (with some difficulty) using a combination of logging, "shell", and "source". Kenneth> I'm using the stock GDB that ships with Mac OS X 10.6 (GNU gdb Kenneth> 6.3.50-20050815 (Apple version gdb-1461). I know... it's old. Ah, Apple's fork. Unfortunately it is Python-free. You could try GDB 7.2. It has some known bugs on Mac OS, but I have also heard reports of it work. Tom