This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: Python: fetch value when building gdb.Value object
- From: Tom Tromey <tromey at redhat dot com>
- To: Paul Koning <paulkoning at comcast dot net>
- Cc: gdb-patches at sourceware dot org
- Date: Tue, 04 Oct 2011 09:44:55 -0600
- Subject: Re: Python: fetch value when building gdb.Value object
- References: <36B29E9D-F2B3-446F-AF8A-97254A3AAEE2@comcast.net>
>>>>> "Paul" == Paul Koning <paulkoning@comcast.net> writes:
Paul> GDB sometimes lazily evaluates operations on values, and
Paul> py-value.c wasn't taking that into account. The result was that
Paul> assigning a Value object to a Python variable could assign a lazy
Paul> value, so that any errors in accessing the data would occur at a
Paul> later time, and sometimes would not be handled right. (For
Paul> example, the "nonzero" operation would fail without a Python
Paul> traceback.) The attached patch cures this by fetching any lazy
Paul> values when the gdb.Value object is built, and adds a test in the
Paul> testcases to verify this.
Paul> Ok to submit?
I am not convinced that this is the right approach.
I think it would probably be better to expose the laziness to the Python
programmer -- via a new attribute and a new method to un-lazy the
object.
The reason is that eager fetching can be very expensive. E.g., you may
construct an intermediate value that is a very large array, but intend
only to reference a few elements. This can be done efficiently by gdb,
but eager fetching will defeat that.
Tom