Blame SOURCES/gdb-rhbz1182151-ibm-z13-10of22.patch

0b42f8
commit bf2d68ab8c9da89a7caec2abdd2cc27c607f4a04
0b42f8
Author: Andreas Arnez <arnez@linux.vnet.ibm.com>
0b42f8
Date:   Mon Mar 2 10:57:40 2015 +0100
0b42f8
0b42f8
    S390: Add vector register support to gdbserver
0b42f8
    
0b42f8
    On S/390 targets with vector registers, enable gdbserver to advertise
0b42f8
    and handle the feature "org.gnu.gdb.s390.vx".
0b42f8
    
0b42f8
    gdb/gdbserver/ChangeLog:
0b42f8
    
0b42f8
    	* Makefile.in (s390-vx-linux64.c, s390-tevx-linux64.c)
0b42f8
    	(s390x-vx-linux64.c, s390x-tevx-linux64.c): New rules.
0b42f8
    	(clean): Add "rm -f" for above C files.
0b42f8
    	* configure.srv (srv_regobj): Add s390-vx-linux64.o,
0b42f8
    	s390-tevx-linux64.o, s390x-vx-linux64.o, and s390x-tevx-linux64.o.
0b42f8
    	(srv_xmlfiles): Add s390-vx-linux64.xml, s390-tevx-linux64.xml,
0b42f8
    	s390x-vx-linux64.xml, s390x-tevx-linux64.xml, and s390-vx.xml.
0b42f8
    	* linux-s390-low.c (HWCAP_S390_VX): New macro.
0b42f8
    	(init_registers_s390_vx_linux64, init_registers_s390_tevx_linux64)
0b42f8
    	(init_registers_s390x_vx_linux64)
0b42f8
    	(init_registers_s390x_tevx_linux64)
0b42f8
    	(tdesc_s390_vx_linux64, tdesc_s390_tevx_linux64)
0b42f8
    	(tdesc_s390x_vx_linux64, tdesc_s390x_tevx_linux64): New extern
0b42f8
    	declarations.
0b42f8
    	(s390_fill_vxrs_low, s390_store_vxrs_low, s390_fill_vxrs_high)
0b42f8
    	(s390_store_vxrs_high): New functions.
0b42f8
    	(s390_regsets): Add entries for NT_S390_VXRS_LOW and
0b42f8
    	NT_S390_VXRS_HIGH.
0b42f8
    	(s390_arch_setup): Add logic for selecting one of the new target
0b42f8
    	descriptions.  Activate the new vector regsets if applicable.
0b42f8
    	(initialize_low_arch): Also invoke init_registers_s390_vx_linux64,
0b42f8
    	init_registers_s390_tevx_linux64, init_registers_s390x_vx_linux64,
0b42f8
    	and init_registers_s390x_tevx_linux64.
0b42f8
0b42f8
### a/gdb/gdbserver/ChangeLog
0b42f8
### b/gdb/gdbserver/ChangeLog
0b42f8
## -1,3 +1,29 @@
0b42f8
+2015-03-02  Andreas Arnez  <arnez@linux.vnet.ibm.com>
0b42f8
+
0b42f8
+	* Makefile.in (s390-vx-linux64.c, s390-tevx-linux64.c)
0b42f8
+	(s390x-vx-linux64.c, s390x-tevx-linux64.c): New rules.
0b42f8
+	(clean): Add "rm -f" for above C files.
0b42f8
+	* configure.srv (srv_regobj): Add s390-vx-linux64.o,
0b42f8
+	s390-tevx-linux64.o, s390x-vx-linux64.o, and s390x-tevx-linux64.o.
0b42f8
+	(srv_xmlfiles): Add s390-vx-linux64.xml, s390-tevx-linux64.xml,
0b42f8
+	s390x-vx-linux64.xml, s390x-tevx-linux64.xml, and s390-vx.xml.
0b42f8
+	* linux-s390-low.c (HWCAP_S390_VX): New macro.
0b42f8
+	(init_registers_s390_vx_linux64, init_registers_s390_tevx_linux64)
0b42f8
+	(init_registers_s390x_vx_linux64)
0b42f8
+	(init_registers_s390x_tevx_linux64)
0b42f8
+	(tdesc_s390_vx_linux64, tdesc_s390_tevx_linux64)
0b42f8
+	(tdesc_s390x_vx_linux64, tdesc_s390x_tevx_linux64): New extern
0b42f8
+	declarations.
0b42f8
+	(s390_fill_vxrs_low, s390_store_vxrs_low, s390_fill_vxrs_high)
0b42f8
+	(s390_store_vxrs_high): New functions.
0b42f8
+	(s390_regsets): Add entries for NT_S390_VXRS_LOW and
0b42f8
+	NT_S390_VXRS_HIGH.
0b42f8
+	(s390_arch_setup): Add logic for selecting one of the new target
0b42f8
+	descriptions.  Activate the new vector regsets if applicable.
0b42f8
+	(initialize_low_arch): Also invoke init_registers_s390_vx_linux64,
0b42f8
+	init_registers_s390_tevx_linux64, init_registers_s390x_vx_linux64,
0b42f8
+	and init_registers_s390x_tevx_linux64.
0b42f8
+
0b42f8
 2015-03-01  Pedro Alves  <palves@redhat.com>
0b42f8
 
0b42f8
 	* linux-i386-ipa.c (gdb_agent_get_raw_reg): Constify 'raw_regs'
0b42f8
Index: gdb-7.6.1/gdb/gdbserver/Makefile.in
0b42f8
===================================================================
0b42f8
--- gdb-7.6.1.orig/gdb/gdbserver/Makefile.in	2016-02-21 23:23:47.125656373 +0100
0b42f8
+++ gdb-7.6.1/gdb/gdbserver/Makefile.in	2016-02-21 23:23:47.596659553 +0100
0b42f8
@@ -331,7 +331,9 @@
0b42f8
 	rm -f s390-linux32.c s390-linux64.c s390x-linux64.c
0b42f8
 	rm -f s390-linux32v1.c s390-linux32v2.c s390-linux64v1.c
0b42f8
 	rm -f s390-linux64v2.c s390x-linux64v1.c s390x-linux64v2.c
0b42f8
-	rm -f s390-te-linux32.c s390-te-linux64.c
0b42f8
+	rm -f s390-te-linux64.c s390x-te-linux64.c
0b42f8
+	rm -f s390-vx-linux64.c s390x-vx-linux64.c
0b42f8
+	rm -f s390-tevx-linux64.c s390x-tevx-linux64.c
0b42f8
 	rm -f tic6x-c64xp-linux.c tic6x-c64x-linux.c tic6x-c62x-linux.c
0b42f8
 	rm -f xml-builtin.c stamp-xml
0b42f8
 	rm -f i386-avx.c i386-avx-linux.c
0b42f8
@@ -663,6 +665,10 @@
0b42f8
 	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/s390-linux64v2.dat s390-linux64v2.c
0b42f8
 s390-te-linux64.c : $(srcdir)/../regformats/s390-te-linux64.dat $(regdat_sh)
0b42f8
 	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/s390-te-linux64.dat s390-te-linux64.c
0b42f8
+s390-vx-linux64.c : $(srcdir)/../regformats/s390-vx-linux64.dat $(regdat_sh)
0b42f8
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/s390-vx-linux64.dat s390-vx-linux64.c
0b42f8
+s390-tevx-linux64.c : $(srcdir)/../regformats/s390-tevx-linux64.dat $(regdat_sh)
0b42f8
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/s390-tevx-linux64.dat s390-tevx-linux64.c
0b42f8
 s390x-linux64.c : $(srcdir)/../regformats/s390x-linux64.dat $(regdat_sh)
0b42f8
 	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/s390x-linux64.dat s390x-linux64.c
0b42f8
 s390x-linux64v1.c : $(srcdir)/../regformats/s390x-linux64v1.dat $(regdat_sh)
0b42f8
@@ -671,6 +677,10 @@
0b42f8
 	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/s390x-linux64v2.dat s390x-linux64v2.c
0b42f8
 s390x-te-linux64.c : $(srcdir)/../regformats/s390x-te-linux64.dat $(regdat_sh)
0b42f8
 	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/s390x-te-linux64.dat s390x-te-linux64.c
0b42f8
+s390x-vx-linux64.c : $(srcdir)/../regformats/s390x-vx-linux64.dat $(regdat_sh)
0b42f8
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/s390x-vx-linux64.dat s390x-vx-linux64.c
0b42f8
+s390x-tevx-linux64.c : $(srcdir)/../regformats/s390x-tevx-linux64.dat $(regdat_sh)
0b42f8
+	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/s390x-tevx-linux64.dat s390x-tevx-linux64.c
0b42f8
 
0b42f8
 tic6x-c64xp-linux.c : $(srcdir)/../regformats/tic6x-c64xp-linux.dat $(regdat_sh)
0b42f8
 	$(SHELL) $(regdat_sh) $(srcdir)/../regformats/tic6x-c64xp-linux.dat tic6x-c64xp-linux.c
0b42f8
Index: gdb-7.6.1/gdb/gdbserver/configure.srv
0b42f8
===================================================================
0b42f8
--- gdb-7.6.1.orig/gdb/gdbserver/configure.srv	2016-02-21 23:23:47.125656373 +0100
0b42f8
+++ gdb-7.6.1/gdb/gdbserver/configure.srv	2016-02-21 23:23:47.596659553 +0100
0b42f8
@@ -260,10 +260,14 @@
0b42f8
 			srv_regobj="${srv_regobj} s390-linux64v1.o"
0b42f8
 			srv_regobj="${srv_regobj} s390-linux64v2.o"
0b42f8
 			srv_regobj="${srv_regobj} s390-te-linux64.o"
0b42f8
+			srv_regobj="${srv_regobj} s390-vx-linux64.o"
0b42f8
+			srv_regobj="${srv_regobj} s390-tevx-linux64.o"
0b42f8
 			srv_regobj="${srv_regobj} s390x-linux64.o"
0b42f8
 			srv_regobj="${srv_regobj} s390x-linux64v1.o"
0b42f8
 			srv_regobj="${srv_regobj} s390x-linux64v2.o"
0b42f8
 			srv_regobj="${srv_regobj} s390x-te-linux64.o"
0b42f8
+			srv_regobj="${srv_regobj} s390x-vx-linux64.o"
0b42f8
+			srv_regobj="${srv_regobj} s390x-tevx-linux64.o"
0b42f8
 			srv_tgtobj="linux-low.o linux-osdata.o linux-s390-low.o linux-procfs.o"
0b42f8
 			srv_tgtobj="${srv_tgtobj} linux-ptrace.o"
0b42f8
 			srv_xmlfiles="s390-linux32.xml"
0b42f8
@@ -273,16 +277,21 @@
0b42f8
 			srv_xmlfiles="${srv_xmlfiles} s390-linux64v1.xml"
0b42f8
 			srv_xmlfiles="${srv_xmlfiles} s390-linux64v2.xml"
0b42f8
 			srv_xmlfiles="${srv_xmlfiles} s390-te-linux64.xml"
0b42f8
+			srv_xmlfiles="${srv_xmlfiles} s390-vx-linux64.xml"
0b42f8
+			srv_xmlfiles="${srv_xmlfiles} s390-tevx-linux64.xml"
0b42f8
 			srv_xmlfiles="${srv_xmlfiles} s390x-linux64.xml"
0b42f8
 			srv_xmlfiles="${srv_xmlfiles} s390x-linux64v1.xml"
0b42f8
 			srv_xmlfiles="${srv_xmlfiles} s390x-linux64v2.xml"
0b42f8
 			srv_xmlfiles="${srv_xmlfiles} s390x-te-linux64.xml"
0b42f8
+			srv_xmlfiles="${srv_xmlfiles} s390x-vx-linux64.xml"
0b42f8
+			srv_xmlfiles="${srv_xmlfiles} s390x-tevx-linux64.xml"
0b42f8
 			srv_xmlfiles="${srv_xmlfiles} s390-core32.xml"
0b42f8
 			srv_xmlfiles="${srv_xmlfiles} s390-core64.xml"
0b42f8
 			srv_xmlfiles="${srv_xmlfiles} s390x-core64.xml"
0b42f8
 			srv_xmlfiles="${srv_xmlfiles} s390-acr.xml"
0b42f8
 			srv_xmlfiles="${srv_xmlfiles} s390-fpr.xml"
0b42f8
 			srv_xmlfiles="${srv_xmlfiles} s390-tdb.xml"
0b42f8
+			srv_xmlfiles="${srv_xmlfiles} s390-vx.xml"
0b42f8
 			srv_linux_usrregs=yes
0b42f8
 			srv_linux_regsets=yes
0b42f8
 			srv_linux_thread_db=yes
0b42f8
Index: gdb-7.6.1/gdb/gdbserver/linux-s390-low.c
0b42f8
===================================================================
0b42f8
--- gdb-7.6.1.orig/gdb/gdbserver/linux-s390-low.c	2016-02-21 23:23:47.169656670 +0100
0b42f8
+++ gdb-7.6.1/gdb/gdbserver/linux-s390-low.c	2016-02-21 23:23:52.590693275 +0100
0b42f8
@@ -36,6 +36,10 @@
0b42f8
 #define HWCAP_S390_TE 1024
0b42f8
 #endif
0b42f8
 
0b42f8
+#ifndef HWCAP_S390_VX
0b42f8
+#define HWCAP_S390_VX 2048
0b42f8
+#endif
0b42f8
+
0b42f8
 #ifndef PTRACE_GETREGSET
0b42f8
 #define PTRACE_GETREGSET 0x4204
0b42f8
 #endif
0b42f8
@@ -69,6 +73,22 @@
0b42f8
 /* Defined in auto-generated file s390-te-linux64.c.  */
0b42f8
 void init_registers_s390_te_linux64 (void);
0b42f8
 
0b42f8
+/* Defined in auto-generated file s390-vx-linux64.c.  */
0b42f8
+void init_registers_s390_vx_linux64 (void);
0b42f8
+extern const struct target_desc *tdesc_s390_vx_linux64;
0b42f8
+
0b42f8
+/* Defined in auto-generated file s390-tevx-linux64.c.  */
0b42f8
+void init_registers_s390_tevx_linux64 (void);
0b42f8
+extern const struct target_desc *tdesc_s390_tevx_linux64;
0b42f8
+
0b42f8
+/* Defined in auto-generated file s390x-vx-linux64.c.  */
0b42f8
+void init_registers_s390x_vx_linux64 (void);
0b42f8
+extern const struct target_desc *tdesc_s390x_vx_linux64;
0b42f8
+
0b42f8
+/* Defined in auto-generated file s390x-tevx-linux64.c.  */
0b42f8
+void init_registers_s390x_tevx_linux64 (void);
0b42f8
+extern const struct target_desc *tdesc_s390x_tevx_linux64;
0b42f8
+
0b42f8
 #define s390_num_regs 52
0b42f8
 
0b42f8
 static int s390_regmap[] = {
0b42f8
@@ -296,6 +316,46 @@
0b42f8
     supply_register (regcache, tr0 + i, (const char *) buf + 8 * (16 + i));
0b42f8
 }
0b42f8
 
0b42f8
+static void
0b42f8
+s390_fill_vxrs_low (struct regcache *regcache, void *buf)
0b42f8
+{
0b42f8
+  int v0 = find_regno ("v0l");
0b42f8
+  int i;
0b42f8
+
0b42f8
+  for (i = 0; i < 16; i++)
0b42f8
+    collect_register (regcache, v0 + i, (char *) buf + 8 * i);
0b42f8
+}
0b42f8
+
0b42f8
+static void
0b42f8
+s390_store_vxrs_low (struct regcache *regcache, const void *buf)
0b42f8
+{
0b42f8
+  int v0 = find_regno ("v0l");
0b42f8
+  int i;
0b42f8
+
0b42f8
+  for (i = 0; i < 16; i++)
0b42f8
+    supply_register (regcache, v0 + i, (const char *) buf + 8 * i);
0b42f8
+}
0b42f8
+
0b42f8
+static void
0b42f8
+s390_fill_vxrs_high (struct regcache *regcache, void *buf)
0b42f8
+{
0b42f8
+  int v16 = find_regno ("v16");
0b42f8
+  int i;
0b42f8
+
0b42f8
+  for (i = 0; i < 16; i++)
0b42f8
+    collect_register (regcache, v16 + i, (char *) buf + 16 * i);
0b42f8
+}
0b42f8
+
0b42f8
+static void
0b42f8
+s390_store_vxrs_high (struct regcache *regcache, const void *buf)
0b42f8
+{
0b42f8
+  int v16 = find_regno ("v16");
0b42f8
+  int i;
0b42f8
+
0b42f8
+  for (i = 0; i < 16; i++)
0b42f8
+    supply_register (regcache, v16 + i, (const char *) buf + 16 * i);
0b42f8
+}
0b42f8
+
0b42f8
 struct regset_info target_regsets[] = {
0b42f8
   { 0, 0, 0, 0, GENERAL_REGS, s390_fill_gregset, NULL },
0b42f8
   /* Last break address is read-only; no fill function.  */
0b42f8
@@ -306,6 +366,10 @@
0b42f8
   /* TDB is read-only.  */
0b42f8
   { PTRACE_GETREGSET, -1, NT_S390_TDB, 0, EXTENDED_REGS,
0b42f8
     NULL, s390_store_tdb },
0b42f8
+  { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_S390_VXRS_LOW, 0,
0b42f8
+    EXTENDED_REGS, s390_fill_vxrs_low, s390_store_vxrs_low },
0b42f8
+  { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_S390_VXRS_HIGH, 0,
0b42f8
+    EXTENDED_REGS, s390_fill_vxrs_high, s390_store_vxrs_high },
0b42f8
   { 0, 0, 0, -1, -1, NULL, NULL }
0b42f8
 };
0b42f8
 
0b42f8
@@ -404,6 +468,8 @@
0b42f8
   int have_regset_system_call
0b42f8
     = s390_check_regset (pid, NT_S390_SYSTEM_CALL, 4);
0b42f8
   int have_regset_tdb = s390_check_regset (pid, NT_S390_TDB, 256);
0b42f8
+  int have_regset_vxrs = s390_check_regset (pid, NT_S390_VXRS_LOW, 128)
0b42f8
+    && s390_check_regset (pid, NT_S390_VXRS_HIGH, 256);
0b42f8
 
0b42f8
   /* Assume 31-bit inferior process.  */
0b42f8
   if (have_regset_system_call)
0b42f8
@@ -432,8 +498,18 @@
0b42f8
 	if (have_regset_tdb)
0b42f8
 	  have_regset_tdb =
0b42f8
 	    (s390_get_hwcap () & HWCAP_S390_TE) != 0;
0b42f8
-
0b42f8
-	if (have_regset_tdb)
0b42f8
+	if (have_regset_vxrs)
0b42f8
+	  have_regset_vxrs =
0b42f8
+	    (s390_get_hwcap () & HWCAP_S390_VX) != 0;
0b42f8
+
0b42f8
+	if (have_regset_vxrs)
0b42f8
+	  {
0b42f8
+	    if (have_regset_tdb)
0b42f8
+	      init_registers_s390x_tevx_linux64 ();
0b42f8
+	    else
0b42f8
+	      init_registers_s390x_vx_linux64 ();
0b42f8
+	  }
0b42f8
+	else if (have_regset_tdb)
0b42f8
 	  init_registers_s390x_te_linux64 ();
0b42f8
 	else if (have_regset_system_call)
0b42f8
 	  init_registers_s390x_linux64v2 ();
0b42f8
@@ -449,8 +525,17 @@
0b42f8
       {
0b42f8
 	if (have_regset_tdb)
0b42f8
 	  have_regset_tdb = (s390_get_hwcap () & HWCAP_S390_TE) != 0;
0b42f8
+	if (have_regset_vxrs)
0b42f8
+	  have_regset_vxrs = (s390_get_hwcap () & HWCAP_S390_VX) != 0;
0b42f8
 
0b42f8
-	if (have_regset_tdb)
0b42f8
+	if (have_regset_vxrs)
0b42f8
+	  {
0b42f8
+	    if (have_regset_tdb)
0b42f8
+	      init_registers_s390_tevx_linux64 ();
0b42f8
+	    else
0b42f8
+	      init_registers_s390_vx_linux64 ();
0b42f8
+	  }
0b42f8
+	else if (have_regset_tdb)
0b42f8
 	  init_registers_s390_te_linux64 ();
0b42f8
 	if (have_regset_system_call)
0b42f8
 	  init_registers_s390_linux64v2 ();
0b42f8
@@ -477,6 +562,13 @@
0b42f8
 	  break;
0b42f8
 	case NT_S390_TDB:
0b42f8
 	  regset->size = have_regset_tdb ? 256 : 0;
0b42f8
+	  break;
0b42f8
+	case NT_S390_VXRS_LOW:
0b42f8
+	  regset->size = have_regset_vxrs ? 128 : 0;
0b42f8
+	  break;
0b42f8
+	case NT_S390_VXRS_HIGH:
0b42f8
+	  regset->size = have_regset_vxrs ? 256 : 0;
0b42f8
+	  break;
0b42f8
 	default:
0b42f8
 	  break;
0b42f8
 	}