* configure.ac (DEBUGDIR_RELOCATABLE): Define for debugdir inside
[deliverable/binutils-gdb.git] / gdb / m68k-tdep.c
index 6469b7ee7d004e383e546ebca83b805c6a3b4c73..ac2ec77282944e468ce574cb78c8aab8554c591f 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, 2004, 2005 Free Software Foundation, Inc.
+   Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2000, 2001,
+   2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -17,8 +17,8 @@
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+   Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
 
 #include "defs.h"
 #include "dwarf2-frame.h"
@@ -413,6 +413,16 @@ m68k_svr4_return_value (struct gdbarch *gdbarch, struct type *type,
 }
 \f
 
+/* Always align the frame to a 4-byte boundary.  This is required on
+   coldfire and harmless on the rest.  */
+
+static CORE_ADDR
+m68k_frame_align (struct gdbarch *gdbarch, CORE_ADDR sp)
+{
+  /* Align the stack to four bytes.  */
+  return sp & ~3;
+}
+
 static CORE_ADDR
 m68k_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
                      struct regcache *regcache, CORE_ADDR bp_addr, int nargs,
@@ -467,6 +477,28 @@ m68k_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
      frame's CFA.  */
   return sp + 8;
 }
+
+/* Convert a dwarf or dwarf2 regnumber to a GDB regnum.  */
+
+static int
+m68k_dwarf_reg_to_regnum (int num)
+{
+  if (num < 8)
+    /* d0..7 */
+    return (num - 0) + M68K_D0_REGNUM;
+  else if (num < 16)
+    /* a0..7 */
+    return (num - 8) + M68K_A0_REGNUM;
+  else if (num < 24)
+    /* fp0..7 */
+    return (num - 16) + M68K_FP0_REGNUM;
+  else if (num == 25)
+    /* pc */
+    return M68K_PC_REGNUM;
+  else
+    return NUM_REGS + NUM_PSEUDO_REGS;
+}
+
 \f
 struct m68k_frame_cache
 {
@@ -645,10 +677,10 @@ m68k_analyze_register_saves (CORE_ADDR pc, CORE_ADDR current_pc,
              else
                break;
            }
-         else if ((op & 0170677) == P_MOVEL_SP)
+         else if ((op & 0177760) == P_MOVEL_SP)
            {
              /* move.l %R,-(%sp) */
-             regno = ((op & 07000) >> 9) | ((op & 0100) >> 3);
+             regno = op & 017;
              cache->saved_regs[regno] = offset;
              offset -= 4;
              pc += 2;
@@ -1133,15 +1165,18 @@ m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   /* Stack grows down. */
   set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
+  set_gdbarch_frame_align (gdbarch, m68k_frame_align);
 
   set_gdbarch_believe_pcc_promotion (gdbarch, 1);
   set_gdbarch_decr_pc_after_break (gdbarch, 2);
 
   set_gdbarch_frame_args_skip (gdbarch, 8);
+  set_gdbarch_dwarf_reg_to_regnum (gdbarch, m68k_dwarf_reg_to_regnum);
+  set_gdbarch_dwarf2_reg_to_regnum (gdbarch, m68k_dwarf_reg_to_regnum);
 
   set_gdbarch_register_type (gdbarch, m68k_register_type);
   set_gdbarch_register_name (gdbarch, m68k_register_name);
-  set_gdbarch_num_regs (gdbarch, 29);
+  set_gdbarch_num_regs (gdbarch, M68K_NUM_REGS);
   set_gdbarch_register_bytes_ok (gdbarch, m68k_register_bytes_ok);
   set_gdbarch_sp_regnum (gdbarch, M68K_SP_REGNUM);
   set_gdbarch_pc_regnum (gdbarch, M68K_PC_REGNUM);
This page took 0.025046 seconds and 4 git commands to generate.