aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbarch.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-04-20 11:50:09 -0600
committerTom Tromey <tom@tromey.com>2018-04-30 11:25:30 -0600
commit2b4424c35b9ebabaab8588b2ba6c38935a48efec (patch)
tree3b1ea57f6b2f1b7d703c4c6532db28b10c74e9d3 /gdb/gdbarch.c
parentfe944acf8f858cfe6bcfd00670a88847a464717c (diff)
downloadgdb-2b4424c35b9ebabaab8588b2ba6c38935a48efec.zip
gdb-2b4424c35b9ebabaab8588b2ba6c38935a48efec.tar.gz
gdb-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/gdbarch.c')
-rw-r--r--gdb/gdbarch.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index 1359c2f..dd7c89d 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -353,6 +353,7 @@ struct gdbarch
gdbarch_addressable_memory_unit_size_ftype *addressable_memory_unit_size;
char ** disassembler_options;
const disasm_options_t * valid_disassembler_options;
+ gdbarch_type_align_ftype *type_align;
};
/* Create a new ``struct gdbarch'' based on information provided by
@@ -465,6 +466,7 @@ gdbarch_alloc (const struct gdbarch_info *info,
gdbarch->gcc_target_options = default_gcc_target_options;
gdbarch->gnu_triplet_regexp = default_gnu_triplet_regexp;
gdbarch->addressable_memory_unit_size = default_addressable_memory_unit_size;
+ gdbarch->type_align = default_type_align;
/* gdbarch_alloc() */
return gdbarch;
@@ -716,6 +718,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
/* Skip verify of addressable_memory_unit_size, invalid_p == 0 */
/* Skip verify of disassembler_options, invalid_p == 0 */
/* Skip verify of valid_disassembler_options, invalid_p == 0 */
+ /* Skip verify of type_align, invalid_p == 0 */
if (!log.empty ())
internal_error (__FILE__, __LINE__,
_("verify_gdbarch: the following are invalid ...%s"),
@@ -1442,6 +1445,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
"gdbarch_dump: target_desc = %s\n",
host_address_to_string (gdbarch->target_desc));
fprintf_unfiltered (file,
+ "gdbarch_dump: type_align = <%s>\n",
+ host_address_to_string (gdbarch->type_align));
+ fprintf_unfiltered (file,
"gdbarch_dump: gdbarch_unwind_pc_p() = %d\n",
gdbarch_unwind_pc_p (gdbarch));
fprintf_unfiltered (file,
@@ -5100,6 +5106,23 @@ set_gdbarch_valid_disassembler_options (struct gdbarch *gdbarch,
gdbarch->valid_disassembler_options = valid_disassembler_options;
}
+ULONGEST
+gdbarch_type_align (struct gdbarch *gdbarch, struct type *type)
+{
+ gdb_assert (gdbarch != NULL);
+ gdb_assert (gdbarch->type_align != NULL);
+ if (gdbarch_debug >= 2)
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_type_align called\n");
+ return gdbarch->type_align (gdbarch, type);
+}
+
+void
+set_gdbarch_type_align (struct gdbarch *gdbarch,
+ gdbarch_type_align_ftype type_align)
+{
+ gdbarch->type_align = type_align;
+}
+
/* Keep a registry of per-architecture data-pointers required by GDB
modules. */