From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17133 invoked by alias); 30 May 2012 21:23:54 -0000 Received: (qmail 17111 invoked by uid 22791); 30 May 2012 21:23:51 -0000 X-SWARE-Spam-Status: No, hits=-6.8 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,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; Wed, 30 May 2012 21:23:34 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q4ULNVXl025285 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 30 May 2012 17:23:31 -0400 Received: from valrhona.uglyboxes.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q4ULNTlp021994 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 30 May 2012 17:23:30 -0400 Message-ID: <4FC68FD0.4060809@redhat.com> Date: Wed, 30 May 2012 21:23:00 -0000 From: Keith Seitz User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120329 Thunderbird/11.0.1 MIME-Version: 1.0 To: Evan Driscoll CC: gdb@sourceware.org Subject: Re: Pythons scripting API question References: <4FC66293.5040908@cs.wisc.edu> In-Reply-To: <4FC66293.5040908@cs.wisc.edu> 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: 2012-05/txt/msg00144.txt.bz2 On 05/30/2012 11:10 AM, Evan Driscoll wrote: > I'd like to get a list of the local variables in a frame, or at least > the parameters. I'm looking through the documentation of the Python API, > and not seeing how to do it. Frames contain blocks, blocks contain variables. Blocks in python can be iterated, so: $ ./gdb -nx -q gdb -ex "break main" -ex "run" (gdb) python import gdb (gdb) python for n in gdb.selected_frame().block(): print n, argc argv args (gdb) python print n.type struct captured_main_args (gdb) python print n.name args (gdb) python print n.is_argument False (gdb) python print n.value(gdb.selected_frame()) {argc = 0, argv = 0x488f80 <_start>, use_windows = -8032, interpreter_p = 0x0} This will give you both parameters and locals. There are methods you can use to determine which is which (e.g., Symbol.is_argument). See the relevant sections in the Gdb Users Manual (23.2.2.16, 23.2.2.18). Keith