2003-01-31 Frank Ch. Eigler <fche@redhat.com>
[deliverable/binutils-gdb.git] / gdb / m32r-tdep.c
index cb5d9c32e860778e541ae6c0788484e63af12c5c..64842347ccfc642c26a8c127f09c96f9994dd496 100644 (file)
@@ -1,5 +1,7 @@
 /* Target-dependent code for the Mitsubishi m32r for GDB, the GNU debugger.
-   Copyright 1996, Free Software Foundation, Inc.
+
+   Copyright 1996, 1998, 1999, 2000, 2001, 2003 Free Software
+   Foundation, Inc.
 
    This file is part of GDB.
 
 #include "defs.h"
 #include "frame.h"
 #include "inferior.h"
-#include "obstack.h"
 #include "target.h"
 #include "value.h"
 #include "bfd.h"
 #include "gdb_string.h"
 #include "gdbcore.h"
 #include "symfile.h"
+#include "regcache.h"
 
 /* Function: m32r_use_struct_convention
    Return nonzero if call_function should allocate stack space for a
    struct return? */
 int
-m32r_use_struct_convention (gcc_p, type)
-     int gcc_p;
-     struct type *type;
+m32r_use_struct_convention (int gcc_p, struct type *type)
 {
   return (TYPE_LENGTH (type) > 8);
 }
@@ -46,9 +46,8 @@ m32r_use_struct_convention (gcc_p, type)
    an empty frame_saved_regs, so I guess that's better than total failure */
 
 void
-m32r_frame_find_saved_regs (fi, regaddr)
-     struct frame_info *fi;
-     struct frame_saved_regs *regaddr;
+m32r_frame_find_saved_regs (struct frame_info *fi,
+                           struct frame_saved_regs *regaddr)
 {
   memcpy (regaddr, &fi->fsr, sizeof (struct frame_saved_regs));
 }
@@ -62,7 +61,7 @@ dump_insn (char *commnt, CORE_ADDR pc, int insn)
 {
   printf_filtered ("  %s %08x %08x ",
                   commnt, (unsigned int) pc, (unsigned int) insn);
-  (*tm_print_insn) (pc, &tm_print_insn_info);
+  TARGET_PRINT_INSN (pc, &tm_print_insn_info);
   printf_filtered ("\n");
 }
 #define insn_debug(args) { printf_filtered args; }
@@ -109,15 +108,9 @@ dump_insn (char *commnt, CORE_ADDR pc, int insn)
  */
 
 static void
-decode_prologue (start_pc, scan_limit,
-                pl_endptr, framelength,
-                fi, fsr)
-     CORE_ADDR start_pc;
-     CORE_ADDR scan_limit;
-     CORE_ADDR *pl_endptr;     /* var parameter */
-     unsigned long *framelength;
-     struct frame_info *fi;
-     struct frame_saved_regs *fsr;
+decode_prologue (CORE_ADDR start_pc, CORE_ADDR scan_limit, CORE_ADDR *pl_endptr,       /* var parameter */
+                unsigned long *framelength, struct frame_info *fi,
+                struct frame_saved_regs *fsr)
 {
   unsigned long framesize;
   int insn;
@@ -309,8 +302,7 @@ decode_prologue (start_pc, scan_limit,
    Find end of function prologue */
 
 CORE_ADDR
-m32r_skip_prologue (pc)
-     CORE_ADDR pc;
+m32r_skip_prologue (CORE_ADDR pc)
 {
   CORE_ADDR func_addr, func_end;
   struct symtab_and_line sal;
@@ -344,9 +336,7 @@ m32r_skip_prologue (pc)
 }
 
 static unsigned long
-m32r_scan_prologue (fi, fsr)
-     struct frame_info *fi;
-     struct frame_saved_regs *fsr;
+m32r_scan_prologue (struct frame_info *fi, struct frame_saved_regs *fsr)
 {
   struct symtab_and_line sal;
   CORE_ADDR prologue_start, prologue_end, current_pc;
@@ -389,8 +379,7 @@ m32r_scan_prologue (fi, fsr)
    examine the prologue.  */
 
 void
-m32r_init_extra_frame_info (fi)
-     struct frame_info *fi;
+m32r_init_extra_frame_info (struct frame_info *fi)
 {
   int reg;
 
@@ -399,11 +388,12 @@ m32r_init_extra_frame_info (fi)
 
   memset (fi->fsr.regs, '\000', sizeof fi->fsr.regs);
 
-  if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
+  if (DEPRECATED_PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
     {
       /* We need to setup fi->frame here because run_stack_dummy gets it wrong
          by assuming it's always FP.  */
-      fi->frame = generic_read_register_dummy (fi->pc, fi->frame, SP_REGNUM);
+      fi->frame = deprecated_read_register_dummy (fi->pc, fi->frame,
+                                                 SP_REGNUM);
       fi->framesize = 0;
       return;
     }
@@ -430,31 +420,28 @@ m32r_init_extra_frame_info (fi)
     }
 }
 
-/* Function: mn10300_virtual_frame_pointer
+/* Function: m32r_virtual_frame_pointer
    Return the register that the function uses for a frame pointer, 
    plus any necessary offset to be applied to the register before
    any frame pointer offsets.  */
 
 void
-m32r_virtual_frame_pointer (pc, reg, offset)
-     CORE_ADDR pc;
-     long *reg;
-     long *offset;
+m32r_virtual_frame_pointer (CORE_ADDR pc, long *reg, long *offset)
 {
-  struct frame_info fi;
+  struct frame_info *fi = deprecated_frame_xmalloc ();
+  struct cleanup *old_chain = make_cleanup (xfree, fi);
 
   /* Set up a dummy frame_info. */
-  fi.next = NULL;
-  fi.prev = NULL;
-  fi.frame = 0;
-  fi.pc = pc;
+  fi->next = NULL;
+  fi->prev = NULL;
+  fi->frame = 0;
+  fi->pc = pc;
 
   /* Analyze the prolog and fill in the extra info.  */
-  m32r_init_extra_frame_info (&fi);
-
+  m32r_init_extra_frame_info (fi);
 
   /* Results will tell us which type of frame it uses.  */
-  if (fi.using_frame_pointer)
+  if (fi->using_frame_pointer)
     {
       *reg = FP_REGNUM;
       *offset = 0;
@@ -464,6 +451,7 @@ m32r_virtual_frame_pointer (pc, reg, offset)
       *reg = SP_REGNUM;
       *offset = 0;
     }
+  do_cleanups (old_chain);
 }
 
 /* Function: find_callers_reg
@@ -474,39 +462,36 @@ m32r_virtual_frame_pointer (pc, reg, offset)
    caller-saves registers for an inner frame.  */
 
 CORE_ADDR
-m32r_find_callers_reg (fi, regnum)
-     struct frame_info *fi;
-     int regnum;
+m32r_find_callers_reg (struct frame_info *fi, int regnum)
 {
   for (; fi; fi = fi->next)
-    if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
-      return generic_read_register_dummy (fi->pc, fi->frame, regnum);
+    if (DEPRECATED_PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
+      return deprecated_read_register_dummy (fi->pc, fi->frame, regnum);
     else if (fi->fsr.regs[regnum] != 0)
       return read_memory_integer (fi->fsr.regs[regnum],
                                  REGISTER_RAW_SIZE (regnum));
   return read_register (regnum);
 }
 
-/* Function: frame_chain
-   Given a GDB frame, determine the address of the calling function's frame.
-   This will be used to create a new GDB frame struct, and then
-   INIT_EXTRA_FRAME_INFO and INIT_FRAME_PC will be called for the new frame.
-   For m32r, we save the frame size when we initialize the frame_info.  */
+/* Function: frame_chain Given a GDB frame, determine the address of
+   the calling function's frame.  This will be used to create a new
+   GDB frame struct, and then INIT_EXTRA_FRAME_INFO and
+   DEPRECATED_INIT_FRAME_PC will be called for the new frame.  For
+   m32r, we save the frame size when we initialize the frame_info.  */
 
 CORE_ADDR
-m32r_frame_chain (fi)
-     struct frame_info *fi;
+m32r_frame_chain (struct frame_info *fi)
 {
   CORE_ADDR fn_start, callers_pc, fp;
 
   /* is this a dummy frame? */
-  if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
+  if (DEPRECATED_PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
     return fi->frame;          /* dummy frame same as caller's frame */
 
   /* is caller-of-this a dummy frame? */
   callers_pc = FRAME_SAVED_PC (fi);    /* find out who called us: */
   fp = m32r_find_callers_reg (fi, FP_REGNUM);
-  if (PC_IN_CALL_DUMMY (callers_pc, fp, fp))
+  if (DEPRECATED_PC_IN_CALL_DUMMY (callers_pc, fp, fp))
     return fp;                 /* dummy frame's frame may bear no relation to ours */
 
   if (find_pc_partial_function (fi->pc, 0, &fn_start, 0))
@@ -529,9 +514,7 @@ m32r_frame_chain (fi)
    (ie. when using an empty CALL_DUMMY) */
 
 CORE_ADDR
-m32r_push_return_address (pc, sp)
-     CORE_ADDR pc;
-     CORE_ADDR sp;
+m32r_push_return_address (CORE_ADDR pc, CORE_ADDR sp)
 {
   write_register (RP_REGNUM, CALL_DUMMY_ADDRESS ());
   return sp;
@@ -543,12 +526,11 @@ m32r_push_return_address (pc, sp)
    restoring all saved registers.  */
 
 struct frame_info *
-m32r_pop_frame (frame)
-     struct frame_info *frame;
+m32r_pop_frame (struct frame_info *frame)
 {
   int regnum;
 
-  if (PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame))
+  if (DEPRECATED_PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame))
     generic_pop_dummy_frame ();
   else
     {
@@ -573,11 +555,10 @@ m32r_pop_frame (frame)
    in the stack anywhere, otherwise we get it from the registers. */
 
 CORE_ADDR
-m32r_frame_saved_pc (fi)
-     struct frame_info *fi;
+m32r_frame_saved_pc (struct frame_info *fi)
 {
-  if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
-    return generic_read_register_dummy (fi->pc, fi->frame, PC_REGNUM);
+  if (DEPRECATED_PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame))
+    return deprecated_read_register_dummy (fi->pc, fi->frame, PC_REGNUM);
   else
     return m32r_find_callers_reg (fi, RP_REGNUM);
 }
@@ -614,12 +595,8 @@ m32r_frame_saved_pc (fi)
    passed as an implicit first argument, always in R0. */
 
 CORE_ADDR
-m32r_push_arguments (nargs, args, sp, struct_return, struct_addr)
-     int nargs;
-     value_ptr *args;
-     CORE_ADDR sp;
-     unsigned char struct_return;
-     CORE_ADDR struct_addr;
+m32r_push_arguments (int nargs, struct value **args, CORE_ADDR sp,
+                    unsigned char struct_return, CORE_ADDR struct_addr)
 {
   int stack_offset, stack_alloc;
   int argreg;
@@ -700,14 +677,8 @@ m32r_push_arguments (nargs, args, sp, struct_return, struct_addr)
    is the target of the target function call.  */
 
 void
-m32r_fix_call_dummy (dummy, pc, fun, nargs, args, type, gcc_p)
-     char *dummy;
-     CORE_ADDR pc;
-     CORE_ADDR fun;
-     int nargs;
-     value_ptr *args;
-     struct type *type;
-     int gcc_p;
+m32r_fix_call_dummy (char *dummy, CORE_ADDR pc, CORE_ADDR fun, int nargs,
+                    struct value **args, struct type *type, int gcc_p)
 {
   /* ld24 r8, <(imm24) fun> */
   *(unsigned long *) (dummy) = (fun & 0x00ffffff) | 0xe8000000;
@@ -719,8 +690,7 @@ m32r_fix_call_dummy (dummy, pc, fun, nargs, args, type, gcc_p)
    we must actually write one of those two as well, depending on PSW. */
 
 void
-m32r_write_sp (val)
-     CORE_ADDR val;
+m32r_write_sp (CORE_ADDR val)
 {
   unsigned long psw = read_register (PSW_REGNUM);
 
@@ -732,7 +702,7 @@ m32r_write_sp (val)
 }
 
 void
-_initialize_m32r_tdep ()
+_initialize_m32r_tdep (void)
 {
   tm_print_insn = print_insn_m32r;
 }
This page took 0.027766 seconds and 4 git commands to generate.