diff options
author | Tom Tromey <tom@tromey.com> | 2018-04-20 11:50:09 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2018-04-30 11:25:30 -0600 |
commit | 2b4424c35b9ebabaab8588b2ba6c38935a48efec (patch) | |
tree | 3b1ea57f6b2f1b7d703c4c6532db28b10c74e9d3 /gdb/i386-tdep.c | |
parent | fe944acf8f858cfe6bcfd00670a88847a464717c (diff) | |
download | binutils-2b4424c35b9ebabaab8588b2ba6c38935a48efec.zip binutils-2b4424c35b9ebabaab8588b2ba6c38935a48efec.tar.gz binutils-2b4424c35b9ebabaab8588b2ba6c38935a48efec.tar.bz2 |
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 <tom@tromey.com>
* 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) <align_log2>: New field.
<instance_flags>: 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.
Diffstat (limited to 'gdb/i386-tdep.c')
-rw-r--r-- | gdb/i386-tdep.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index bf4ca54..fec74ee 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -8347,6 +8347,31 @@ i386_validate_tdesc_p (struct gdbarch_tdep *tdep, } + +/* Implement the type_align gdbarch function. */ + +static ULONGEST +i386_type_align (struct gdbarch *gdbarch, struct type *type) +{ + type = check_typedef (type); + + if (gdbarch_ptr_bit (gdbarch) == 32) + { + if ((TYPE_CODE (type) == TYPE_CODE_INT + || TYPE_CODE (type) == TYPE_CODE_FLT) + && TYPE_LENGTH (type) > 4) + return 4; + + /* Handle x86's funny long double. */ + if (TYPE_CODE (type) == TYPE_CODE_FLT + && gdbarch_long_double_bit (gdbarch) == TYPE_LENGTH (type) * 8) + return 4; + } + + return TYPE_LENGTH (type); +} + + /* Note: This is called for both i386 and amd64. */ static struct gdbarch * @@ -8405,6 +8430,7 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) tdep->record_regmap = i386_record_regmap; set_gdbarch_long_long_align_bit (gdbarch, 32); + set_gdbarch_type_align (gdbarch, i386_type_align); /* The format used for `long double' on almost all i386 targets is the i387 extended floating-point format. In fact, of all targets |