Add translations for various sub-directories
[binutils-gdb.git] / gdb / testsuite / gdb.arch / aarch64-sme-core.exp.tcl
blobb9b83b93772d621f1f48b43f40af196bad4f7b1b
1 # Copyright (C) 2023-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 # Exercise core file reading/writing in the presence of SME and SME2 support.
17 # This test exercises GDB's dumping/loading capability for Linux
18 # Kernel core files and for gcore core files.
20 load_lib aarch64-scalable.exp
23 # Validate that CORE_FILENAME can be read correctly and that the register
24 # state is sane.
26 proc check_sme_core_file { core_filename state vl svl } {
27 # Load the core file.
28 if [gdb_test "core $core_filename" \
29 [multi_line \
30 "Core was generated by.*\." \
31 "Program terminated with signal SIGSEGV, Segmentation fault\." \
32 "#0 ${::hex} in main \\(.*\\) at .*" \
33 ".*p = 0xff;.* crash point .*"] \
34 "load core file"] {
35 untested "failed to generate core file"
36 return -1
39 check_state $state $vl $svl
41 # Check the value of TPIDR2 in the core file.
42 gdb_test "print/x \$tpidr2" " = 0xffffffffffffffff" \
43 "tpidr2 contents from core file"
47 # Generate two core files for EXECUTABLE, BINFILE with a test id of ID.
48 # STATE is the register state, VL is the SVE vector length and SVL is the
49 # SME vector length.
50 # One of the core files is generated by the kernel and the other by the
51 # gcore command.
53 proc generate_sme_core_files { executable binfile id state vl svl} {
54 # Run the program until the point where we need to adjust the
55 # test id.
56 set init_breakpoint "stop to initialize test_id"
57 gdb_breakpoint [gdb_get_line_number $init_breakpoint]
58 gdb_continue_to_breakpoint $init_breakpoint
59 gdb_test_no_output "set test_id = $id"
61 # Run the program until just before the crash.
62 set crash_breakpoint "crash point"
63 gdb_breakpoint [gdb_get_line_number $crash_breakpoint]
64 gdb_continue_to_breakpoint $crash_breakpoint
65 gdb_test_no_output "set print repeats 1" "adjust repeat count pre-crash"
67 # Adjust the register to custom values that we will check later when
68 # loading the core files.
69 check_state $state $vl $svl
71 # Continue until a crash.
72 gdb_test "continue" \
73 [multi_line \
74 "Program received signal SIGSEGV, Segmentation fault\." \
75 "${::hex} in main \\(.*\\) at .*" \
76 ".*p = 0xff;.* crash point .*"] \
77 "run to crash"
79 # Generate the gcore core file.
80 set gcore_filename [standard_output_file "${executable}-${id}-${state}-${vl}-${svl}.gcore"]
81 set gcore_generated [gdb_gcore_cmd "$gcore_filename" "generate gcore file"]
83 # Generate a native core file.
84 set core_filename [core_find ${binfile} {} $id]
85 set core_generated [expr {$core_filename != ""}]
86 set native_core_name "${binfile}-${id}-${state}-${vl}-${svl}.core"
87 remote_exec build "mv $core_filename ${native_core_name}"
88 set core_filename ${native_core_name}
90 # At this point we have a couple core files, the gcore one generated by GDB
91 # and the native one generated by the Linux Kernel. Make sure GDB can read
92 # both correctly.
93 if {$gcore_generated} {
94 clean_restart ${binfile}
95 gdb_test_no_output "set print repeats 1" \
96 "adjust repeat count post-crash gcore"
98 with_test_prefix "gcore corefile" {
99 check_sme_core_file $gcore_filename $state $vl $svl
101 } else {
102 fail "gcore corefile not generated"
105 if {$core_generated} {
106 clean_restart ${binfile}
108 gdb_test_no_output "set print repeats 1" \
109 "adjust repeat count post-crash native core"
111 with_test_prefix "native corefile" {
112 check_sme_core_file $core_filename $state $vl $svl
114 } else {
115 untested "native corefile not generated"
120 # Exercise core file reading (kernel-generated core files) and writing
121 # (gcore command) for test id's ID_START through ID_END.
123 proc test_sme_core_file { id_start id_end } {
124 set compile_flags {"debug" "macros" "additional_flags=-march=armv8.5-a+sve"}
125 standard_testfile ${::srcdir}/${::subdir}/aarch64-sme-core.c
126 set executable "${::testfile}"
127 if {[prepare_for_testing "failed to prepare" ${executable} ${::srcfile} ${compile_flags}]} {
128 return -1
130 set binfile [standard_output_file ${executable}]
132 for {set id $id_start} {$id <= $id_end} {incr id} {
133 set state [test_id_to_state $id]
134 set vl [test_id_to_vl $id]
135 set svl [test_id_to_svl $id]
137 set skip_unsupported 0
138 if {![aarch64_supports_sve_vl $vl]
139 || ![aarch64_supports_sme_svl $svl]} {
140 # We have a vector length or streaming vector length that
141 # is not supported by this target. Skip to the next iteration
142 # since it is no use running tests for an unsupported vector
143 # length.
144 if {![aarch64_supports_sve_vl $vl]} {
145 verbose -log "SVE vector length $vl not supported."
146 } elseif {![aarch64_supports_sme_svl $svl]} {
147 verbose -log "SME streaming vector length $svl not supported."
149 verbose -log "Skipping test."
150 set skip_unsupported 1
153 with_test_prefix "state=${state} vl=${vl} svl=${svl}" {
154 # If the SVE or SME vector length is not supported, just skip
155 # these next tests.
156 if {$skip_unsupported} {
157 untested "unsupported configuration on target"
158 continue
161 # Check if we are talking to a remote target. If so, bail out,
162 # as right now remote targets can't communicate vector length (vl
163 # or svl) changes to gdb via the RSP. When this restriction is
164 # lifted, we can remove this guard.
165 if {[gdb_protocol_is_remote]} {
166 unsupported "aarch64 sve/sme tests not supported for remote targets"
167 return -1
170 if ![runto_main] {
171 untested "could not run to main"
172 return -1
175 generate_sme_core_files ${executable} ${binfile} $id $state $vl $svl
180 require is_aarch64_target
181 require allow_aarch64_sve_tests
182 require allow_aarch64_sme_tests
184 test_sme_core_file $id_start $id_end