mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-05-28 22:21:26 +08:00
2011-07-11 Phil Muldoon <pmuldoon@redhat.com>
* python/py-inferior.c (infpy_dealloc): New function. (inferior_to_inferior_object): Return a new object, or a new reference to the existing object. (find_thread_object): Cleanup references to inferior. (delete_thread_object): Ditto. * python/py-infthread.c (create_thread_object): Do not increment inferior reference count.
This commit is contained in:
@ -1,3 +1,13 @@
|
|||||||
|
2011-07-11 Phil Muldoon <pmuldoon@redhat.com>
|
||||||
|
|
||||||
|
* python/py-inferior.c (infpy_dealloc): New function.
|
||||||
|
(inferior_to_inferior_object): Return a new object, or a
|
||||||
|
new reference to the existing object.
|
||||||
|
(find_thread_object): Cleanup references to inferior.
|
||||||
|
(delete_thread_object): Ditto.
|
||||||
|
* python/py-infthread.c (create_thread_object): Do not increment
|
||||||
|
inferior reference count.
|
||||||
|
|
||||||
2011-07-08 Tom Tromey <tromey@redhat.com>
|
2011-07-08 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
* dwarf2loc.c (locexpr_regname): New function.
|
* dwarf2loc.c (locexpr_regname): New function.
|
||||||
|
@ -125,9 +125,10 @@ python_inferior_exit (struct inferior *inf)
|
|||||||
do_cleanups (cleanup);
|
do_cleanups (cleanup);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return a borrowed reference to the Python object of type Inferior
|
/* Return a reference to the Python object of type Inferior
|
||||||
representing INFERIOR. If the object has already been created,
|
representing INFERIOR. If the object has already been created,
|
||||||
return it, otherwise, create it. Return NULL on failure. */
|
return it and increment the reference count, otherwise, create it.
|
||||||
|
Return NULL on failure. */
|
||||||
PyObject *
|
PyObject *
|
||||||
inferior_to_inferior_object (struct inferior *inferior)
|
inferior_to_inferior_object (struct inferior *inferior)
|
||||||
{
|
{
|
||||||
@ -154,13 +155,14 @@ inferior_to_inferior_object (struct inferior *inferior)
|
|||||||
|
|
||||||
do_cleanups (cleanup);
|
do_cleanups (cleanup);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
Py_INCREF ((PyObject *)inf_obj);
|
||||||
|
|
||||||
return (PyObject *) inf_obj;
|
return (PyObject *) inf_obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Finds the Python Inferior object for the given PID. Returns a
|
/* Finds the Python Inferior object for the given PID. Returns a
|
||||||
borrowed reference, or NULL if PID does not match any inferior
|
reference, or NULL if PID does not match any inferior object. */
|
||||||
object. */
|
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
find_inferior_object (int pid)
|
find_inferior_object (int pid)
|
||||||
@ -180,6 +182,7 @@ find_thread_object (ptid_t ptid)
|
|||||||
int pid;
|
int pid;
|
||||||
struct threadlist_entry *thread;
|
struct threadlist_entry *thread;
|
||||||
PyObject *inf_obj;
|
PyObject *inf_obj;
|
||||||
|
thread_object *found = NULL;
|
||||||
|
|
||||||
pid = PIDGET (ptid);
|
pid = PIDGET (ptid);
|
||||||
if (pid == 0)
|
if (pid == 0)
|
||||||
@ -187,11 +190,21 @@ find_thread_object (ptid_t ptid)
|
|||||||
|
|
||||||
inf_obj = find_inferior_object (pid);
|
inf_obj = find_inferior_object (pid);
|
||||||
|
|
||||||
if (inf_obj)
|
if (! inf_obj)
|
||||||
for (thread = ((inferior_object *)inf_obj)->threads; thread;
|
return NULL;
|
||||||
thread = thread->next)
|
|
||||||
if (ptid_equal (thread->thread_obj->thread->ptid, ptid))
|
for (thread = ((inferior_object *)inf_obj)->threads; thread;
|
||||||
return thread->thread_obj;
|
thread = thread->next)
|
||||||
|
if (ptid_equal (thread->thread_obj->thread->ptid, ptid))
|
||||||
|
{
|
||||||
|
found = thread->thread_obj;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Py_DECREF (inf_obj);
|
||||||
|
|
||||||
|
if (found)
|
||||||
|
return found;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -245,7 +258,10 @@ delete_thread_object (struct thread_info *tp, int ignore)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
if (!*entry)
|
if (!*entry)
|
||||||
return;
|
{
|
||||||
|
Py_DECREF (inf_obj);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
cleanup = ensure_python_env (python_gdbarch, python_language);
|
cleanup = ensure_python_env (python_gdbarch, python_language);
|
||||||
|
|
||||||
@ -256,6 +272,7 @@ delete_thread_object (struct thread_info *tp, int ignore)
|
|||||||
inf_obj->nthreads--;
|
inf_obj->nthreads--;
|
||||||
|
|
||||||
Py_DECREF (tmp->thread_obj);
|
Py_DECREF (tmp->thread_obj);
|
||||||
|
Py_DECREF (inf_obj);
|
||||||
xfree (tmp);
|
xfree (tmp);
|
||||||
|
|
||||||
do_cleanups (cleanup);
|
do_cleanups (cleanup);
|
||||||
@ -321,8 +338,15 @@ build_inferior_list (struct inferior *inf, void *arg)
|
|||||||
{
|
{
|
||||||
PyObject *list = arg;
|
PyObject *list = arg;
|
||||||
PyObject *inferior = inferior_to_inferior_object (inf);
|
PyObject *inferior = inferior_to_inferior_object (inf);
|
||||||
|
int success = 0;
|
||||||
|
|
||||||
if (PyList_Append (list, inferior))
|
if (! inferior)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
success = PyList_Append (list, inferior);
|
||||||
|
Py_DECREF (inferior);
|
||||||
|
|
||||||
|
if (success)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -617,6 +641,17 @@ infpy_is_valid (PyObject *self, PyObject *args)
|
|||||||
Py_RETURN_TRUE;
|
Py_RETURN_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
infpy_dealloc (PyObject *obj)
|
||||||
|
{
|
||||||
|
inferior_object *inf_obj = (inferior_object *) obj;
|
||||||
|
struct inferior *inf = inf_obj->inferior;
|
||||||
|
|
||||||
|
if (! inf)
|
||||||
|
return;
|
||||||
|
|
||||||
|
set_inferior_data (inf, infpy_inf_data_key, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/* Clear the INFERIOR pointer in an Inferior object and clear the
|
/* Clear the INFERIOR pointer in an Inferior object and clear the
|
||||||
thread list. */
|
thread list. */
|
||||||
@ -714,7 +749,7 @@ static PyTypeObject inferior_object_type =
|
|||||||
"gdb.Inferior", /* tp_name */
|
"gdb.Inferior", /* tp_name */
|
||||||
sizeof (inferior_object), /* tp_basicsize */
|
sizeof (inferior_object), /* tp_basicsize */
|
||||||
0, /* tp_itemsize */
|
0, /* tp_itemsize */
|
||||||
0, /* tp_dealloc */
|
infpy_dealloc, /* tp_dealloc */
|
||||||
0, /* tp_print */
|
0, /* tp_print */
|
||||||
0, /* tp_getattr */
|
0, /* tp_getattr */
|
||||||
0, /* tp_setattr */
|
0, /* tp_setattr */
|
||||||
|
@ -49,7 +49,6 @@ create_thread_object (struct thread_info *tp)
|
|||||||
|
|
||||||
thread_obj->thread = tp;
|
thread_obj->thread = tp;
|
||||||
thread_obj->inf_obj = find_inferior_object (PIDGET (tp->ptid));
|
thread_obj->inf_obj = find_inferior_object (PIDGET (tp->ptid));
|
||||||
Py_INCREF (thread_obj->inf_obj);
|
|
||||||
|
|
||||||
return thread_obj;
|
return thread_obj;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user