Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: "Joel Borggrén-Franck" <joel.borggren.franck@gmail.com>
To: Phil Muldoon <pmuldoon@redhat.com>
Cc: gdb@sourceware.org
Subject: Re: Python API questions and use cases
Date: Thu, 16 Sep 2010 06:13:00 -0000	[thread overview]
Message-ID: <AANLkTikPqbiRUr=ky_RHvQv54kssdHgTTO=F0yYh+M_2@mail.gmail.com> (raw)
In-Reply-To: <4C9118CE.9020606@redhat.com>

On Wed, Sep 15, 2010 at 9:04 PM, Phil Muldoon <pmuldoon@redhat.com> wrote:
> On 09/15/2010 06:56 PM, Tom Tromey wrote:
>>>>>>> "Joel" == Joel Borggrén-Franck <joel.borggren.franck@gmail.com> 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?)
>

This is a global symbol, so that should not work. If you can get to
global symbols through a frame you have to devise a some way of
telling the programmer if she got the value for a frame-local symbol
with the same name or the global symbol.

IMHO it is better to just add a Symbol.getGlobalValue that returns Nil
or raises if used on a frame-local symbol.

Cheers
/Joel


  reply	other threads:[~2010-09-16  6:13 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-15 13:43 Joel Borggrén-Franck
2010-09-15 18:01 ` Tom Tromey
2010-09-15 19:04   ` Phil Muldoon
2010-09-16  6:13     ` Joel Borggrén-Franck [this message]
2010-09-16  7:33   ` Joel Borggrén-Franck
2010-09-16  9:30     ` Joachim Protze
2010-09-16  9:57       ` André Pönitz
2010-09-16  9:49     ` André Pönitz
2010-09-16 11:56       ` Joel Borggrén-Franck
2010-09-16 19:11         ` Tom Tromey
2010-09-17  7:35           ` Joel Borggrén-Franck
2010-09-21 18:02             ` Tom Tromey
2010-09-16 19:09     ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='AANLkTikPqbiRUr=ky_RHvQv54kssdHgTTO=F0yYh+M_2@mail.gmail.com' \
    --to=joel.borggren.franck@gmail.com \
    --cc=gdb@sourceware.org \
    --cc=pmuldoon@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox