2012-07-19 Pedro Alves <palves@redhat.com>
[deliverable/binutils-gdb.git] / gdb / ppc-linux-nat.c
index 2c98f765e836428983dddf940de39e543586b3d5..14f4ecbdb48eb1d82aa766a0326b183537133f97 100644 (file)
@@ -1351,7 +1351,8 @@ store_ppc_registers (const struct regcache *regcache, int tid)
 }
 
 /* Fetch the AT_HWCAP entry from the aux vector.  */
-unsigned long ppc_linux_get_hwcap (void)
+static unsigned long
+ppc_linux_get_hwcap (void)
 {
   CORE_ADDR field;
 
@@ -1420,17 +1421,20 @@ have_ptrace_booke_interface (void)
       /* Check for kernel support for BOOKE debug registers.  */
       if (ptrace (PPC_PTRACE_GETHWDBGINFO, tid, 0, &booke_debug_info) >= 0)
        {
-         have_ptrace_booke_interface = 1;
-         max_slots_number = booke_debug_info.num_instruction_bps
-           + booke_debug_info.num_data_bps
-           + booke_debug_info.num_condition_regs;
-       }
-      else
-       {
-         /* Old school interface and no BOOKE debug registers support.  */
-         have_ptrace_booke_interface = 0;
-         memset (&booke_debug_info, 0, sizeof (struct ppc_debug_info));
+         /* Check whether ptrace BOOKE interface is functional and
+            provides any supported feature.  */
+         if (booke_debug_info.features != 0)
+           {
+             have_ptrace_booke_interface = 1;
+             max_slots_number = booke_debug_info.num_instruction_bps
+               + booke_debug_info.num_data_bps
+               + booke_debug_info.num_condition_regs;
+             return have_ptrace_booke_interface;
+           }
        }
+      /* Old school interface and no BOOKE debug registers support.  */
+      have_ptrace_booke_interface = 0;
+      memset (&booke_debug_info, 0, sizeof (struct ppc_debug_info));
     }
 
   return have_ptrace_booke_interface;
@@ -1460,7 +1464,7 @@ ppc_linux_can_use_hw_breakpoint (int type, int cnt, int ot)
   if (type == bp_hardware_watchpoint || type == bp_read_watchpoint
       || type == bp_access_watchpoint || type == bp_watchpoint)
     {
-      if (cnt > total_hw_wp)
+      if (cnt + ot > total_hw_wp)
        return -1;
     }
   else if (type == bp_hardware_breakpoint)
@@ -2217,12 +2221,13 @@ ppc_linux_thread_exit (struct thread_info *tp, int silent)
 static int
 ppc_linux_stopped_data_address (struct target_ops *target, CORE_ADDR *addr_p)
 {
-  struct siginfo *siginfo_p;
+  siginfo_t siginfo;
 
-  siginfo_p = linux_nat_get_siginfo (inferior_ptid);
+  if (!linux_nat_get_siginfo (inferior_ptid, &siginfo))
+    return 0;
 
-  if (siginfo_p->si_signo != SIGTRAP
-      || (siginfo_p->si_code & 0xffff) != 0x0004 /* TRAP_HWBKPT */)
+  if (siginfo.si_signo != SIGTRAP
+      || (siginfo.si_code & 0xffff) != 0x0004 /* TRAP_HWBKPT */)
     return 0;
 
   if (have_ptrace_booke_interface ())
@@ -2231,7 +2236,7 @@ ppc_linux_stopped_data_address (struct target_ops *target, CORE_ADDR *addr_p)
       struct thread_points *t;
       struct hw_break_tuple *hw_breaks;
       /* The index (or slot) of the *point is passed in the si_errno field.  */
-      int slot = siginfo_p->si_errno;
+      int slot = siginfo.si_errno;
 
       t = booke_find_thread_points_by_tid (TIDGET (inferior_ptid), 0);
 
@@ -2248,7 +2253,7 @@ ppc_linux_stopped_data_address (struct target_ops *target, CORE_ADDR *addr_p)
        }
     }
 
-  *addr_p = (CORE_ADDR) (uintptr_t) siginfo_p->si_addr;
+  *addr_p = (CORE_ADDR) (uintptr_t) siginfo.si_addr;
   return 1;
 }
 
This page took 0.026184 seconds and 4 git commands to generate.