Update copyright year range in header of all files managed by GDB
[binutils-gdb.git] / gdb / testsuite / gdb.arch / aarch64-sve.exp
blob659e81f5c06cb387e441862331b5d792b281f17f
1 # Copyright 2022-2023 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 a binary that uses SVE and exercise changing the SVE vector length.
18 if {[skip_aarch64_sve_tests]} {
19     verbose "Skipping ${gdb_test_file_name}."
20     return
23 standard_testfile
24 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
25     return
28 set linespec ${srcfile}:[gdb_get_line_number "break here"]
30 if ![runto ${linespec}] {
31     return
34 # Count number of lines in "info registers" output.
35 proc count_info_registers {} {
36     global gdb_prompt
37     set ret 0
39     gdb_test_multiple "info all-registers" "" {
40         -re ".*$gdb_prompt $" {
41             set ret [count_newlines $expect_out(buffer)]
42         }
43     }
45     return ${ret}
48 proc get_register_value {register} {
49     global gdb_prompt
50     set ret ""
52     gdb_test_multiple "print \$${register}" "" {
53         -re ". = \[0-9\]+\r\n$gdb_prompt $" {
54             regexp {. = ([0-9]+)} $expect_out(buffer) matched ret
55         }
56         -re ".*$gdb_prompt $" {
57         }
58     }
60     return ${ret}
63 # The test executable halves the vector length in a loop, so loop along
64 # to check it.
65 for {set i [get_register_value "vg"]} {$i > 1} {set i [expr $i / 2]} {
66     set lines_before [count_info_registers]
68     gdb_test "next" ".*if .res < 0." "step over prctl vg = ${i}"
70     set lines_after [count_info_registers]
72     # There was a bug where GDB would lose track of some registers when the
73     # vector length changed.  Make sure they're still all there.
74     if {${lines_before} == ${lines_after}} {
75         pass "same number of registers vg = ${i}"
76     } else {
77         fail "same number of registers vg = ${i}"
78     }
80     gdb_test "print \$vg" ". = ${i}" "vg was changed to ${i}"
82     set size_after [expr {$i * 8}]
84     for {set j 0} {$j < 32} {set j [incr j]} {
85         gdb_test "print sizeof(\$z$j)" ". = ${size_after}" "z$j has ${size_after} bytes"
86     }
88     gdb_test_multiple "continue" "" {
89         -re ".*Breakpoint $decimal, do_sve_ioctl_test .*$gdb_prompt $" {
90             # Next iteration.
91         }
92         -re "Inferior 1 .* exited normally.*$gdb_prompt $" {
93             # We're done.
94             break
95         }
96         -re "$gdb_prompt $" {
97             fail "unexpected output"
98             break;
99         }
100     }