state information, or None, if there is no such additional
information.
+ ** New read-only attribute gdb.Type.is_scalar, which is True for
+ scalar types, and False for all other types.
+
* New features in the GDB remote stub, GDBserver
** GDBserver is now supported on OpenRISC GNU/Linux.
there is no associated objfile.
@end defvar
+@defvar Type.is_scalar
+This property is @code{True} if the type is a scalar type, otherwise,
+this property is @code{False}. Examples of non-scalar types include
+structures, unions, and classes.
+@end defvar
+
The following methods are provided:
@defun Type.fields ()
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)
"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 }
};
int aligncheck;
+union UU
+{
+ int i;
+ float f;
+ int a[5];
+};
+
#ifdef __cplusplus
struct C
{
#endif
+unsigned char global_unsigned_char;
+char global_char;
+signed char global_signed_char;
+
+unsigned int global_unsigned_int;
+int global_int;
+signed int global_signed_int;
+
enum E
{ v1, v2, v3
};
int ar[2] = {1,2};
struct s st;
struct SS ss;
+ union UU uu;
#ifdef __cplusplus
C c;
c.c = 1;
gdb_test "python print (ttype.template_argument(2))" "&C::c"
}
+# Test the gdb.Type.is_scalar property.
+proc test_is_scalar { lang } {
+ if {$lang == "c++"} {
+ gdb_test "python print(gdb.parse_and_eval ('c').type.is_scalar)" "False"
+ gdb_test "python print(gdb.parse_and_eval ('&c').type.is_scalar)" "True"
+ }
+
+ foreach type { char int } {
+ gdb_test "python print(gdb.parse_and_eval('global_unsigned_${type}').type.is_scalar)" "True"
+ gdb_test "python print(gdb.parse_and_eval('global_${type}').type.is_scalar)" "True"
+ gdb_test "python print(gdb.parse_and_eval('global_signed_${type}').type.is_scalar)" "True"
+ }
+
+ gdb_test "python print(gdb.parse_and_eval ('ss.x').type.is_scalar)" "True"
+ gdb_test "python print(gdb.parse_and_eval ('ss').type.is_scalar)" "False"
+ gdb_test "python print(gdb.parse_and_eval ('uu').type.is_scalar)" "False"
+
+ gdb_test "python print(gdb.parse_and_eval ('uu.i').type.is_scalar)" "True"
+ gdb_test "python print(gdb.parse_and_eval ('uu.f').type.is_scalar)" "True"
+ gdb_test "python print(gdb.parse_and_eval ('uu.a').type.is_scalar)" "False"
+ gdb_test "python print(gdb.parse_and_eval ('&ss.x').type.is_scalar)" "True"
+}
+
# Perform C Tests.
if { [build_inferior "${binfile}" "c"] == 0 } {
restart_gdb "${binfile}"
runto_bp "break to inspect struct and array."
test_fields "c"
test_enums
+ test_is_scalar "c"
}
}
-
# Perform C++ Tests.
if { [build_inferior "${binfile}-cxx" "c++"] == 0 } {
restart_gdb "${binfile}-cxx"
test_range
test_template
test_enums
+ test_is_scalar "c++"
}
}