1 # Copyright 2013-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 # 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 require isnative {istarget s390x-*-*}
29 set binprefix $binfile
31 proc compile_and_dump {variant ccopts binfile} {
32 global srcdir subdir srcfile
33 set compile_flags {debug}
35 lappend compile_flags "additional_flags=$opt"
37 set test "compile ($variant)"
38 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "$binfile" executable $compile_flags] != "" } {
44 set test "create core file ($variant)"
45 set corefile [core_find $binfile]
46 if {$corefile == ""} {
54 proc 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 $" {
63 -re "Invalid register `system_call'.*\r\n$gdb_prompt $" {
64 unsupported "$test (no system_call reg)"
71 proc test_register_valid {reg} {
72 gdb_test "info reg $reg" \
73 "$reg\[ \t\]+0x\[0-9a-z\]+\[ \t\]+.*" \
77 proc test_register_invalid {reg} {
78 gdb_test "info reg $reg" \
79 "Invalid register `$reg'.*" \
80 "'$reg' must not exist"
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] } {
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"
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] } {
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"
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"
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
132 remote_exec host "$binfile $core31 ${core31}.2 775 1023"
133 # Remove 'last_break'
134 remote_exec host "$binfile ${core31}.2 ${core31}.3 774"
139 if { $core64 != "" } {
140 test_all_core64 $core64 "no exec"
141 gdb_load "${binprefix}-64"
142 test_all_core64 $core64 "with exec"
145 gdb_test "file" ".*" "discard symbol table" \
146 {Discard symbol table from `.*'\? \(y or n\) } "y"
148 if { $core31 != "" } {
149 test_all_core31 $core31 "no exec"
150 gdb_load "${binprefix}-31"
151 test_all_core31 $core31 "with exec"