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

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