This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [rfa] expose gdb values to python, mark II
- From: Daniel Jacobowitz <drow at false dot org>
- To: Thiago Jung Bauermann <bauerman at br dot ibm dot com>
- Cc: gdb-patches at sources dot redhat dot com
- Date: Tue, 14 Oct 2008 08:34:40 -0400
- Subject: Re: [rfa] expose gdb values to python, mark II
- References: <gc8q9k$74e$2@ger.gmane.org>
On Sat, Oct 04, 2008 at 07:22:09PM -0300, Thiago Jung Bauermann wrote:
> +Inferior values that are simple scalars can be used directly in
> +Python expressions that are valid for the value's data type Here's
> +an example for an integer or floating-point value @code{some_val}:
Typo (missing period).
This only works for scalars (now including pointers), right? Do you
have to call overloaded operators explicitly?
> +/* Returns a value object which is the sum of this value with the given
> + integer argument. */
> +static PyObject *
> +valpy_binop (enum valpy_opcode opcode, PyObject *self, PyObject *other)
The comment is not accurate, this is more than sum.
> +{
> + long l;
> + double d;
> + struct value *res_val = NULL; /* Initialize to appease gcc warning. */
> + struct value *other_val;
> + value_object *self_value;
> + volatile struct gdb_exception except;
> +
> + /* If the gdb.Value object is the second operand, then it will be passed
> + to us as the OTHER argument, and SELF will be an entirely different
> + kind of object, altogether. Swap them to avoid surprises. */
> + if (!PyObject_TypeCheck (self, &value_object_type))
> + {
> + PyObject *tmp;
> +
> + tmp = self;
> + self = other;
> + other = tmp;
> + }
And since it's more than sum.... what about "1 - foo"?
Otherwise, OK.
--
Daniel Jacobowitz
CodeSourcery