* monitor.c (monitor_load_srec monitor_make_srec): Move all
[binutils-gdb.git] / gdb / sh-tdep.c
index 389b153273b8094d78e53f8527bb866f8aad8779..a56c826e9fb6798c1849262d60413caad9246182 100644 (file)
@@ -1,5 +1,5 @@
-/* Target-machine dependent code for Hitachi Super-H, for GDB.
-   Copyright (C) 1993 Free Software Foundation, Inc.
+/* Target-dependent code for Hitachi Super-H, for GDB.
+   Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
 
 This file is part of GDB.
 
@@ -15,7 +15,7 @@ GNU General Public License for more details.
 
 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., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 /*
  Contributed by Steve Chamberlain
@@ -28,11 +28,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "gdbcmd.h"
+#include "gdbcore.h"
 #include "value.h"
 #include "dis-asm.h"
-#include "../opcodes/sh-opc.h"
-
-
 
 /* Prologue looks like
    [mov.l      <regs>,@-r15]...
@@ -74,22 +72,19 @@ sh_skip_prologue (start_pc)
   return start_pc;
 }
 
-/* Disassemble an instruction */
+/* Disassemble an instruction */
 
 int
-print_insn (memaddr, stream)
-     CORE_ADDR memaddr;
-     GDB_FILE *stream;
+gdb_print_insn_sh (memaddr, info)
+     bfd_vma memaddr;
+     disassemble_info *info;
 {
-  disassemble_info info;
-
-  GDB_INIT_DISASSEMBLE_INFO (info, stream);
-
   if (TARGET_BYTE_ORDER == BIG_ENDIAN)
-    return print_insn_sh (memaddr, &info);
+    return print_insn_sh (memaddr, info);
   else
-    return print_insn_shl (memaddr, &info);
+    return print_insn_shl (memaddr, info);
 }
+
 /* 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.
@@ -107,12 +102,11 @@ sh_frame_chain (frame)
     return 0;
 }
 
-/* Put here the code to store, into a struct frame_saved_regs,
-   the addresses of the saved registers of frame described by FRAME_INFO.
+/* Put here the code to store, into a struct frame_saved_regs, the
+   addresses of the saved registers of frame described by FRAME_INFO.
    This includes special registers such as pc and fp saved in special
-   ways in the stack frame.  sp is even more special:
-   the address we return for it IS the sp for the next frame. */
-
+   ways in the stack frame.  sp is even more special: the address we
+   return for it IS the sp for the next frame. */
 
 void
 frame_find_saved_regs (fi, fsr)
@@ -126,7 +120,6 @@ frame_find_saved_regs (fi, fsr)
   int pc;
   int opc;
   int insn;
-  int hadf;
   int r3_val = 0;
 
   opc = pc = get_pc_function_start (fi->pc);
@@ -220,23 +213,11 @@ frame_find_saved_regs (fi, fsr)
   fi->f_offset = depth - where[FP_REGNUM] - 4;
   /* Work out the return pc - either from the saved pr or the pr
      value */
-  /* Just called, so dig out the real return */
-  if (fi->return_pc == 0)
-    {
-      fi->return_pc = read_register (PR_REGNUM) + 4;
-    }
-  else
-    {
 
-      if (fsr->regs[PR_REGNUM])
-       {
-         fi->return_pc = read_memory_integer (fsr->regs[PR_REGNUM], 4) + 4;
-       }
-      else
-       {
-         fi->return_pc = read_register (PR_REGNUM) + 4;
-       }
-    }
+  if (fsr->regs[PR_REGNUM])
+    fi->return_pc = read_memory_integer (fsr->regs[PR_REGNUM], 4);
+  else
+    fi->return_pc = read_register (PR_REGNUM);
 }
 
 /* initialize the extra info saved in a FRAME */
@@ -247,6 +228,10 @@ init_extra_frame_info (fromleaf, fi)
      struct frame_info *fi;
 {
   struct frame_saved_regs dummy;
+
+  if (fi->next)
+    fi->pc = fi->next->return_pc;
+
   frame_find_saved_regs (fi, &dummy);
 }
 
@@ -313,17 +298,10 @@ show_regs (args, from_tty)
                   read_register (15));
 }
 \f
-
 void
 _initialize_sh_tdep ()
 {
-  extern int sim_memory_size;
-  /* FIXME, there should be a way to make a CORE_ADDR variable settable. */
-  add_show_from_set
-    (add_set_cmd ("memory_size", class_support, var_uinteger,
-                 (char *) &sim_memory_size,
-               "Set simulated memory size of simulator target.", &setlist),
-     &showlist);
+  tm_print_insn = gdb_print_insn_sh;
 
   add_com ("regs", class_vars, show_regs, "Print all registers");
 }