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