This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [python] acessing struct elements
- From: Tom Tromey <tromey at redhat dot com>
- To: Thiago Jung Bauermann <bauerman at br dot ibm dot com>
- Cc: gdb-patches at sources dot redhat dot com
- Date: Sun, 17 Aug 2008 14:15:48 -0600
- Subject: Re: [python] acessing struct elements
- References: <20080429155212.444237503@br.ibm.com> <20080429155304.466637516@br.ibm.com> <20080528212451.GB2969@caradoc.them.org> <m3k5h78j64.fsf@fleche.redhat.com> <1215410598.1795.58.camel@localhost.localdomain> <g7tvla$lck$2@ger.gmane.org>
- Reply-to: tromey at redhat dot com
>>>>> "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