Fix -Wuh and -Wnhu options so that they work.
[deliverable/binutils-gdb.git] / gdb / ns32k-tdep.c
index 3edb7f5d5d99eeb9d711ee5c669ecd4bb8334b81..bf5208a2b5ae5c512e62c8d1d88c9fe2c7b32edc 100644 (file)
@@ -26,6 +26,126 @@ _initialize_ns32k_tdep ()
   tm_print_insn = print_insn_ns32k;
 }
 
+/* Advance PC across any function entry prologue instructions
+   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;
+{
+  register unsigned char 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;
+}
+
+/* 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;
+{
+  int numargs;
+  CORE_ADDR pc;
+  CORE_ADDR enter_addr;
+  unsigned int insn;
+  unsigned int addr_mode;
+  int width;
+
+  numargs = -1;
+  enter_addr = ns32k_get_enter_addr ((fi)->pc);
+  if (enter_addr > 0)
+    {
+      pc = ((enter_addr == 1)
+           ? SAVED_PC_AFTER_CALL (fi)
+           : 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;
+       }
+    }
+  return numargs;
+}
+
+
 sign_extend (value, bits)
 {
   value = value & ((1 << bits) - 1);
This page took 0.02352 seconds and 4 git commands to generate.