This is the mail archive of the
archer@sourceware.org
mailing list for the Archer project.
Re: Python convenience functions that return GDB values causesegfault
- From: Thiago Jung Bauermann <bauerman at br dot ibm dot com>
- To: Jim Blandy <jimb at red-bean dot com>
- Cc: archer at sourceware dot org
- Date: Wed, 04 Feb 2009 14:22:30 -0200
- Subject: Re: Python convenience functions that return GDB values causesegfault
- References: <8f2776cb0902031709g55787f3are0b3c18d743a5827@mail.gmail.com>
El mar, 03-02-2009 a las 17:09 -0800, Jim Blandy escribiÃ:
> else if (PyObject_TypeCheck (obj, &value_object_type))
> - value = ((value_object *) obj)->value;
> + {
> + value_object *value_obj = (value_object *) obj;
> + value = value_obj->value;
> + value_obj->owned_by_gdb = 1;
> + }
To properly "give the value back" to GDB, you'd have to reinsert it into
the all_values list, and remove it from the values_in_python list. But
then when the GDB frees the value, the Python gdb.Value object would be
pointing to garbage...
I think it's better to return a copy of the value.
--
[]'s
Thiago Jung Bauermann
IBM Linux Technology Center