aboutsummaryrefslogtreecommitdiff
path: root/gdb/python/python-internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/python/python-internal.h')
-rw-r--r--gdb/python/python-internal.h34
1 files changed, 25 insertions, 9 deletions
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index 95619bf775e..f6915a62b7a 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -107,6 +107,15 @@ typedef unsigned long gdb_py_ulongest;
#endif /* HAVE_LONG_LONG */
+#if PY_VERSION_HEX < 0x030a0000
+static inline PyObject *
+Py_NewRef (PyObject *obj)
+{
+ Py_INCREF (obj);
+ return obj;
+}
+#endif
+
/* A template variable holding the format character (as for
Py_BuildValue) for a given type. */
template<typename T>
@@ -384,22 +393,27 @@ struct gdbpy_breakpoint_object
extern gdbpy_breakpoint_object *bppy_pending_object;
-struct thread_object
+struct thread_object : public gdbpy_dict_wrapper
{
- PyObject_HEAD
-
/* The thread we represent. */
struct thread_info *thread;
/* The Inferior object to which this thread belongs. */
PyObject *inf_obj;
-
- /* Dictionary holding user-added attributes. This is the __dict__
- attribute of the object. */
- PyObject *dict;
};
-struct inferior_object;
+using thread_map_t
+ = gdb::unordered_map<thread_info *, gdbpy_ref<thread_object>>;
+
+struct inferior_object : public gdbpy_dict_wrapper
+{
+ /* The inferior we represent. */
+ struct inferior *inferior;
+
+ /* thread_object instances under this inferior. This owns a
+ reference to each object it contains. */
+ thread_map_t *threads;
+};
extern struct cmd_list_element *set_python_list;
extern struct cmd_list_element *show_python_list;
@@ -989,7 +1003,9 @@ gdbpy_ref<> gdb_py_object_from_longest (LONGEST l);
gdbpy_ref<> gdb_py_object_from_ulongest (ULONGEST l);
int gdb_py_int_as_long (PyObject *, long *);
-PyObject *gdb_py_generic_dict (PyObject *self, void *closure);
+PyObject *gdb_py_generic_dict_getter (PyObject *self, void *closure);
+PyObject *gdb_py_generic_getattro (PyObject *self, PyObject *attr);
+int gdb_py_generic_setattro (PyObject *self, PyObject *attr, PyObject *value);
int gdb_pymodule_addobject (PyObject *mod, const char *name,
PyObject *object);