From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1754 invoked by alias); 11 Aug 2005 09:27:07 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 1694 invoked by uid 22791); 11 Aug 2005 09:26:57 -0000 Received: from mta08-winn.ispmail.ntl.com (HELO mta08-winn.ispmail.ntl.com) (81.103.221.48) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Thu, 11 Aug 2005 09:26:57 +0000 Received: from aamta12-winn.ispmail.ntl.com ([81.103.221.35]) by mta08-winn.ispmail.ntl.com with ESMTP id <20050811092651.OANA23002.mta08-winn.ispmail.ntl.com@aamta12-winn.ispmail.ntl.com>; Thu, 11 Aug 2005 10:26:51 +0100 Received: from jack.nin ([81.97.154.243]) by aamta12-winn.ispmail.ntl.com with ESMTP id <20050811092651.BKCO17166.aamta12-winn.ispmail.ntl.com@jack.nin>; Thu, 11 Aug 2005 10:26:51 +0100 Received: from [192.168.1.3] (helo=malory) by jack.nin with esmtp (Exim 3.36 #1 (Debian)) id 1E39Kq-0007uS-00; Thu, 11 Aug 2005 10:26:48 +0100 Subject: Re: Getting to the source for a given C++ object From: Alex Bennee Reply-To: kernel-hacker@bennee.com To: Jason Molenda Cc: gdb@sources.redhat.com In-Reply-To: <186AD8EB-8137-4F61-8715-7A4CF6E00E7A@apple.com> References: <1123694226.6601.12.camel@okra.transitives.com> <186AD8EB-8137-4F61-8715-7A4CF6E00E7A@apple.com> Content-Type: text/plain Date: Thu, 11 Aug 2005 09:27:00 -0000 Message-Id: <1123752517.15935.72.camel@malory> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-SW-Source: 2005-08/txt/msg00051.txt.bz2 On Wed, 2005-08-10 at 13:35 -0700, Jason Molenda wrote: > On Aug 10, 2005, at 10:17 AM, Alex Bennee wrote: > > > I'm currently trying to debug a C++ program that makes heavy use of > > templates and derived classes. Is there an easy way to get to the > > actual > > code for a given class pointer? > > > I'm not sure exactly what you're looking for. ptype can tell you > the class - is that what you want? e.g. > > (gdb) p beta > $1 = { = {_vptr$A = 0x30b0, a1 = 200}, b1 = 201, b2 = 202} > (gdb) ptype beta > type = class B : public A { > public: > int b1; > int b2; > > B(B const&); > B(B const&); > B(); > B(); > ~B(); > virtual ~B(); > virtual ~B(); > } Thats useful, but its the derived information I want. Basically how can I get from that to the code for the virtual function used by that particular object. The trouble is the class is specialised into a fair number of different subclasses via templates. What I would ideally like is to do something like "l beta.method" and be looking directly at the code for that objects method call so I can set up breakpoints and the like. -- Alex, homepage: http://www.bennee.com/~alex/ Actresses will happen in the best regulated families. -- Addison Mizner and Oliver Herford, "The Entirely New Cynic's Calendar", 1905