aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2022-02-25 10:54:04 +0000
committerAndrew Burgess <aburgess@redhat.com>2022-03-07 19:42:07 +0000
commitee6a3d9e9496d469986a192aa374a43dffa83f96 (patch)
tree50ac979957042eaea384c1bd4a6055447e8cebdc /gdb/python
parent6fd90137e776c1a29f75651af8e7a129337254c7 (diff)
downloadbinutils-ee6a3d9e9496d469986a192aa374a43dffa83f96.zip
binutils-ee6a3d9e9496d469986a192aa374a43dffa83f96.tar.gz
binutils-ee6a3d9e9496d469986a192aa374a43dffa83f96.tar.bz2
gdb/python: add Type.is_scalar property
Add a new read-only property which is True for scalar types, otherwise, it's False.
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/py-type.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
index 13dae1e..5476123 100644
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -433,6 +433,19 @@ typy_get_objfile (PyObject *self, void *closure)
return objfile_to_objfile_object (objfile).release ();
}
+/* Return true if this is a scalar type, otherwise, returns false. */
+
+static PyObject *
+typy_is_scalar (PyObject *self, void *closure)
+{
+ struct type *type = ((type_object *) self)->type;
+
+ if (is_scalar_type (type))
+ Py_RETURN_TRUE;
+ else
+ Py_RETURN_FALSE;
+}
+
/* Return the type, stripped of typedefs. */
static PyObject *
typy_strip_typedefs (PyObject *self, PyObject *args)
@@ -1487,6 +1500,8 @@ static gdb_PyGetSetDef type_object_getset[] =
"The tag name for this type, or None.", NULL },
{ "objfile", typy_get_objfile, NULL,
"The objfile this type was defined in, or None.", NULL },
+ { "is_scalar", typy_is_scalar, nullptr,
+ "Is this a scalar type?", nullptr },
{ NULL }
};