This is the mail archive of the gdb-prs@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]

[Bug python/12027] New: Can't get to value from a global symbol using Pyhton API


Currently there is no way of getting the Value of a global symbol using the 
Python API.

There is Frame.read_var but that implies a local value.

I think there should be two api calls:

gdb.get_global_value(sym) where sym is a string or a Symbol. This should return 
the global value for sym (like Frame.read_var).

also

Symbol.get_global_value(self) which returns the global value or Nil (or raises 
if that is the Python way) if 'self' is not a global symbol.

Thanks
/Joel

For reference, an answer I got from Tom Tromey on GDB maillist:

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?

-- 
           Summary: Can't get to value from a global symbol using Pyhton API
           Product: gdb
           Version: 7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: python
        AssignedTo: unassigned at sourceware dot org
        ReportedBy: joel dot borggren dot franck at gmail dot com
                CC: gdb-prs at sourceware dot org


http://sourceware.org/bugzilla/show_bug.cgi?id=12027

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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