1 # Copyright
(C
) 2018-2019 Free Software Foundation
, Inc.
3 # This
program is free software
; you can redistribute it and
/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation
; either version
3 of the License
, or
6 #
(at your option
) any later version.
8 # This
program is distributed in the hope that it will be useful
,
9 # but WITHOUT
ANY WARRANTY
; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License
for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this
program.
If not
, see
<http
://www.gnu.org
/licenses
/>.
16 # This file is part of the gdb testsuite.
18 # Test access to special purpose register TAR
(the Target Address
19 # Register
). The test inferior writes to this register
, we check that
20 # GDB reads the same value
, then write to the register the address of
21 # another label. We
then let the inferior
continue and
execute a
22 # branch to TAR and check that we stop at the address that we wrote to
25 if {![istarget
"powerpc*-*-linux*"]} then {
26 verbose
"Skipping PowerPC test for the TAR register."
32 if {[build_executable
"compile" $binfile $srcfile {debug}] == -1} {
36 proc check_register_access
{ regname
} {
39 set test
"$regname register access"
40 gdb_test_multiple
"info reg $regname" "$test" {
41 -re
"Invalid register.*\r\n$gdb_prompt $" {
45 -re
"\r\n$regname.*\r\n$gdb_prompt $" {
53 proc tar_available
{} {
55 global inferior_exited_re
57 set test
"TAR available to inferior"
58 gdb_test_multiple
"continue" "" {
59 -re
"Illegal instruction.*\r\n$gdb_prompt $" {
63 -re
"$inferior_exited_re normally.*$gdb_prompt $" {
71 #
Do one pass to check
if TAR is usable
, system
72 # software can prevent it from being used.
73 with_test_prefix
"check TAR access" {
74 clean_restart $binfile
80 if {![check_register_access
"tar"]} {
84 if {![tar_available
]} {
89 # Now
do the actual test
90 clean_restart $binfile
96 gdb_breakpoint
[gdb_get_line_number
"marker"]
98 gdb_continue_to_breakpoint
"continue to marker"
100 set target1
[get_hexadecimal_valueof
"target1" -1]
101 set tar
[get_hexadecimal_valueof
"\$tar" -2]
103 set test
"TAR value from mtspr"
105 if {$
{target1
} == $
{tar
}} {
111 set target2
[get_hexadecimal_valueof
"target2" -1]
113 if {$target2
== -1} {
114 fail
"Could not get value of target2"
118 gdb_test_no_output
"set \$tar = $target2" "set tar"
120 gdb_breakpoint
[gdb_get_line_number
"marker 2"]
122 gdb_continue_to_breakpoint
"continue to new target address" ".*marker 2.*"