1 # Copyright 2013-2022 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 # Please email any bugs, comments, and/or additions to this file to:
19 # This file is part of the gdb testsuite.
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.
26 if { ![isnative] || ![istarget s390x-*-* ] } {
27 verbose "Skipping s390 multi-arch tests."
32 set binprefix $binfile
36 if { [get_compiler_info] } {
40 proc compile_and_dump {variant ccopts binfile} {
41 global srcdir subdir srcfile
42 set compile_flags {debug}
44 lappend compile_flags "additional_flags=$opt"
46 set test "compile ($variant)"
47 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "$binfile" executable $compile_flags] != "" } {
53 set test "create core file ($variant)"
54 set corefile [core_find $binfile]
55 if {$corefile == ""} {
63 proc test_linux_v2 {} {
67 gdb_test_multiple "info reg system_call" "$test" {
68 -re "system_call\[ \t\]+0x\[0-9a-z\]+\[ \t\]+.*\r\n$gdb_prompt $" {
72 -re "Invalid register `system_call'.*\r\n$gdb_prompt $" {
73 unsupported "$test (no system_call reg)"
80 proc test_register_valid {reg variant} {
81 gdb_test "info reg $reg" \
82 "$reg\[ \t\]+0x\[0-9a-z\]+\[ \t\]+.*" \
83 "'$reg' exists ($variant)"
86 proc test_register_invalid {reg variant} {
87 gdb_test "info reg $reg" \
88 "Invalid register `$reg'.*" \
89 "'$reg' must not exist ($variant)"
92 proc test_all_core64 {core type} {
93 set variant "64-bit $type"
94 gdb_core_cmd $core "core-file ($variant)"
95 if { ! [test_linux_v2] } {
98 test_register_valid "last_break" $variant
99 gdb_core_cmd "${core}.2" "core-file #2 ($variant)"
100 test_register_invalid "system_call" $variant
101 gdb_core_cmd "${core}.3" "core-file #3 ($variant)"
102 test_register_invalid "last_break" $variant
105 proc test_all_core31 {core type} {
106 set variant "31-bit $type"
107 gdb_core_cmd $core "core-file ($variant)"
108 if { ! [test_linux_v2] } {
111 test_register_valid "r0h" $variant
112 test_register_valid "last_break" $variant
113 gdb_core_cmd "${core}.1" "core-file #1 ($variant)"
114 test_register_invalid "r0h" $variant
115 gdb_core_cmd "${core}.2" "core-file #2 ($variant)"
116 test_register_invalid "system_call" $variant
117 gdb_core_cmd "${core}.3" "core-file #3 ($variant)"
118 test_register_invalid "last_break" $variant
121 set binfile "${binprefix}-64"
122 set core64 [compile_and_dump 64 {-m64} $binfile]
123 if { $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"
130 set binfile "${binprefix}-31"
131 set core31 [compile_and_dump 31 {-m31 -mesa} $binfile]
132 if { $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
137 remote_exec host "$binfile $core31 ${core31}.2 775 1023"
138 # Remove 'last_break'
139 remote_exec host "$binfile ${core31}.2 ${core31}.3 774"
143 gdb_reinitialize_dir $srcdir/$subdir
145 if { $core64 != "" } {
146 test_all_core64 $core64 "no exec"
147 gdb_load "${binprefix}-64"
148 test_all_core64 $core64 "with exec"
151 gdb_test "file" ".*" "discard symbol table" \
152 {Discard symbol table from `.*'\? \(y or n\) } "y"
154 if { $core31 != "" } {
155 test_all_core31 $core31 "no exec"
156 gdb_load "${binprefix}-31"
157 test_all_core31 $core31 "with exec"