Commit | Line | Data |
---|---|---|
e2882c85 | 1 | # Copyright 2013-2018 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 | ||
26 | if { ![isnative] || ![istarget s390x-*-* ] } { | |
27 | verbose "Skipping s390 multi-arch tests." | |
28 | return | |
29 | } | |
30 | ||
64bcd522 AA |
31 | standard_testfile |
32 | set binprefix $binfile | |
9772d074 UW |
33 | |
34 | gdb_exit | |
35 | ||
36 | if { [get_compiler_info] } { | |
37 | return -1 | |
38 | } | |
39 | ||
40 | proc compile_and_dump {variant ccopts binfile} { | |
64bcd522 | 41 | global srcdir subdir srcfile |
9772d074 UW |
42 | set compile_flags {debug} |
43 | foreach opt $ccopts { | |
44 | lappend compile_flags "additional_flags=$opt" | |
45 | } | |
46 | set test "compile ($variant)" | |
64bcd522 | 47 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "$binfile" executable $compile_flags] != "" } { |
9772d074 UW |
48 | fail $test |
49 | return {} | |
50 | } | |
51 | pass $test | |
52 | ||
53 | set test "create core file ($variant)" | |
54 | set corefile [core_find $binfile] | |
55 | if {$corefile == ""} { | |
56 | fail $test | |
57 | return {} | |
58 | } | |
59 | pass $test | |
60 | return $corefile | |
61 | } | |
62 | ||
63 | proc test_linux_v2 {} { | |
055e608a UW |
64 | global gdb_prompt |
65 | ||
9772d074 UW |
66 | set test "Linux v2" |
67 | gdb_test_multiple "info reg system_call" "$test" { | |
055e608a | 68 | -re "system_call\[ \t\]+0x\[0-9a-z\]+\t.*\r\n$gdb_prompt $" { |
9772d074 UW |
69 | pass "$test" |
70 | return 1 | |
71 | } | |
055e608a | 72 | -re "Invalid register `system_call'.*\r\n$gdb_prompt $" { |
9772d074 UW |
73 | unsupported "$test (no system_call reg)" |
74 | return 0 | |
75 | } | |
76 | } | |
77 | return 0 | |
78 | } | |
79 | ||
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)" | |
84 | } | |
85 | ||
86 | proc test_register_invalid {reg variant} { | |
87 | gdb_test "info reg $reg" \ | |
88 | "Invalid register `$reg'.*" \ | |
89 | "'$reg' must not exist ($variant)" | |
90 | } | |
91 | ||
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] } { | |
96 | return | |
97 | } | |
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 | |
103 | } | |
104 | ||
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] } { | |
109 | return | |
110 | } | |
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 | |
119 | } | |
120 | ||
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" | |
128 | } | |
129 | ||
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 | |
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 | ||
142 | gdb_start | |
143 | gdb_reinitialize_dir $srcdir/$subdir | |
144 | ||
145 | if { $core64 != "" } { | |
146 | test_all_core64 $core64 "no exec" | |
147 | gdb_load "${binprefix}-64" | |
148 | test_all_core64 $core64 "with exec" | |
149 | } | |
150 | ||
151 | gdb_test "file" ".*" "discard symbol table" \ | |
152 | {Discard symbol table from `.*'\? \(y or n\) } "y" | |
153 | ||
154 | if { $core31 != "" } { | |
155 | test_all_core31 $core31 "no exec" | |
156 | gdb_load "${binprefix}-31" | |
157 | test_all_core31 $core31 "with exec" | |
158 | } | |
159 | ||
160 | gdb_exit |