daily update
[deliverable/binutils-gdb.git] / gdb / ns32k-tdep.c
index fc166de5ee01963327a31649fc000de83981696b..e9bbfc479a985db9c16598ecbdde394bdaaaf958 100644 (file)
@@ -1,5 +1,5 @@
 /* Print NS 32000 instructions for GDB, the GNU debugger.
-   Copyright 1986, 1988, 1991, 1992, 1994, 1995
+   Copyright 1986, 1988, 1991, 1992, 1994, 1995, 1998, 1999, 2000, 2001
    Free Software Foundation, Inc.
 
    This file is part of GDB.
    Boston, MA 02111-1307, USA.  */
 
 #include "defs.h"
+#include "frame.h"
+#include "gdbcore.h"
+
+static int sign_extend (int value, int bits);
 
 void
-_initialize_ns32k_tdep ()
+_initialize_ns32k_tdep (void)
 {
   tm_print_insn = print_insn_ns32k;
 }
@@ -31,26 +35,7 @@ _initialize_ns32k_tdep ()
    to reach some "real" code.  */
 
 CORE_ADDR
-merlin_skip_prologue (pc)
-     CORE_ADDR pc;
-{
-  register int op = read_memory_integer (pc, 1);
-  if (op == 0x82)
-    {
-      op = read_memory_integer (pc + 2, 1);
-      if ((op & 0x80) == 0)
-       pc += 3;
-      else if ((op & 0xc0) == 0x80)
-       pc += 4;
-      else
-       pc += 6;
-    }
-  return pc;
-}
-
-CORE_ADDR
-umax_skip_prologue (pc)
-     CORE_ADDR pc;
+umax_skip_prologue (CORE_ADDR pc)
 {
   register unsigned char op = read_memory_integer (pc, 1);
   if (op == 0x82)
@@ -66,51 +51,14 @@ umax_skip_prologue (pc)
   return pc;
 }
 
-/* Return number of args passed to a frame.
-   Can return -1, meaning no way to tell.  */
-
-int
-merlin_frame_num_args (fi)
-     struct frame_info *fi;
-{
-  int numargs;
-  CORE_ADDR pc;
-  int insn;
-  int addr_mode;
-  int width;
-
-  pc = FRAME_SAVED_PC (fi);
-  insn = read_memory_integer (pc, 2);
-  addr_mode = (insn >> 11) & 0x1f;
-  insn = insn & 0x7ff;
-  if ((insn & 0x7fc) == 0x57c
-      && addr_mode == 0x14)    /* immediate */
-    {
-      if (insn == 0x57c)       /* adjspb */
-       width = 1;
-      else if (insn == 0x57d)  /* adjspw */
-       width = 2;
-      else if (insn == 0x57f)  /* adjspd */
-       width = 4;
-      numargs = read_memory_integer (pc + 2, width);
-      if (width > 1)
-       flip_bytes (&numargs, width);
-      numargs = -sign_extend (numargs, width * 8) / 4;
-    }
-  else
-    numargs = -1;
-  return numargs;
-}
-
-
 /* Return number of args passed to a frame.
    Can return -1, meaning no way to tell.
    Encore's C compiler often reuses same area on stack for args,
    so this will often not work properly.  If the arg names
    are known, it's likely most of them will be printed. */
+
 int
-umax_frame_num_args (fi)
-     struct frame_info *fi;
+umax_frame_num_args (struct frame_info *fi)
 {
   int numargs;
   CORE_ADDR pc;
@@ -138,6 +86,8 @@ umax_frame_num_args (fi)
            width = 2;
          else if (insn == 0x57f)       /* adjspd */
            width = 4;
+         else
+           internal_error (__FILE__, __LINE__, "bad else");
          numargs = read_memory_integer (pc + 2, width);
          if (width > 1)
            flip_bytes (&numargs, width);
@@ -147,8 +97,8 @@ umax_frame_num_args (fi)
   return numargs;
 }
 
-
-sign_extend (value, bits)
+static int
+sign_extend (int value, int bits)
 {
   value = value & ((1 << bits) - 1);
   return (value & (1 << (bits - 1))
@@ -157,11 +107,10 @@ sign_extend (value, bits)
 }
 
 void
-flip_bytes (ptr, count)
-     char *ptr;
-     int count;
+flip_bytes (void *p, int count)
 {
   char tmp;
+  char *ptr = 0;
 
   while (count > 0)
     {
@@ -178,8 +127,7 @@ flip_bytes (ptr, count)
    FRAME_FIND_SAVED_REGS.  */
 
 int
-ns32k_localcount (enter_pc)
-     CORE_ADDR enter_pc;
+ns32k_localcount (CORE_ADDR enter_pc)
 {
   unsigned char localtype;
   int localcount;
@@ -202,8 +150,7 @@ ns32k_localcount (enter_pc)
 /* Nonzero if instruction at PC is a return instruction.  */
 
 static int
-ns32k_about_to_return (pc)
-     CORE_ADDR pc;
+ns32k_about_to_return (CORE_ADDR pc)
 {
   return (read_memory_integer (pc, 1) == 0x12);
 }
@@ -218,8 +165,7 @@ ns32k_about_to_return (pc)
  */
 
 CORE_ADDR
-ns32k_get_enter_addr (pc)
-     CORE_ADDR pc;
+ns32k_get_enter_addr (CORE_ADDR pc)
 {
   CORE_ADDR enter_addr;
   unsigned char op;
This page took 0.025032 seconds and 4 git commands to generate.