]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.arch/powerpc-lnia.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.arch / powerpc-lnia.exp
1 # Copyright 2021-2023 Free Software Foundation, Inc.
2
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.
7 #
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.
12 #
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/>.
15
16 # Test to see if gdb is properly single stepping over the
17 # displaced lnia instruction. This test checks that a series
18 # of lnia instructions are loading ascending values as expected.
19
20 # lnia is an extended mnemonic for the addpcis instruction, which
21 # stores the $NIA plus an immediate value into a register.
22 #
23 # lnia Rx == addpcis Rx,0 == lnia Rx
24 # subcis Rx,value == addpcis Rx,-value
25
26 if { ![istarget powerpc*-*] } {
27 verbose "Skipping powerpc lnia test."
28 return
29 }
30
31 set retval 0
32
33 standard_testfile .s
34
35 if { [prepare_for_testing "failed to prepare" $testfile "$srcfile" \
36 {debug quiet}] } {
37 return -1
38 }
39
40 if {![runto_main]} {
41 return
42 }
43
44 set before_pc 0
45 set check_pc [get_hexadecimal_valueof "\$pc" "default0"]
46
47 # set some breakpoints on the instructions below main().
48 set bp1 *$check_pc+4
49 set bp2 *$check_pc+12
50 set bp3 *$check_pc+16
51 gdb_breakpoint $bp1
52 gdb_breakpoint $bp2
53 gdb_breakpoint $bp3
54
55 # single-step through the lnia instructions, and retrieve the
56 # register values as we proceed.
57 set insn_supported 1
58 gdb_test_multiple "stepi" "set r3" {
59 -re "Program received signal SIGILL, Illegal instruction\\..*" {
60 set insn_supported 0
61 }
62 -re -wrap "" {
63 pass $gdb_test_name
64 }
65 }
66 if { ! $insn_supported } {
67 unsupported "illegal instruction"
68 return
69 }
70 set check_r3 [get_hexadecimal_valueof "\$r3" "default0"]
71 gdb_test "stepi" "" "set r4"
72 set check_r4 [get_hexadecimal_valueof "\$r4" "default0"]
73 gdb_test "stepi" "" "set r5"
74 set check_r5 [get_hexadecimal_valueof "\$r5" "default0"]
75 gdb_test "stepi" "" "set r6"
76 set check_r6 [get_hexadecimal_valueof "\$r6" "default0"]
77 gdb_test "stepi" "" "set r7"
78 set check_r7 [get_hexadecimal_valueof "\$r7" "default0"]
79 gdb_test "stepi" "" "set r8"
80 set check_r8 [get_hexadecimal_valueof "\$r8" "default0"]
81 gdb_test "stepi" "" "set r9"
82 set check_r9 [get_hexadecimal_valueof "\$r9" "default0"]
83
84 # Ensure that our register values are as expected.
85 # Specifically that the values loaded by the lnia instruction
86 # reflect the value of the PC as if the instruction was
87 # not displaced.
88 if [expr $check_r3 + 4 != $check_r4] {
89 fail "unexpected value r3+4 != r4 , r3: $check_r3 r4: $check_r4 "
90 }
91 if [expr $check_r4 + 4 != $check_r5] {
92 fail "unexpected value r4+4 != r5 , r4: $check_r4 r5: $check_r5 "
93 }
94 if [expr $check_r5 + 4 != $check_r6] {
95 fail "unexpected value r5+4 != r6 , r5: $check_r5 r6: $check_r6 "
96 }
97 if [expr $check_r6 + 4 != $check_r7] {
98 fail "unexpected value r6+4 != r7 , r6: $check_r6 r7: $check_r7 "
99 }
100 if [expr $check_r7 + 4 != $check_r8] {
101 fail "unexpected value r7+4 != r8 , r7: $check_r7 r8: $check_r8 "
102 }
103 if [expr $check_r8 + 4 != $check_r9] {
104 fail "unexpected value r8+4 != r9 , r8: $check_r8 r9: $check_r9 "
105 }
106
107 gdb_test "info break"
108 gdb_test "info register r3 r4 r5 r6 r7 r8 r9"
109 gdb_test "disas main"
110
111 # Let the inferior store all vector registers in a buffer, then dump
112 # the buffer and check it.
113