]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - 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
1 # Copyright 2013-2024 Free Software Foundation, Inc.
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
26 require isnative {istarget s390x-*-*}
27
28 standard_testfile
29 set binprefix $binfile
30
31 proc compile_and_dump {variant ccopts binfile} {
32 global srcdir subdir srcfile
33 set compile_flags {debug}
34 foreach opt $ccopts {
35 lappend compile_flags "additional_flags=$opt"
36 }
37 set test "compile ($variant)"
38 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "$binfile" executable $compile_flags] != "" } {
39 fail $test
40 return {}
41 }
42 pass $test
43
44 set test "create core file ($variant)"
45 set corefile [core_find $binfile]
46 if {$corefile == ""} {
47 fail $test
48 return {}
49 }
50 pass $test
51 return $corefile
52 }
53
54 proc test_linux_v2 {} {
55 global gdb_prompt
56
57 set test "Linux v2"
58 gdb_test_multiple "info reg system_call" "$test" {
59 -re "system_call\[ \t\]+0x\[0-9a-z\]+\[ \t\]+.*\r\n$gdb_prompt $" {
60 pass "$test"
61 return 1
62 }
63 -re "Invalid register `system_call'.*\r\n$gdb_prompt $" {
64 unsupported "$test (no system_call reg)"
65 return 0
66 }
67 }
68 return 0
69 }
70
71 proc test_register_valid {reg} {
72 gdb_test "info reg $reg" \
73 "$reg\[ \t\]+0x\[0-9a-z\]+\[ \t\]+.*" \
74 "'$reg' exists"
75 }
76
77 proc test_register_invalid {reg} {
78 gdb_test "info reg $reg" \
79 "Invalid register `$reg'.*" \
80 "'$reg' must not exist"
81 }
82
83 proc test_all_core64 {core type} {
84 set variant "64-bit $type"
85 with_test_prefix $variant {
86 gdb_core_cmd $core "core-file"
87 if { ! [test_linux_v2] } {
88 return
89 }
90 test_register_valid "last_break"
91 gdb_core_cmd "${core}.2" "core-file #2"
92 test_register_invalid "system_call"
93 gdb_core_cmd "${core}.3" "core-file #3"
94 test_register_invalid "last_break"
95 }
96 }
97
98 proc test_all_core31 {core type} {
99 set variant "31-bit $type"
100 with_test_prefix $variant {
101 gdb_core_cmd $core "core-file"
102 if { ! [test_linux_v2] } {
103 return
104 }
105 test_register_valid "r0h"
106 test_register_valid "last_break"
107 gdb_core_cmd "${core}.1" "core-file #1 "
108 test_register_invalid "r0h"
109 gdb_core_cmd "${core}.2" "core-file #2"
110 test_register_invalid "system_call"
111 gdb_core_cmd "${core}.3" "core-file #3"
112 test_register_invalid "last_break"
113 }
114 }
115
116 set binfile "${binprefix}-64"
117 set core64 [compile_and_dump 64 {-m64} $binfile]
118 if { $core64 != "" } {
119 # Remove 'system_call' and mask hwcap
120 remote_exec host "$binfile $core64 ${core64}.2 775 1023"
121 # Remove 'last_break'
122 remote_exec host "$binfile ${core64}.2 ${core64}.3 774"
123 }
124
125 set binfile "${binprefix}-31"
126 set core31 [compile_and_dump 31 {-m31 -mesa} $binfile]
127 if { $core31 != "" } {
128 # Create "patched" core file by removing 'high_gprs' notes
129 remote_exec host "$binfile $core31 ${core31}.1 768"
130 # Remove 'system_call' and mask off TE and any newer capabilities
131 # from hwcap
132 remote_exec host "$binfile $core31 ${core31}.2 775 1023"
133 # Remove 'last_break'
134 remote_exec host "$binfile ${core31}.2 ${core31}.3 774"
135 }
136
137 clean_restart
138
139 if { $core64 != "" } {
140 test_all_core64 $core64 "no exec"
141 gdb_load "${binprefix}-64"
142 test_all_core64 $core64 "with exec"
143 }
144
145 gdb_test "file" ".*" "discard symbol table" \
146 {Discard symbol table from `.*'\? \(y or n\) } "y"
147
148 if { $core31 != "" } {
149 test_all_core31 $core31 "no exec"
150 gdb_load "${binprefix}-31"
151 test_all_core31 $core31 "with exec"
152 }
153
154 gdb_exit