* dsrec.c (load_srec, make_srec): Use bfd_get_section_size instead of
[binutils-gdb.git] / gdb / mcore-tdep.c
index af1900a9ce2a86e87701330322eff6a4e2343aa7..1c9eafe1872538e6fca1681ef113678433b8dfec 100644 (file)
@@ -1,5 +1,7 @@
 /* Target-machine dependent code for Motorola MCore for GDB, the GNU debugger
-   Copyright 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+
+   Copyright 1999, 2000, 2001, 2002, 2003, 2004 Free Software
+   Foundation, Inc.
 
    This file is part of GDB.
 
@@ -23,7 +25,7 @@
 #include "value.h"
 #include "gdbcmd.h"
 #include "regcache.h"
-#include "symfile.h"
+#include "objfiles.h"
 #include "gdbcore.h"
 #include "inferior.h"
 #include "arch-utils.h"
@@ -246,25 +248,16 @@ mcore_reg_struct_has_addr (int gcc_p, struct type *type)
 static struct frame_info *
 analyze_dummy_frame (CORE_ADDR pc, CORE_ADDR frame)
 {
-  static struct frame_info *dummy = NULL;
-
-  if (dummy == NULL)
-    {
-      struct frame_extra_info *extra_info;
-      CORE_ADDR *saved_regs;
-      dummy = deprecated_frame_xmalloc ();
-      saved_regs = (CORE_ADDR *) xmalloc (SIZEOF_FRAME_SAVED_REGS);
-      deprecated_set_frame_saved_regs_hack (dummy, saved_regs);
-      extra_info = XMALLOC (struct frame_extra_info);
-      deprecated_set_frame_extra_info_hack (dummy, extra_info);
-    }
-
+  struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
+  struct frame_info *dummy
+    = deprecated_frame_xmalloc_with_cleanup (SIZEOF_FRAME_SAVED_REGS,
+                                            sizeof (struct frame_extra_info));
   deprecated_update_frame_pc_hack (dummy, pc);
   deprecated_update_frame_base_hack (dummy, frame);
   get_frame_extra_info (dummy)->status = 0;
   get_frame_extra_info (dummy)->framesize = 0;
-  memset (deprecated_get_frame_saved_regs (dummy), '\000', SIZEOF_FRAME_SAVED_REGS);
   mcore_analyze_prologue (dummy, 0, 0);
+  do_cleanups (old_chain);
   return dummy;
 }
 
@@ -720,8 +713,7 @@ mcore_find_callers_reg (struct frame_info *fi, int regnum)
 {
   for (; fi != NULL; fi = get_next_frame (fi))
     {
-      if (DEPRECATED_PC_IN_CALL_DUMMY (get_frame_pc (fi), get_frame_base (fi),
-                                      get_frame_base (fi)))
+      if (deprecated_pc_in_call_dummy (get_frame_pc (fi)))
        return deprecated_read_register_dummy (get_frame_pc (fi),
                                               get_frame_base (fi), regnum);
       else if (deprecated_get_frame_saved_regs (fi)[regnum] != 0)
@@ -738,8 +730,7 @@ static CORE_ADDR
 mcore_frame_saved_pc (struct frame_info * fi)
 {
 
-  if (DEPRECATED_PC_IN_CALL_DUMMY (get_frame_pc (fi), get_frame_base (fi),
-                                  get_frame_base (fi)))
+  if (deprecated_pc_in_call_dummy (get_frame_pc (fi)))
     return deprecated_read_register_dummy (get_frame_pc (fi),
                                           get_frame_base (fi), PC_REGNUM);
   else
@@ -757,9 +748,8 @@ mcore_pop_frame (void)
   int rn;
   struct frame_info *fi = get_current_frame ();
 
-  if (DEPRECATED_PC_IN_CALL_DUMMY (get_frame_pc (fi), get_frame_base (fi),
-                                  get_frame_base (fi)))
-    generic_pop_dummy_frame ();
+  if (deprecated_pc_in_call_dummy (get_frame_pc (fi)))
+    deprecated_pop_dummy_frame ();
   else
     {
       /* Write out the PC we saved. */
@@ -926,16 +916,13 @@ mcore_push_return_address (CORE_ADDR pc, CORE_ADDR sp)
    argument.
 
    For gdb, this leaves us two routes, based on what
-   USE_STRUCT_CONVENTION (mcore_use_struct_convention) returns.
-   If this macro returns 1, gdb will call STORE_STRUCT_RETURN and
-   EXTRACT_STRUCT_VALUE_ADDRESS.
-
-   If USE_STRUCT_CONVENTION retruns 0, then gdb uses STORE_RETURN_VALUE
-   and EXTRACT_RETURN_VALUE to store/fetch the functions return value. */
+   USE_STRUCT_CONVENTION (mcore_use_struct_convention) returns.  If
+   this macro returns 1, gdb will call STORE_STRUCT_RETURN to store
+   the return value.
 
-/* Should we use EXTRACT_STRUCT_VALUE_ADDRESS instead of
-   EXTRACT_RETURN_VALUE?  GCC_P is true if compiled with gcc
-   and TYPE is the type (which is known to be struct, union or array). */
+   If USE_STRUCT_CONVENTION returns 0, then gdb uses
+   STORE_RETURN_VALUE and EXTRACT_RETURN_VALUE to store/fetch the
+   functions return value.  */
 
 static int
 mcore_use_struct_convention (int gcc_p, struct type *type)
@@ -943,16 +930,6 @@ mcore_use_struct_convention (int gcc_p, struct type *type)
   return (TYPE_LENGTH (type) > 8);
 }
 
-/* Where is the return value saved? For MCore, a pointer to 
-   this buffer was passed as a hidden first argument, so
-   just return that address. */
-
-static CORE_ADDR
-mcore_extract_struct_value_address (char *regbuf)
-{
-  return extract_unsigned_integer (regbuf + DEPRECATED_REGISTER_BYTE (FIRST_ARGREG), DEPRECATED_REGISTER_SIZE);
-}
-
 /* Given a function which returns a value of type TYPE, extract the
    the function's return value and place the result into VALBUF.
    REGBUF is the register contents of the target. */
@@ -1015,8 +992,7 @@ mcore_init_extra_frame_info (int fromleaf, struct frame_info *fi)
   get_frame_extra_info (fi)->status = 0;
   get_frame_extra_info (fi)->framesize = 0;
 
-  if (DEPRECATED_PC_IN_CALL_DUMMY (get_frame_pc (fi), get_frame_base (fi),
-                                  get_frame_base (fi)))
+  if (deprecated_pc_in_call_dummy (get_frame_pc (fi)))
     {
       /* We need to setup fi->frame here because call_function_by_hand
          gets it wrong by assuming it's always FP.  */
@@ -1042,7 +1018,6 @@ get_insn (CORE_ADDR pc)
 static struct gdbarch *
 mcore_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 {
-  static LONGEST call_dummy_words[7] = { };
   struct gdbarch_tdep *tdep = NULL;
   struct gdbarch *gdbarch;
 
@@ -1061,8 +1036,6 @@ mcore_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   /* All registers are 32 bits */
   set_gdbarch_deprecated_register_size (gdbarch, MCORE_REG_SIZE);
-  set_gdbarch_deprecated_max_register_raw_size (gdbarch, MCORE_REG_SIZE);
-  set_gdbarch_deprecated_max_register_virtual_size (gdbarch, MCORE_REG_SIZE);
   set_gdbarch_register_name (gdbarch, mcore_register_name);
   set_gdbarch_deprecated_register_virtual_type (gdbarch, mcore_register_virtual_type);
   set_gdbarch_deprecated_register_virtual_size (gdbarch, mcore_register_size);
@@ -1076,12 +1049,7 @@ mcore_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   /* Call Dummies:  */
 
-  set_gdbarch_deprecated_call_dummy_words (gdbarch, call_dummy_words);
-  set_gdbarch_deprecated_sizeof_call_dummy_words (gdbarch, 0);
-  set_gdbarch_deprecated_save_dummy_frame_tos (gdbarch, generic_save_dummy_frame_tos);
   set_gdbarch_deprecated_saved_pc_after_call (gdbarch, mcore_saved_pc_after_call);
-  set_gdbarch_function_start_offset (gdbarch, 0);
-  set_gdbarch_decr_pc_after_break (gdbarch, 0);
   set_gdbarch_breakpoint_from_pc (gdbarch, mcore_breakpoint_from_pc);
   set_gdbarch_deprecated_push_return_address (gdbarch, mcore_push_return_address);
   set_gdbarch_deprecated_push_arguments (gdbarch, mcore_push_arguments);
@@ -1096,10 +1064,7 @@ mcore_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_deprecated_extract_return_value (gdbarch, 
                                               mcore_extract_return_value);
   set_gdbarch_deprecated_store_struct_return (gdbarch, mcore_store_struct_return);
-  set_gdbarch_deprecated_extract_struct_value_address (gdbarch, 
-                                                      mcore_extract_struct_value_address);
   set_gdbarch_skip_prologue (gdbarch, mcore_skip_prologue);
-  set_gdbarch_frame_args_skip (gdbarch, 0);
   set_gdbarch_deprecated_frame_args_address (gdbarch, mcore_frame_args_address);
   set_gdbarch_deprecated_frame_locals_address (gdbarch, mcore_frame_locals_address);
   set_gdbarch_deprecated_pop_frame (gdbarch, mcore_pop_frame);