Fix type of not saved registers.
[deliverable/binutils-gdb.git] / gdb / ppc-linux-nat.c
index 4b3c78c7ac047e08fa871f4dbff85a61be6ccca8..d6820be99c5857815e7639be44a2ea034301c9d9 100644 (file)
@@ -18,7 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
-#include "gdb_string.h"
+#include <string.h>
 #include "observer.h"
 #include "frame.h"
 #include "inferior.h"
@@ -177,7 +177,11 @@ struct ppc_hw_breakpoint
         (1<<((n)+PPC_BREAKPOINT_CONDITION_BE_SHIFT))
 #endif /* PPC_PTRACE_GETHWDBGINFO */
 
-
+/* Feature defined on Linux kernel v3.9: DAWR interface, that enables wider
+   watchpoint (up to 512 bytes).  */
+#ifndef PPC_DEBUG_FEATURE_DATA_BP_DAWR
+#define PPC_DEBUG_FEATURE_DATA_BP_DAWR 0x10
+#endif /* PPC_DEBUG_FEATURE_DATA_BP_DAWR */
 
 /* Similarly for the general-purpose (gp0 -- gp31)
    and floating-point registers (fp0 -- fp31).  */
@@ -860,11 +864,11 @@ ppc_linux_fetch_inferior_registers (struct target_ops *ops,
                                    struct regcache *regcache, int regno)
 {
   /* Overload thread id onto process id.  */
-  int tid = TIDGET (inferior_ptid);
+  int tid = ptid_get_lwp (inferior_ptid);
 
   /* No thread id, just use process id.  */
   if (tid == 0)
-    tid = PIDGET (inferior_ptid);
+    tid = ptid_get_pid (inferior_ptid);
 
   if (regno == -1)
     fetch_ppc_registers (regcache, tid);
@@ -1413,9 +1417,9 @@ have_ptrace_hwdebug_interface (void)
     {
       int tid;
 
-      tid = TIDGET (inferior_ptid);
+      tid = ptid_get_lwp (inferior_ptid);
       if (tid == 0)
-       tid = PIDGET (inferior_ptid);
+       tid = ptid_get_pid (inferior_ptid);
 
       /* Check for kernel support for PowerPC HWDEBUG ptrace interface.  */
       if (ptrace (PPC_PTRACE_GETHWDBGINFO, tid, 0, &hwdebug_info) >= 0)
@@ -1480,9 +1484,9 @@ ppc_linux_can_use_hw_breakpoint (int type, int cnt, int ot)
       /* We need to know whether ptrace supports PTRACE_SET_DEBUGREG
         and whether the target has DABR.  If either answer is no, the
         ptrace call will return -1.  Fail in that case.  */
-      tid = TIDGET (ptid);
+      tid = ptid_get_lwp (ptid);
       if (tid == 0)
-       tid = PIDGET (ptid);
+       tid = ptid_get_pid (ptid);
 
       if (ptrace (PTRACE_SET_DEBUGREG, tid, 0, 0) == -1)
        return 0;
@@ -1504,6 +1508,7 @@ ppc_linux_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
      watchpoints.  */
   if (have_ptrace_hwdebug_interface ())
     {
+      int region_size;
       /* Embedded DAC-based processors, like the PowerPC 440 have ranged
         watchpoints and can watch any access within an arbitrary memory
         region. This is useful to watch arrays and structs, for instance.  It
@@ -1512,11 +1517,17 @@ ppc_linux_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
          && hwdebug_info.features & PPC_DEBUG_FEATURE_DATA_BP_RANGE
          && ppc_linux_get_hwcap () & PPC_FEATURE_BOOKE)
        return 2;
+      /* Check if the processor provides DAWR interface.  */
+      if (hwdebug_info.features & PPC_DEBUG_FEATURE_DATA_BP_DAWR)
+       /* DAWR interface allows to watch up to 512 byte wide ranges which
+          can't cross a 512 byte boundary.  */
+       region_size = 512;
+      else
+       region_size = hwdebug_info.data_bp_alignment;
       /* Server processors provide one hardware watchpoint and addr+len should
          fall in the watchable region provided by the ptrace interface.  */
-      if (hwdebug_info.data_bp_alignment
-         && (addr + len > (addr & ~(hwdebug_info.data_bp_alignment - 1))
-             + hwdebug_info.data_bp_alignment))
+      if (region_size
+         && (addr + len > (addr & ~(region_size - 1)) + region_size))
        return 0;
     }
   /* addr+len must fall in the 8 byte watchable region for DABR-based
@@ -1691,7 +1702,7 @@ ppc_linux_insert_hw_breakpoint (struct gdbarch *gdbarch,
     }
 
   ALL_LWPS (lp)
-    hwdebug_insert_point (&p, TIDGET (lp->ptid));
+    hwdebug_insert_point (&p, ptid_get_lwp (lp->ptid));
 
   return 0;
 }
@@ -1727,7 +1738,7 @@ ppc_linux_remove_hw_breakpoint (struct gdbarch *gdbarch,
     }
 
   ALL_LWPS (lp)
-    hwdebug_remove_point (&p, TIDGET (lp->ptid));
+    hwdebug_remove_point (&p, ptid_get_lwp (lp->ptid));
 
   return 0;
 }
@@ -1770,7 +1781,7 @@ ppc_linux_insert_mask_watchpoint (struct target_ops *ops, CORE_ADDR addr,
   p.condition_value = 0;
 
   ALL_LWPS (lp)
-    hwdebug_insert_point (&p, TIDGET (lp->ptid));
+    hwdebug_insert_point (&p, ptid_get_lwp (lp->ptid));
 
   return 0;
 }
@@ -1798,7 +1809,7 @@ ppc_linux_remove_mask_watchpoint (struct target_ops *ops, CORE_ADDR addr,
   p.condition_value = 0;
 
   ALL_LWPS (lp)
-    hwdebug_remove_point (&p, TIDGET (lp->ptid));
+    hwdebug_remove_point (&p, ptid_get_lwp (lp->ptid));
 
   return 0;
 }
@@ -1808,7 +1819,7 @@ static int
 can_use_watchpoint_cond_accel (void)
 {
   struct thread_points *p;
-  int tid = TIDGET (inferior_ptid);
+  int tid = ptid_get_lwp (inferior_ptid);
   int cnt = hwdebug_info.num_condition_regs, i;
   CORE_ADDR tmp_value;
 
@@ -1941,7 +1952,7 @@ check_condition (CORE_ADDR watch_addr, struct expression *cond,
   if (cond->elts[0].opcode != BINOP_EQUAL)
     return 0;
 
-  fetch_subexp_value (cond, &pc, &left_val, NULL, &left_chain);
+  fetch_subexp_value (cond, &pc, &left_val, NULL, &left_chain, 0);
   num_accesses_left = num_memory_accesses (left_chain);
 
   if (left_val == NULL || num_accesses_left < 0)
@@ -1951,7 +1962,7 @@ check_condition (CORE_ADDR watch_addr, struct expression *cond,
       return 0;
     }
 
-  fetch_subexp_value (cond, &pc, &right_val, NULL, &right_chain);
+  fetch_subexp_value (cond, &pc, &right_val, NULL, &right_chain, 0);
   num_accesses_right = num_memory_accesses (right_chain);
 
   if (right_val == NULL || num_accesses_right < 0)
@@ -2075,7 +2086,7 @@ ppc_linux_insert_watchpoint (CORE_ADDR addr, int len, int rw,
       create_watchpoint_request (&p, addr, len, rw, cond, 1);
 
       ALL_LWPS (lp)
-       hwdebug_insert_point (&p, TIDGET (lp->ptid));
+       hwdebug_insert_point (&p, ptid_get_lwp (lp->ptid));
 
       ret = 0;
     }
@@ -2119,7 +2130,7 @@ ppc_linux_insert_watchpoint (CORE_ADDR addr, int len, int rw,
       saved_dabr_value = dabr_value;
 
       ALL_LWPS (lp)
-       if (ptrace (PTRACE_SET_DEBUGREG, TIDGET (lp->ptid), 0,
+       if (ptrace (PTRACE_SET_DEBUGREG, ptid_get_lwp (lp->ptid), 0,
                    saved_dabr_value) < 0)
          return -1;
 
@@ -2143,7 +2154,7 @@ ppc_linux_remove_watchpoint (CORE_ADDR addr, int len, int rw,
       create_watchpoint_request (&p, addr, len, rw, cond, 0);
 
       ALL_LWPS (lp)
-       hwdebug_remove_point (&p, TIDGET (lp->ptid));
+       hwdebug_remove_point (&p, ptid_get_lwp (lp->ptid));
 
       ret = 0;
     }
@@ -2151,7 +2162,7 @@ ppc_linux_remove_watchpoint (CORE_ADDR addr, int len, int rw,
     {
       saved_dabr_value = 0;
       ALL_LWPS (lp)
-       if (ptrace (PTRACE_SET_DEBUGREG, TIDGET (lp->ptid), 0,
+       if (ptrace (PTRACE_SET_DEBUGREG, ptid_get_lwp (lp->ptid), 0,
                    saved_dabr_value) < 0)
          return -1;
 
@@ -2164,7 +2175,7 @@ ppc_linux_remove_watchpoint (CORE_ADDR addr, int len, int rw,
 static void
 ppc_linux_new_thread (struct lwp_info *lp)
 {
-  int tid = TIDGET (lp->ptid);
+  int tid = ptid_get_lwp (lp->ptid);
 
   if (have_ptrace_hwdebug_interface ())
     {
@@ -2203,7 +2214,7 @@ static void
 ppc_linux_thread_exit (struct thread_info *tp, int silent)
 {
   int i;
-  int tid = TIDGET (tp->ptid);
+  int tid = ptid_get_lwp (tp->ptid);
   struct hw_break_tuple *hw_breaks;
   struct thread_points *t = NULL, *p;
 
@@ -2252,7 +2263,7 @@ ppc_linux_stopped_data_address (struct target_ops *target, CORE_ADDR *addr_p)
       /* The index (or slot) of the *point is passed in the si_errno field.  */
       int slot = siginfo.si_errno;
 
-      t = hwdebug_find_thread_points_by_tid (TIDGET (inferior_ptid), 0);
+      t = hwdebug_find_thread_points_by_tid (ptid_get_lwp (inferior_ptid), 0);
 
       /* Find out if this *point is a hardware breakpoint.
         If so, we should return 0.  */
@@ -2324,11 +2335,11 @@ ppc_linux_store_inferior_registers (struct target_ops *ops,
                                    struct regcache *regcache, int regno)
 {
   /* Overload thread id onto process id.  */
-  int tid = TIDGET (inferior_ptid);
+  int tid = ptid_get_lwp (inferior_ptid);
 
   /* No thread id, just use process id.  */
   if (tid == 0)
-    tid = PIDGET (inferior_ptid);
+    tid = ptid_get_pid (inferior_ptid);
 
   if (regno >= 0)
     store_register (regcache, tid, regno);
@@ -2390,9 +2401,9 @@ ppc_linux_target_wordsize (void)
 #ifdef __powerpc64__
   long msr;
 
-  int tid = TIDGET (inferior_ptid);
+  int tid = ptid_get_lwp (inferior_ptid);
   if (tid == 0)
-    tid = PIDGET (inferior_ptid);
+    tid = ptid_get_pid (inferior_ptid);
 
   errno = 0;
   msr = (long) ptrace (PTRACE_PEEKUSER, tid, PT_MSR * 8, 0);
@@ -2434,9 +2445,9 @@ ppc_linux_read_description (struct target_ops *ops)
   int isa205 = 0;
   int cell = 0;
 
-  int tid = TIDGET (inferior_ptid);
+  int tid = ptid_get_lwp (inferior_ptid);
   if (tid == 0)
-    tid = PIDGET (inferior_ptid);
+    tid = ptid_get_pid (inferior_ptid);
 
   if (have_ptrace_getsetevrregs)
     {
This page took 0.030306 seconds and 4 git commands to generate.