Fix checks for VSX and Altivec availability on Power

Message ID 1460756881-25422-1-git-send-email-emachado@linux.vnet.ibm.com
State New, archived
Headers

Commit Message

Edjunior Barbosa Machado April 15, 2016, 9:48 p.m. UTC
  Hi,

in order to identify if it is running in a machine with VSX available, current
GDB is relying only on the ptrace call using PTRACE_GETVSXREGS, which is
successful in some kernels even if the processor version does not have such
feature (as Power6 and previous), leading to show registers that actually do
not exist.  This simple patch fixes this issue adding checks using
PPC_FEATURE_HAS_VSX and PPC_FEATURE_HAS_ALTIVEC from ppc hwcap to assure these
features are available.  OK?

Thanks and regards,
--
Edjunior

gdb/ChangeLog
2016-04-15  Edjunior Barbosa Machado  <emachado@linux.vnet.ibm.com>

	* ppc-linux-nat.c (ppc_linux_read_description): Use PPC_FEATURE_HAS_VSX
	and PPC_FEATURE_HAS_ALTIVEC to check if such features are available.
  

Patch

diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
index bf91462..84c14a1 100644
--- a/gdb/ppc-linux-nat.c
+++ b/gdb/ppc-linux-nat.c
@@ -2419,7 +2419,8 @@  ppc_linux_read_description (struct target_ops *ops)
 	perror_with_name (_("Unable to fetch SPE registers"));
     }
 
-  if (have_ptrace_getsetvsxregs)
+  if (have_ptrace_getsetvsxregs
+      && (ppc_linux_get_hwcap () & PPC_FEATURE_HAS_VSX))
     {
       gdb_vsxregset_t vsxregset;
 
@@ -2432,7 +2433,8 @@  ppc_linux_read_description (struct target_ops *ops)
 	perror_with_name (_("Unable to fetch VSX registers"));
     }
 
-  if (have_ptrace_getvrregs)
+  if (have_ptrace_getvrregs
+      && (ppc_linux_get_hwcap () & PPC_FEATURE_HAS_ALTIVEC))
     {
       gdb_vrregset_t vrregset;