py_decref: Don't check for NULL before calling Py_DECREF.
[deliverable/binutils-gdb.git] / gdb / ppc-linux-nat.c
index edb16c0b7a6b945c21ddbe2e2489bd855c6fa15a..1ff00a6d04e6251eb5206b0d5b041be297d543be 100644 (file)
@@ -1503,16 +1503,19 @@ ppc_linux_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
      to determine the hardcoded watchable region for watchpoints.  */
   if (have_ptrace_booke_interface ())
     {
-      /* DAC-based processors (i.e., embedded 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 takes two hardware watchpoints though.  */
+      /* 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
+         takes two hardware watchpoints though.  */
       if (len > 1
-         && booke_debug_info.features & PPC_DEBUG_FEATURE_DATA_BP_RANGE)
+         && booke_debug_info.features & PPC_DEBUG_FEATURE_DATA_BP_RANGE
+         && ppc_linux_get_hwcap () & PPC_FEATURE_BOOKE)
        return 2;
-      else if (booke_debug_info.data_bp_alignment
-              && (addr + len > (addr & ~(booke_debug_info.data_bp_alignment - 1))
-                  + booke_debug_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 (booke_debug_info.data_bp_alignment
+         && (addr + len > (addr & ~(booke_debug_info.data_bp_alignment - 1))
+             + booke_debug_info.data_bp_alignment))
        return 0;
     }
   /* addr+len must fall in the 8 byte watchable region for DABR-based
@@ -2178,7 +2181,18 @@ ppc_linux_new_thread (struct lwp_info *lp)
       /* Copy that thread's breakpoints and watchpoints to the new thread.  */
       for (i = 0; i < max_slots_number; i++)
        if (hw_breaks[i].hw_break)
-         booke_insert_point (hw_breaks[i].hw_break, tid);
+         {
+           /* Older kernels did not make new threads inherit their parent
+              thread's debug state, so we always clear the slot and replicate
+              the debug state ourselves, ensuring compatibility with all
+              kernels.  */
+
+           /* The ppc debug resource accounting is done through "slots".
+              Ask the kernel the deallocate this specific *point's slot.  */
+           ptrace (PPC_PTRACE_DELHWDEBUG, tid, 0, hw_breaks[i].slot);
+
+           booke_insert_point (hw_breaks[i].hw_break, tid);
+         }
     }
   else
     ptrace (PTRACE_SET_DEBUGREG, tid, 0, saved_dabr_value);
This page took 0.02497 seconds and 4 git commands to generate.