This adds an "alignof" attribute to gdb.Type in the Python API.
2018-04-30 Tom Tromey <tom@tromey.com>
* NEWS: Mention Type.align.
* python/py-type.c (typy_get_alignof): New function.
(type_object_getset): Add "alignof".
2018-04-30 Tom Tromey <tom@tromey.com>
* python.texi (Types In Python): Document Type.align.
2018-04-30 Tom Tromey <tom@tromey.com>
* gdb.python/py-type.exp: Check align attribute.
* gdb.python/py-type.c: New "aligncheck" global.
+2018-04-30 Tom Tromey <tom@tromey.com>
+
+ * NEWS: Mention Type.align.
+ * python/py-type.c (typy_get_alignof): New function.
+ (type_object_getset): Add "alignof".
+
2018-04-30 Tom Tromey <tom@tromey.com>
PR exp/17095:
Controls the processor to be used for enabling errata workarounds for
branch trace decode.
+* Python API
+
+ ** Type alignment is now exposed via the "align" attribute of a gdb.Type.
+
* New targets
RiscV ELF riscv*-*-elf
+2018-04-30 Tom Tromey <tom@tromey.com>
+
+ * python.texi (Types In Python): Document Type.align.
+
2018-04-13 Andreas Arnez <arnez@linux.vnet.ibm.com>
* gdb.texinfo (Symbols): Mention the fact that "info
An instance of @code{Type} has the following attributes:
+@defvar Type.alignof
+The alignment of this type, in bytes. Type alignment comes from the
+debugging information; if it was not specified, then @value{GDBN} will
+use the relevant ABI to try to determine the alignment. In some
+cases, even this is not possible, and zero will be returned.
+@end defvar
+
@defvar Type.code
The type code for this type. The type code will be one of the
@code{TYPE_CODE_} constants defined below.
return gdb_py_long_from_longest (TYPE_LENGTH (type));
}
+/* Return the alignment of the type represented by SELF, in bytes. */
+static PyObject *
+typy_get_alignof (PyObject *self, void *closure)
+{
+ struct type *type = ((type_object *) self)->type;
+
+ ULONGEST align = 0;
+ TRY
+ {
+ align = type_align (type);
+ }
+ CATCH (except, RETURN_MASK_ALL)
+ {
+ align = 0;
+ }
+ END_CATCH
+
+ /* Ignore exceptions. */
+
+ return gdb_py_object_from_ulongest (align);
+}
+
static struct type *
typy_lookup_typename (const char *type_name, const struct block *block)
{
static gdb_PyGetSetDef type_object_getset[] =
{
+ { "alignof", typy_get_alignof, NULL,
+ "The alignment of this type, in bytes.", NULL },
{ "code", typy_get_code, NULL,
"The code for this type.", NULL },
{ "name", typy_get_name, NULL,
+2018-04-30 Tom Tromey <tom@tromey.com>
+
+ * gdb.python/py-type.exp: Check align attribute.
+ * gdb.python/py-type.c: New "aligncheck" global.
+
2018-04-30 Tom Tromey <tom@tromey.com>
PR exp/17095:
typedef struct s TS;
TS ts;
+int aligncheck;
+
#ifdef __cplusplus
struct C
{
gdb_test "python print(gdb.lookup_type('int').optimized_out())" \
"<optimized out>"
+ set sint [get_sizeof int 0]
+ gdb_test "python print(gdb.parse_and_eval('aligncheck').type.alignof)" \
+ $sint
+
with_test_prefix "lang_c" {
runto_bp "break to inspect struct and array."
test_fields "c"