From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32553 invoked by alias); 24 Mar 2010 15:54:40 -0000 Received: (qmail 32543 invoked by uid 22791); 24 Mar 2010 15:54:38 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from eu1sys200aog109.obsmtp.com (HELO eu1sys200aog109.obsmtp.com) (207.126.144.127) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 24 Mar 2010 15:54:31 +0000 Received: from source ([167.4.1.35]) (using TLSv1) by eu1sys200aob109.postini.com ([207.126.147.11]) with SMTP ID DSNKS6o1siC7+xU3RlcANsgWRqrAiHbVJe/9@postini.com; Wed, 24 Mar 2010 15:54:30 UTC Received: from zeta.dmz-us.st.com (ns4.st.com [167.4.80.115]) by beta.dmz-us.st.com (STMicroelectronics) with ESMTP id DA83B78; Wed, 24 Mar 2010 15:51:32 +0000 (GMT) Received: from mail2.crn.st.com (mail2.crn.st.com [167.4.2.66]) by zeta.dmz-us.st.com (STMicroelectronics) with ESMTP id 6932D176; Wed, 24 Mar 2010 15:54:23 +0000 (GMT) Received: from [167.4.249.181] (ottl131.ott.st.com [167.4.249.181]) by mail2.crn.st.com (MOS 3.8.7a) with ESMTP id AHW71736 (AUTH "michel metzger"); Wed, 24 Mar 2010 10:54:22 -0500 (CDT) Message-ID: <4BAA35AD.1090809@st.com> Date: Wed, 24 Mar 2010 15:54:00 -0000 From: Michel METZGER User-Agent: Thunderbird 2.0.0.24 (X11/20100228) MIME-Version: 1.0 To: Jeroen Dobbelaere Cc: gdb@sourceware.org Subject: Re: gdb python and 'complete' References: <325e93671003240824t3e940773ned358335b9fe1f40@mail.gmail.com> In-Reply-To: <325e93671003240824t3e940773ned358335b9fe1f40@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes 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-03/txt/msg00194.txt.bz2 Hi, You could used the lookup_type method. Something like: type = gdb.lookup_type("MyClass") and then iterate over the type.field() collection. Take a look at section 23.2.2.5 of the GDB doc to see what is available in the Field object. Regards, Michel Metzger. Jeroen Dobbelaere wrote: > Hi, > > I am trying to create some helper commands using python with gdb-7.1. > > One of the things I want to do, is to retrieve the members of a c++ > class, do some filtering and > present the result in a nice way. > > I tried doing this, by delegating part of the request to the > 'complete' command, like in : > > class ShowNiceRepresentation(gdb.Command): > ... > > def retrieveFunctionSummary(self): > member_list=gdb.execute("complete b 'MyClass::").split("\n") > .... > > Now, the 'complete' command is indeed retrieving all the member > functions, but it will output them in the terminal in stead of feeding > it back to 'member_list'. > > Is there a way to redirect the output, so that the python program can > investigate it ? > Or is there a more appropriate way to access the members of a c++ > class form within python ? > > Greetings, > > Jeroen Dobbelaere >