From 7ca18ed6d22398dd3009ba72d3a1e7747e40753d Mon Sep 17 00:00:00 2001 From: Edjunior Barbosa Machado Date: Fri, 26 Oct 2018 09:37:54 -0300 Subject: [PowerPC] Add support for PPR and DSCR This patch adds gdb support for the Program Priorty Register and the Data Stream Control Register, for the powerpc linux native and core file targets, and for the powerpc linux server stub. gdb/ChangeLog: 2018-10-26 Edjunior Barbosa Machado Pedro Franco de Carvalho * arch/ppc-linux-tdesc.h (tdesc_powerpc_isa205_ppr_dscr_vsx32l) (tdesc_powerpc_isa205_ppr_dscr_vsx64l): Declare. * arch/ppc-linux-common.h (PPC_LINUX_SIZEOF_PPRREGSET) (PPC_LINUX_SIZEOF_DSCRREGSET): Define. (struct ppc_linux_features) : New field. (ppc_linux_no_features): Add initializer for ppr_dscr field. * arch/ppc-linux-common.c (ppc_linux_match_description): Return new tdescs. * nat/ppc-linux.h (PPC_FEATURE2_DSCR, NT_PPC_PPR, NT_PPC_DSCR): Define if not already defined. * features/Makefile (WHICH): Add rs6000/powerpc-isa205-ppr-dscr-vsx32l and rs6000/powerpc-isa205-ppr-dscr-vsx64l. (XMLTOC): Add rs6000/powerpc-isa205-ppr-dscr-vsx32l.xml and rs6000/powerpc-isa205-ppr-dscr-vsx64l.xml. * features/rs6000/power-dscr.xml: New file. * features/rs6000/power-ppr.xml: New file. * features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.xml: New file. * features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.xml: New file. * features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c: Generate. * features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c: Generate. * regformats/rs6000/powerpc-isa205-ppr-dscr-vsx32l.dat: Generate. * regformats/rs6000/powerpc-isa205-ppr-dscr-vsx64l.dat: Generate. * ppc-linux-nat.c: Include . (fetch_regset, store_regset, check_regset): New functions. (fetch_register, fetch_ppc_registers): Call fetch_regset with DSCR and PPR regsets. (store_register, store_ppc_registers): Call store_regset with DSCR and PPR regsets. (ppc_linux_get_hwcap2): New function. (ppc_linux_nat_target::read_description): Call ppc_linux_get_hwcap2 and check_regset, set ppr_dscr field in the features struct if needed. * ppc-linux-tdep.c: Include features/rs6000/powerpc-isa205-ppr-dscr-vsx32l.c and features/rs6000/powerpc-isa205-ppr-dscr-vsx64l.c. (ppc32_regmap_ppr, ppc32_regmap_dscr, ppc32_linux_pprregset) (ppc32_linux_dscrregset): New globals. (ppc_linux_iterate_over_regset_sections): Call back with the ppr and dscr regsets. (ppc_linux_core_read_description): Check if the ppr and dscr sections are present and set ppr_dscr in the features struct. (_initialize_ppc_linux_tdep): Call initialize_tdesc_powerpc_isa205_ppr_dscr_vsx32l and initialize_tdesc_powerpc_isa205_ppr_dscr_vsx64l. * ppc-linux-tdep.h (ppc32_linux_pprregset) (ppc32_linux_dscrregset): Declare. * ppc-tdep.h (struct gdbarch_tdep) : New field. : New field. (enum) : New enum values. * rs6000-tdep.c (rs6000_gdbarch_init): Look for and validate ppr and dscr features. (ppc_process_record_op31): Record changes to PPR and DSCR. gdb/gdbserver/ChangeLog: 2018-10-26 Edjunior Barbosa Machado Pedro Franco de Carvalho * configure.srv (ipa_ppc_linux_regobj): Add powerpc-isa205-ppr-dscr-vsx32l-ipa.o and powerpc-isa205-ppr-dscr-vsx64l-ipa.o. (powerpc*-*-linux*): Add powerpc-isa205-ppr-dscr-vsx32l.o and powerpc-isa205-ppr-dscr-vsx64l.o to srv_regobj, add rs6000/power-dscr.xml, rs6000/power-ppr.xml, rs6000/powerpc-isa205-ppr-dscr-vsx32l.xml and rs6000/powerpc-isa205-ppr-dscr-vsx64l.xml to srv_xmlfiles. * linux-ppc-tdesc-init.h (enum ppc_linux_tdesc) : New enum value. (init_registers_powerpc_isa205_ppr_dscr_vsx32l) (init_registers_powerpc_isa205_ppr_dscr_vsx64l): Declare. * linux-ppc-low.c: Include "elf/common.h" and . (ppc_hwcap): Add comment. (ppc_hwcap2): New global. (ppc_check_regset, ppc_fill_pprregset, ppc_store_pprregset) (ppc_fill_dscrregset, ppc_store_dscrregset): New functions. (ppc_regsets): Add entries for the DSCR and PPR regsets. (ppc_arch_setup): Get AT_HWCAP2. Set ppr_dscr in features struct when needed. Set sizes for the the DSCR and PPR regsets. (ppc_get_ipa_tdesc_idx): Return PPC_TDESC_ISA205_PPR_DSCR_VSX. (initialize_low_arch): Call init_registers_powerpc_isa205_ppr_dscr_vsx32l and init_registers_powerpc_isa205_ppr_dscr_vsx64l. * linux-ppc-ipa.c (get_ipa_tdesc): Handle PPC_TDESC_ISA205_PPR_DSCR_VSX. (initialize_low_tracepoint): Call init_registers_powerpc_isa205_ppr_dscr_vsx32l and init_registers_powerpc_isa205_ppr_dscr_vsx64l. gdb/testsuite/ChangeLog: 2018-10-26 Pedro Franco de Carvalho * gdb.arch/powerpc-ppr-dscr.c: New file. * gdb.arch/powerpc-ppr-dscr.exp: New file. gdb/doc/ChangeLog: 2018-10-26 Pedro Franco de Carvalho * gdb.texinfo (PowerPC Features): Describe new features "org.gnu.gdb.power.ppr" and "org.gnu.gdb.power.dscr". --- gdb/gdbserver/ChangeLog | 33 ++++++++++++ gdb/gdbserver/configure.srv | 8 ++- gdb/gdbserver/linux-ppc-ipa.c | 6 +++ gdb/gdbserver/linux-ppc-low.c | 97 ++++++++++++++++++++++++++++++++++++ gdb/gdbserver/linux-ppc-tdesc-init.h | 7 +++ 5 files changed, 150 insertions(+), 1 deletion(-) (limited to 'gdb/gdbserver') diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 42fafac..526b787 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,36 @@ +2018-10-26 Edjunior Barbosa Machado + Pedro Franco de Carvalho + + * configure.srv (ipa_ppc_linux_regobj): Add + powerpc-isa205-ppr-dscr-vsx32l-ipa.o and + powerpc-isa205-ppr-dscr-vsx64l-ipa.o. + (powerpc*-*-linux*): Add powerpc-isa205-ppr-dscr-vsx32l.o and + powerpc-isa205-ppr-dscr-vsx64l.o to srv_regobj, add + rs6000/power-dscr.xml, rs6000/power-ppr.xml, + rs6000/powerpc-isa205-ppr-dscr-vsx32l.xml and + rs6000/powerpc-isa205-ppr-dscr-vsx64l.xml to srv_xmlfiles. + * linux-ppc-tdesc-init.h (enum ppc_linux_tdesc) + : New enum value. + (init_registers_powerpc_isa205_ppr_dscr_vsx32l) + (init_registers_powerpc_isa205_ppr_dscr_vsx64l): Declare. + * linux-ppc-low.c: Include "elf/common.h" and . + (ppc_hwcap): Add comment. + (ppc_hwcap2): New global. + (ppc_check_regset, ppc_fill_pprregset, ppc_store_pprregset) + (ppc_fill_dscrregset, ppc_store_dscrregset): New functions. + (ppc_regsets): Add entries for the DSCR and PPR regsets. + (ppc_arch_setup): Get AT_HWCAP2. Set ppr_dscr in features struct + when needed. Set sizes for the the DSCR and PPR regsets. + (ppc_get_ipa_tdesc_idx): Return PPC_TDESC_ISA205_PPR_DSCR_VSX. + (initialize_low_arch): Call + init_registers_powerpc_isa205_ppr_dscr_vsx32l and + init_registers_powerpc_isa205_ppr_dscr_vsx64l. + * linux-ppc-ipa.c (get_ipa_tdesc): Handle + PPC_TDESC_ISA205_PPR_DSCR_VSX. + (initialize_low_tracepoint): Call + init_registers_powerpc_isa205_ppr_dscr_vsx32l and + init_registers_powerpc_isa205_ppr_dscr_vsx64l. + 2018-10-26 Pedro Franco de Carvalho * linux-ppc-low.c (ppc_fill_vrregset): Remove memset calls. diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv index 636d830..bb0272a 100644 --- a/gdb/gdbserver/configure.srv +++ b/gdb/gdbserver/configure.srv @@ -32,7 +32,7 @@ else srv_amd64_linux_regobj="" fi -ipa_ppc_linux_regobj="powerpc-32l-ipa.o powerpc-altivec32l-ipa.o powerpc-cell32l-ipa.o powerpc-vsx32l-ipa.o powerpc-isa205-32l-ipa.o powerpc-isa205-altivec32l-ipa.o powerpc-isa205-vsx32l-ipa.o powerpc-e500l-ipa.o powerpc-64l-ipa.o powerpc-altivec64l-ipa.o powerpc-cell64l-ipa.o powerpc-vsx64l-ipa.o powerpc-isa205-64l-ipa.o powerpc-isa205-altivec64l-ipa.o powerpc-isa205-vsx64l-ipa.o" +ipa_ppc_linux_regobj="powerpc-32l-ipa.o powerpc-altivec32l-ipa.o powerpc-cell32l-ipa.o powerpc-vsx32l-ipa.o powerpc-isa205-32l-ipa.o powerpc-isa205-altivec32l-ipa.o powerpc-isa205-vsx32l-ipa.o powerpc-isa205-ppr-dscr-vsx32l-ipa.o powerpc-e500l-ipa.o powerpc-64l-ipa.o powerpc-altivec64l-ipa.o powerpc-cell64l-ipa.o powerpc-vsx64l-ipa.o powerpc-isa205-64l-ipa.o powerpc-isa205-altivec64l-ipa.o powerpc-isa205-vsx64l-ipa.o powerpc-isa205-ppr-dscr-vsx64l-ipa.o" # Linux object files. This is so we don't have to repeat # these files over and over again. @@ -217,6 +217,7 @@ case "${target}" in srv_regobj="${srv_regobj} powerpc-isa205-32l.o" srv_regobj="${srv_regobj} powerpc-isa205-altivec32l.o" srv_regobj="${srv_regobj} powerpc-isa205-vsx32l.o" + srv_regobj="${srv_regobj} powerpc-isa205-ppr-dscr-vsx32l.o" srv_regobj="${srv_regobj} powerpc-e500l.o" srv_regobj="${srv_regobj} powerpc-64l.o" srv_regobj="${srv_regobj} powerpc-altivec64l.o" @@ -225,6 +226,7 @@ case "${target}" in srv_regobj="${srv_regobj} powerpc-isa205-64l.o" srv_regobj="${srv_regobj} powerpc-isa205-altivec64l.o" srv_regobj="${srv_regobj} powerpc-isa205-vsx64l.o" + srv_regobj="${srv_regobj} powerpc-isa205-ppr-dscr-vsx64l.o" srv_tgtobj="$srv_linux_obj linux-ppc-low.o ppc-linux.o" srv_tgtobj="${srv_tgtobj} arch/ppc-linux-common.o" srv_xmlfiles="rs6000/powerpc-32l.xml" @@ -234,12 +236,15 @@ case "${target}" in srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa205-32l.xml" srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa205-altivec32l.xml" srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa205-vsx32l.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa205-ppr-dscr-vsx32l.xml" srv_xmlfiles="${srv_xmlfiles} rs6000/power-altivec.xml" srv_xmlfiles="${srv_xmlfiles} rs6000/power-vsx.xml" srv_xmlfiles="${srv_xmlfiles} rs6000/power-core.xml" srv_xmlfiles="${srv_xmlfiles} rs6000/power-linux.xml" srv_xmlfiles="${srv_xmlfiles} rs6000/power-fpu.xml" srv_xmlfiles="${srv_xmlfiles} rs6000/power-fpu-isa205.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/power-dscr.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/power-ppr.xml" srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-e500l.xml" srv_xmlfiles="${srv_xmlfiles} rs6000/power-spe.xml" srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-64l.xml" @@ -249,6 +254,7 @@ case "${target}" in srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa205-64l.xml" srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa205-altivec64l.xml" srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa205-vsx64l.xml" + srv_xmlfiles="${srv_xmlfiles} rs6000/powerpc-isa205-ppr-dscr-vsx64l.xml" srv_xmlfiles="${srv_xmlfiles} rs6000/power64-core.xml" srv_xmlfiles="${srv_xmlfiles} rs6000/power64-linux.xml" srv_linux_usrregs=yes diff --git a/gdb/gdbserver/linux-ppc-ipa.c b/gdb/gdbserver/linux-ppc-ipa.c index f6861f0..c8b4c3b 100644 --- a/gdb/gdbserver/linux-ppc-ipa.c +++ b/gdb/gdbserver/linux-ppc-ipa.c @@ -191,6 +191,8 @@ get_ipa_tdesc (int idx) return tdesc_powerpc_isa205_altivec64l; case PPC_TDESC_ISA205_VSX: return tdesc_powerpc_isa205_vsx64l; + case PPC_TDESC_ISA205_PPR_DSCR_VSX: + return tdesc_powerpc_isa205_ppr_dscr_vsx64l; #else case PPC_TDESC_BASE: return tdesc_powerpc_32l; @@ -206,6 +208,8 @@ get_ipa_tdesc (int idx) return tdesc_powerpc_isa205_altivec32l; case PPC_TDESC_ISA205_VSX: return tdesc_powerpc_isa205_vsx32l; + case PPC_TDESC_ISA205_PPR_DSCR_VSX: + return tdesc_powerpc_isa205_ppr_dscr_vsx32l; case PPC_TDESC_E500: return tdesc_powerpc_e500l; #endif @@ -234,6 +238,7 @@ initialize_low_tracepoint (void) init_registers_powerpc_isa205_64l (); init_registers_powerpc_isa205_altivec64l (); init_registers_powerpc_isa205_vsx64l (); + init_registers_powerpc_isa205_ppr_dscr_vsx64l (); #else init_registers_powerpc_32l (); init_registers_powerpc_altivec32l (); @@ -242,6 +247,7 @@ initialize_low_tracepoint (void) init_registers_powerpc_isa205_32l (); init_registers_powerpc_isa205_altivec32l (); init_registers_powerpc_isa205_vsx32l (); + init_registers_powerpc_isa205_ppr_dscr_vsx32l (); init_registers_powerpc_e500l (); #endif } diff --git a/gdb/gdbserver/linux-ppc-low.c b/gdb/gdbserver/linux-ppc-low.c index d1ab69f..e7eab37 100644 --- a/gdb/gdbserver/linux-ppc-low.c +++ b/gdb/gdbserver/linux-ppc-low.c @@ -20,6 +20,8 @@ #include "server.h" #include "linux-low.h" +#include "elf/common.h" +#include #include #include @@ -41,8 +43,14 @@ #define PPC_LI(insn) (PPC_SEXT (PPC_FIELD (insn, 6, 24), 24) << 2) #define PPC_BD(insn) (PPC_SEXT (PPC_FIELD (insn, 16, 14), 14) << 2) +/* Holds the AT_HWCAP auxv entry. */ + static unsigned long ppc_hwcap; +/* Holds the AT_HWCAP2 auxv entry. */ + +static unsigned long ppc_hwcap2; + #define ppc_num_regs 73 @@ -116,6 +124,24 @@ static int ppc_regmap_e500[] = }; #endif +/* Check whether the kernel provides a register set with number + REGSET_ID of size REGSETSIZE for process/thread TID. */ + +static int +ppc_check_regset (int tid, int regset_id, int regsetsize) +{ + void *buf = alloca (regsetsize); + struct iovec iov; + + iov.iov_base = buf; + iov.iov_len = regsetsize; + + if (ptrace (PTRACE_GETREGSET, tid, regset_id, &iov) >= 0 + || errno == ENODATA) + return 1; + return 0; +} + static int ppc_cannot_store_register (int regno) { @@ -459,6 +485,46 @@ static void ppc_fill_gregset (struct regcache *regcache, void *buf) ppc_collect_ptrace_register (regcache, i, (char *) buf + ppc_regmap[i]); } +/* Program Priority Register regset fill function. */ + +static void +ppc_fill_pprregset (struct regcache *regcache, void *buf) +{ + char *ppr = (char *) buf; + + collect_register_by_name (regcache, "ppr", ppr); +} + +/* Program Priority Register regset store function. */ + +static void +ppc_store_pprregset (struct regcache *regcache, const void *buf) +{ + const char *ppr = (const char *) buf; + + supply_register_by_name (regcache, "ppr", ppr); +} + +/* Data Stream Control Register regset fill function. */ + +static void +ppc_fill_dscrregset (struct regcache *regcache, void *buf) +{ + char *dscr = (char *) buf; + + collect_register_by_name (regcache, "dscr", dscr); +} + +/* Data Stream Control Register regset store function. */ + +static void +ppc_store_dscrregset (struct regcache *regcache, const void *buf) +{ + const char *dscr = (const char *) buf; + + supply_register_by_name (regcache, "dscr", dscr); +} + static void ppc_fill_vsxregset (struct regcache *regcache, void *buf) { @@ -568,6 +634,10 @@ static struct regset_info ppc_regsets[] = { fetch them every time, but still fall back to PTRACE_PEEKUSER for the general registers. Some kernels support these, but not the newer PPC_PTRACE_GETREGS. */ + { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_PPR, 0, EXTENDED_REGS, + ppc_fill_pprregset, ppc_store_pprregset }, + { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_PPC_DSCR, 0, EXTENDED_REGS, + ppc_fill_dscrregset, ppc_store_dscrregset }, { PTRACE_GETVSXREGS, PTRACE_SETVSXREGS, 0, 0, EXTENDED_REGS, ppc_fill_vsxregset, ppc_store_vsxregset }, { PTRACE_GETVRREGS, PTRACE_SETVRREGS, 0, 0, EXTENDED_REGS, @@ -625,6 +695,7 @@ ppc_arch_setup (void) /* The value of current_process ()->tdesc needs to be set for this call. */ ppc_get_auxv (AT_HWCAP, &ppc_hwcap); + ppc_get_auxv (AT_HWCAP2, &ppc_hwcap2); features.isa205 = ppc_linux_has_isa205 (ppc_hwcap); @@ -634,6 +705,11 @@ ppc_arch_setup (void) if (ppc_hwcap & PPC_FEATURE_HAS_ALTIVEC) features.altivec = true; + if ((ppc_hwcap2 & PPC_FEATURE2_DSCR) + && ppc_check_regset (tid, NT_PPC_DSCR, PPC_LINUX_SIZEOF_DSCRREGSET) + && ppc_check_regset (tid, NT_PPC_PPR, PPC_LINUX_SIZEOF_PPRREGSET)) + features.ppr_dscr = true; + if (ppc_hwcap & PPC_FEATURE_CELL) features.cell = true; @@ -678,6 +754,21 @@ ppc_arch_setup (void) else regset->size = 0; break; + case PTRACE_GETREGSET: + switch (regset->nt_type) + { + case NT_PPC_PPR: + regset->size = (features.ppr_dscr ? + PPC_LINUX_SIZEOF_PPRREGSET : 0); + break; + case NT_PPC_DSCR: + regset->size = (features.ppr_dscr ? + PPC_LINUX_SIZEOF_DSCRREGSET : 0); + break; + default: + break; + } + break; default: break; } @@ -3053,6 +3144,8 @@ ppc_get_ipa_tdesc_idx (void) return PPC_TDESC_ISA205_ALTIVEC; if (tdesc == tdesc_powerpc_isa205_vsx64l) return PPC_TDESC_ISA205_VSX; + if (tdesc == tdesc_powerpc_isa205_ppr_dscr_vsx64l) + return PPC_TDESC_ISA205_PPR_DSCR_VSX; #endif if (tdesc == tdesc_powerpc_32l) @@ -3069,6 +3162,8 @@ ppc_get_ipa_tdesc_idx (void) return PPC_TDESC_ISA205_ALTIVEC; if (tdesc == tdesc_powerpc_isa205_vsx32l) return PPC_TDESC_ISA205_VSX; + if (tdesc == tdesc_powerpc_isa205_ppr_dscr_vsx32l) + return PPC_TDESC_ISA205_PPR_DSCR_VSX; if (tdesc == tdesc_powerpc_e500l) return PPC_TDESC_E500; @@ -3127,6 +3222,7 @@ initialize_low_arch (void) init_registers_powerpc_isa205_32l (); init_registers_powerpc_isa205_altivec32l (); init_registers_powerpc_isa205_vsx32l (); + init_registers_powerpc_isa205_ppr_dscr_vsx32l (); init_registers_powerpc_e500l (); #if __powerpc64__ init_registers_powerpc_64l (); @@ -3136,6 +3232,7 @@ initialize_low_arch (void) init_registers_powerpc_isa205_64l (); init_registers_powerpc_isa205_altivec64l (); init_registers_powerpc_isa205_vsx64l (); + init_registers_powerpc_isa205_ppr_dscr_vsx64l (); #endif initialize_regsets_info (&ppc_regsets_info); diff --git a/gdb/gdbserver/linux-ppc-tdesc-init.h b/gdb/gdbserver/linux-ppc-tdesc-init.h index 422e7bd..c5c10c0 100644 --- a/gdb/gdbserver/linux-ppc-tdesc-init.h +++ b/gdb/gdbserver/linux-ppc-tdesc-init.h @@ -29,6 +29,7 @@ enum ppc_linux_tdesc { PPC_TDESC_ISA205, PPC_TDESC_ISA205_ALTIVEC, PPC_TDESC_ISA205_VSX, + PPC_TDESC_ISA205_PPR_DSCR_VSX, PPC_TDESC_E500, }; @@ -55,6 +56,9 @@ void init_registers_powerpc_isa205_altivec32l (void); /* Defined in auto-generated file powerpc-isa205-vsx32l.c. */ void init_registers_powerpc_isa205_vsx32l (void); +/* Defined in auto-generated file powerpc-isa205-ppr-dscr-vsx32l.c. */ +void init_registers_powerpc_isa205_ppr_dscr_vsx32l (void); + /* Defined in auto-generated file powerpc-e500l.c. */ void init_registers_powerpc_e500l (void); @@ -83,4 +87,7 @@ void init_registers_powerpc_isa205_altivec64l (void); /* Defined in auto-generated file powerpc-isa205-vsx64l.c. */ void init_registers_powerpc_isa205_vsx64l (void); +/* Defined in auto-generated file powerpc-isa205-ppr-dscr-vsx64l.c. */ +void init_registers_powerpc_isa205_ppr_dscr_vsx64l (void); + #endif -- cgit v1.1