Fix typo in ChangeLog entry.
[deliverable/binutils-gdb.git] / gdb / m68k-tdep.c
index 2a675e063de15a8608c3be2808dde48113445413..a499005ac75e15c79d38c739a854bcc2640a1112 100644 (file)
@@ -1,7 +1,7 @@
 /* Target dependent code for the Motorola 68000 series.
-   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2000, 2001,
-   2002, 2003
-   Free Software Foundation, Inc.
+
+   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2000,
+   2001, 2002, 2003, 2004 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -21,6 +21,7 @@
    Boston, MA 02111-1307, USA.  */
 
 #include "defs.h"
+#include "dwarf2-frame.h"
 #include "frame.h"
 #include "frame-base.h"
 #include "frame-unwind.h"
@@ -33,6 +34,7 @@
 #include "regcache.h"
 #include "arch-utils.h"
 #include "osabi.h"
+#include "dis-asm.h"
 
 #include "m68k-tdep.h"
 \f
 #endif
 
 
-/* gdbarch_breakpoint_from_pc is set to m68k_local_breakpoint_from_pc
-   so m68k_remote_breakpoint_from_pc is currently not used.  */
-
-static const unsigned char *
-m68k_remote_breakpoint_from_pc (CORE_ADDR *pcptr, int *lenptr)
-{
-  static unsigned char break_insn[] = {0x4e, (0x40 | REMOTE_BPT_VECTOR)};
-  *lenptr = sizeof (break_insn);
-  return break_insn;
-}
-
 static const unsigned char *
 m68k_local_breakpoint_from_pc (CORE_ADDR *pcptr, int *lenptr)
 {
@@ -142,20 +133,6 @@ m68k_register_name (int regnum)
   else
     return register_names[regnum];
 }
-
-/* Index within `registers' of the first byte of the space for
-   register regnum.  */
-
-static int
-m68k_register_byte (int regnum)
-{
-  if (regnum >= M68K_FPC_REGNUM)
-    return (((regnum - M68K_FPC_REGNUM) * 4) + 168);
-  else if (regnum >= FP0_REGNUM)
-    return (((regnum - FP0_REGNUM) * 12) + 72);
-  else
-    return (regnum * 4);
-}
 \f
 /* Extract from an array REGBUF containing the (raw) register state, a
    function return value of TYPE, and copy that, in virtual format,
@@ -235,6 +212,16 @@ m68k_extract_struct_value_address (struct regcache *regcache)
   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.  */
@@ -245,7 +232,7 @@ m68k_frameless_function_invocation (struct frame_info *fi)
   if (get_frame_type (fi) == SIGTRAMP_FRAME)
     return 0;
   else
-    return frameless_look_for_prologue (fi);
+    return legacy_frameless_look_for_prologue (fi);
 }
 
 int
@@ -264,7 +251,7 @@ delta68_frame_args_address (struct frame_info *frame_info)
      or other functions who do not put anything on the stack. */
   if (get_frame_type (frame_info) == SIGTRAMP_FRAME)
     return get_frame_base (frame_info) + 12;
-  else if (frameless_look_for_prologue (frame_info))
+  else if (legacy_frameless_look_for_prologue (frame_info))
     {
       /* Check for an interrupted system call */
       if (get_next_frame (frame_info) && (get_frame_type (get_next_frame (frame_info)) == SIGTRAMP_FRAME))
@@ -317,20 +304,29 @@ m68k_push_dummy_call (struct gdbarch *gdbarch, CORE_ADDR func_addr,
   /* 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.  */
@@ -765,7 +761,7 @@ static const struct frame_unwind m68k_frame_unwind =
 };
 
 static const struct frame_unwind *
-m68k_frame_p (CORE_ADDR pc)
+m68k_frame_sniffer (struct frame_info *next_frame)
 {
   return &m68k_frame_unwind;
 }
@@ -832,8 +828,9 @@ static const struct frame_unwind m68k_sigtramp_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
@@ -927,8 +924,8 @@ m68k_unwind_dummy_id (struct gdbarch *gdbarch, struct frame_info *next_frame)
 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++)
     {
@@ -941,8 +938,8 @@ supply_gregset (gregset_t *gregsetp)
 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++)
     {
@@ -964,7 +961,7 @@ fill_gregset (gregset_t *gregsetp, int regno)
 void
 supply_fpregset (fpregset_t *fpregsetp)
 {
-  register int regi;
+  int regi;
   char *from;
 
   for (regi = FP0_REGNUM; regi < M68K_FPC_REGNUM; regi++)
@@ -1040,26 +1037,6 @@ m68k_get_longjmp_target (CORE_ADDR *pc)
   return 1;
 }
 
-#ifdef SYSCALL_TRAP
-/* Immediately after a function call, return the saved pc before the frame
-   is setup.  For sun3's, we check for the common case of being inside of a
-   system call, and if so, we know that Sun pushes the call # on the stack
-   prior to doing the trap. */
-
-static CORE_ADDR
-m68k_saved_pc_after_call (struct frame_info *frame)
-{
-  int op;
-
-  op = read_memory_unsigned_integer (frame->pc - SYSCALL_TRAP_OFFSET, 2);
-
-  if (op == SYSCALL_TRAP)
-    return read_memory_unsigned_integer (read_register (SP_REGNUM) + 4, 4);
-  else
-    return read_memory_unsigned_integer (read_register (SP_REGNUM), 4);
-}
-#endif /* SYSCALL_TRAP */
-
 /* Function: m68k_gdbarch_init
    Initializer function for the m68k gdbarch vector.
    Called by gdbarch.  Sets up the gdbarch vector(s) for this target. */
@@ -1081,12 +1058,7 @@ m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_long_double_format (gdbarch, &floatformat_m68881_ext);
   set_gdbarch_long_double_bit (gdbarch, 96);
 
-  set_gdbarch_function_start_offset (gdbarch, 0);
-
   set_gdbarch_skip_prologue (gdbarch, m68k_skip_prologue);
-#ifdef SYSCALL_TRAP
-  set_gdbarch_deprecated_saved_pc_after_call (gdbarch, m68k_saved_pc_after_call);
-#endif
   set_gdbarch_breakpoint_from_pc (gdbarch, m68k_local_breakpoint_from_pc);
 
   /* Stack grows down. */
@@ -1098,11 +1070,10 @@ m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   set_gdbarch_extract_return_value (gdbarch, m68k_extract_return_value);
   set_gdbarch_store_return_value (gdbarch, m68k_store_return_value);
-  set_gdbarch_extract_struct_value_address (gdbarch,
-                                           m68k_extract_struct_value_address);
+  set_gdbarch_deprecated_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);
+  set_gdbarch_deprecated_frameless_function_invocation (gdbarch, m68k_frameless_function_invocation);
   set_gdbarch_frame_args_skip (gdbarch, 8);
 
   set_gdbarch_register_type (gdbarch, m68k_register_type);
@@ -1126,10 +1097,15 @@ m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   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.  */
@@ -1141,8 +1117,8 @@ m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   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;
 }
This page took 0.027572 seconds and 4 git commands to generate.