From 2b4424c35b9ebabaab8588b2ba6c38935a48efec Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 20 Apr 2018 11:50:09 -0600 Subject: Add initial type alignment support This adds some basic type alignment support to gdb. It changes struct type to store the alignment, and updates dwarf2read.c to handle DW_AT_alignment. It also adds a new gdbarch method and updates i386-tdep.c. None of this new functionality is used anywhere yet, so tests will wait until the next patch. 2018-04-30 Tom Tromey * i386-tdep.c (i386_type_align): New function. (i386_gdbarch_init): Update. * gdbarch.sh (type_align): New method. * gdbarch.c, gdbarch.h: Rebuild. * arch-utils.h (default_type_align): Declare. * arch-utils.c (default_type_align): New function. * gdbtypes.h (TYPE_ALIGN_BITS): New define. (struct type) : New field. : Now a bitfield. (TYPE_RAW_ALIGN): New macro. (type_align, type_raw_align, set_type_align): Declare. * gdbtypes.c (type_align, type_raw_align, set_type_align): New functions. * dwarf2read.c (quirk_rust_enum): Set type alignment. (get_alignment, maybe_set_alignment): New functions. (read_structure_type, read_enumeration_type, read_array_type) (read_set_type, read_tag_pointer_type, read_tag_reference_type) (read_subrange_type, read_base_type): Set type alignment. --- gdb/gdbarch.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gdb/gdbarch.h') diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index 0084f19..3848ec5 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -1560,6 +1560,12 @@ extern void set_gdbarch_disassembler_options (struct gdbarch *gdbarch, char ** d extern const disasm_options_t * gdbarch_valid_disassembler_options (struct gdbarch *gdbarch); extern void set_gdbarch_valid_disassembler_options (struct gdbarch *gdbarch, const disasm_options_t * valid_disassembler_options); +/* Type alignment. */ + +typedef ULONGEST (gdbarch_type_align_ftype) (struct gdbarch *gdbarch, struct type *type); +extern ULONGEST gdbarch_type_align (struct gdbarch *gdbarch, struct type *type); +extern void set_gdbarch_type_align (struct gdbarch *gdbarch, gdbarch_type_align_ftype *type_align); + /* Definition for an unknown syscall, used basically in error-cases. */ #define UNKNOWN_SYSCALL (-1) -- cgit v1.1