aboutsummaryrefslogtreecommitdiff
path: root/gdb/python/py-arch.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/python/py-arch.c')
-rw-r--r--gdb/python/py-arch.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/gdb/python/py-arch.c b/gdb/python/py-arch.c
index 0f273b3..e6dfb24 100644
--- a/gdb/python/py-arch.c
+++ b/gdb/python/py-arch.c
@@ -62,16 +62,25 @@ arch_object_data_init (struct gdbarch *gdbarch)
}
/* Returns the struct gdbarch value corresponding to the given Python
- architecture object OBJ. */
+ architecture object OBJ, which must be a gdb.Architecture object. */
struct gdbarch *
arch_object_to_gdbarch (PyObject *obj)
{
- arch_object *py_arch = (arch_object *) obj;
+ gdb_assert (gdbpy_is_architecture (obj));
+ arch_object *py_arch = (arch_object *) obj;
return py_arch->gdbarch;
}
+/* See python-internal.h. */
+
+bool
+gdbpy_is_architecture (PyObject *obj)
+{
+ return PyObject_TypeCheck (obj, &arch_object_type);
+}
+
/* Returns the Python architecture object corresponding to GDBARCH.
Returns a new reference to the arch_object associated as data with
GDBARCH. */