PR python/14387:
* python/py-bpevent.c (create_breakpoint_event_object): Update comment. * python/py-event.c (evpy_add_attribute): Update comment. * python/py-exitedevent.c (create_exited_event_object): Fix reference counting and error handling. * python/py-newobjfileevent.c (create_new_objfile_event_object): Fix reference counting. * python/py-signalevent.c (create_signal_event_object): Fix reference counting and error handling. * python/py-stopevent.c (emit_stop_event): Fix reference counting. * python/py-threadevent.c (get_event_thread): Return a borrowed reference. * python/py-type.c (convert_field): Fix reference counting.
This commit is contained in:
parent
a036ba48ef
commit
db6573d664
9 changed files with 63 additions and 19 deletions
|
@ -1,3 +1,21 @@
|
||||||
|
2012-08-15 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
|
PR python/14387:
|
||||||
|
* python/py-bpevent.c (create_breakpoint_event_object): Update
|
||||||
|
comment.
|
||||||
|
* python/py-event.c (evpy_add_attribute): Update comment.
|
||||||
|
* python/py-exitedevent.c (create_exited_event_object): Fix
|
||||||
|
reference counting and error handling.
|
||||||
|
* python/py-newobjfileevent.c (create_new_objfile_event_object):
|
||||||
|
Fix reference counting.
|
||||||
|
* python/py-signalevent.c (create_signal_event_object): Fix
|
||||||
|
reference counting and error handling.
|
||||||
|
* python/py-stopevent.c (emit_stop_event): Fix reference
|
||||||
|
counting.
|
||||||
|
* python/py-threadevent.c (get_event_thread): Return a
|
||||||
|
borrowed reference.
|
||||||
|
* python/py-type.c (convert_field): Fix reference counting.
|
||||||
|
|
||||||
2012-08-15 Tom Tromey <tromey@redhat.com>
|
2012-08-15 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
* dwarf2read.c (dwarf_decode_macro_bytes)
|
* dwarf2read.c (dwarf_decode_macro_bytes)
|
||||||
|
|
|
@ -21,7 +21,8 @@
|
||||||
|
|
||||||
static PyTypeObject breakpoint_event_object_type;
|
static PyTypeObject breakpoint_event_object_type;
|
||||||
|
|
||||||
/* Create and initialize a BreakpointEvent object. */
|
/* Create and initialize a BreakpointEvent object. This acquires new
|
||||||
|
references to BREAKPOINT_LIST and FIRST_BP. */
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
create_breakpoint_event_object (PyObject *breakpoint_list, PyObject *first_bp)
|
create_breakpoint_event_object (PyObject *breakpoint_list, PyObject *first_bp)
|
||||||
|
|
|
@ -48,7 +48,8 @@ create_event_object (PyTypeObject *py_type)
|
||||||
|
|
||||||
/* Add the attribute ATTR to the event object EVENT. In
|
/* Add the attribute ATTR to the event object EVENT. In
|
||||||
python this attribute will be accessible by the name NAME.
|
python this attribute will be accessible by the name NAME.
|
||||||
returns 0 if the operation succeeds and -1 otherwise. */
|
returns 0 if the operation succeeds and -1 otherwise. This
|
||||||
|
function acquires a new reference to ATTR. */
|
||||||
|
|
||||||
int
|
int
|
||||||
evpy_add_attribute (PyObject *event, char *name, PyObject *attr)
|
evpy_add_attribute (PyObject *event, char *name, PyObject *attr)
|
||||||
|
|
|
@ -25,28 +25,39 @@ static PyObject *
|
||||||
create_exited_event_object (const LONGEST *exit_code, struct inferior *inf)
|
create_exited_event_object (const LONGEST *exit_code, struct inferior *inf)
|
||||||
{
|
{
|
||||||
PyObject *exited_event;
|
PyObject *exited_event;
|
||||||
PyObject *inf_obj;
|
PyObject *inf_obj = NULL;
|
||||||
|
|
||||||
exited_event = create_event_object (&exited_event_object_type);
|
exited_event = create_event_object (&exited_event_object_type);
|
||||||
|
|
||||||
if (!exited_event)
|
if (!exited_event)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (exit_code
|
if (exit_code)
|
||||||
&& evpy_add_attribute (exited_event,
|
{
|
||||||
"exit_code",
|
PyObject *exit_code_obj = PyLong_FromLongLong (*exit_code);
|
||||||
PyLong_FromLongLong (*exit_code)) < 0)
|
int failed;
|
||||||
|
|
||||||
|
if (exit_code_obj == NULL)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
failed = evpy_add_attribute (exited_event, "exit_code",
|
||||||
|
exit_code_obj) < 0;
|
||||||
|
Py_DECREF (exit_code_obj);
|
||||||
|
if (failed)
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
inf_obj = inferior_to_inferior_object (inf);
|
inf_obj = inferior_to_inferior_object (inf);
|
||||||
if (!inf_obj || evpy_add_attribute (exited_event,
|
if (!inf_obj || evpy_add_attribute (exited_event,
|
||||||
"inferior",
|
"inferior",
|
||||||
inf_obj) < 0)
|
inf_obj) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
Py_DECREF (inf_obj);
|
||||||
|
|
||||||
return exited_event;
|
return exited_event;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
|
Py_XDECREF (inf_obj);
|
||||||
Py_XDECREF (exited_event);
|
Py_XDECREF (exited_event);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ static PyObject *
|
||||||
create_new_objfile_event_object (struct objfile *objfile)
|
create_new_objfile_event_object (struct objfile *objfile)
|
||||||
{
|
{
|
||||||
PyObject *objfile_event;
|
PyObject *objfile_event;
|
||||||
PyObject *py_objfile;
|
PyObject *py_objfile = NULL;
|
||||||
|
|
||||||
objfile_event = create_event_object (&new_objfile_event_object_type);
|
objfile_event = create_event_object (&new_objfile_event_object_type);
|
||||||
if (!objfile_event)
|
if (!objfile_event)
|
||||||
|
@ -36,10 +36,12 @@ create_new_objfile_event_object (struct objfile *objfile)
|
||||||
"new_objfile",
|
"new_objfile",
|
||||||
py_objfile) < 0)
|
py_objfile) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
Py_DECREF (py_objfile);
|
||||||
|
|
||||||
return objfile_event;
|
return objfile_event;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
|
Py_XDECREF (py_objfile);
|
||||||
Py_XDECREF (objfile_event);
|
Py_XDECREF (objfile_event);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ PyObject *
|
||||||
create_signal_event_object (enum gdb_signal stop_signal)
|
create_signal_event_object (enum gdb_signal stop_signal)
|
||||||
{
|
{
|
||||||
const char *signal_name;
|
const char *signal_name;
|
||||||
|
PyObject *signal_name_obj = NULL;
|
||||||
PyObject *signal_event_obj =
|
PyObject *signal_event_obj =
|
||||||
create_stop_event_object (&signal_event_object_type);
|
create_stop_event_object (&signal_event_object_type);
|
||||||
|
|
||||||
|
@ -33,14 +34,19 @@ create_signal_event_object (enum gdb_signal stop_signal)
|
||||||
|
|
||||||
signal_name = gdb_signal_to_name (stop_signal);
|
signal_name = gdb_signal_to_name (stop_signal);
|
||||||
|
|
||||||
|
signal_name_obj = PyString_FromString (signal_name);
|
||||||
|
if (signal_name_obj == NULL)
|
||||||
|
goto fail;
|
||||||
if (evpy_add_attribute (signal_event_obj,
|
if (evpy_add_attribute (signal_event_obj,
|
||||||
"stop_signal",
|
"stop_signal",
|
||||||
PyString_FromString (signal_name)) < 0)
|
signal_name_obj) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
Py_DECREF (signal_name_obj);
|
||||||
|
|
||||||
return signal_event_obj;
|
return signal_event_obj;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
|
Py_XDECREF (signal_name_obj);
|
||||||
Py_XDECREF (signal_event_obj);
|
Py_XDECREF (signal_event_obj);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,6 +81,7 @@ emit_stop_event (struct bpstats *bs, enum gdb_signal stop_signal)
|
||||||
stop_event_obj = create_breakpoint_event_object (list, first_bp);
|
stop_event_obj = create_breakpoint_event_object (list, first_bp);
|
||||||
if (!stop_event_obj)
|
if (!stop_event_obj)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
Py_DECREF (list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if the signal is "Signal 0" or "Trace/breakpoint trap". */
|
/* Check if the signal is "Signal 0" or "Trace/breakpoint trap". */
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
running in non-stop mode then the event is thread specific, otherwise
|
running in non-stop mode then the event is thread specific, otherwise
|
||||||
it is process wide.
|
it is process wide.
|
||||||
This function returns the currently stopped thread in non-stop mode and
|
This function returns the currently stopped thread in non-stop mode and
|
||||||
Py_None otherwise. */
|
Py_None otherwise. In each case it returns a borrowed reference. */
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
get_event_thread (void)
|
get_event_thread (void)
|
||||||
|
@ -39,8 +39,6 @@ get_event_thread (void)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Py_INCREF (thread);
|
|
||||||
|
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -186,6 +186,7 @@ convert_field (struct type *type, int field)
|
||||||
/* At least python-2.4 had the second parameter non-const. */
|
/* At least python-2.4 had the second parameter non-const. */
|
||||||
if (PyObject_SetAttrString (result, (char *) attrstring, arg) < 0)
|
if (PyObject_SetAttrString (result, (char *) attrstring, arg) < 0)
|
||||||
goto failarg;
|
goto failarg;
|
||||||
|
Py_DECREF (arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TYPE_FIELD_NAME (type, field))
|
if (TYPE_FIELD_NAME (type, field))
|
||||||
|
@ -199,11 +200,13 @@ convert_field (struct type *type, int field)
|
||||||
goto fail;
|
goto fail;
|
||||||
if (PyObject_SetAttrString (result, "name", arg) < 0)
|
if (PyObject_SetAttrString (result, "name", arg) < 0)
|
||||||
goto failarg;
|
goto failarg;
|
||||||
|
Py_DECREF (arg);
|
||||||
|
|
||||||
arg = TYPE_FIELD_ARTIFICIAL (type, field) ? Py_True : Py_False;
|
arg = TYPE_FIELD_ARTIFICIAL (type, field) ? Py_True : Py_False;
|
||||||
Py_INCREF (arg);
|
Py_INCREF (arg);
|
||||||
if (PyObject_SetAttrString (result, "artificial", arg) < 0)
|
if (PyObject_SetAttrString (result, "artificial", arg) < 0)
|
||||||
goto failarg;
|
goto failarg;
|
||||||
|
Py_DECREF (arg);
|
||||||
|
|
||||||
if (TYPE_CODE (type) == TYPE_CODE_CLASS)
|
if (TYPE_CODE (type) == TYPE_CODE_CLASS)
|
||||||
arg = field < TYPE_N_BASECLASSES (type) ? Py_True : Py_False;
|
arg = field < TYPE_N_BASECLASSES (type) ? Py_True : Py_False;
|
||||||
|
@ -212,12 +215,14 @@ convert_field (struct type *type, int field)
|
||||||
Py_INCREF (arg);
|
Py_INCREF (arg);
|
||||||
if (PyObject_SetAttrString (result, "is_base_class", arg) < 0)
|
if (PyObject_SetAttrString (result, "is_base_class", arg) < 0)
|
||||||
goto failarg;
|
goto failarg;
|
||||||
|
Py_DECREF (arg);
|
||||||
|
|
||||||
arg = PyLong_FromLong (TYPE_FIELD_BITSIZE (type, field));
|
arg = PyLong_FromLong (TYPE_FIELD_BITSIZE (type, field));
|
||||||
if (!arg)
|
if (!arg)
|
||||||
goto fail;
|
goto fail;
|
||||||
if (PyObject_SetAttrString (result, "bitsize", arg) < 0)
|
if (PyObject_SetAttrString (result, "bitsize", arg) < 0)
|
||||||
goto failarg;
|
goto failarg;
|
||||||
|
Py_DECREF (arg);
|
||||||
|
|
||||||
/* A field can have a NULL type in some situations. */
|
/* A field can have a NULL type in some situations. */
|
||||||
if (TYPE_FIELD_TYPE (type, field) == NULL)
|
if (TYPE_FIELD_TYPE (type, field) == NULL)
|
||||||
|
@ -231,6 +236,7 @@ convert_field (struct type *type, int field)
|
||||||
goto fail;
|
goto fail;
|
||||||
if (PyObject_SetAttrString (result, "type", arg) < 0)
|
if (PyObject_SetAttrString (result, "type", arg) < 0)
|
||||||
goto failarg;
|
goto failarg;
|
||||||
|
Py_DECREF (arg);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue