aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.arch/powerpc-tar.exp
diff options
context:
space:
mode:
authorEdjunior Barbosa Machado <emachado@linux.vnet.ibm.com>2018-10-26 09:37:54 -0300
committerPedro Franco de Carvalho <pedromfc@linux.ibm.com>2018-10-26 10:11:33 -0300
commitf2cf6173f33bbb562881c571bfecd129fe94b158 (patch)
treebef6f882782fecf1c92393acee00f685a112cff7 /gdb/testsuite/gdb.arch/powerpc-tar.exp
parent7ca18ed6d22398dd3009ba72d3a1e7747e40753d (diff)
downloadgdb-f2cf6173f33bbb562881c571bfecd129fe94b158.zip
gdb-f2cf6173f33bbb562881c571bfecd129fe94b158.tar.gz
gdb-f2cf6173f33bbb562881c571bfecd129fe94b158.tar.bz2
[PowerPC] Add support for TAR
This patch adds support for the Target Address Register for powerpc linux native and core file targets, and in 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_isa207_vsx32l) (tdesc_powerpc_isa207_vsx64l): Declare. * arch/ppc-linux-common.h (PPC_LINUX_SIZEOF_TARREGSET): Define. (struct ppc_linux_features) <isa207>: New field. (ppc_linux_no_features): Add initializer for isa207 field. * arch/ppc-linux-common.c (ppc_linux_match_description): Return new tdescs. * nat/ppc-linux.h (PPC_FEATURE2_ARCH_2_07, PPC_FEATURE2_TAR) (NT_PPC_TAR): Define if not already defined. * features/Makefile (WHICH): Add rs6000/powerpc-isa207-vsx32l and rs6000/powerpc-isa207-vsx64l. (XMLTOC): Add rs6000/powerpc-isa207-vsx32l.xml and rs6000/powerpc-isa207-vsx64l.xml. * features/rs6000/power-tar.xml: New file. * features/rs6000/powerpc-isa207-vsx32l.xml: New file. * features/rs6000/powerpc-isa207-vsx64l.xml: New file. * features/rs6000/powerpc-isa207-vsx32l.c: Generate. * features/rs6000/powerpc-isa207-vsx64l.c: Generate. * regformats/rs6000/powerpc-isa207-vsx32l.dat: Generate. * regformats/rs6000/powerpc-isa207-vsx64l.dat: Generate. * ppc-linux-nat.c (fetch_register, fetch_ppc_registers): Call fetch_regset with the TAR regset. (store_register, store_ppc_registers): Call store_regset with the TAR regset. (ppc_linux_nat_target::read_description): Set isa207 field in the features struct if needed. * ppc-linux-tdep.c: Include features/rs6000/powerpc-isa207-vsx32l.c and features/rs6000/powerpc-isa207-vsx64l.c. (ppc32_regmap_tar, ppc32_linux_tarregset): New globals. (ppc_linux_iterate_over_regset_sections): Call back with the tar regset. (ppc_linux_core_read_description): Check if the tar section is present and set isa207 in the features struct. (_initialize_ppc_linux_tdep): Call initialize_tdesc_powerpc_isa207_vsx32l and initialize_tdesc_powerpc_isa207_vsx64l. * ppc-linux-tdep.h (ppc32_linux_tarregset): Declare. * ppc-tdep.h (gdbarch_tdep) <ppc_tar_regnum>: New field. (enum) <PPC_TAR_REGNUM>: New enum value. * rs6000-tdep.c (rs6000_gdbarch_init): Look for and validate tar feature. (ppc_process_record_op31): Record changes to TAR. gdb/gdbserver/ChangeLog: 2018-10-26 Pedro Franco de Carvalho <pedromfc@linux.ibm.com> * configure.srv (ipa_ppc_linux_regobj): Add powerpc-isa207-vsx64l-ipa.o and powerpc-isa207-vsx32l-ipa.o. (powerpc*-*-linux*): Add powerpc-isa207-vsx32l.o and powerpc-isa207-vsx64l.o to srv_regobj, add rs6000/power-tar.xml, rs6000/powerpc-isa207-vsx32l.xml, and rs6000/powerpc-isa207-vsx64l.xml to srv_xmlfiles. * linux-ppc-tdesc-init.h (enum ppc_linux_tdesc) <PPC_TDESC_ISA207_VSX>: New enum value. (init_registers_powerpc_isa207_vsx32l): Declare. (init_registers_powerpc_isa207_vsx64l): Declare. * linux-ppc-low.c (ppc_fill_tarregset): New function. (ppc_store_tarregset): New function. (ppc_regsets): Add entry for the TAR regset. (ppc_arch_setup): Set isa207 in features struct when needed. Set size for the TAR regsets. (ppc_get_ipa_tdesc_idx): Return PPC_TDESC_ISA207_VSX. (initialize_low_arch): Call init_registers_powerpc_isa207_vsx32l and init_registers_powerpc_isa207_vsx64l. * linux-ppc-ipa.c (get_ipa_tdesc): Handle PPC_TDESC_ISA207_VSX. (initialize_low_tracepoint): Call init_registers_powerpc_isa207_vsx32l and init_registers_powerpc_isa207_vsx64l. gdb/testsuite/ChangeLog: 2018-10-26 Pedro Franco de Carvalho <pedromfc@linux.ibm.com> * gdb.arch/powerpc-tar.c: New file. * gdb.arch/powerpc-tar.exp: New file. gdb/doc/ChangeLog: 2018-10-26 Pedro Franco de Carvalho <pedromfc@linux.ibm.com> * gdb.texinfo (PowerPC Features): Describe new feature "org.gnu.gdb.power.tar".
Diffstat (limited to 'gdb/testsuite/gdb.arch/powerpc-tar.exp')
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-tar.exp122
1 files changed, 122 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.arch/powerpc-tar.exp b/gdb/testsuite/gdb.arch/powerpc-tar.exp
new file mode 100644
index 0000000..98bdfd0
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/powerpc-tar.exp
@@ -0,0 +1,122 @@
+# 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 register TAR (the Target Address
+# Register). The test inferior writes to this register, we check that
+# GDB reads the same value, then write to the register the address of
+# another label. We then let the inferior continue and execute a
+# branch to TAR and check that we stop at the address that we wrote to
+# register.
+
+if {![istarget "powerpc*-*-linux*"]} then {
+ verbose "Skipping PowerPC test for the TAR register."
+ return
+}
+
+standard_testfile .c
+
+if {[build_executable "compile" $binfile $srcfile {debug}] == -1} {
+ return -1
+}
+
+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
+}
+
+proc tar_available {} {
+ global gdb_prompt
+ global inferior_exited_re
+
+ set test "TAR 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
+}
+
+# Do one pass to check if TAR is usable, system
+# software can prevent it from being used.
+with_test_prefix "check TAR access" {
+ clean_restart $binfile
+
+ if ![runto_main] {
+ return
+ }
+
+ if {![check_register_access "tar"]} {
+ return
+ }
+
+ if {![tar_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"
+
+set target1 [get_hexadecimal_valueof "target1" -1]
+set tar [get_hexadecimal_valueof "\$tar" -2]
+
+set test "TAR value from mtspr"
+
+if {${target1} == ${tar}} {
+ pass $test
+} else {
+ fail $test
+}
+
+set target2 [get_hexadecimal_valueof "target2" -1]
+
+if {$target2 == -1} {
+ fail "Could not get value of target2"
+ return
+}
+
+gdb_test_no_output "set \$tar = $target2" "set tar"
+
+gdb_breakpoint [gdb_get_line_number "marker 2"]
+
+gdb_continue_to_breakpoint "continue to new target address" ".*marker 2.*"