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