Automatic date update in version.in
[platform/upstream/binutils.git] / gdb / m68k-tdep.c
index 2706969..6bb7e33 100644 (file)
@@ -1,8 +1,6 @@
 /* Target-dependent code for the Motorola 68000 series.
 
-   Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2000, 2001,
-   2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
-   Free Software Foundation, Inc.
+   Copyright (C) 1990-2014 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -28,8 +26,6 @@
 #include "symtab.h"
 #include "gdbcore.h"
 #include "value.h"
-#include "gdb_string.h"
-#include "gdb_assert.h"
 #include "inferior.h"
 #include "regcache.h"
 #include "arch-utils.h"
@@ -317,7 +313,6 @@ static void
 m68k_svr4_extract_return_value (struct type *type, struct regcache *regcache,
                                gdb_byte *valbuf)
 {
-  int len = TYPE_LENGTH (type);
   gdb_byte buf[M68K_MAX_REGISTER_SIZE];
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
@@ -328,7 +323,7 @@ m68k_svr4_extract_return_value (struct type *type, struct regcache *regcache,
       regcache_raw_read (regcache, M68K_FP0_REGNUM, buf);
       convert_typed_floating (buf, fpreg_type, valbuf, type);
     }
-  else if (TYPE_CODE (type) == TYPE_CODE_PTR && len == 4)
+  else if (TYPE_CODE (type) == TYPE_CODE_PTR && TYPE_LENGTH (type) == 4)
     regcache_raw_read (regcache, M68K_A0_REGNUM, valbuf);
   else
     m68k_extract_return_value (type, regcache, valbuf);
@@ -359,7 +354,6 @@ static void
 m68k_svr4_store_return_value (struct type *type, struct regcache *regcache,
                              const gdb_byte *valbuf)
 {
-  int len = TYPE_LENGTH (type);
   struct gdbarch *gdbarch = get_regcache_arch (regcache);
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
@@ -370,7 +364,7 @@ m68k_svr4_store_return_value (struct type *type, struct regcache *regcache,
       convert_typed_floating (valbuf, type, buf, fpreg_type);
       regcache_raw_write (regcache, M68K_FP0_REGNUM, buf);
     }
-  else if (TYPE_CODE (type) == TYPE_CODE_PTR && len == 4)
+  else if (TYPE_CODE (type) == TYPE_CODE_PTR && TYPE_LENGTH (type) == 4)
     {
       regcache_raw_write (regcache, M68K_A0_REGNUM, valbuf);
       regcache_raw_write (regcache, M68K_D0_REGNUM, valbuf);
@@ -379,8 +373,8 @@ m68k_svr4_store_return_value (struct type *type, struct regcache *regcache,
     m68k_store_return_value (type, regcache, valbuf);
 }
 
-/* Return non-zero if TYPE, which is assumed to be a structure or
-   union type, should be returned in registers for architecture
+/* Return non-zero if TYPE, which is assumed to be a structure, union or
+   complex type, should be returned in registers for architecture
    GDBARCH.  */
 
 static int
@@ -390,7 +384,8 @@ m68k_reg_struct_return_p (struct gdbarch *gdbarch, struct type *type)
   enum type_code code = TYPE_CODE (type);
   int len = TYPE_LENGTH (type);
 
-  gdb_assert (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION);
+  gdb_assert (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION
+             || code == TYPE_CODE_COMPLEX);
 
   if (tdep->struct_return == pcc_struct_return)
     return 0;
@@ -405,14 +400,15 @@ m68k_reg_struct_return_p (struct gdbarch *gdbarch, struct type *type)
    from WRITEBUF into REGCACHE.  */
 
 static enum return_value_convention
-m68k_return_value (struct gdbarch *gdbarch, struct type *func_type,
+m68k_return_value (struct gdbarch *gdbarch, struct value *function,
                   struct type *type, struct regcache *regcache,
                   gdb_byte *readbuf, const gdb_byte *writebuf)
 {
   enum type_code code = TYPE_CODE (type);
 
   /* GCC returns a `long double' in memory too.  */
-  if (((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION)
+  if (((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION
+       || code == TYPE_CODE_COMPLEX)
        && !m68k_reg_struct_return_p (gdbarch, type))
       || (code == TYPE_CODE_FLT && TYPE_LENGTH (type) == 12))
     {
@@ -440,13 +436,14 @@ m68k_return_value (struct gdbarch *gdbarch, struct type *func_type,
 }
 
 static enum return_value_convention
-m68k_svr4_return_value (struct gdbarch *gdbarch, struct type *func_type,
+m68k_svr4_return_value (struct gdbarch *gdbarch, struct value *function,
                        struct type *type, struct regcache *regcache,
                        gdb_byte *readbuf, const gdb_byte *writebuf)
 {
   enum type_code code = TYPE_CODE (type);
 
-  if ((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION)
+  if ((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION
+       || code == TYPE_CODE_COMPLEX)
       && !m68k_reg_struct_return_p (gdbarch, type))
     {
       /* The System V ABI says that:
@@ -479,7 +476,7 @@ m68k_svr4_return_value (struct gdbarch *gdbarch, struct type *func_type,
   if (code == TYPE_CODE_STRUCT && TYPE_NFIELDS (type) == 1)
     {
       type = check_typedef (TYPE_FIELD_TYPE (type, 0));
-      return m68k_svr4_return_value (gdbarch, func_type, type, regcache,
+      return m68k_svr4_return_value (gdbarch, function, type, regcache,
                                     readbuf, writebuf);
     }
 
@@ -856,7 +853,6 @@ m68k_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
 {
   struct m68k_frame_cache cache;
   CORE_ADDR pc;
-  int op;
 
   cache.locals = -1;
   pc = m68k_analyze_prologue (gdbarch, start_pc, (CORE_ADDR) -1, &cache);
@@ -976,6 +972,7 @@ m68k_frame_prev_register (struct frame_info *this_frame, void **this_cache,
 static const struct frame_unwind m68k_frame_unwind =
 {
   NORMAL_FRAME,
+  default_frame_unwind_stop_reason,
   m68k_frame_this_id,
   m68k_frame_prev_register,
   NULL,
@@ -1052,6 +1049,16 @@ m68k_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
 }
 \f
 
+/* This is the implementation of gdbarch method
+   return_in_first_hidden_param_p.  */
+
+static int
+m68k_return_in_first_hidden_param_p (struct gdbarch *gdbarch,
+                                    struct type *type)
+{
+  return 0;
+}
+
 /* System V Release 4 (SVR4).  */
 
 void
@@ -1091,9 +1098,6 @@ m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
       feature = tdesc_find_feature (info.target_desc,
                                    "org.gnu.gdb.m68k.core");
-      if (feature != NULL)
-       /* Do nothing.  */
-       ;
 
       if (feature == NULL)
        {
@@ -1237,6 +1241,8 @@ m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   /* Function call & return.  */
   set_gdbarch_push_dummy_call (gdbarch, m68k_push_dummy_call);
   set_gdbarch_return_value (gdbarch, m68k_return_value);
+  set_gdbarch_return_in_first_hidden_param_p (gdbarch,
+                                             m68k_return_in_first_hidden_param_p);
 
 
   /* Disassembler.  */