struct threadlist_entry *next;
};
-typedef struct
+struct inferior_object
{
PyObject_HEAD
/* Number of threads in the list. */
int nthreads;
-} inferior_object;
+};
extern PyTypeObject inferior_object_type
CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF ("inferior_object");
representing INFERIOR. If the object has already been created,
return it and increment the reference count, otherwise, create it.
Return NULL on failure. */
-PyObject *
+
+inferior_object *
inferior_to_inferior_object (struct inferior *inferior)
{
inferior_object *inf_obj;
/* We are returning a new reference. */
Py_INCREF ((PyObject *)inf_obj);
- return (PyObject *) inf_obj;
+ return inf_obj;
}
/* Called when a new inferior is created. Notifies any Python event
if (evregpy_no_listeners_p (gdb_py_events.new_inferior))
return;
- gdbpy_ref<> inf_obj (inferior_to_inferior_object (inf));
+ gdbpy_ref<inferior_object> inf_obj (inferior_to_inferior_object (inf));
if (inf_obj == NULL)
{
gdbpy_print_stack ();
gdbpy_ref<> event (create_event_object (&new_inferior_event_object_type));
if (event == NULL
- || evpy_add_attribute (event.get (), "inferior", inf_obj.get ()) < 0
+ || evpy_add_attribute (event.get (), "inferior",
+ (PyObject *) inf_obj.get ()) < 0
|| evpy_emit_event (event.get (), gdb_py_events.new_inferior) < 0)
gdbpy_print_stack ();
}
if (evregpy_no_listeners_p (gdb_py_events.inferior_deleted))
return;
- gdbpy_ref<> inf_obj (inferior_to_inferior_object (inf));
+ gdbpy_ref<inferior_object> inf_obj (inferior_to_inferior_object (inf));
if (inf_obj == NULL)
{
gdbpy_print_stack ();
gdbpy_ref<> event (create_event_object (&inferior_deleted_event_object_type));
if (event == NULL
- || evpy_add_attribute (event.get (), "inferior", inf_obj.get ()) < 0
+ || evpy_add_attribute (event.get (), "inferior",
+ (PyObject *) inf_obj.get ()) < 0
|| evpy_emit_event (event.get (), gdb_py_events.inferior_deleted) < 0)
gdbpy_print_stack ();
}
struct inferior *inf = find_inferior_pid (pid);
if (inf)
- return inferior_to_inferior_object (inf);
+ return (PyObject *) inferior_to_inferior_object (inf);
return NULL;
}
thread_object *
-find_thread_object (ptid_t ptid)
+thread_to_thread_object (thread_info *thr)
{
- int pid;
- struct threadlist_entry *thread;
-
- pid = ptid_get_pid (ptid);
- if (pid == 0)
- return NULL;
-
- gdbpy_ref<> inf_obj (find_inferior_object (pid));
+ gdbpy_ref<inferior_object> inf_obj (inferior_to_inferior_object (thr->inf));
if (inf_obj == NULL)
return NULL;
- for (thread = ((inferior_object *)(inf_obj.get ()))->threads; thread;
+ for (threadlist_entry *thread = inf_obj->threads;
+ thread != NULL;
thread = thread->next)
- if (ptid_equal (thread->thread_obj->thread->ptid, ptid))
+ if (thread->thread_obj->thread == thr)
return thread->thread_obj;
return NULL;
gdbpy_enter enter_py (python_gdbarch, python_language);
gdbpy_ref<inferior_object> inf_obj
- ((inferior_object *) find_inferior_object (ptid_get_pid (tp->ptid)));
+ ((inferior_object *) inferior_to_inferior_object (tp->inf));
if (inf_obj == NULL)
return;
build_inferior_list (struct inferior *inf, void *arg)
{
PyObject *list = (PyObject *) arg;
- gdbpy_ref<> inferior (inferior_to_inferior_object (inf));
+ gdbpy_ref<inferior_object> inferior (inferior_to_inferior_object (inf));
- if (inferior == NULL)
+ if (inferior == NULL)
return 0;
- return PyList_Append (list, inferior.get ()) ? 1 : 0;
+ return PyList_Append (list, (PyObject *) inferior.get ()) ? 1 : 0;
}
/* Implementation of gdb.inferiors () -> (gdb.Inferior, ...).
thread_info = find_thread_by_handle (val, inf_obj->inferior);
if (thread_info != NULL)
{
- result = (PyObject *) find_thread_object (thread_info->ptid);
+ result = (PyObject *) thread_to_thread_object (thread_info);
if (result != NULL)
Py_INCREF (result);
}
PyObject *
gdbpy_selected_inferior (PyObject *self, PyObject *args)
{
- return inferior_to_inferior_object (current_inferior ());
+ return (PyObject *) inferior_to_inferior_object (current_inferior ());
}
int