Change thread_to_thread_object to return a new reference
This changes thread_to_thread_object to return a new reference and fixes up all the callers. gdb/ChangeLog 2018-09-16 Tom Tromey <tom@tromey.com> * python/python-internal.h (thread_to_thread_object): Change return type. * python/py-inferior.c (thread_to_thread_object): Return a new reference. (infpy_thread_from_thread_handle): Update. * python/py-infthread.c (gdbpy_selected_thread): Update. * python/py-stopevent.c (create_stop_event_object): Update. * python/py-threadevent.c (py_get_event_thread): Return a new reference. (py_get_event_thread): Update. * python/py-event.h (py_get_event_thread): Change return type. * python/py-continueevent.c (create_continue_event_object): Update.
This commit is contained in:
parent
0a9db5ad8a
commit
db1337cc83
8 changed files with 49 additions and 46 deletions
|
@ -1,3 +1,19 @@
|
||||||
|
2018-09-16 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
|
* python/python-internal.h (thread_to_thread_object): Change
|
||||||
|
return type.
|
||||||
|
* python/py-inferior.c (thread_to_thread_object): Return a new
|
||||||
|
reference.
|
||||||
|
(infpy_thread_from_thread_handle): Update.
|
||||||
|
* python/py-infthread.c (gdbpy_selected_thread): Update.
|
||||||
|
* python/py-stopevent.c (create_stop_event_object): Update.
|
||||||
|
* python/py-threadevent.c (py_get_event_thread): Return a new
|
||||||
|
reference.
|
||||||
|
(py_get_event_thread): Update.
|
||||||
|
* python/py-event.h (py_get_event_thread): Change return type.
|
||||||
|
* python/py-continueevent.c (create_continue_event_object):
|
||||||
|
Update.
|
||||||
|
|
||||||
2018-09-16 Tom Tromey <tom@tromey.com>
|
2018-09-16 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
* python/py-progspace.c (pspy_get_objfiles): Update.
|
* python/py-progspace.c (pspy_get_objfiles): Update.
|
||||||
|
|
|
@ -32,12 +32,13 @@
|
||||||
static gdbpy_ref<>
|
static gdbpy_ref<>
|
||||||
create_continue_event_object (ptid_t ptid)
|
create_continue_event_object (ptid_t ptid)
|
||||||
{
|
{
|
||||||
PyObject *py_thr = py_get_event_thread (ptid);
|
gdbpy_ref<> py_thr = py_get_event_thread (ptid);
|
||||||
|
|
||||||
if (py_thr == nullptr)
|
if (py_thr == nullptr)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
return create_thread_event_object (&continue_event_object_type, py_thr);
|
return create_thread_event_object (&continue_event_object_type,
|
||||||
|
py_thr.get ());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Callback function which notifies observers when a continue event occurs.
|
/* Callback function which notifies observers when a continue event occurs.
|
||||||
|
|
|
@ -68,9 +68,8 @@ extern gdbpy_ref<> create_event_object (PyTypeObject *py_type);
|
||||||
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. In each case it returns a borrowed reference. */
|
Py_None otherwise. */
|
||||||
extern PyObject *py_get_event_thread (ptid_t ptid)
|
extern gdbpy_ref<> py_get_event_thread (ptid_t ptid);
|
||||||
CPYCHECKER_RETURNS_BORROWED_REF;
|
|
||||||
|
|
||||||
extern gdbpy_ref<> create_thread_event_object (PyTypeObject *py_type,
|
extern gdbpy_ref<> create_thread_event_object (PyTypeObject *py_type,
|
||||||
PyObject *thread);
|
PyObject *thread);
|
||||||
|
|
|
@ -306,7 +306,7 @@ find_inferior_object (int pid)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
thread_object *
|
gdbpy_ref<>
|
||||||
thread_to_thread_object (thread_info *thr)
|
thread_to_thread_object (thread_info *thr)
|
||||||
{
|
{
|
||||||
gdbpy_ref<inferior_object> inf_obj (inferior_to_inferior_object (thr->inf));
|
gdbpy_ref<inferior_object> inf_obj (inferior_to_inferior_object (thr->inf));
|
||||||
|
@ -317,7 +317,7 @@ thread_to_thread_object (thread_info *thr)
|
||||||
thread != NULL;
|
thread != NULL;
|
||||||
thread = thread->next)
|
thread = thread->next)
|
||||||
if (thread->thread_obj->thread == thr)
|
if (thread->thread_obj->thread == thr)
|
||||||
return thread->thread_obj;
|
return gdbpy_ref<>::new_reference ((PyObject *) thread->thread_obj);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -832,7 +832,7 @@ infpy_is_valid (PyObject *self, PyObject *args)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
infpy_thread_from_thread_handle (PyObject *self, PyObject *args, PyObject *kw)
|
infpy_thread_from_thread_handle (PyObject *self, PyObject *args, PyObject *kw)
|
||||||
{
|
{
|
||||||
PyObject *handle_obj, *result;
|
PyObject *handle_obj;
|
||||||
inferior_object *inf_obj = (inferior_object *) self;
|
inferior_object *inf_obj = (inferior_object *) self;
|
||||||
static const char *keywords[] = { "thread_handle", NULL };
|
static const char *keywords[] = { "thread_handle", NULL };
|
||||||
|
|
||||||
|
@ -841,8 +841,6 @@ infpy_thread_from_thread_handle (PyObject *self, PyObject *args, PyObject *kw)
|
||||||
if (! gdb_PyArg_ParseTupleAndKeywords (args, kw, "O", keywords, &handle_obj))
|
if (! gdb_PyArg_ParseTupleAndKeywords (args, kw, "O", keywords, &handle_obj))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
result = Py_None;
|
|
||||||
|
|
||||||
if (!gdbpy_is_value_object (handle_obj))
|
if (!gdbpy_is_value_object (handle_obj))
|
||||||
{
|
{
|
||||||
PyErr_SetString (PyExc_TypeError,
|
PyErr_SetString (PyExc_TypeError,
|
||||||
|
@ -850,29 +848,27 @@ infpy_thread_from_thread_handle (PyObject *self, PyObject *args, PyObject *kw)
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
gdbpy_ref<> result;
|
||||||
|
TRY
|
||||||
{
|
{
|
||||||
TRY
|
struct thread_info *thread_info;
|
||||||
{
|
struct value *val = value_object_to_value (handle_obj);
|
||||||
struct thread_info *thread_info;
|
|
||||||
struct value *val = value_object_to_value (handle_obj);
|
|
||||||
|
|
||||||
thread_info = find_thread_by_handle (val, inf_obj->inferior);
|
thread_info = find_thread_by_handle (val, inf_obj->inferior);
|
||||||
if (thread_info != NULL)
|
if (thread_info != NULL)
|
||||||
{
|
result = thread_to_thread_object (thread_info);
|
||||||
result = (PyObject *) thread_to_thread_object (thread_info);
|
|
||||||
if (result != NULL)
|
|
||||||
Py_INCREF (result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CATCH (except, RETURN_MASK_ALL)
|
|
||||||
{
|
|
||||||
GDB_PY_HANDLE_EXCEPTION (except);
|
|
||||||
}
|
|
||||||
END_CATCH
|
|
||||||
}
|
}
|
||||||
|
CATCH (except, RETURN_MASK_ALL)
|
||||||
|
{
|
||||||
|
GDB_PY_HANDLE_EXCEPTION (except);
|
||||||
|
}
|
||||||
|
END_CATCH
|
||||||
|
|
||||||
return result;
|
if (result == NULL)
|
||||||
|
result = gdbpy_ref<>::new_reference (Py_None);
|
||||||
|
|
||||||
|
return result.release ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Implement repr() for gdb.Inferior. */
|
/* Implement repr() for gdb.Inferior. */
|
||||||
|
|
|
@ -284,15 +284,7 @@ PyObject *
|
||||||
gdbpy_selected_thread (PyObject *self, PyObject *args)
|
gdbpy_selected_thread (PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
if (inferior_ptid != null_ptid)
|
if (inferior_ptid != null_ptid)
|
||||||
{
|
return thread_to_thread_object (inferior_thread ()).release ();
|
||||||
PyObject *thread_obj
|
|
||||||
= (PyObject *) thread_to_thread_object (inferior_thread ());
|
|
||||||
if (thread_obj != NULL)
|
|
||||||
{
|
|
||||||
Py_INCREF (thread_obj);
|
|
||||||
return thread_obj;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,8 @@
|
||||||
gdbpy_ref<>
|
gdbpy_ref<>
|
||||||
create_stop_event_object (PyTypeObject *py_type)
|
create_stop_event_object (PyTypeObject *py_type)
|
||||||
{
|
{
|
||||||
return create_thread_event_object (py_type,
|
gdbpy_ref<> thread = py_get_event_thread (inferior_ptid);
|
||||||
py_get_event_thread (inferior_ptid));
|
return create_thread_event_object (py_type, thread.get ());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Callback observers when a stop event occurs. This function will create a
|
/* Callback observers when a stop event occurs. This function will create a
|
||||||
|
|
|
@ -22,19 +22,19 @@
|
||||||
|
|
||||||
/* See py-event.h. */
|
/* See py-event.h. */
|
||||||
|
|
||||||
PyObject *
|
gdbpy_ref<>
|
||||||
py_get_event_thread (ptid_t ptid)
|
py_get_event_thread (ptid_t ptid)
|
||||||
{
|
{
|
||||||
PyObject *pythread = nullptr;
|
gdbpy_ref<> pythread;
|
||||||
|
|
||||||
if (non_stop)
|
if (non_stop)
|
||||||
{
|
{
|
||||||
thread_info *thread = find_thread_ptid (ptid);
|
thread_info *thread = find_thread_ptid (ptid);
|
||||||
if (thread != nullptr)
|
if (thread != nullptr)
|
||||||
pythread = (PyObject *) thread_to_thread_object (thread);
|
pythread = thread_to_thread_object (thread);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
pythread = Py_None;
|
pythread = gdbpy_ref<>::new_reference (Py_None);
|
||||||
|
|
||||||
if (pythread == nullptr)
|
if (pythread == nullptr)
|
||||||
{
|
{
|
||||||
|
|
|
@ -532,8 +532,7 @@ PyObject *gdbpy_lookup_objfile (PyObject *self, PyObject *args, PyObject *kw);
|
||||||
PyObject *gdbarch_to_arch_object (struct gdbarch *gdbarch);
|
PyObject *gdbarch_to_arch_object (struct gdbarch *gdbarch);
|
||||||
|
|
||||||
thread_object *create_thread_object (struct thread_info *tp);
|
thread_object *create_thread_object (struct thread_info *tp);
|
||||||
thread_object *thread_to_thread_object (thread_info *thr)
|
gdbpy_ref<> thread_to_thread_object (thread_info *thr);;
|
||||||
CPYCHECKER_RETURNS_BORROWED_REF;
|
|
||||||
inferior_object *inferior_to_inferior_object (inferior *inf);
|
inferior_object *inferior_to_inferior_object (inferior *inf);
|
||||||
|
|
||||||
const struct block *block_object_to_block (PyObject *obj);
|
const struct block *block_object_to_block (PyObject *obj);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue