aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2019-04-12 14:25:32 +0100
committerAndrew Burgess <andrew.burgess@embecosm.com>2019-04-23 22:02:59 +0100
commit030197b43cd8ccfe6869f798dd39fa27a29c0e01 (patch)
treee5557f32d55efcda6dba06c458faadaaad83d9d8 /gdb
parentb907456c3eb8a08f6b211f66abb448df962749e1 (diff)
downloadgdb-030197b43cd8ccfe6869f798dd39fa27a29c0e01.zip
gdb-030197b43cd8ccfe6869f798dd39fa27a29c0e01.tar.gz
gdb-030197b43cd8ccfe6869f798dd39fa27a29c0e01.tar.bz2
gdb/arm: Use type_align instead of arm_type_align
Replaces use of arm_type_align with common type_align function. Doing this fixes a bug in arm_type_align where static fields are considered as part of the alignment calculation of a struct, which results in arguments passed on the stack being misaligned, this bug was causing a failure in gdb.cp/many-args.exp. Part of the old arm_type_align is retained and used as the gdbarch type align callback in order to correctly align vectors. gdb/ChangeLog: * arm-tdep.c (arm_type_align): Only handle vector override case. (arm_push_dummy_call): Use type_align. (arm_gdbarch_init): Register arm_type_align gdbarch function.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/arm-tdep.c68
2 files changed, 23 insertions, 51 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6918644..99f67d8 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
2019-04-23 Andrew Burgess <andrew.burgess@embecosm.com>
+ * arm-tdep.c (arm_type_align): Only handle vector override case.
+ (arm_push_dummy_call): Use type_align.
+ (arm_gdbarch_init): Register arm_type_align gdbarch function.
+
+2019-04-23 Andrew Burgess <andrew.burgess@embecosm.com>
+
* aarch64-tdep.c (aarch64_type_align): Only handle vector override
case.
(pass_on_stack): Use type_align.
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 599f785..742bfa5 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -3314,62 +3314,25 @@ pop_stack_item (struct stack_item *si)
return si;
}
+/* Implement the gdbarch type alignment method, overrides the generic
+ alignment algorithm for anything that is arm specific. */
-/* Return the alignment (in bytes) of the given type. */
-
-static int
-arm_type_align (struct type *t)
+static ULONGEST
+arm_type_align (gdbarch *gdbarch, struct type *t)
{
- int n;
- int align;
- int falign;
-
t = check_typedef (t);
- switch (TYPE_CODE (t))
+ if (TYPE_CODE (t) == TYPE_CODE_ARRAY && TYPE_VECTOR (t))
{
- default:
- /* Should never happen. */
- internal_error (__FILE__, __LINE__, _("unknown type alignment"));
- return 4;
-
- case TYPE_CODE_PTR:
- case TYPE_CODE_ENUM:
- case TYPE_CODE_INT:
- case TYPE_CODE_FLT:
- case TYPE_CODE_SET:
- case TYPE_CODE_RANGE:
- case TYPE_CODE_REF:
- case TYPE_CODE_RVALUE_REF:
- case TYPE_CODE_CHAR:
- case TYPE_CODE_BOOL:
- return TYPE_LENGTH (t);
-
- case TYPE_CODE_ARRAY:
- if (TYPE_VECTOR (t))
- {
- /* Use the natural alignment for vector types (the same for
- scalar type), but the maximum alignment is 64-bit. */
- if (TYPE_LENGTH (t) > 8)
- return 8;
- else
- return TYPE_LENGTH (t);
- }
+ /* Use the natural alignment for vector types (the same for
+ scalar type), but the maximum alignment is 64-bit. */
+ if (TYPE_LENGTH (t) > 8)
+ return 8;
else
- return arm_type_align (TYPE_TARGET_TYPE (t));
- case TYPE_CODE_COMPLEX:
- return arm_type_align (TYPE_TARGET_TYPE (t));
-
- case TYPE_CODE_STRUCT:
- case TYPE_CODE_UNION:
- align = 1;
- for (n = 0; n < TYPE_NFIELDS (t); n++)
- {
- falign = arm_type_align (TYPE_FIELD_TYPE (t, n));
- if (falign > align)
- align = falign;
- }
- return align;
+ return TYPE_LENGTH (t);
}
+
+ /* Allow the common code to calculate the alignment. */
+ return 0;
}
/* Possible base types for a candidate for passing and returning in
@@ -3715,7 +3678,7 @@ arm_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
typecode = TYPE_CODE (arg_type);
val = value_contents (args[argnum]);
- align = arm_type_align (arg_type);
+ align = type_align (arg_type);
/* Round alignment up to a whole number of words. */
align = (align + INT_REGISTER_SIZE - 1) & ~(INT_REGISTER_SIZE - 1);
/* Different ABIs have different maximum alignments. */
@@ -9309,6 +9272,9 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
else
set_gdbarch_wchar_signed (gdbarch, 1);
+ /* Compute type alignment. */
+ set_gdbarch_type_align (gdbarch, arm_type_align);
+
/* Note: for displaced stepping, this includes the breakpoint, and one word
of additional scratch space. This setting isn't used for anything beside
displaced stepping at present. */