Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.arch / powerpc-lnia.exp
1 # Copyright 2021-2022 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] then {
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 gdb_test "stepi" "" "set r3"
58 set check_r3 [get_hexadecimal_valueof "\$r3" "default0"]
59 gdb_test "stepi" "" "set r4"
60 set check_r4 [get_hexadecimal_valueof "\$r4" "default0"]
61 gdb_test "stepi" "" "set r5"
62 set check_r5 [get_hexadecimal_valueof "\$r5" "default0"]
63 gdb_test "stepi" "" "set r6"
64 set check_r6 [get_hexadecimal_valueof "\$r6" "default0"]
65 gdb_test "stepi" "" "set r7"
66 set check_r7 [get_hexadecimal_valueof "\$r7" "default0"]
67 gdb_test "stepi" "" "set r8"
68 set check_r8 [get_hexadecimal_valueof "\$r8" "default0"]
69 gdb_test "stepi" "" "set r9"
70 set check_r9 [get_hexadecimal_valueof "\$r9" "default0"]
71
72 # Ensure that our register values are as expected.
73 # Specifically that the values loaded by the lnia instruction
74 # reflect the value of the PC as if the instruction was
75 # not displaced.
76 if [expr $check_r3 + 4 != $check_r4] {
77 fail "unexpected value r3+4 != r4 , r3: $check_r3 r4: $check_r4 "
78 }
79 if [expr $check_r4 + 4 != $check_r5] {
80 fail "unexpected value r4+4 != r5 , r4: $check_r4 r5: $check_r5 "
81 }
82 if [expr $check_r5 + 4 != $check_r6] {
83 fail "unexpected value r5+4 != r6 , r5: $check_r5 r6: $check_r6 "
84 }
85 if [expr $check_r6 + 4 != $check_r7] {
86 fail "unexpected value r6+4 != r7 , r6: $check_r6 r7: $check_r7 "
87 }
88 if [expr $check_r7 + 4 != $check_r8] {
89 fail "unexpected value r7+4 != r8 , r7: $check_r7 r8: $check_r8 "
90 }
91 if [expr $check_r8 + 4 != $check_r9] {
92 fail "unexpected value r8+4 != r9 , r8: $check_r8 r9: $check_r9 "
93 }
94
95 gdb_test "info break"
96 gdb_test "info register r3 r4 r5 r6 r7 r8 r9"
97 gdb_test "disas main"
98
99 # Let the inferior store all vector registers in a buffer, then dump
100 # the buffer and check it.
101
This page took 0.031163 seconds and 4 git commands to generate.