]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright 2022-2024 Free Software Foundation, Inc. |
a960d5f9 TJB |
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 a binary that uses SVE and exercise changing the SVE vector length. | |
17 | ||
71fd14a9 | 18 | require allow_aarch64_sve_tests |
a960d5f9 TJB |
19 | |
20 | standard_testfile | |
21 | if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } { | |
22 | return | |
23 | } | |
24 | ||
25 | set linespec ${srcfile}:[gdb_get_line_number "break here"] | |
26 | ||
27 | if ![runto ${linespec}] { | |
28 | return | |
29 | } | |
30 | ||
31 | # Count number of lines in "info registers" output. | |
32 | proc count_info_registers {} { | |
33 | global gdb_prompt | |
34 | set ret 0 | |
35 | ||
36 | gdb_test_multiple "info all-registers" "" { | |
37 | -re ".*$gdb_prompt $" { | |
38 | set ret [count_newlines $expect_out(buffer)] | |
39 | } | |
40 | } | |
41 | ||
42 | return ${ret} | |
43 | } | |
44 | ||
45 | proc get_register_value {register} { | |
46 | global gdb_prompt | |
47 | set ret "" | |
48 | ||
49 | gdb_test_multiple "print \$${register}" "" { | |
50 | -re ". = \[0-9\]+\r\n$gdb_prompt $" { | |
51 | regexp {. = ([0-9]+)} $expect_out(buffer) matched ret | |
52 | } | |
53 | -re ".*$gdb_prompt $" { | |
54 | } | |
55 | } | |
56 | ||
57 | return ${ret} | |
58 | } | |
59 | ||
60 | # The test executable halves the vector length in a loop, so loop along | |
61 | # to check it. | |
62 | for {set i [get_register_value "vg"]} {$i > 1} {set i [expr $i / 2]} { | |
63 | set lines_before [count_info_registers] | |
64 | ||
65 | gdb_test "next" ".*if .res < 0." "step over prctl vg = ${i}" | |
66 | ||
67 | set lines_after [count_info_registers] | |
68 | ||
69 | # There was a bug where GDB would lose track of some registers when the | |
70 | # vector length changed. Make sure they're still all there. | |
71 | if {${lines_before} == ${lines_after}} { | |
72 | pass "same number of registers vg = ${i}" | |
73 | } else { | |
74 | fail "same number of registers vg = ${i}" | |
75 | } | |
76 | ||
77 | gdb_test "print \$vg" ". = ${i}" "vg was changed to ${i}" | |
78 | ||
79 | set size_after [expr {$i * 8}] | |
80 | ||
81 | for {set j 0} {$j < 32} {set j [incr j]} { | |
82 | gdb_test "print sizeof(\$z$j)" ". = ${size_after}" "z$j has ${size_after} bytes" | |
83 | } | |
84 | ||
85 | gdb_test_multiple "continue" "" { | |
86 | -re ".*Breakpoint $decimal, do_sve_ioctl_test .*$gdb_prompt $" { | |
87 | # Next iteration. | |
88 | } | |
89 | -re "Inferior 1 .* exited normally.*$gdb_prompt $" { | |
90 | # We're done. | |
91 | break | |
92 | } | |
93 | -re "$gdb_prompt $" { | |
94 | fail "unexpected output" | |
95 | break; | |
96 | } | |
97 | } | |
98 | } |