[PATCH 12/57][Arm][GAS] Add support for MVE instructions: vaddlv and vaddv
[binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-frame-regs.exp
blob75085538e9f190d1057b3627182c98730e1076c6
1 # Copyright 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 # Test essential Machine interface (MI) operations
18 # Verify that -var-update will provide the correct values for floating
19 # and fixed varobjs that represent the pc register.
22 load_lib mi-support.exp
23 set MIFLAGS "-i=mi"
25 standard_testfile basics.c
27 if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
28 executable {debug}] != "" } then {
29 untested mi-frame-regs.exp
30 return -1
33 # Return the address of the specified breakpoint.
35 proc breakpoint_address {bpnum} {
36 global hex
37 global expect_out
38 global mi_gdb_prompt
40 send_gdb "info breakpoint $bpnum\n"
41 gdb_expect {
42 -re ".*($hex).*$mi_gdb_prompt$" {
43 return $expect_out(1,string)
45 -re ".*$mi_gdb_prompt$" {
46 unresolved "get address of breakpoint $bpnum"
47 return ""
49 timeout {
50 unresolved "get address of breakpoint $bpnum (timeout)"
51 return ""
56 # Test that a floating varobj representing $pc will provide the
57 # correct value via -var-update as the program stops at
58 # breakpoints in different functions.
60 proc_with_prefix do_floating_varobj_test {} {
61 global srcfile
62 global hex
63 global expect_out
65 gdb_exit
66 if {[mi_gdb_start]} then {
67 fail "couldn't start gdb"
68 return
71 mi_run_to_main
73 # Create a floating varobj for $pc.
74 mi_gdb_test "-var-create --thread 1 --frame 0 - @ \$pc" \
75 "\\^done,.*value=\"$hex.*" \
76 "create varobj for pc in frame 0"
78 set nframes 4
79 for {set i 1} {$i < $nframes} {incr i} {
81 # Run to a breakpoint in each callee function in succession.
82 # Note that we can't use mi_runto because we need the
83 # breakpoint to be persistent, so we can use its address.
84 set bpnum [expr $i + 1]
85 mi_create_breakpoint \
86 "basics.c:callee$i" \
87 "insert breakpoint at basics.c:callee$i" \
88 -number $bpnum -func callee$i -file ".*basics.c"
90 mi_execute_to "exec-continue" "breakpoint-hit" \
91 "callee$i" ".*" ".*${srcfile}" ".*" \
92 { "" "disp=\"keep\"" } "breakpoint hit in callee$i"
94 # Get the value of $pc from the floating varobj.
95 mi_gdb_test "-var-update 1 var1" \
96 "\\^done,.*value=\"($hex) .*" \
97 "-var-update for frame $i"
98 set pcval $expect_out(3,string)
100 # Get the address of the current breakpoint.
101 set bpaddr [breakpoint_address $bpnum]
102 if {$bpaddr == ""} then { return }
104 # Check that the addresses are the same.
105 gdb_assert [expr $bpaddr == $pcval] "\$pc equals address of breakpoint in callee$i"
109 # Test that fixed varobjs representing $pc in different stack frames
110 # will provide the correct value via -var-update after the program
111 # counter changes (without substantially changing the stack).
113 proc_with_prefix do_fixed_varobj_test {} {
114 global srcfile
115 global hex
117 gdb_exit
118 if {[mi_gdb_start]} then {
119 fail "couldn't start gdb"
120 return
123 mi_run_to_main
125 # Run to the function 'callee3' so we have several frames.
126 mi_create_breakpoint "basics.c:callee3" \
127 "insert breakpoint at basics.c:callee3" \
128 -number 2 -func callee3 -file ".*basics.c"
130 mi_execute_to "exec-continue" "breakpoint-hit" \
131 "callee3" ".*" ".*${srcfile}" ".*" \
132 { "" "disp=\"keep\"" } "breakpoint hit in callee3"
134 # At the breakpoint in callee3 there are 4 frames.
136 # Create some varobj based on $pc in all frames. When we single
137 # step we expect the varobj for frame 0 to change, while the
138 # varobj for all other frames should be unchanged.
140 # Track in FIRST_UNCHANGING_VARNUM the number of the first varobj
141 # that is not in frame 0, varobj with a lower number we expect to
142 # change, while this and later varobj should not change.
144 # Track the number of the next varobj to be created in VARNUM.
145 set first_unchanging_varnum 0
146 set varnum 1
148 for {set i 0} {$i < 4} {incr i} {
150 if { $i == 1 } then { set first_unchanging_varnum $varnum }
152 mi_gdb_test "-var-create --thread 1 --frame $i - \* \$pc" \
153 "\\^done,.*value=\"$hex.*" \
154 "create varobj for \$pc in frame $i"
155 incr varnum
157 mi_gdb_test "-var-create --thread 1 --frame $i - \* \"global_zero + \$pc\"" \
158 "\\^done,.*value=\"$hex.*" \
159 "create varobj for 'global_zero + \$pc' in frame $i"
160 incr varnum
163 # Step one instruction to change the program counter.
164 mi_execute_to "exec-next-instruction" "end-stepping-range" \
165 "callee3" ".*" ".*${srcfile}" ".*" "" \
166 "next instruction in callee3"
168 # Check that -var-update reports that the values are changed for
169 # varobj in frame 0.
170 for {set i 1} {$i < $first_unchanging_varnum} {incr i} {
171 mi_gdb_test "-var-update 1 var$i" \
172 "\\^done,(changelist=\\\[\{name=\"var$i\"\[^\\\]\]+\\\])" \
173 "varobj var$i has changed"
176 # Check that -var-update reports that the values are unchanged for
177 # varobj in frames other than 0.
178 for {set i $first_unchanging_varnum} {$i < $varnum} {incr i} {
179 mi_gdb_test "-var-update 1 var$i" \
180 "\\^done,(changelist=\\\[\\\])" \
181 "varobj var$i has not changed"
185 do_fixed_varobj_test
186 do_floating_varobj_test