From: Andreas Arnez Date: Mon, 25 Sep 2017 14:02:23 +0000 (+0200) Subject: S390: Add guarded-storage register support to gdbserver X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ad3396348e0ebb61fdf71cff307bac08175ed366;p=binutils-gdb.git S390: Add guarded-storage register support to gdbserver Enable gdbserver to deal with the new guarded-storage register sets. gdb/gdbserver/ChangeLog: * configure.srv (s390*-*-linux*): Add s390-gs-linux64.o and s390x-gs-linux64.o to srv_regobj. Add s390-gs-linux64.xml, s390x-gs-linux64.xml, s390-gs.xml, and s390-gsbc.xml to srv_xmlfiles. Add s390-gs-linux64-ipa.o and s390x-gs-linux64-ipa.o to ipa_obj. * linux-s390-low.c (HWCAP_S390_GS): New define. (s390_fill_gs, s390_store_gs, s390_fill_gsbc, s390_store_gsbc): New functions. (s390_regsets): Add regsets for NT_S390_GS_CB and NT_S390_GS_BC. (s390_arch_setup): Check for guarded-storage support and choose appropriate tdesc. (initialize_low_arch): Invoke init_registers_s390_gs_linux64 and init_registers_s390x_gs_linux64. * linux-s390-tdesc.h (enum s390_linux_tdesc) : New enum value. (init_registers_s390x_gs_linux64, tdesc_s390x_gs_linux64) (init_registers_s390_gs_linux64, tdesc_s390_gs_linux64): Declare. --- diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index a82dd863906..a628b966e77 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,23 @@ +2017-09-25 Andreas Arnez + + * configure.srv (s390*-*-linux*): Add s390-gs-linux64.o and + s390x-gs-linux64.o to srv_regobj. Add s390-gs-linux64.xml, + s390x-gs-linux64.xml, s390-gs.xml, and s390-gsbc.xml to + srv_xmlfiles. Add s390-gs-linux64-ipa.o and + s390x-gs-linux64-ipa.o to ipa_obj. + * linux-s390-low.c (HWCAP_S390_GS): New define. + (s390_fill_gs, s390_store_gs, s390_fill_gsbc, s390_store_gsbc): + New functions. + (s390_regsets): Add regsets for NT_S390_GS_CB and NT_S390_GS_BC. + (s390_arch_setup): Check for guarded-storage support and choose + appropriate tdesc. + (initialize_low_arch): Invoke init_registers_s390_gs_linux64 and + init_registers_s390x_gs_linux64. + * linux-s390-tdesc.h (enum s390_linux_tdesc) : New + enum value. + (init_registers_s390x_gs_linux64, tdesc_s390x_gs_linux64) + (init_registers_s390_gs_linux64, tdesc_s390_gs_linux64): Declare. + 2017-09-22 Simon Marchi * win32-i386-low.c (i386_arch_setup): Call init_target_desc. diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv index 2a0c2b29647..80b4b377765 100644 --- a/gdb/gdbserver/configure.srv +++ b/gdb/gdbserver/configure.srv @@ -285,12 +285,14 @@ case "${target}" in 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} s390-gs-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_regobj="${srv_regobj} s390x-gs-linux64.o" srv_tgtobj="$srv_linux_obj linux-s390-low.o" srv_xmlfiles="s390-linux32.xml" srv_xmlfiles="${srv_xmlfiles} s390-linux32v1.xml" @@ -301,12 +303,14 @@ case "${target}" in 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} s390-gs-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} s390x-gs-linux64.xml" srv_xmlfiles="${srv_xmlfiles} s390-core32.xml" srv_xmlfiles="${srv_xmlfiles} s390-core64.xml" srv_xmlfiles="${srv_xmlfiles} s390x-core64.xml" @@ -314,6 +318,8 @@ case "${target}" in srv_xmlfiles="${srv_xmlfiles} s390-fpr.xml" srv_xmlfiles="${srv_xmlfiles} s390-tdb.xml" srv_xmlfiles="${srv_xmlfiles} s390-vx.xml" + srv_xmlfiles="${srv_xmlfiles} s390-gs.xml" + srv_xmlfiles="${srv_xmlfiles} s390-gsbc.xml" srv_linux_usrregs=yes srv_linux_regsets=yes srv_linux_thread_db=yes @@ -327,12 +333,14 @@ case "${target}" in ipa_obj="${ipa_obj} s390-vx-linux64-ipa.o" ipa_obj="${ipa_obj} s390-te-linux64-ipa.o" ipa_obj="${ipa_obj} s390-tevx-linux64-ipa.o" + ipa_obj="${ipa_obj} s390-gs-linux64-ipa.o" ipa_obj="${ipa_obj} s390x-linux64-ipa.o" ipa_obj="${ipa_obj} s390x-linux64v1-ipa.o" ipa_obj="${ipa_obj} s390x-linux64v2-ipa.o" ipa_obj="${ipa_obj} s390x-vx-linux64-ipa.o" ipa_obj="${ipa_obj} s390x-te-linux64-ipa.o" ipa_obj="${ipa_obj} s390x-tevx-linux64-ipa.o" + ipa_obj="${ipa_obj} s390x-gs-linux64-ipa.o" ;; sh*-*-linux*) srv_regobj=reg-sh.o srv_tgtobj="$srv_linux_obj linux-sh-low.o" diff --git a/gdb/gdbserver/linux-s390-low.c b/gdb/gdbserver/linux-s390-low.c index f02c2d3569a..d7aa31c319a 100644 --- a/gdb/gdbserver/linux-s390-low.c +++ b/gdb/gdbserver/linux-s390-low.c @@ -45,6 +45,10 @@ #define HWCAP_S390_VX 2048 #endif +#ifndef HWCAP_S390_GS +#define HWCAP_S390_GS 16384 +#endif + #define s390_num_regs 52 static int s390_regmap[] = { @@ -370,6 +374,46 @@ s390_store_vxrs_high (struct regcache *regcache, const void *buf) supply_register (regcache, v16 + i, (const char *) buf + 16 * i); } +static void +s390_fill_gs (struct regcache *regcache, void *buf) +{ + int gsd = find_regno (regcache->tdesc, "gsd"); + int i; + + for (i = 0; i < 3; i++) + collect_register (regcache, gsd + i, (char *) buf + 8 * (i + 1)); +} + +static void +s390_store_gs (struct regcache *regcache, const void *buf) +{ + int gsd = find_regno (regcache->tdesc, "gsd"); + int i; + + for (i = 0; i < 3; i++) + supply_register (regcache, gsd + i, (const char *) buf + 8 * (i + 1)); +} + +static void +s390_fill_gsbc (struct regcache *regcache, void *buf) +{ + int bc_gsd = find_regno (regcache->tdesc, "bc_gsd"); + int i; + + for (i = 0; i < 3; i++) + collect_register (regcache, bc_gsd + i, (char *) buf + 8 * (i + 1)); +} + +static void +s390_store_gsbc (struct regcache *regcache, const void *buf) +{ + int bc_gsd = find_regno (regcache->tdesc, "bc_gsd"); + int i; + + for (i = 0; i < 3; i++) + supply_register (regcache, bc_gsd + i, (const char *) buf + 8 * (i + 1)); +} + static struct regset_info s390_regsets[] = { { 0, 0, 0, 0, GENERAL_REGS, s390_fill_gregset, NULL }, #ifndef __s390x__ @@ -388,6 +432,10 @@ static struct regset_info s390_regsets[] = { 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 }, + { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_S390_GS_CB, 0, + EXTENDED_REGS, s390_fill_gs, s390_store_gs }, + { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_S390_GS_BC, 0, + EXTENDED_REGS, s390_fill_gsbc, s390_store_gsbc }, NULL_REGSET }; @@ -501,6 +549,8 @@ s390_arch_setup (void) 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); + int have_regset_gs = s390_check_regset (pid, NT_S390_GS_CB, 32) + && s390_check_regset (pid, NT_S390_GS_BC, 32); /* Assume 31-bit inferior process. */ if (have_regset_system_call) @@ -529,8 +579,13 @@ s390_arch_setup (void) if (have_regset_vxrs) have_regset_vxrs = (s390_get_hwcap (tdesc_s390x_linux64v2) & HWCAP_S390_VX) != 0; + if (have_regset_gs) + have_regset_gs = + (s390_get_hwcap (tdesc_s390x_linux64v2) & HWCAP_S390_GS) != 0; - if (have_regset_vxrs) + if (have_regset_gs) + tdesc = tdesc_s390x_gs_linux64; + else if (have_regset_vxrs) tdesc = (have_regset_tdb ? tdesc_s390x_tevx_linux64 : tdesc_s390x_vx_linux64); else if (have_regset_tdb) @@ -554,8 +609,12 @@ s390_arch_setup (void) have_regset_tdb = (s390_get_hwcap (tdesc) & HWCAP_S390_TE) != 0; if (have_regset_vxrs) have_regset_vxrs = (s390_get_hwcap (tdesc) & HWCAP_S390_VX) != 0; + if (have_regset_gs) + have_regset_gs = (s390_get_hwcap (tdesc) & HWCAP_S390_GS) != 0; - if (have_regset_vxrs) + if (have_regset_gs) + tdesc = tdesc_s390_gs_linux64; + else if (have_regset_vxrs) tdesc = (have_regset_tdb ? tdesc_s390_tevx_linux64 : tdesc_s390_vx_linux64); else if (have_regset_tdb) @@ -596,6 +655,9 @@ s390_arch_setup (void) case NT_S390_VXRS_HIGH: regset->size = have_regset_vxrs ? 256 : 0; break; + case NT_S390_GS_CB: + case NT_S390_GS_BC: + regset->size = have_regset_gs ? 32 : 0; default: break; } @@ -2797,6 +2859,7 @@ initialize_low_arch (void) init_registers_s390_te_linux64 (); init_registers_s390_vx_linux64 (); init_registers_s390_tevx_linux64 (); + init_registers_s390_gs_linux64 (); #ifdef __s390x__ init_registers_s390x_linux64 (); init_registers_s390x_linux64v1 (); @@ -2804,6 +2867,7 @@ initialize_low_arch (void) init_registers_s390x_te_linux64 (); init_registers_s390x_vx_linux64 (); init_registers_s390x_tevx_linux64 (); + init_registers_s390x_gs_linux64 (); #endif initialize_regsets_info (&s390_regsets_info); diff --git a/gdb/gdbserver/linux-s390-tdesc.h b/gdb/gdbserver/linux-s390-tdesc.h index 6dc3899b4cc..170ab8afc4f 100644 --- a/gdb/gdbserver/linux-s390-tdesc.h +++ b/gdb/gdbserver/linux-s390-tdesc.h @@ -31,6 +31,7 @@ enum s390_linux_tdesc { S390_TDESC_TE, S390_TDESC_VX, S390_TDESC_TEVX, + S390_TDESC_GS, }; #ifdef __s390x__ @@ -59,6 +60,10 @@ extern const struct target_desc *tdesc_s390x_vx_linux64; void init_registers_s390x_tevx_linux64 (void); extern const struct target_desc *tdesc_s390x_tevx_linux64; +/* Defined in auto-generated file s390x-gs-linux64.c. */ +void init_registers_s390x_gs_linux64 (void); +extern const struct target_desc *tdesc_s390x_gs_linux64; + #endif #if !defined __s390x__ || !defined IN_PROCESS_AGENT @@ -99,4 +104,8 @@ extern const struct target_desc *tdesc_s390_vx_linux64; void init_registers_s390_tevx_linux64 (void); extern const struct target_desc *tdesc_s390_tevx_linux64; +/* Defined in auto-generated file s390-gs-linux64.c. */ +void init_registers_s390_gs_linux64 (void); +extern const struct target_desc *tdesc_s390_gs_linux64; + #endif