Re: [rfc] expose gdb values to python

Joel Brobecker
2008-10-01T05:48:22Z

(Sorry I am participating so late in the discussion, but I am still
recovering from my summer, and only recently managed to learn some Python)

> The underlying question is what type model Value presents. If a Value
> has a derived type, should we be able to access fields of the base
> class using v["f"]? Or should we need v["Base"]["f"]?

My initial reaction to this question is that the Value object
should follow the same semantics as the debugger. For instance,
if class Foo inherits from class Bar, then any component of class
Bar should be directly visible from class Foo. So if X is Value
of type class Foo, and class Bar has a component named "Baz",
then I should be able to access that component with X["Baz"].

Better yet, I would love for the object to have one attribute
for each component that I could simply access using X.baz.
But I suspect that there is no way we can implement that without
having to compute the value of each component, which would be
quite wastful the vast majority of the time. Sigh, is it not
possible to lazy-initialize attributes?

--
Joel