Boston, MA 02111-1307, USA. */
#include "defs.h"
+#include "dwarf2-frame.h"
#include "frame.h"
#include "frame-base.h"
#include "frame-unwind.h"
#include "regcache.h"
#include "arch-utils.h"
#include "osabi.h"
+#include "dis-asm.h"
#include "m68k-tdep.h"
\f
return extract_unsigned_integer (buf, 4);
}
+static int
+m68k_use_struct_convention (int gcc_p, struct type *type)
+{
+ enum struct_return struct_return;
+
+ struct_return = gdbarch_tdep (current_gdbarch)->struct_return;
+ return generic_use_struct_convention (struct_return == reg_struct_return,
+ type);
+}
+
/* A function that tells us whether the function invocation represented
by fi does not have a frame on the stack associated with it. If it
does not, FRAMELESS is set to 1, else 0. */
/* Push arguments in reverse order. */
for (i = nargs - 1; i >= 0; i--)
{
- int len = TYPE_LENGTH (VALUE_ENCLOSING_TYPE (args[i]));
+ struct type *value_type = VALUE_ENCLOSING_TYPE (args[i]);
+ int len = TYPE_LENGTH (value_type);
int container_len = (len + 3) & ~3;
- int offset = container_len - len;
-
+ int offset;
+
+ /* Non-scalars bigger than 4 bytes are left aligned, others are
+ right aligned. */
+ if ((TYPE_CODE (value_type) == TYPE_CODE_STRUCT
+ || TYPE_CODE (value_type) == TYPE_CODE_UNION
+ || TYPE_CODE (value_type) == TYPE_CODE_ARRAY)
+ && len > 4)
+ offset = 0;
+ else
+ offset = container_len - len;
sp -= container_len;
write_memory (sp + offset, VALUE_CONTENTS_ALL (args[i]), len);
}
- /* Push value address. */
+ /* Store struct value address. */
if (struct_return)
{
- sp -= 4;
store_unsigned_integer (buf, 4, struct_addr);
- write_memory (sp, buf, 4);
+ regcache_cooked_write (regcache, M68K_A1_REGNUM, buf);
}
/* Store return address. */
};
static const struct frame_unwind *
-m68k_frame_p (CORE_ADDR pc)
+m68k_frame_sniffer (struct frame_info *next_frame)
{
return &m68k_frame_unwind;
}
};
static const struct frame_unwind *
-m68k_sigtramp_frame_p (CORE_ADDR pc)
+m68k_sigtramp_frame_sniffer (struct frame_info *next_frame)
{
+ CORE_ADDR pc = frame_pc_unwind (next_frame);
char *name;
/* We shouldn't even bother to try if the OSABI didn't register
void
supply_gregset (gregset_t *gregsetp)
{
- register int regi;
- register greg_t *regp = (greg_t *) gregsetp;
+ int regi;
+ greg_t *regp = (greg_t *) gregsetp;
for (regi = 0; regi < R_PC; regi++)
{
void
fill_gregset (gregset_t *gregsetp, int regno)
{
- register int regi;
- register greg_t *regp = (greg_t *) gregsetp;
+ int regi;
+ greg_t *regp = (greg_t *) gregsetp;
for (regi = 0; regi < R_PC; regi++)
{
void
supply_fpregset (fpregset_t *fpregsetp)
{
- register int regi;
+ int regi;
char *from;
for (regi = FP0_REGNUM; regi < M68K_FPC_REGNUM; regi++)
set_gdbarch_store_return_value (gdbarch, m68k_store_return_value);
set_gdbarch_extract_struct_value_address (gdbarch,
m68k_extract_struct_value_address);
+ set_gdbarch_use_struct_convention (gdbarch, m68k_use_struct_convention);
set_gdbarch_frameless_function_invocation (gdbarch,
m68k_frameless_function_invocation);
tdep->jb_pc = -1;
#endif
tdep->get_sigtramp_info = NULL;
+ tdep->struct_return = pcc_struct_return;
/* Frame unwinder. */
set_gdbarch_unwind_dummy_id (gdbarch, m68k_unwind_dummy_id);
set_gdbarch_unwind_pc (gdbarch, m68k_unwind_pc);
+
+ /* Hook in the DWARF CFI frame unwinder. */
+ frame_unwind_append_sniffer (gdbarch, dwarf2_frame_sniffer);
+
frame_base_set_default (gdbarch, &m68k_frame_base);
/* Hook in ABI-specific overrides, if they have been registered. */
if (tdep->jb_pc >= 0)
set_gdbarch_get_longjmp_target (gdbarch, m68k_get_longjmp_target);
- frame_unwind_append_predicate (gdbarch, m68k_sigtramp_frame_p);
- frame_unwind_append_predicate (gdbarch, m68k_frame_p);
+ frame_unwind_append_sniffer (gdbarch, m68k_sigtramp_frame_sniffer);
+ frame_unwind_append_sniffer (gdbarch, m68k_frame_sniffer);
return gdbarch;
}