]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.arch/s390-multiarch.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.arch / s390-multiarch.exp
CommitLineData
213516ef 1# Copyright 2013-2023 Free Software Foundation, Inc.
9772d074
UW
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# Please email any bugs, comments, and/or additions to this file to:
17# bug-gdb@gnu.org
18
19# This file is part of the gdb testsuite.
20
21
22# This test is supported on 64-bit s390 targets only, and only when
23# running native. It should be executed on a sufficiently new Linux
24# kernel that provides the 'system_call' regset.
25
26if { ![isnative] || ![istarget s390x-*-* ] } {
27 verbose "Skipping s390 multi-arch tests."
28 return
29}
30
64bcd522
AA
31standard_testfile
32set binprefix $binfile
9772d074
UW
33
34gdb_exit
35
9772d074 36proc compile_and_dump {variant ccopts binfile} {
64bcd522 37 global srcdir subdir srcfile
9772d074
UW
38 set compile_flags {debug}
39 foreach opt $ccopts {
40 lappend compile_flags "additional_flags=$opt"
41 }
42 set test "compile ($variant)"
64bcd522 43 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "$binfile" executable $compile_flags] != "" } {
9772d074
UW
44 fail $test
45 return {}
46 }
47 pass $test
48
49 set test "create core file ($variant)"
50 set corefile [core_find $binfile]
51 if {$corefile == ""} {
52 fail $test
53 return {}
54 }
55 pass $test
56 return $corefile
57}
58
59proc test_linux_v2 {} {
055e608a
UW
60 global gdb_prompt
61
9772d074
UW
62 set test "Linux v2"
63 gdb_test_multiple "info reg system_call" "$test" {
adf8243b 64 -re "system_call\[ \t\]+0x\[0-9a-z\]+\[ \t\]+.*\r\n$gdb_prompt $" {
9772d074
UW
65 pass "$test"
66 return 1
67 }
055e608a 68 -re "Invalid register `system_call'.*\r\n$gdb_prompt $" {
9772d074
UW
69 unsupported "$test (no system_call reg)"
70 return 0
71 }
72 }
73 return 0
74}
75
f5c697b1 76proc test_register_valid {reg} {
9772d074 77 gdb_test "info reg $reg" \
adf8243b 78 "$reg\[ \t\]+0x\[0-9a-z\]+\[ \t\]+.*" \
f5c697b1 79 "'$reg' exists"
9772d074
UW
80}
81
f5c697b1 82proc test_register_invalid {reg} {
9772d074
UW
83 gdb_test "info reg $reg" \
84 "Invalid register `$reg'.*" \
f5c697b1 85 "'$reg' must not exist"
9772d074
UW
86}
87
88proc test_all_core64 {core type} {
89 set variant "64-bit $type"
f5c697b1
TV
90 with_test_prefix $variant {
91 gdb_core_cmd $core "core-file"
92 if { ! [test_linux_v2] } {
93 return
94 }
95 test_register_valid "last_break"
96 gdb_core_cmd "${core}.2" "core-file #2"
97 test_register_invalid "system_call"
98 gdb_core_cmd "${core}.3" "core-file #3"
99 test_register_invalid "last_break"
9772d074 100 }
9772d074
UW
101}
102
103proc test_all_core31 {core type} {
104 set variant "31-bit $type"
f5c697b1
TV
105 with_test_prefix $variant {
106 gdb_core_cmd $core "core-file"
107 if { ! [test_linux_v2] } {
108 return
109 }
110 test_register_valid "r0h"
111 test_register_valid "last_break"
112 gdb_core_cmd "${core}.1" "core-file #1 "
113 test_register_invalid "r0h"
114 gdb_core_cmd "${core}.2" "core-file #2"
115 test_register_invalid "system_call"
116 gdb_core_cmd "${core}.3" "core-file #3"
117 test_register_invalid "last_break"
9772d074 118 }
9772d074
UW
119}
120
121set binfile "${binprefix}-64"
122set core64 [compile_and_dump 64 {-m64} $binfile]
123if { $core64 != "" } {
124 # Remove 'system_call' and mask hwcap
125 remote_exec host "$binfile $core64 ${core64}.2 775 1023"
126 # Remove 'last_break'
127 remote_exec host "$binfile ${core64}.2 ${core64}.3 774"
128}
129
130set binfile "${binprefix}-31"
131set core31 [compile_and_dump 31 {-m31 -mesa} $binfile]
132if { $core31 != "" } {
133 # Create "patched" core file by removing 'high_gprs' notes
134 remote_exec host "$binfile $core31 ${core31}.1 768"
135 # Remove 'system_call' and mask off TE and any newer capabilities
136 # from hwcap
137 remote_exec host "$binfile $core31 ${core31}.2 775 1023"
138 # Remove 'last_break'
139 remote_exec host "$binfile ${core31}.2 ${core31}.3 774"
140}
141
142gdb_start
143gdb_reinitialize_dir $srcdir/$subdir
144
145if { $core64 != "" } {
146 test_all_core64 $core64 "no exec"
147 gdb_load "${binprefix}-64"
148 test_all_core64 $core64 "with exec"
149}
150
151gdb_test "file" ".*" "discard symbol table" \
152 {Discard symbol table from `.*'\? \(y or n\) } "y"
153
154if { $core31 != "" } {
155 test_all_core31 $core31 "no exec"
156 gdb_load "${binprefix}-31"
157 test_all_core31 $core31 "with exec"
158}
159
160gdb_exit