From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28810 invoked by alias); 21 Feb 2012 19:54:43 -0000 Received: (qmail 28801 invoked by uid 22791); 21 Feb 2012 19:54:43 -0000 X-SWARE-Spam-Status: No, hits=-6.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_RG,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, 21 Feb 2012 19:54:08 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q1LJrxi6006683 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 21 Feb 2012 14:54:06 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q1LIEaXM007548; Tue, 21 Feb 2012 13:14:36 -0500 Received: from barimba (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 q1LIEZY0016153; Tue, 21 Feb 2012 13:14:35 -0500 From: Tom Tromey To: Cristian Zamfir Cc: gdb@sourceware.org Subject: Re: Python API iterate through the arguments of a frame References: <3EDCC9ED-AD12-42B4-854E-3404A8EBCF70@epfl.ch> Date: Tue, 21 Feb 2012 19:54:00 -0000 In-Reply-To: <3EDCC9ED-AD12-42B4-854E-3404A8EBCF70@epfl.ch> (Cristian Zamfir's message of "Tue, 21 Feb 2012 16:54:53 +0100") Message-ID: <87obsst5o4.fsf@fleche.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.93 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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: 2012-02/txt/msg00056.txt.bz2 >>>>> "Cristian" == Cristian Zamfir writes: Cristian> I would like to write a Python script that iterates through the Cristian> arguments of a frame. I was hoping I can retrieve these arguments from Cristian> a Frame object, but I did not find a way to do this, unless I know the Cristian> name of the variables. Similarly, I would like to iterate through all Cristian> the locals of the frame. Cristian> Is this possible with the current Python API? If not, can you please Cristian> point me to where I could add additional functions to the Python API? You can find the locals and arguments via Frame.block. I see that gdb.Block is under-documented in this area. Sorry about that, I will write a patch. Here's a quick example: (top-gdb) start [...] Temporary breakpoint 3, main (argc= During symbol reading, incomplete CFI data; unspecified registers (e.g., rax) at 0x488914. 1, argv=0x7fffffffe558) at ../../archer/gdb/gdb.c:26 (top-gdb) python >for sym in gdb.newest_frame().block(): > print sym >end argc argv args In order to find all the locals in scope, and the arguments, you may have to iterate upwards over blocks via Block.superblock. The block with a non-None 'function' attribute will hold the arguments. Tom