* regcache.c (struct regcache): Add ptid_t member.
[deliverable/binutils-gdb.git] / gdb / ia64-linux-nat.c
index dbe6e53c64b352b8603c2efc6c1db4fa5083751c..f42ca0ffc3087aafcff4660d6af3f1c5757c37bf 100644 (file)
@@ -308,7 +308,7 @@ ia64_register_addr (int regno)
 {
   CORE_ADDR addr;
 
-  if (regno < 0 || regno >= NUM_REGS)
+  if (regno < 0 || regno >= gdbarch_num_regs (current_gdbarch))
     error (_("Invalid register number %d."), regno);
 
   if (u_offsets[regno] == -1)
@@ -322,7 +322,9 @@ ia64_register_addr (int regno)
 static int
 ia64_cannot_fetch_register (int regno)
 {
-  return regno < 0 || regno >= NUM_REGS || u_offsets[regno] == -1;
+  return regno < 0
+        || regno >= gdbarch_num_regs (current_gdbarch)
+        || u_offsets[regno] == -1;
 }
 
 static int
@@ -357,7 +359,9 @@ ia64_cannot_store_register (int regno)
      were previously read from the inferior process to be written
      back.)  */
 
-  return regno < 0 || regno >= NUM_REGS || u_offsets[regno] == -1
+  return regno < 0
+        || regno >= gdbarch_num_regs (current_gdbarch)
+        || u_offsets[regno] == -1
          || regno == IA64_BSPSTORE_REGNUM;
 }
 
@@ -477,16 +481,16 @@ fill_fpregset (const struct regcache *regcache,
 #define IA64_PSR_DD (1UL << 39)
 
 static void
-enable_watchpoints_in_psr (ptid_t ptid)
+enable_watchpoints_in_psr (struct regcache *regcache)
 {
-  CORE_ADDR psr;
+  ULONGEST psr;
 
-  psr = read_register_pid (IA64_PSR_REGNUM, ptid);
+  regcache_cooked_read_unsigned (regcache, IA64_PSR_REGNUM, &psr);
   if (!(psr & IA64_PSR_DB))
     {
       psr |= IA64_PSR_DB;      /* Set the db bit - this enables hardware
                                   watchpoints and breakpoints. */
-      write_register_pid (IA64_PSR_REGNUM, psr, ptid);
+      regcache_cooked_write_unsigned (regcache, IA64_PSR_REGNUM, psr);
     }
 }
 
@@ -591,7 +595,7 @@ ia64_linux_insert_watchpoint (CORE_ADDR addr, int len, int rw)
     }
 
   store_debug_register_pair (ptid, idx, &dbr_addr, &dbr_mask);
-  enable_watchpoints_in_psr (ptid);
+  enable_watchpoints_in_psr (get_current_regcache ());
 
   return 0;
 }
@@ -628,6 +632,7 @@ ia64_linux_stopped_data_address (struct target_ops *ops, CORE_ADDR *addr_p)
   int tid;
   struct siginfo siginfo;
   ptid_t ptid = inferior_ptid;
+  struct regcache *regcache = get_current_regcache ();
 
   tid = TIDGET(ptid);
   if (tid == 0)
@@ -640,10 +645,10 @@ ia64_linux_stopped_data_address (struct target_ops *ops, CORE_ADDR *addr_p)
       (siginfo.si_code & 0xffff) != 0x0004 /* TRAP_HWBKPT */)
     return 0;
 
-  psr = read_register_pid (IA64_PSR_REGNUM, ptid);
+  regcache_cooked_read_unsigned (regcache, IA64_PSR_REGNUM, &psr);
   psr |= IA64_PSR_DD;  /* Set the dd bit - this will disable the watchpoint
                            for the next instruction */
-  write_register_pid (IA64_PSR_REGNUM, psr, ptid);
+  regcache_cooked_write_unsigned (regcache, IA64_PSR_REGNUM, psr);
 
   *addr_p = (CORE_ADDR)siginfo.si_addr;
   return 1;
@@ -699,7 +704,8 @@ ia64_linux_fetch_register (struct regcache *regcache, int regnum)
       buf[i] = ptrace (PT_READ_U, pid, (PTRACE_TYPE_ARG3)addr, 0);
       if (errno != 0)
        error (_("Couldn't read register %s (#%d): %s."),
-              REGISTER_NAME (regnum), regnum, safe_strerror (errno));
+              gdbarch_register_name (current_gdbarch, regnum),
+              regnum, safe_strerror (errno));
 
       addr += sizeof (PTRACE_TYPE_RET);
     }
@@ -713,7 +719,7 @@ static void
 ia64_linux_fetch_registers (struct regcache *regcache, int regnum)
 {
   if (regnum == -1)
-    for (regnum = 0; regnum < NUM_REGS; regnum++)
+    for (regnum = 0; regnum < gdbarch_num_regs (current_gdbarch); regnum++)
       ia64_linux_fetch_register (regcache, regnum);
   else
     ia64_linux_fetch_register (regcache, regnum);
@@ -753,7 +759,8 @@ ia64_linux_store_register (const struct regcache *regcache, int regnum)
       ptrace (PT_WRITE_U, pid, (PTRACE_TYPE_ARG3)addr, buf[i]);
       if (errno != 0)
        error (_("Couldn't write register %s (#%d): %s."),
-              REGISTER_NAME (regnum), regnum, safe_strerror (errno));
+              gdbarch_register_name (current_gdbarch, regnum),
+              regnum, safe_strerror (errno));
 
       addr += sizeof (PTRACE_TYPE_RET);
     }
@@ -766,7 +773,7 @@ static void
 ia64_linux_store_registers (struct regcache *regcache, int regnum)
 {
   if (regnum == -1)
-    for (regnum = 0; regnum < NUM_REGS; regnum++)
+    for (regnum = 0; regnum < gdbarch_num_regs (current_gdbarch); regnum++)
       ia64_linux_store_register (regcache, regnum);
   else
     ia64_linux_store_register (regcache, regnum);
This page took 0.028781 seconds and 4 git commands to generate.