+2019-02-27 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * arc-tdep.c (arc_type_align): Provide alignment for basic types,
+ return 0 for other types.
+ * arch-utils.c (default_type_align): Always return 0.
+ * gdbarch.h: Regenerate.
+ * gdbarch.sh (type_align): Extend comment.
+ * gdbtypes.c (type_align): Add additional comments, always call
+ gdbarch_type_align before applying the default rules.
+ * i386-tdep.c (i386_type_align): Return 0 as the default rule,
+ generic code will then apply a suitable default.
+ * nios2-tdep.c (nios2_type_align): Provide alignment for basic
+ types, return 0 for other types.
+
2019-02-27 Joel Brobecker <brobecker@adacore.com>
* NEWS: Create a new section for the next release branch.
static ULONGEST
arc_type_align (struct gdbarch *gdbarch, struct type *type)
{
- type = check_typedef (type);
- return std::min<ULONGEST> (4, TYPE_LENGTH (type));
+ switch (TYPE_CODE (type))
+ {
+ case TYPE_CODE_PTR:
+ case TYPE_CODE_FUNC:
+ case TYPE_CODE_FLAGS:
+ case TYPE_CODE_INT:
+ case TYPE_CODE_RANGE:
+ case TYPE_CODE_FLT:
+ case TYPE_CODE_ENUM:
+ case TYPE_CODE_REF:
+ case TYPE_CODE_RVALUE_REF:
+ case TYPE_CODE_CHAR:
+ case TYPE_CODE_BOOL:
+ case TYPE_CODE_DECFLOAT:
+ case TYPE_CODE_METHODPTR:
+ case TYPE_CODE_MEMBERPTR:
+ type = check_typedef (type);
+ return std::min<ULONGEST> (4, TYPE_LENGTH (type));
+ default:
+ return 0;
+ }
}
/* Implement the "init" gdbarch method. */
ULONGEST
default_type_align (struct gdbarch *gdbarch, struct type *type)
{
- return type_length_units (check_typedef (type));
+ return 0;
}
void
extern const disasm_options_and_args_t * gdbarch_valid_disassembler_options (struct gdbarch *gdbarch);
extern void set_gdbarch_valid_disassembler_options (struct gdbarch *gdbarch, const disasm_options_and_args_t * valid_disassembler_options);
-/* Type alignment. */
+/* Type alignment override method. Return the architecture specific
+ alignment required for TYPE. If there is no special handling
+ required for TYPE then return the value 0, GDB will then apply the
+ default rules as laid out in gdbtypes.c:type_align. */
typedef ULONGEST (gdbarch_type_align_ftype) (struct gdbarch *gdbarch, struct type *type);
extern ULONGEST gdbarch_type_align (struct gdbarch *gdbarch, struct type *type);
v;char **;disassembler_options;;;0;0;;0;pstring_ptr (gdbarch->disassembler_options)
v;const disasm_options_and_args_t *;valid_disassembler_options;;;0;0;;0;host_address_to_string (gdbarch->valid_disassembler_options)
-# Type alignment.
+# Type alignment override method. Return the architecture specific
+# alignment required for TYPE. If there is no special handling
+# required for TYPE then return the value 0, GDB will then apply the
+# default rules as laid out in gdbtypes.c:type_align.
m;ULONGEST;type_align;struct type *type;type;;default_type_align;;0
EOF
unsigned
type_align (struct type *type)
{
+ /* Check alignment provided in the debug information. */
unsigned raw_align = type_raw_align (type);
if (raw_align != 0)
return raw_align;
- ULONGEST align = 0;
+ /* Allow the architecture to provide an alignment. */
+ struct gdbarch *arch = get_type_arch (type);
+ ULONGEST align = gdbarch_type_align (arch, type);
+ if (align != 0)
+ return align;
+
switch (TYPE_CODE (type))
{
case TYPE_CODE_PTR:
case TYPE_CODE_DECFLOAT:
case TYPE_CODE_METHODPTR:
case TYPE_CODE_MEMBERPTR:
- {
- struct gdbarch *arch = get_type_arch (type);
- align = gdbarch_type_align (arch, type);
- }
+ align = type_length_units (check_typedef (type));
break;
case TYPE_CODE_ARRAY:
return 4;
}
- return TYPE_LENGTH (type);
+ return 0;
}
\f
static ULONGEST
nios2_type_align (struct gdbarch *gdbarch, struct type *type)
{
- type = check_typedef (type);
- return std::min<ULONGEST> (4, TYPE_LENGTH (type));
+ switch (TYPE_CODE (type))
+ {
+ case TYPE_CODE_PTR:
+ case TYPE_CODE_FUNC:
+ case TYPE_CODE_FLAGS:
+ case TYPE_CODE_INT:
+ case TYPE_CODE_RANGE:
+ case TYPE_CODE_FLT:
+ case TYPE_CODE_ENUM:
+ case TYPE_CODE_REF:
+ case TYPE_CODE_RVALUE_REF:
+ case TYPE_CODE_CHAR:
+ case TYPE_CODE_BOOL:
+ case TYPE_CODE_DECFLOAT:
+ case TYPE_CODE_METHODPTR:
+ case TYPE_CODE_MEMBERPTR:
+ type = check_typedef (type);
+ return std::min<ULONGEST> (4, TYPE_LENGTH (type));
+ default:
+ return 0;
+ }
}
/* Implement the gcc_target_options gdbarch method. */