1 # Copyright 2021-2024 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 # 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.
20 # lnia is an extended mnemonic for the addpcis instruction, which
21 # stores the $NIA plus an immediate value into a register.
23 # lnia Rx == addpcis Rx,0 == lnia Rx
24 # subcis Rx,value == addpcis Rx,-value
26 require {istarget powerpc*-*}
32 if { [prepare_for_testing "failed to prepare" $testfile "$srcfile" \
42 set check_pc [get_hexadecimal_valueof "\$pc" "default0"]
44 # set some breakpoints on the instructions below main().
52 # single-step through the lnia instructions, and retrieve the
53 # register values as we proceed.
55 gdb_test_multiple "stepi" "set r3" {
56 -re "Program received signal SIGILL, Illegal instruction\\..*" {
63 if { ! $insn_supported } {
64 unsupported "illegal instruction"
67 set check_r3 [get_hexadecimal_valueof "\$r3" "default0"]
68 gdb_test "stepi" "" "set r4"
69 set check_r4 [get_hexadecimal_valueof "\$r4" "default0"]
70 gdb_test "stepi" "" "set r5"
71 set check_r5 [get_hexadecimal_valueof "\$r5" "default0"]
72 gdb_test "stepi" "" "set r6"
73 set check_r6 [get_hexadecimal_valueof "\$r6" "default0"]
74 gdb_test "stepi" "" "set r7"
75 set check_r7 [get_hexadecimal_valueof "\$r7" "default0"]
76 gdb_test "stepi" "" "set r8"
77 set check_r8 [get_hexadecimal_valueof "\$r8" "default0"]
78 gdb_test "stepi" "" "set r9"
79 set check_r9 [get_hexadecimal_valueof "\$r9" "default0"]
81 # Ensure that our register values are as expected.
82 # Specifically that the values loaded by the lnia instruction
83 # reflect the value of the PC as if the instruction was
85 if [expr $check_r3 + 4 != $check_r4] {
86 fail "unexpected value r3+4 != r4 , r3: $check_r3 r4: $check_r4 "
88 if [expr $check_r4 + 4 != $check_r5] {
89 fail "unexpected value r4+4 != r5 , r4: $check_r4 r5: $check_r5 "
91 if [expr $check_r5 + 4 != $check_r6] {
92 fail "unexpected value r5+4 != r6 , r5: $check_r5 r6: $check_r6 "
94 if [expr $check_r6 + 4 != $check_r7] {
95 fail "unexpected value r6+4 != r7 , r6: $check_r6 r7: $check_r7 "
97 if [expr $check_r7 + 4 != $check_r8] {
98 fail "unexpected value r7+4 != r8 , r7: $check_r7 r8: $check_r8 "
100 if [expr $check_r8 + 4 != $check_r9] {
101 fail "unexpected value r8+4 != r9 , r8: $check_r8 r9: $check_r9 "
104 gdb_test "info break"
105 gdb_test "info register r3 r4 r5 r6 r7 r8 r9"
106 gdb_test "disas main"
108 # Let the inferior store all vector registers in a buffer, then dump
109 # the buffer and check it.