Blame SOURCES/gdb-rhbz1854784-powerpc-remove-region-limit-dawr-3of7.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 18:45:37 -0400
599b31
Subject: gdb-rhbz1854784-powerpc-remove-region-limit-dawr-3of7.patch
599b31
599b31
;; Backport "[PowerPC] Move up some register access routines"
599b31
;; (Pedro Franco de Carvalho, RH BZ 1854784)
599b31
599b31
Keep the routines related to register access grouped together.
599b31
599b31
gdb/ChangeLog:
599b31
2020-03-30  Pedro Franco de Carvalho  <pedromfc@linux.ibm.com>
599b31
599b31
	* ppc-linux-nat.c (ppc_linux_nat_target::store_registers)
599b31
	(ppc_linux_nat_target::auxv_parse)
599b31
	(ppc_linux_nat_target::read_description)
599b31
	(supply_gregset, fill_gregset, supply_fpregset, fill_fpregset):
599b31
	Move up.
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
@@ -1561,6 +1561,170 @@ store_ppc_registers (const struct regcache *regcache, int tid)
599b31
      function to fail most of the time, so we ignore them.  */
599b31
 }
599b31
 
599b31
+void
599b31
+ppc_linux_nat_target::store_registers (struct regcache *regcache, int regno)
599b31
+{
599b31
+  pid_t tid = get_ptrace_pid (regcache->ptid ());
599b31
+
599b31
+  if (regno >= 0)
599b31
+    store_register (regcache, tid, regno);
599b31
+  else
599b31
+    store_ppc_registers (regcache, tid);
599b31
+}
599b31
+
599b31
+/* Functions for transferring registers between a gregset_t or fpregset_t
599b31
+   (see sys/ucontext.h) and gdb's regcache.  The word size is that used
599b31
+   by the ptrace interface, not the current program's ABI.  Eg. if a
599b31
+   powerpc64-linux gdb is being used to debug a powerpc32-linux app, we
599b31
+   read or write 64-bit gregsets.  This is to suit the host libthread_db.  */
599b31
+
599b31
+void
599b31
+supply_gregset (struct regcache *regcache, const gdb_gregset_t *gregsetp)
599b31
+{
599b31
+  const struct regset *regset = ppc_linux_gregset (sizeof (long));
599b31
+
599b31
+  ppc_supply_gregset (regset, regcache, -1, gregsetp, sizeof (*gregsetp));
599b31
+}
599b31
+
599b31
+void
599b31
+fill_gregset (const struct regcache *regcache,
599b31
+	      gdb_gregset_t *gregsetp, int regno)
599b31
+{
599b31
+  const struct regset *regset = ppc_linux_gregset (sizeof (long));
599b31
+
599b31
+  if (regno == -1)
599b31
+    memset (gregsetp, 0, sizeof (*gregsetp));
599b31
+  ppc_collect_gregset (regset, regcache, regno, gregsetp, sizeof (*gregsetp));
599b31
+}
599b31
+
599b31
+void
599b31
+supply_fpregset (struct regcache *regcache, const gdb_fpregset_t * fpregsetp)
599b31
+{
599b31
+  const struct regset *regset = ppc_linux_fpregset ();
599b31
+
599b31
+  ppc_supply_fpregset (regset, regcache, -1,
599b31
+		       fpregsetp, sizeof (*fpregsetp));
599b31
+}
599b31
+
599b31
+void
599b31
+fill_fpregset (const struct regcache *regcache,
599b31
+	       gdb_fpregset_t *fpregsetp, int regno)
599b31
+{
599b31
+  const struct regset *regset = ppc_linux_fpregset ();
599b31
+
599b31
+  ppc_collect_fpregset (regset, regcache, regno,
599b31
+			fpregsetp, sizeof (*fpregsetp));
599b31
+}
599b31
+
599b31
+int
599b31
+ppc_linux_nat_target::auxv_parse (gdb_byte **readptr,
599b31
+				  gdb_byte *endptr, CORE_ADDR *typep,
599b31
+				  CORE_ADDR *valp)
599b31
+{
599b31
+  int tid = inferior_ptid.lwp ();
599b31
+  if (tid == 0)
599b31
+    tid = inferior_ptid.pid ();
599b31
+
599b31
+  int sizeof_auxv_field = ppc_linux_target_wordsize (tid);
599b31
+
599b31
+  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
599b31
+  gdb_byte *ptr = *readptr;
599b31
+
599b31
+  if (endptr == ptr)
599b31
+    return 0;
599b31
+
599b31
+  if (endptr - ptr < sizeof_auxv_field * 2)
599b31
+    return -1;
599b31
+
599b31
+  *typep = extract_unsigned_integer (ptr, sizeof_auxv_field, byte_order);
599b31
+  ptr += sizeof_auxv_field;
599b31
+  *valp = extract_unsigned_integer (ptr, sizeof_auxv_field, byte_order);
599b31
+  ptr += sizeof_auxv_field;
599b31
+
599b31
+  *readptr = ptr;
599b31
+  return 1;
599b31
+}
599b31
+
599b31
+const struct target_desc *
599b31
+ppc_linux_nat_target::read_description ()
599b31
+{
599b31
+  int tid = inferior_ptid.lwp ();
599b31
+  if (tid == 0)
599b31
+    tid = inferior_ptid.pid ();
599b31
+
599b31
+  if (have_ptrace_getsetevrregs)
599b31
+    {
599b31
+      struct gdb_evrregset_t evrregset;
599b31
+
599b31
+      if (ptrace (PTRACE_GETEVRREGS, tid, 0, &evrregset) >= 0)
599b31
+        return tdesc_powerpc_e500l;
599b31
+
599b31
+      /* EIO means that the PTRACE_GETEVRREGS request isn't supported.
599b31
+	 Anything else needs to be reported.  */
599b31
+      else if (errno != EIO)
599b31
+	perror_with_name (_("Unable to fetch SPE registers"));
599b31
+    }
599b31
+
599b31
+  struct ppc_linux_features features = ppc_linux_no_features;
599b31
+
599b31
+  features.wordsize = ppc_linux_target_wordsize (tid);
599b31
+
599b31
+  CORE_ADDR hwcap = linux_get_hwcap (current_top_target ());
599b31
+  CORE_ADDR hwcap2 = linux_get_hwcap2 (current_top_target ());
599b31
+
599b31
+  if (have_ptrace_getsetvsxregs
599b31
+      && (hwcap & PPC_FEATURE_HAS_VSX))
599b31
+    {
599b31
+      gdb_vsxregset_t vsxregset;
599b31
+
599b31
+      if (ptrace (PTRACE_GETVSXREGS, tid, 0, &vsxregset) >= 0)
599b31
+	features.vsx = true;
599b31
+
599b31
+      /* EIO means that the PTRACE_GETVSXREGS request isn't supported.
599b31
+	 Anything else needs to be reported.  */
599b31
+      else if (errno != EIO)
599b31
+	perror_with_name (_("Unable to fetch VSX registers"));
599b31
+    }
599b31
+
599b31
+  if (have_ptrace_getvrregs
599b31
+      && (hwcap & PPC_FEATURE_HAS_ALTIVEC))
599b31
+    {
599b31
+      gdb_vrregset_t vrregset;
599b31
+
599b31
+      if (ptrace (PTRACE_GETVRREGS, tid, 0, &vrregset) >= 0)
599b31
+        features.altivec = true;
599b31
+
599b31
+      /* EIO means that the PTRACE_GETVRREGS request isn't supported.
599b31
+	 Anything else needs to be reported.  */
599b31
+      else if (errno != EIO)
599b31
+	perror_with_name (_("Unable to fetch AltiVec registers"));
599b31
+    }
599b31
+
599b31
+  features.isa205 = ppc_linux_has_isa205 (hwcap);
599b31
+
599b31
+  if ((hwcap2 & PPC_FEATURE2_DSCR)
599b31
+      && check_regset (tid, NT_PPC_PPR, PPC_LINUX_SIZEOF_PPRREGSET)
599b31
+      && check_regset (tid, NT_PPC_DSCR, PPC_LINUX_SIZEOF_DSCRREGSET))
599b31
+    {
599b31
+      features.ppr_dscr = true;
599b31
+      if ((hwcap2 & PPC_FEATURE2_ARCH_2_07)
599b31
+	  && (hwcap2 & PPC_FEATURE2_TAR)
599b31
+	  && (hwcap2 & PPC_FEATURE2_EBB)
599b31
+	  && check_regset (tid, NT_PPC_TAR, PPC_LINUX_SIZEOF_TARREGSET)
599b31
+	  && check_regset (tid, NT_PPC_EBB, PPC_LINUX_SIZEOF_EBBREGSET)
599b31
+	  && check_regset (tid, NT_PPC_PMU, PPC_LINUX_SIZEOF_PMUREGSET))
599b31
+	{
599b31
+	  features.isa207 = true;
599b31
+	  if ((hwcap2 & PPC_FEATURE2_HTM)
599b31
+	      && check_regset (tid, NT_PPC_TM_SPR,
599b31
+			       PPC_LINUX_SIZEOF_TM_SPRREGSET))
599b31
+	    features.htm = true;
599b31
+	}
599b31
+    }
599b31
+
599b31
+  return ppc_linux_match_description (features);
599b31
+}
599b31
+
599b31
 /* The cached DABR value, to install in new threads.
599b31
    This variable is used when the PowerPC HWDEBUG ptrace
599b31
    interface is not available.  */
599b31
@@ -2514,173 +2678,7 @@ ppc_linux_nat_target::masked_watch_num_registers (CORE_ADDR addr, CORE_ADDR mask
599b31
     return 2;
599b31
 }
599b31
 
599b31
-void
599b31
-ppc_linux_nat_target::store_registers (struct regcache *regcache, int regno)
599b31
-{
599b31
-  pid_t tid = get_ptrace_pid (regcache->ptid ());
599b31
-
599b31
-  if (regno >= 0)
599b31
-    store_register (regcache, tid, regno);
599b31
-  else
599b31
-    store_ppc_registers (regcache, tid);
599b31
-}
599b31
-
599b31
-/* Functions for transferring registers between a gregset_t or fpregset_t
599b31
-   (see sys/ucontext.h) and gdb's regcache.  The word size is that used
599b31
-   by the ptrace interface, not the current program's ABI.  Eg. if a
599b31
-   powerpc64-linux gdb is being used to debug a powerpc32-linux app, we
599b31
-   read or write 64-bit gregsets.  This is to suit the host libthread_db.  */
599b31
-
599b31
-void
599b31
-supply_gregset (struct regcache *regcache, const gdb_gregset_t *gregsetp)
599b31
-{
599b31
-  const struct regset *regset = ppc_linux_gregset (sizeof (long));
599b31
-
599b31
-  ppc_supply_gregset (regset, regcache, -1, gregsetp, sizeof (*gregsetp));
599b31
-}
599b31
-
599b31
-void
599b31
-fill_gregset (const struct regcache *regcache,
599b31
-	      gdb_gregset_t *gregsetp, int regno)
599b31
-{
599b31
-  const struct regset *regset = ppc_linux_gregset (sizeof (long));
599b31
-
599b31
-  if (regno == -1)
599b31
-    memset (gregsetp, 0, sizeof (*gregsetp));
599b31
-  ppc_collect_gregset (regset, regcache, regno, gregsetp, sizeof (*gregsetp));
599b31
-}
599b31
-
599b31
-void
599b31
-supply_fpregset (struct regcache *regcache, const gdb_fpregset_t * fpregsetp)
599b31
-{
599b31
-  const struct regset *regset = ppc_linux_fpregset ();
599b31
-
599b31
-  ppc_supply_fpregset (regset, regcache, -1,
599b31
-		       fpregsetp, sizeof (*fpregsetp));
599b31
-}
599b31
-
599b31
-void
599b31
-fill_fpregset (const struct regcache *regcache,
599b31
-	       gdb_fpregset_t *fpregsetp, int regno)
599b31
-{
599b31
-  const struct regset *regset = ppc_linux_fpregset ();
599b31
-
599b31
-  ppc_collect_fpregset (regset, regcache, regno,
599b31
-			fpregsetp, sizeof (*fpregsetp));
599b31
-}
599b31
-
599b31
-int
599b31
-ppc_linux_nat_target::auxv_parse (gdb_byte **readptr,
599b31
-				  gdb_byte *endptr, CORE_ADDR *typep,
599b31
-				  CORE_ADDR *valp)
599b31
-{
599b31
-  int tid = inferior_ptid.lwp ();
599b31
-  if (tid == 0)
599b31
-    tid = inferior_ptid.pid ();
599b31
-
599b31
-  int sizeof_auxv_field = ppc_linux_target_wordsize (tid);
599b31
-
599b31
-  enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
599b31
-  gdb_byte *ptr = *readptr;
599b31
-
599b31
-  if (endptr == ptr)
599b31
-    return 0;
599b31
-
599b31
-  if (endptr - ptr < sizeof_auxv_field * 2)
599b31
-    return -1;
599b31
-
599b31
-  *typep = extract_unsigned_integer (ptr, sizeof_auxv_field, byte_order);
599b31
-  ptr += sizeof_auxv_field;
599b31
-  *valp = extract_unsigned_integer (ptr, sizeof_auxv_field, byte_order);
599b31
-  ptr += sizeof_auxv_field;
599b31
-
599b31
-  *readptr = ptr;
599b31
-  return 1;
599b31
-}
599b31
-
599b31
-const struct target_desc *
599b31
-ppc_linux_nat_target::read_description ()
599b31
-{
599b31
-  int tid = inferior_ptid.lwp ();
599b31
-  if (tid == 0)
599b31
-    tid = inferior_ptid.pid ();
599b31
-
599b31
-  if (have_ptrace_getsetevrregs)
599b31
-    {
599b31
-      struct gdb_evrregset_t evrregset;
599b31
-
599b31
-      if (ptrace (PTRACE_GETEVRREGS, tid, 0, &evrregset) >= 0)
599b31
-        return tdesc_powerpc_e500l;
599b31
-
599b31
-      /* EIO means that the PTRACE_GETEVRREGS request isn't supported.
599b31
-	 Anything else needs to be reported.  */
599b31
-      else if (errno != EIO)
599b31
-	perror_with_name (_("Unable to fetch SPE registers"));
599b31
-    }
599b31
-
599b31
-  struct ppc_linux_features features = ppc_linux_no_features;
599b31
-
599b31
-  features.wordsize = ppc_linux_target_wordsize (tid);
599b31
-
599b31
-  CORE_ADDR hwcap = linux_get_hwcap (current_top_target ());
599b31
-  CORE_ADDR hwcap2 = linux_get_hwcap2 (current_top_target ());
599b31
-
599b31
-  if (have_ptrace_getsetvsxregs
599b31
-      && (hwcap & PPC_FEATURE_HAS_VSX))
599b31
-    {
599b31
-      gdb_vsxregset_t vsxregset;
599b31
-
599b31
-      if (ptrace (PTRACE_GETVSXREGS, tid, 0, &vsxregset) >= 0)
599b31
-	features.vsx = true;
599b31
-
599b31
-      /* EIO means that the PTRACE_GETVSXREGS request isn't supported.
599b31
-	 Anything else needs to be reported.  */
599b31
-      else if (errno != EIO)
599b31
-	perror_with_name (_("Unable to fetch VSX registers"));
599b31
-    }
599b31
-
599b31
-  if (have_ptrace_getvrregs
599b31
-      && (hwcap & PPC_FEATURE_HAS_ALTIVEC))
599b31
-    {
599b31
-      gdb_vrregset_t vrregset;
599b31
-
599b31
-      if (ptrace (PTRACE_GETVRREGS, tid, 0, &vrregset) >= 0)
599b31
-        features.altivec = true;
599b31
-
599b31
-      /* EIO means that the PTRACE_GETVRREGS request isn't supported.
599b31
-	 Anything else needs to be reported.  */
599b31
-      else if (errno != EIO)
599b31
-	perror_with_name (_("Unable to fetch AltiVec registers"));
599b31
-    }
599b31
-
599b31
-  if (hwcap & PPC_FEATURE_CELL)
599b31
-    features.cell = true;
599b31
-
599b31
-  features.isa205 = ppc_linux_has_isa205 (hwcap);
599b31
-
599b31
-  if ((hwcap2 & PPC_FEATURE2_DSCR)
599b31
-      && check_regset (tid, NT_PPC_PPR, PPC_LINUX_SIZEOF_PPRREGSET)
599b31
-      && check_regset (tid, NT_PPC_DSCR, PPC_LINUX_SIZEOF_DSCRREGSET))
599b31
-    {
599b31
-      features.ppr_dscr = true;
599b31
-      if ((hwcap2 & PPC_FEATURE2_ARCH_2_07)
599b31
-	  && (hwcap2 & PPC_FEATURE2_TAR)
599b31
-	  && (hwcap2 & PPC_FEATURE2_EBB)
599b31
-	  && check_regset (tid, NT_PPC_TAR, PPC_LINUX_SIZEOF_TARREGSET)
599b31
-	  && check_regset (tid, NT_PPC_EBB, PPC_LINUX_SIZEOF_EBBREGSET)
599b31
-	  && check_regset (tid, NT_PPC_PMU, PPC_LINUX_SIZEOF_PMUREGSET))
599b31
-	{
599b31
-	  features.isa207 = true;
599b31
-	  if ((hwcap2 & PPC_FEATURE2_HTM)
599b31
-	      && check_regset (tid, NT_PPC_TM_SPR,
599b31
-			       PPC_LINUX_SIZEOF_TM_SPRREGSET))
599b31
-	    features.htm = true;
599b31
-	}
599b31
-    }
599b31
-
599b31
-  return ppc_linux_match_description (features);
599b31
-}
599b31
-
599b31
+void _initialize_ppc_linux_nat ();
599b31
 void
599b31
 _initialize_ppc_linux_nat (void)
599b31
 {