Mon Mar 2 16:47:11 1998 Philippe De Muyter <phdm@macqel.be>
[deliverable/binutils-gdb.git] / gdb / hppa-tdep.c
index efc8081cf0a2e33a45535b705ebfaaca479976d0..0ecbc85647d5e74bbabec79f619f9ac716c2c772 100644 (file)
@@ -40,9 +40,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include "a.out.encap.h"
 #else
 #endif
-#ifndef N_SET_MAGIC
-#define N_SET_MAGIC(exec, val) ((exec).a_magic = (val))
-#endif
 
 /*#include <sys/user.h>                After a.out.h  */
 #include <sys/file.h>
@@ -55,12 +52,41 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include "symfile.h"
 #include "objfiles.h"
 
+static int extract_5_load PARAMS ((unsigned int));
+
+static unsigned extract_5R_store PARAMS ((unsigned int));
+
+static unsigned extract_5r_store PARAMS ((unsigned int));
+
+static void find_dummy_frame_regs PARAMS ((struct frame_info *,
+                                          struct frame_saved_regs *));
+
+static int find_proc_framesize PARAMS ((CORE_ADDR));
+
+static int find_return_regnum PARAMS ((CORE_ADDR));
+
+struct unwind_table_entry *find_unwind_entry PARAMS ((CORE_ADDR));
+
+static int extract_17 PARAMS ((unsigned int));
+
+static unsigned deposit_21 PARAMS ((unsigned int, unsigned int));
+
+static int extract_21 PARAMS ((unsigned));
+
+static unsigned deposit_14 PARAMS ((int, unsigned int));
+
+static int extract_14 PARAMS ((unsigned));
+
+static void unwind_command PARAMS ((char *, int));
+
+static int low_sign_extend PARAMS ((unsigned int, unsigned int));
+
+static int sign_extend PARAMS ((unsigned int, unsigned int));
+
 static int restore_pc_queue PARAMS ((struct frame_saved_regs *));
 
 static int hppa_alignof PARAMS ((struct type *));
 
-CORE_ADDR frame_saved_pc PARAMS ((struct frame_info *));
-
 static int prologue_inst_adjust_sp PARAMS ((unsigned long));
 
 static int is_branch PARAMS ((unsigned long));
@@ -91,23 +117,26 @@ static void pa_print_fp_reg PARAMS ((int));
 /* This assumes that no garbage lies outside of the lower bits of 
    value. */
 
-int
+static int
 sign_extend (val, bits)
      unsigned val, bits;
 {
-  return (int)(val >> bits - 1 ? (-1 << bits) | val : val);
+  return (int)(val >> (bits - 1) ? (-1 << bits) | val : val);
 }
 
 /* For many immediate values the sign bit is the low bit! */
 
-int
+static int
 low_sign_extend (val, bits)
      unsigned val, bits;
 {
   return (int)((val & 0x1 ? (-1 << (bits - 1)) : 0) | val >> 1);
 }
+
 /* extract the immediate field from a ld{bhw}s instruction */
 
+#if 0
+
 unsigned
 get_field (val, from, to)
      unsigned val, from, to;
@@ -126,18 +155,24 @@ set_field (val, from, to, new_val)
 
 /* extract a 3-bit space register number from a be, ble, mtsp or mfsp */
 
+int
 extract_3 (word)
      unsigned word;
 {
   return GET_FIELD (word, 18, 18) << 2 | GET_FIELD (word, 16, 17);
 }
-       
+
+#endif
+
+static int
 extract_5_load (word)
      unsigned word;
 {
   return low_sign_extend (word >> 16 & MASK_5, 5);
 }
 
+#if 0
+
 /* extract the immediate field from a st{bhw}s instruction */
 
 int
@@ -147,9 +182,11 @@ extract_5_store (word)
   return low_sign_extend (word & MASK_5, 5);
 }
 
+#endif /* 0 */
+       
 /* extract the immediate field from a break instruction */
 
-unsigned
+static unsigned
 extract_5r_store (word)
      unsigned word;
 {
@@ -158,7 +195,7 @@ extract_5r_store (word)
 
 /* extract the immediate field from a {sr}sm instruction */
 
-unsigned
+static unsigned
 extract_5R_store (word)
      unsigned word;
 {
@@ -167,6 +204,8 @@ extract_5R_store (word)
 
 /* extract an 11 bit immediate field */
 
+#if 0
+
 int
 extract_11 (word)
      unsigned word;
@@ -174,9 +213,11 @@ extract_11 (word)
   return low_sign_extend (word & MASK_11, 11);
 }
 
+#endif
+
 /* extract a 14 bit immediate field */
 
-int
+static int
 extract_14 (word)
      unsigned word;
 {
@@ -185,7 +226,7 @@ extract_14 (word)
 
 /* deposit a 14 bit constant in a word */
 
-unsigned
+static unsigned
 deposit_14 (opnd, word)
      int opnd;
      unsigned word;
@@ -197,7 +238,7 @@ deposit_14 (opnd, word)
 
 /* extract a 21 bit constant */
 
-int
+static int
 extract_21 (word)
      unsigned word;
 {
@@ -221,7 +262,7 @@ extract_21 (word)
    usually the top 21 bits of a 32 bit constant, we assume that only
    the low 21 bits of opnd are relevant */
 
-unsigned
+static unsigned
 deposit_21 (opnd, word)
      unsigned opnd, word;
 {
@@ -241,6 +282,8 @@ deposit_21 (opnd, word)
 
 /* extract a 12 bit constant from branch instructions */
 
+#if 0
+
 int
 extract_12 (word)
      unsigned word;
@@ -264,10 +307,12 @@ deposit_17 (opnd, word)
   return word;
 }
 
+#endif
+
 /* extract a 17 bit constant from branch instructions, returning the
    19 bit signed value. */
 
-int
+static int
 extract_17 (word)
      unsigned word;
 {
@@ -667,7 +712,7 @@ find_return_regnum(pc)
 }
 
 /* Return size of frame, or -1 if we should use a frame pointer.  */
-int
+static int
 find_proc_framesize (pc)
      CORE_ADDR pc;
 {
@@ -764,13 +809,13 @@ saved_pc_after_call (frame)
      the stub will return to out of the stack.  */
   u = find_unwind_entry (pc);
   if (u && u->stub_type != 0)
-    return frame_saved_pc (frame);
+    return FRAME_SAVED_PC (frame);
   else
     return pc;
 }
 \f
 CORE_ADDR
-frame_saved_pc (frame)
+hppa_frame_saved_pc (frame)
      struct frame_info *frame;
 {
   CORE_ADDR pc = get_frame_pc (frame);
@@ -1267,7 +1312,7 @@ push_dummy_frame (inf_status)
   write_register (SP_REGNUM, sp);
 }
 
-void
+static void
 find_dummy_frame_regs (frame, frame_saved_regs)
      struct frame_info *frame;
      struct frame_saved_regs *frame_saved_regs;
@@ -1275,7 +1320,7 @@ find_dummy_frame_regs (frame, frame_saved_regs)
   CORE_ADDR fp = frame->frame;
   int i;
 
-  frame_saved_regs->regs[RP_REGNUM] = fp - 20 & ~0x3;
+  frame_saved_regs->regs[RP_REGNUM] = (fp - 20) & ~0x3;
   frame_saved_regs->regs[FP_REGNUM] = fp;
   frame_saved_regs->regs[1] = fp + 8;
 
@@ -1346,7 +1391,7 @@ hppa_pop_frame ()
   else 
     {
       npc = read_register (RP_REGNUM);
-      target_write_pc (npc, 0);
+      write_pc (npc);
     }
 
   write_register (FP_REGNUM, read_memory_integer (fp, 4));
@@ -1559,7 +1604,7 @@ hppa_fix_call_dummy (dummy, pc, fun, nargs, args, type, gcc_p)
                {
                  struct unwind_table_entry *u;
                  /* It must be a shared library trampoline.  */
-                 if (SYMBOL_TYPE (stub_symbol) != mst_solib_trampoline)
+                 if (MSYMBOL_TYPE (stub_symbol) != mst_solib_trampoline)
                    continue;
 
                  /* It must also be an import stub.  */
@@ -1701,12 +1746,15 @@ CORE_ADDR
 target_read_pc (pid)
      int pid;
 {
-  int flags = read_register (FLAGS_REGNUM);
+  int flags = read_register_pid (FLAGS_REGNUM, pid);
 
-  if (flags & 2) {
-    return read_register (31) & ~0x3;
-  }
-  return read_register (PC_REGNUM) & ~0x3;
+  /* The following test does not belong here.  It is OS-specific, and belongs
+     in native code.  */
+  /* Test SS_INSYSCALL */
+  if (flags & 2)
+    return read_register_pid (31, pid) & ~0x3;
+
+  return read_register_pid (PC_REGNUM, pid) & ~0x3;
 }
 
 /* Write out the PC.  If currently in a syscall, then also write the new
@@ -1717,15 +1765,18 @@ target_write_pc (v, pid)
      CORE_ADDR v;
      int pid;
 {
-  int flags = read_register (FLAGS_REGNUM);
+  int flags = read_register_pid (FLAGS_REGNUM, pid);
 
+  /* The following test does not belong here.  It is OS-specific, and belongs
+     in native code.  */
   /* If in a syscall, then set %r31.  Also make sure to get the 
      privilege bits set correctly.  */
+  /* Test SS_INSYSCALL */
   if (flags & 2)
-    write_register (31, (long) (v | 0x3));
+    write_register_pid (31, v | 0x3, pid);
 
-  write_register (PC_REGNUM, (long) v);
-  write_register (NPC_REGNUM, (long) v + 4);
+  write_register_pid (PC_REGNUM, v, pid);
+  write_register_pid (NPC_REGNUM, v + 4, pid);
 }
 
 /* return the alignment of a type in bytes. Structures have the maximum
@@ -1747,7 +1798,7 @@ hppa_alignof (type)
       return hppa_alignof (TYPE_FIELD_TYPE (type, 0));
     case TYPE_CODE_STRUCT:
     case TYPE_CODE_UNION:
-      max_align = 2;
+      max_align = 1;
       for (i = 0; i < TYPE_NFIELDS (type); i++)
        {
          /* Bit fields have no real alignment. */
@@ -2520,8 +2571,7 @@ restart:
      but never were, mask them out and restart.
 
      This should only happen in optimized code, and should be very rare.  */
-  if (save_gr || save_fr
-      && ! (restart_fr || restart_gr))
+  if (save_gr || (save_fr && ! (restart_fr || restart_gr)))
     {
       pc = orig_pc;
       restart_gr = save_gr;
This page took 0.028328 seconds and 4 git commands to generate.