From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25340 invoked by alias); 15 Sep 2010 19:04:56 -0000 Received: (qmail 25330 invoked by uid 22791); 15 Sep 2010 19:04:55 -0000 X-SWARE-Spam-Status: No, hits=-5.5 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; Wed, 15 Sep 2010 19:04:51 +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.13.8/8.13.8) with ESMTP id o8FJ4mjm021332 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 15 Sep 2010 15:04:48 -0400 Received: from localhost.localdomain (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 o8FJ4kDo031738; Wed, 15 Sep 2010 15:04:47 -0400 Message-ID: <4C9118CE.9020606@redhat.com> Date: Wed, 15 Sep 2010 19:04:00 -0000 From: Phil Muldoon User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100430 Fedora/3.0.4-2.fc12 Lightning/1.0b2pre Thunderbird/3.0.4 MIME-Version: 1.0 To: Tom Tromey CC: =?UTF-8?B?Sm9lbCBCb3JnZ3LDqW4tRnJhbmNr?= , gdb@sourceware.org Subject: Re: Python API questions and use cases References: In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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-09/txt/msg00088.txt.bz2 On 09/15/2010 06:56 PM, Tom Tromey wrote: >>>>>> "Joel" == Joel Borggrén-Franck writes: > > Joel> 1) Getting the value of a global > Joel> foo myGlobalFoo; > Joel> in some C file, how do I access the value of myGlobalFoo from > Joel> python? > > Joel> The only working solution I have at the moment is to escape to > Joel> gdb-script with: > Joel> gdb.parse_and_eval("myGlobalFoo") > Joel> is this intended? > > This is simplest. > > Joel> I know I can iterate over symbols in the symbol table, but I > Joel> haven't found a way to go from symbol to value. > > Hmm, we don't seem to expose a way to do that. Sorry about that. > Could you file a bug report for this? If you have the frame, you can use .read_var and pass the symbol as an argument. You can read the value behind the symbol then (as we know what frame; can you divine it otherwise, just from the symbol?) Cheers, Phil