Use PTRACE_PEEKUSER to get fs_base/gs_base
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.stabs / weird.exp
CommitLineData
c5a57081
JB
1# Copyright 1997-1999, 2001, 2003-2004, 2006-2012 Free Software
2# Foundation, Inc.
c906108c
SS
3
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
e22f8b7c 6# the Free Software Foundation; either version 3 of the License, or
c906108c 7# (at your option) any later version.
e22f8b7c 8#
c906108c
SS
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
e22f8b7c 13#
c906108c 14# You should have received a copy of the GNU General Public License
e22f8b7c 15# along with this program. If not, see <http://www.gnu.org/licenses/>.
c906108c 16
c906108c
SS
17# Test that GDB properly ignores invalid stabs.
18# Also test that GDB can debug a .o file, and that it doesn't mind
19# a file that's more minimal than what a compiler normally puts out.
c906108c
SS
20# If the test directory was not created by configure then skip
21# this test.
22if ![file isdirectory ${objdir}/${subdir}] then {
23 return 0
24}
25
c906108c 26
fe11a27f
MC
27set testfile weird
28set srcfile ${objdir}/${subdir}/weird.s
29set binfile ${objdir}/${subdir}/weirdx.o
30
4c93b1db 31if { [ get_compiler_info ] } {
fe11a27f
MC
32 return -1
33}
34
35if { $hp_cc_compiler || $hp_aCC_compiler } {
36 # The native hp-ux assembler does not support stabs at all.
37 # If the compiler is native hp-ux, of course the assembler is too.
38 # But if someone builds gcc with the native assembler (not recommended)
39 # rather than the gnu assembler, then this logic will not suppress it.
40 # -- chastain 2004-01-07
41 unsupported "stabs with hp-ux assembler"
42 continue
43}
44
c906108c
SS
45proc do_tests {} {
46 global binfile
47 global gdb_prompt
48
49 # Mips/alpha targets that use gcc with mips-tfile put out the stabs
50 # assembler directives embedded in comments. If the assembler
51 # file is then processed with native cc, all stabs directives
52 # will be lost.
53 # Skip the rest of the stabs tests for this case.
54 send_gdb "ptype inttype\n"
55 gdb_expect {
56 -re "^ptype inttype\r*\ntype = inttype.*$gdb_prompt $" {
57 pass "stabs found"
58 }
59 -re ".*$gdb_prompt $" {
60 setup_xfail "mips-*-*"
61 setup_xfail "alpha-*-*"
62 fail "stabs not found"
63 return
64 }
65 default { fail "checking for stabs" }
66 }
67
68 print_weird_var var0
69 print_weird_var var1
70 print_weird_var var2
71 print_weird_var var3
72
73 print_weird_var attr32
74 print_weird_var attr33
75 print_weird_var attr35
76 print_weird_var attr36
77 print_weird_var attr37
78 print_weird_var attr38
79 print_weird_var attr39
80 print_weird_var attr41
81 print_weird_var attr42
82 print_weird_var attr43
83 print_weird_var attr44
84 print_weird_var attr46
85 print_weird_var attr47
86 print_weird_var attr58
87 print_weird_var attr59
88 print_weird_var attr60
89 print_weird_var attr61
90 print_weird_var attr62
91 print_weird_var attr63
92 print_weird_var attr64
93 print_weird_var attr65
94 print_weird_var attr66
95 print_weird_var attr67
96 print_weird_var attr68
97 print_weird_var attr69
98 print_weird_var attr70
99 print_weird_var attr71
100 print_weird_var attr72
101 print_weird_var attr73
102 print_weird_var attr74
103 print_weird_var attr75
104 print_weird_var attr76
105 print_weird_var attr77
106 print_weird_var attr78
107 print_weird_var attr79
108 print_weird_var attr80
109 print_weird_var attr81
110 print_weird_var attr82
111 print_weird_var attr83
112 print_weird_var attr84
113 print_weird_var attr85
114 print_weird_var attr86
115 print_weird_var attr87
116 print_weird_var attr88
117 print_weird_var attr89
118 print_weird_var attr90
119 print_weird_var attr91
120 print_weird_var attr92
121 print_weird_var attr93
122 print_weird_var attr94
123 print_weird_var attr95
124 print_weird_var attr96
125 print_weird_var attr97
126 print_weird_var attr98
127 print_weird_var attr99
128 print_weird_var attr100
129 print_weird_var attr101
130 print_weird_var attr102
131 print_weird_var attr103
132 print_weird_var attr104
133 print_weird_var attr105
134 print_weird_var attr106
135 print_weird_var attr107
136 print_weird_var attr108
137 print_weird_var attr109
138 print_weird_var attr110
139 print_weird_var attr111
140 print_weird_var attr112
141 print_weird_var attr113
142 print_weird_var attr114
143 print_weird_var attr115
144 print_weird_var attr116
145 print_weird_var attr117
146 print_weird_var attr118
147 print_weird_var attr119
148 print_weird_var attr120
149 print_weird_var attr121
150 print_weird_var attr122
151 print_weird_var attr123
152 print_weird_var attr124
153 print_weird_var attr125
154 print_weird_var attr126
155
156 gdb_test "p const69" " = 69" "'e' constant on non-enum type"
157 gdb_test "whatis const69" "type = (unsigned int|inttype)" "whatis const69"
158
159 gdb_test "p sizeof (const70)" " = 2" "'e' constant with embedded type"
160
ec8a089a
PM
161 gdb_test "p constchar" " = 97 'a'" "char constant"
162 gdb_test "p constString1" " = \"Single quote String1\"" "String constant 1"
163 gdb_test "p constString2" " = \"Double quote String2\"" "String constant 2"
164
165 gdb_test "p constString3" " = \"String3 with embedded quote ' in the middle\"" "String constant 3"
166 gdb_test "p constString4" { = "String4 with embedded quote \\" in the middle"} "String constant 4"
c906108c
SS
167 gdb_test "p bad_neg0" " = \{field0 = 42, field2 =.*field3 = 45\}" "p bad_neg0"
168
169 gdb_test "ptype inttype" "type = (unsigned int|inttype)" "ptype on inttype"
170 gdb_test "p sizeof (float72type)" " = 9" "unrecognized floating point type"
171
172 # This big number needs to be kept as one piece
173 gdb_test "p/x int256var" " = 0x0*2a0000002b0000002c0000002d0000002d0000002c0000002b0000002a" "print very big integer"
174
175 gdb_test "whatis consth" "type = inttype" "whatis consth"
176 gdb_test "whatis consth2" "type = inttype" "whatis consth2"
177
178 # GDB does not yet understand S constants
179 setup_xfail "*-*-*"
180 gdb_test "p/x bad_neg0const" " = \{field0 = 0x11222211, field2 =.*\
181field3 = 0x77888877\}" "print struct constant"
182
183 gdb_test "ptype bad_type0" "type = .*" "print bad_type0"
184 gdb_test "ptype bad_type1" "type = .*" "print bad_type1"
185
186 # GDB does not yet support arrays indexed by anything at all unusual
187 setup_xfail "*-*-*"
cb135b83 188 gdb_test "p array0" " = \\{42, 43, 44, 45, 46, 47\\}" "array0 with strange index"
c906108c 189 setup_xfail "*-*-*"
cb135b83 190 gdb_test "p array1" " = \\{42, 43, 44\\}" "array1 with strange index"
c906108c
SS
191
192 # GDB does not yet support this feature
193 gdb_test "whatis one_var" "type = inttype_one" \
194 "whatis one_var (known failure in gdb 4.10)"
195 # But do make sure that it prints as something reasonable
196 gdb_test "whatis one_var" "type = inttype(|_one)" \
197 "whatis one_var test 2"
198
199 gdb_test "whatis two_var" "type = inttype_two" \
200 "whatis two_var (known failure in gdb 4.10)"
201 # But do make sure that it prints as something reasonable
202 gdb_test "whatis two_var" "type = inttype(|_two)" \
203 "whatis two_var test 2"
204
205 setup_xfail "*-*-*"
206 gdb_test "whatis pointer_to_int_var" "type = int \[*\]"
207 setup_xfail "*-*-*"
208 gdb_test "whatis intp_var" "type = intp"
209
210 gdb_test "p common0var0" "= 42"
211 # GDB seems to only understand common blocks local to a function.
212 # These variables never get relocated to be relative to the common
213 # block.
214 # I'm not sure whether it is valid to have a common block which
215 # is not local to a function.
216 setup_xfail "*-*-*"
217 gdb_test "p common0var1" "= 24"
218 setup_xfail "*-*-*"
219 gdb_test "p common0var2" "= 22"
c906108c
SS
220}
221
222proc print_weird_var { var } {
223 global gdb_prompt
224
225 # Make sure that the variable gets printed out correctly, without
226 # any sort of warning message.
32a13b1a 227 gdb_test_multiple "print $var" "variable $var printed property" {
c906108c
SS
228 -re "^print $var\r*\n.\[0-9\]* = 42.*$gdb_prompt $" {
229 pass "variable $var printed properly"
230 }
231 -re ".*$gdb_prompt $" {
0398c9aa 232 fail "variable $var printed properly"
c906108c 233 }
c906108c
SS
234 }
235
236 # Make sure that the stabs did get loaded in a sensible way.
237 # If somehow the stabs got skipped, then the above test can
238 # pass because GDB assumes int for variables without a stab.
239
240 # This doesn't work because 32=45 doesn't preserve the name in
241 # gdb (as of 14 Sep 93 anyway).
242 #gdb_test "whatis $var" "type = (unsigned int|inttype)"
243
244 # But the size should be right.
245 gdb_test "print sizeof ($var)" "= 4"
246}
247
248
249# Don't use gdb_load; it doesn't bitch if the loading produced some
250# error messages during symbol reading.
c906108c
SS
251
252global target_os
253set sedscript ${srcdir}/${subdir}/aout.sed
ec8a089a
PM
254set sedoptions ""
255
c906108c
SS
256switch -glob ${target_triplet} {
257 "hppa*-*-*" {
258 set sedscript ${srcdir}/${subdir}/hppa.sed
259 }
260 "mips-*-ecoff" {
261 set sedscript ${srcdir}/${subdir}/ecoff.sed
262 }
263 "powerpc-*-aix*" {
264 set sedscript ${srcdir}/${subdir}/xcoff.sed
ec8a089a 265 set sedoptions "-r"
c906108c
SS
266 }
267 "rs6000-*-aix*" {
268 set sedscript ${srcdir}/${subdir}/xcoff.sed
ec8a089a 269 set sedoptions "-r"
c906108c
SS
270 }
271 "*-*-aout" {
272 set sedscript ${srcdir}/${subdir}/aout.sed
273 }
274 "*-*-xcoff" {
275 set sedscript ${srcdir}/${subdir}/xcoff.sed
ec8a089a 276 set sedoptions "-r"
c906108c
SS
277 }
278 "alpha-*-*" {
279 set sedscript ${srcdir}/${subdir}/ecoff.sed
280 }
281}
282
c906108c 283# Hope this is a Unix box.
ec8a089a 284set exec_output [remote_exec build "sed" "${sedoptions} -f ${sedscript}" "${srcdir}/${subdir}/weird.def" "${srcfile}"]
c906108c
SS
285if { [lindex $exec_output 0] != 0 } {
286 perror "Couldn't make test case. $exec_output"
287 return -1
288}
289
290if { [gdb_compile "${srcfile}" "${binfile}" object ""] != "" } {
b60f0898
JB
291 untested weird.exp
292 return -1
c906108c
SS
293}
294
295remote_file build delete ${srcfile}
296
297# Start with a fresh gdb
298gdb_exit
299gdb_start
300gdb_reinitialize_dir $srcdir/$subdir
301
302set binfile [remote_download host ${binfile} object.o]
303send_gdb "file $binfile\n"
304# If $binfile is very long, a \r (but not a \n) will echo in the
305# middle of the echo of the command. So to match the echo, we
306# would like to match anything not containing \n
307# (we would prefer to be sure not to match any warning message).
308# But \[^\n\]* doesn't seem to work, so instead use the heuristic
309# that a filename won't contain a space and a warning message will.
310# But spaces following by backspaces aren't really spaces.
311gdb_expect 60 {
312 -re "^file (\[^ \]| +\008)*\r*\n" {
313 exp_continue
314 }
4c42eaff 315 -re "A program is being debugged already.\[\r\n\]+Are you sure you want to change the file\\? \\(y or n\\)" {
c906108c
SS
316 send_gdb "y\n"
317 exp_continue
318 }
3b611f1a 319 -re "^Reading symbols from .*$binfile\\.\\.\\.done\.(|\r\nUsing host libthread_db library .*libthread_db.so.*\\.)\r\n$gdb_prompt $" {
c906108c
SS
320 pass "weirdx.o read without error"
321 }
322 -re ".*$gdb_prompt $" {
323 fail "Errors reading weirdx.o"
324 }
325 timeout {
326 perror "couldn't load $binfile into $GDB (timed out)."
327 return -1
328 }
329 eof { fail "(eof) cannot read weirdx.o" }
330}
331
332do_tests
333
334remote_file host delete ${binfile}
335
336return 0
This page took 1.321541 seconds and 4 git commands to generate.