2002-11-02 Andrew Cagney <cagney@redhat.com>
[deliverable/binutils-gdb.git] / gdb / rs6000-tdep.c
index a650f68ac92fcb8fc78ef80aed1c29002354e28a..d3ad2a5c955e3fa8341534b04dbc52199a8a6c2f 100644 (file)
@@ -465,6 +465,7 @@ skip_prologue (CORE_ADDR pc, CORE_ADDR lim_pc, struct rs6000_framedata *fdata)
   int prev_insn_was_prologue_insn = 1;
   int num_skip_non_prologue_insns = 0;
   const struct bfd_arch_info *arch_info = gdbarch_bfd_arch_info (current_gdbarch);
+  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
   
   /* Attempt to find the end of the prologue when no limit is specified.
      Note that refine_prologue_limit() has been written so that it may
@@ -694,7 +695,7 @@ skip_prologue (CORE_ADDR pc, CORE_ADDR lim_pc, struct rs6000_framedata *fdata)
        {                       /* mr r31, r1 */
          fdata->frameless = 0;
          framep = 1;
-         fdata->alloca_reg = 31;
+         fdata->alloca_reg = (tdep->ppc_gp0_regnum + 31);
          continue;
 
          /* Another way to set up the frame pointer.  */
@@ -703,7 +704,8 @@ skip_prologue (CORE_ADDR pc, CORE_ADDR lim_pc, struct rs6000_framedata *fdata)
        {                       /* addi rX, r1, 0x0 */
          fdata->frameless = 0;
          framep = 1;
-         fdata->alloca_reg = (op & ~0x38010000) >> 21;
+         fdata->alloca_reg = (tdep->ppc_gp0_regnum
+                              + ((op & ~0x38010000) >> 21));
          continue;
        }
       /* AltiVec related instructions.  */
@@ -1032,6 +1034,13 @@ rs6000_fix_call_dummy (char *dummyname, CORE_ADDR pc, CORE_ADDR fun,
     }
 }
 
+/* All the ABI's require 16 byte alignment.  */
+static CORE_ADDR
+rs6000_frame_align (struct gdbarch *gdbarch, CORE_ADDR addr)
+{
+  return (addr & -16);
+}
+
 /* Pass the arguments in either registers, or in the stack. In RS/6000,
    the first eight words of the argument list (that might be less than
    eight parameters if some parameters occupy more than one word) are
@@ -1363,13 +1372,6 @@ rs6000_extract_return_value (struct type *valtype, char *regbuf, char *valbuf)
     }
 }
 
-/* Keep structure return address in this variable.
-   FIXME:  This is a horrid kludge which should not be allowed to continue
-   living.  This only allows a single nested call to a structure-returning
-   function.  Come on, guys!  -- gnu@cygnus.com, Aug 92  */
-
-static CORE_ADDR rs6000_struct_return_address;
-
 /* Return whether handle_inferior_event() should proceed through code
    starting at PC in function NAME when stepping.
 
@@ -1741,7 +1743,9 @@ rs6000_frame_chain (struct frame_info *thisframe)
   int wordsize = gdbarch_tdep (current_gdbarch)->wordsize;
 
   if (PC_IN_CALL_DUMMY (thisframe->pc, thisframe->frame, thisframe->frame))
-    return thisframe->frame;   /* dummy frame same as caller's frame */
+    /* A dummy frame always correctly chains back to the previous
+       frame.  */
+    return read_memory_addr ((thisframe)->frame, wordsize);
 
   if (inside_entry_file (thisframe->pc) ||
       thisframe->pc == entry_point_address ())
@@ -1758,13 +1762,6 @@ rs6000_frame_chain (struct frame_info *thisframe)
     fp = FRAME_FP (thisframe);
   else
     fp = read_memory_addr ((thisframe)->frame, wordsize);
-
-  lr = read_register (gdbarch_tdep (current_gdbarch)->ppc_lr_regnum);
-  if (lr == entry_point_address ())
-    if (fp != 0 && (fpp = read_memory_addr (fp, wordsize)) != 0)
-      if (PC_IN_CALL_DUMMY (lr, fpp, fpp))
-       return fpp;
-
   return fp;
 }
 
@@ -1989,18 +1986,13 @@ rs6000_stab_reg_to_regnum (int num)
 }
 
 /* Store the address of the place in which to copy the structure the
-   subroutine will return.  This is called from call_function.
-
-   In RS/6000, struct return addresses are passed as an extra parameter in r3.
-   In function return, callee is not responsible of returning this address
-   back.  Since gdb needs to find it, we will store in a designated variable
-   `rs6000_struct_return_address'.  */
+   subroutine will return.  */
 
 static void
 rs6000_store_struct_return (CORE_ADDR addr, CORE_ADDR sp)
 {
-  write_register (3, addr);
-  rs6000_struct_return_address = addr;
+  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
+  write_register (tdep->ppc_gp0_regnum + 3, addr);
 }
 
 /* Write into appropriate registers a function return value
@@ -2022,7 +2014,7 @@ e500_store_return_value (struct type *type, char *valbuf)
 
       memcpy (reg_val_buf, valbuf + copied, reg_size);
       copied += reg_size;
-      write_register_gen (regnum, reg_val_buf);
+      deprecated_write_register_gen (regnum, reg_val_buf);
       i++;
     }
 }
@@ -2058,9 +2050,20 @@ rs6000_store_return_value (struct type *type, char *valbuf)
    as a CORE_ADDR (or an expression that can be used as one).  */
 
 static CORE_ADDR
-rs6000_extract_struct_value_address (char *regbuf)
-{
-  return rs6000_struct_return_address;
+rs6000_extract_struct_value_address (struct regcache *regcache)
+{
+  /* FIXME: cagney/2002-09-26: PR gdb/724: When making an inferior
+     function call GDB knows the address of the struct return value
+     and hence, should not need to call this function.  Unfortunately,
+     the current hand_function_call() code only saves the most recent
+     struct address leading to occasional calls.  The code should
+     instead maintain a stack of such addresses (in the dummy frame
+     object).  */
+  /* NOTE: cagney/2002-09-26: Return 0 which indicates that we've
+     really got no idea where the return value is being stored.  While
+     r3, on function entry, contained the address it will have since
+     been reused (scratch) and hence wouldn't be valid */
+  return 0;
 }
 
 /* Return whether PC is in a dummy function call.
@@ -2793,7 +2796,7 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
        break;
       case bfd_mach_ppc_7400:
        tdep->ppc_vr0_regnum = 119;
-       tdep->ppc_vrsave_regnum = 153;
+       tdep->ppc_vrsave_regnum = 152;
        tdep->ppc_ev0_regnum = -1;
        tdep->ppc_ev31_regnum = -1;
        break;
@@ -2887,6 +2890,7 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_call_dummy_stack_adjust_p (gdbarch, 0);
   set_gdbarch_get_saved_register (gdbarch, generic_unwind_get_saved_register);
   set_gdbarch_fix_call_dummy (gdbarch, rs6000_fix_call_dummy);
+  set_gdbarch_frame_align (gdbarch, rs6000_frame_align);
   set_gdbarch_push_dummy_frame (gdbarch, generic_push_dummy_frame);
   set_gdbarch_save_dummy_frame_tos (gdbarch, generic_save_dummy_frame_tos);
   set_gdbarch_push_return_address (gdbarch, ppc_push_return_address);
@@ -2910,7 +2914,7 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
     set_gdbarch_push_arguments (gdbarch, rs6000_push_arguments);
 
   set_gdbarch_store_struct_return (gdbarch, rs6000_store_struct_return);
-  set_gdbarch_deprecated_extract_struct_value_address (gdbarch, rs6000_extract_struct_value_address);
+  set_gdbarch_extract_struct_value_address (gdbarch, rs6000_extract_struct_value_address);
   set_gdbarch_pop_frame (gdbarch, rs6000_pop_frame);
 
   set_gdbarch_skip_prologue (gdbarch, rs6000_skip_prologue);
This page took 0.032904 seconds and 4 git commands to generate.