This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Python API questions and use cases


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]