Re: [python] acessing struct elements

Tom Tromey
2008-08-17T20:16:22Z

>>>>> "Thiago" == Thiago Jung Bauermann <bauerman@br.ibm.com> writes:

Thiago> There's one unexpected consequence of this: to enable the
Thiago> syntax above, all gdb.Value objects need to implement the map
Thiago> methods, and Python considers empty maps to be False in
Thiago> contexts which expect a boolean. Because of this, the
Thiago> following will not generally work:

Thiago> val = frame.read_var_value (sym)
Thiago> if val:
Thiago> print "Variable value is: " + str (val)

I think read_var_value should throw an exception if the symbol is not
found. My reason is that this is an error condition -- the caller has
asked for a symbol that does not exist. (Actually, I was assuming
this is what we'd do, but I realize now that this was just an
assumption :)

This would bypass this particular problem here. I have a feeling
there might be other similar problems lurking, but I'm not sure what.

Tom