This is the mail archive of the gdb-patches@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] acessing struct elements


>>>>> "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


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