Blame SOURCES/gdb-rhbz1854784-powerpc-remove-region-limit-dawr-5of7.patch

599b31
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
599b31
From: Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
599b31
Date: Wed, 7 Jul 2021 19:03:16 -0400
599b31
Subject: gdb-rhbz1854784-powerpc-remove-region-limit-dawr-5of7.patch
599b31
599b31
;; Backport "[PowerPC] Use < 0 and >= 0 for watchpoint ptrace calls"
599b31
;; (Pedro Franco de Carvalho, RH BZ 1854784)
599b31
599b31
In commit 227c0bf4b3dd0cf65dceb58e729e9da81b38b5a7, which fixed some
599b31
watchpoint bugs, I compared the return value of some ptrace calls with ==
599b31
-1 and != -1.  Althought this should be correct, since the rest of the
599b31
file uses < 0 and >= 0, I have modified this for consistency.
599b31
599b31
gdb/ChangeLog:
599b31
599b31
	* ppc-linux-nat.c (ppc_linux_dreg_interface::detect)
599b31
	(ppc_linux_nat_target::low_prepare_to_resume): Use ptrace () < 0
599b31
	and >= to check return value instead of == -1 and != -1.
599b31
599b31
diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
599b31
--- a/gdb/ppc-linux-nat.c
599b31
+++ b/gdb/ppc-linux-nat.c
599b31
@@ -385,7 +385,7 @@ public:
599b31
     bool no_features = false;
599b31
 
599b31
     if (ptrace (PPC_PTRACE_GETHWDBGINFO, ptid.lwp (), 0, &m_hwdebug_info)
599b31
-	!= -1)
599b31
+	>= 0)
599b31
       {
599b31
 	/* If there are no advertised features, we don't use the
599b31
 	   HWDEBUG interface and try the DEBUGREG interface instead.
599b31
@@ -431,7 +431,7 @@ public:
599b31
       {
599b31
 	unsigned long wp;
599b31
 
599b31
-	if (ptrace (PTRACE_GET_DEBUGREG, ptid.lwp (), 0, &wp) != -1)
599b31
+	if (ptrace (PTRACE_GET_DEBUGREG, ptid.lwp (), 0, &wp) >= 0)
599b31
 	  {
599b31
 	    m_interface.emplace (DEBUGREG);
599b31
 	    return;
599b31
@@ -2880,7 +2880,7 @@ ppc_linux_nat_target::low_prepare_to_resume (struct lwp_info *lp)
599b31
 		 the debug register state when fork and clone events are
599b31
 		 detected.  */
599b31
 	      if (ptrace (PPC_PTRACE_DELHWDEBUG, lp->ptid.lwp (), 0,
599b31
-			  bp_it->first) == -1)
599b31
+			  bp_it->first) < 0)
599b31
 		if (errno != ENOENT)
599b31
 		  perror_with_name (_("Error deleting hardware "
599b31
 				      "breakpoint or watchpoint"));
599b31
@@ -2934,7 +2934,7 @@ ppc_linux_nat_target::low_prepare_to_resume (struct lwp_info *lp)
599b31
       long ret = ptrace (PTRACE_SET_DEBUGREG, lp->ptid.lwp (),
599b31
 			 0, wp);
599b31
 
599b31
-      if (ret == -1)
599b31
+      if (ret < 0)
599b31
 	perror_with_name (_("Error setting hardware watchpoint"));
599b31
     }
599b31