diff options
author | Edjunior Barbosa Machado <emachado@linux.vnet.ibm.com> | 2018-10-26 09:37:54 -0300 |
---|---|---|
committer | Pedro Franco de Carvalho <pedromfc@linux.ibm.com> | 2018-10-26 10:03:46 -0300 |
commit | 7ca18ed6d22398dd3009ba72d3a1e7747e40753d (patch) | |
tree | c531258259984fbedc9196c14420ca56da323b75 /gdb/testsuite | |
parent | 93b4691f0fe1f8249de3c3f9d2e271cb0ba3254e (diff) | |
download | gdb-7ca18ed6d22398dd3009ba72d3a1e7747e40753d.zip gdb-7ca18ed6d22398dd3009ba72d3a1e7747e40753d.tar.gz gdb-7ca18ed6d22398dd3009ba72d3a1e7747e40753d.tar.bz2 |
[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 <emachado@linux.vnet.ibm.com>
Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
* 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) <ppr_dscr>: 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 <sys/uio.h>.
(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) <ppc_ppr_regnum>: New field.
<ppc_dscr_regnum>: New field.
(enum) <PPC_PPR_REGNUM, PPC_DSCR_REGNUM>: 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 <emachado@linux.vnet.ibm.com>
Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
* 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)
<PPC_TDESC_ISA205_PPR_DSCR_VSX>: 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 <sys/uio.h>.
(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 <pedromfc@linux.ibm.com>
* 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 <pedromfc@linux.ibm.com>
* gdb.texinfo (PowerPC Features): Describe new features
"org.gnu.gdb.power.ppr" and "org.gnu.gdb.power.dscr".
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/testsuite/gdb.arch/powerpc-ppr-dscr.c | 34 | ||||
-rw-r--r-- | gdb/testsuite/gdb.arch/powerpc-ppr-dscr.exp | 120 |
3 files changed, 159 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 611d788..f4aa66f 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-10-26 Pedro Franco de Carvalho <pedromfc@linux.ibm.com> + + * gdb.arch/powerpc-ppr-dscr.c: New file. + * gdb.arch/powerpc-ppr-dscr.exp: New file. + 2018-10-25 Tom de Vries <tdevries@suse.de> * gdb.base/valgrind-db-attach.exp: Rewrite to use vgdb. diff --git a/gdb/testsuite/gdb.arch/powerpc-ppr-dscr.c b/gdb/testsuite/gdb.arch/powerpc-ppr-dscr.c new file mode 100644 index 0000000..81a3a8d --- /dev/null +++ b/gdb/testsuite/gdb.arch/powerpc-ppr-dscr.c @@ -0,0 +1,34 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright (C) 2018 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +int main (void) +{ + /* Set Load Stream Disable bit in DSCR. */ + unsigned long dscr = 0x20; + + /* This is the non-privileged SPR number to access DSCR, + available since isa 207. */ + asm volatile ("mtspr 3,%0" : : "r" (dscr)); + + /* Set PPR to low priority (010 in bits 11:13, or + 0x0008000000000000). */ + asm volatile ("or 1,1,1"); + asm volatile ("nop"); // marker + asm volatile ("nop"); + + return 0; +} diff --git a/gdb/testsuite/gdb.arch/powerpc-ppr-dscr.exp b/gdb/testsuite/gdb.arch/powerpc-ppr-dscr.exp new file mode 100644 index 0000000..b5eb1f8 --- /dev/null +++ b/gdb/testsuite/gdb.arch/powerpc-ppr-dscr.exp @@ -0,0 +1,120 @@ +# Copyright (C) 2018 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# This file is part of the gdb testsuite. + +# Test access to special purpose registers PPR and DSCR. The test +# inferior writes to these registers, we check that GDB reads the same +# values, then write to the registers trough GDB, step once, and check +# again if we read back the same values. + +if {![istarget "powerpc*-*-linux*"]} then { + verbose "Skipping PowerPC test for PPR and DSCR registers." + return +} + +standard_testfile .c + +if {[build_executable "compile" $binfile $srcfile {debug}] == -1} { + return +} + +proc check_register_access { regname } { + global gdb_prompt + + set test "$regname register access" + gdb_test_multiple "info reg $regname" "$test" { + -re "Invalid register.*\r\n$gdb_prompt $" { + unsupported "$test" + return 0 + } + -re "\r\n$regname.*\r\n$gdb_prompt $" { + pass "$test" + return 1 + } + } + return 0 +} + +# Do one pass to check if the instructions in our test programs are +# available to this processor (e.g. mtspr 3, RS for accessing DSCR). +proc ppr_dscr_available {} { + global gdb_prompt + global inferior_exited_re + + set test "PPR/DSCR available to inferior" + gdb_test_multiple "continue" "" { + -re "Illegal instruction.*\r\n$gdb_prompt $" { + unsupported "$test" + return 0 + } + -re "$inferior_exited_re normally.*$gdb_prompt $" { + pass "$test" + return 1 + } + } + return 0 +} + +with_test_prefix "check PPR/DSCR access" { + clean_restart $binfile + + if ![runto_main] { + return + } + + if {![check_register_access "ppr"]} { + return + } + + if {![check_register_access "dscr"]} { + return + } + + if {![ppr_dscr_available]} { + return + } +} + +# Now do the actual test +clean_restart $binfile + +if ![runto_main] { + return +} + +gdb_breakpoint [gdb_get_line_number "marker"] + +gdb_continue_to_breakpoint "continue to marker" + +# At the breakpoint the inferior should have set the +# registers to these expected values. + +with_test_prefix "before write" { + gdb_test "info reg dscr" "dscr.*0x0*20\[ \t\]+.*" + gdb_test "info reg ppr" "ppr.*0x0*8000000000000\[ \t\]+.*" +} + +# Set Store Stream Enable in DSCR and set PPR to the medium-low +# priority. +gdb_test_no_output "set \$dscr = 0x8" +gdb_test_no_output "set \$ppr = 0xC000000000000" + +gdb_test "stepi" "asm.*" + +with_test_prefix "after write" { + gdb_test "info reg dscr" "dscr.*0x0*8+\[ \t\]+.*" + gdb_test "info reg ppr" "ppr.*0x0*\[cC\]000000000000\[ \t\]+.*" +} |