1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
|
# Copyright (C) 1997, 1998 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Please email any bugs, comments, and/or additions to this file to:
# bug-gdb@prep.ai.mit.edu
# Written by Satish Pai <pai@apollo.hp.com> 1997-07-07
# In the spirit of constvars.exp: added volatile, const-volatile stuff.
# This file is part of the gdb testsuite
# Tests for:
# volatile vars
# pointers to volatile vars
# const volatile vars
# pointers to const volatile vars
# const pointers to volatile vars
# volatile pointers to const vars
# const volatile pointers to const vars
# const volatile pointers to volatile vars
# ... etc. (you get the idea)
# Mostly with char and unsigned char.
if $tracelevel then {
strace $tracelevel
}
#
# test running programs
#
set prms_id 0
set bug_id 0
set testfile "constvars"
set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
}
remote_exec build "rm -f ${binfile}.ci"
if [get_compiler_info ${binfile}] {
return -1
}
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
source ${binfile}.ci
#
# set it up at a breakpoint so we can play with the variable values
#
if ![runto_main] then {
perror "couldn't run to breakpoint"
continue
}
send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $"
send_gdb "cont\n"
gdb_expect {
-re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" {
send_gdb "up\n"
gdb_expect {
-re ".*$gdb_prompt $" {}
timeout { fail "up from marker1" }
}
}
-re "Break.* marker1__.* \\(\\) at .*:$decimal.*$gdb_prompt $" {
fail "continue to marker1 (demangling)"
send_gdb "up\n"
gdb_expect {
-re ".*$gdb_prompt $" {}
timeout { fail "up from marker1" }
}
}
-re "$gdb_prompt $" { fail "continue to marker1" }
timeout { fail "(timeout) continue to marker1" }
}
send_gdb "ptype vox\n"
gdb_expect {
-re "type = volatile char.*$gdb_prompt $" { pass "ptype vox" }
-re ".*$gdb_prompt $" { fail "ptype vox" }
timeout { fail "(timeout) ptype vox" }
}
send_gdb "ptype victuals\n"
gdb_expect {
-re "type = volatile unsigned char.*$gdb_prompt $" { pass "ptype victuals" }
-re ".*$gdb_prompt $" { fail "ptype victuals" }
timeout { fail "(timeout) ptype victuals" }
}
send_gdb "ptype vixen\n"
gdb_expect {
-re "type = volatile short.*$gdb_prompt $" { pass "ptype vixen" }
-re ".*$gdb_prompt $" { fail "ptype vixen" }
timeout { fail "(timeout) ptype vixen" }
}
send_gdb "ptype vitriol\n"
gdb_expect {
-re "type = volatile unsigned short.*$gdb_prompt $" { pass "ptype vitriol" }
-re ".*$gdb_prompt $" { fail "ptype vitriol" }
timeout { fail "(timeout) ptype vitriol" }
}
send_gdb "ptype vellum\n"
gdb_expect {
-re "type = volatile long.*$gdb_prompt $" { pass "ptype vellum" }
-re ".*$gdb_prompt $" { fail "ptype vellum" }
timeout { fail "(timeout) ptype vellum" }
}
send_gdb "ptype valve\n"
gdb_expect {
-re "type = volatile unsigned long.*$gdb_prompt $" { pass "ptype valve" }
-re ".*$gdb_prompt $" { fail "ptype valve" }
timeout { fail "(timeout) ptype valve" }
}
send_gdb "ptype vacuity\n"
gdb_expect {
-re "type = volatile float.*$gdb_prompt $" { pass "ptype vacuity" }
-re ".*$gdb_prompt $" { fail "ptype vacuity" }
timeout { fail "(timeout) ptype vacuity" }
}
send_gdb "ptype vertigo\n"
gdb_expect {
-re "type = volatile double.*$gdb_prompt $" { pass "ptype vertigo" }
-re ".*$gdb_prompt $" { fail "ptype vertigo" }
timeout { fail "(timeout) ptype vertigo" }
}
send_gdb "ptype vampire\n"
gdb_expect {
-re "type = volatile char \\*.*$gdb_prompt $" { pass "ptype vampire" }
-re ".*$gdb_prompt $" { fail "ptype vampire" }
timeout { fail "(timeout) ptype vampire" }
}
send_gdb "ptype viper\n"
gdb_expect {
-re "type = volatile unsigned char \\*.*$gdb_prompt $" { pass "ptype viper" }
-re ".*$gdb_prompt $" { fail "ptype viper" }
timeout { fail "(timeout) ptype viper" }
}
send_gdb "ptype vigour\n"
gdb_expect {
-re "type = volatile short \\*.*$gdb_prompt $" { pass "ptype vigour" }
-re ".*$gdb_prompt $" { fail "ptype vigour" }
timeout { fail "(timeout) ptype vigour" }
}
send_gdb "ptype vapour\n"
gdb_expect {
-re "type = volatile unsigned short \\*.*$gdb_prompt $" { pass "ptype vapour" }
-re ".*$gdb_prompt $" { fail "ptype vapour" }
timeout { fail "(timeout) ptype vapour" }
}
send_gdb "ptype ventricle\n"
gdb_expect {
-re "type = volatile long \\*.*$gdb_prompt $" { pass "ptype ventricle" }
-re ".*$gdb_prompt $" { fail "ptype ventricle" }
timeout { fail "(timeout) ptype ventricle" }
}
send_gdb "ptype vigintillion\n"
gdb_expect {
-re "type = volatile unsigned long \\*.*$gdb_prompt $" { pass "ptype vigintillion" }
-re ".*$gdb_prompt $" { fail "ptype vigintillion" }
timeout { fail "(timeout) ptype vigintillion" }
}
send_gdb "ptype vocation\n"
gdb_expect {
-re "type = volatile float \\*.*$gdb_prompt $" { pass "ptype vocation" }
-re ".*$gdb_prompt $" { fail "ptype vocation" }
timeout { fail "(timeout) ptype vocation" }
}
send_gdb "ptype veracity\n"
gdb_expect {
-re "type = volatile double \\*.*$gdb_prompt $" { pass "ptype veracity" }
-re ".*$gdb_prompt $" { fail "ptype veracity" }
timeout { fail "(timeout) ptype veracity" }
}
send_gdb "ptype vapidity\n"
gdb_expect {
-re "type = volatile char \\* volatile.*$gdb_prompt $" { pass "ptype vapidity" }
-re ".*$gdb_prompt $" { fail "ptype vapidity" }
timeout { fail "(timeout) ptype vapidity" }
}
send_gdb "ptype velocity\n"
gdb_expect {
-re "type = volatile unsigned char \\* volatile.*$gdb_prompt $" { pass "ptype velocity" }
-re ".*$gdb_prompt $" { fail "ptype velocity" }
timeout { fail "(timeout) ptype velocity" }
}
send_gdb "ptype veneer\n"
gdb_expect {
-re "type = volatile short \\* volatile.*$gdb_prompt $" { pass "ptype veneer" }
-re ".*$gdb_prompt $" { fail "ptype veneer" }
timeout { fail "(timeout) ptype veneer" }
}
send_gdb "ptype video\n"
gdb_expect {
-re "type = volatile unsigned short \\* volatile.*$gdb_prompt $" { pass "ptype video" }
-re ".*$gdb_prompt $" { fail "ptype video" }
timeout { fail "(timeout) ptype video" }
}
send_gdb "ptype vacuum\n"
gdb_expect {
-re "type = volatile long \\* volatile.*$gdb_prompt $" { pass "ptype vacuum" }
-re ".*$gdb_prompt $" { fail "ptype vacuum" }
timeout { fail "(timeout) ptype vacuum" }
}
send_gdb "ptype veniality\n"
gdb_expect {
-re "type = volatile unsigned long \\* volatile.*$gdb_prompt $" { pass "ptype veniality" }
-re ".*$gdb_prompt $" { fail "ptype veniality" }
timeout { fail "(timeout) ptype veniality" }
}
send_gdb "ptype vitality\n"
gdb_expect {
-re "type = volatile float \\* volatile.*$gdb_prompt $" { pass "ptype vitality" }
-re ".*$gdb_prompt $" { fail "ptype vitality" }
timeout { fail "(timeout) ptype vitality" }
}
send_gdb "ptype voracity\n"
gdb_expect {
-re "type = volatile double \\* volatile.*$gdb_prompt $" { pass "ptype voracity" }
-re ".*$gdb_prompt $" { fail "ptype voracity" }
timeout { fail "(timeout) ptype voracity" }
}
send_gdb "ptype victor\n"
gdb_expect {
-re "type = const volatile char.*$gdb_prompt $" { pass "ptype victor" }
-re ".*$gdb_prompt $" { fail "ptype victor" }
timeout { fail "(timeout) ptype victor" }
}
send_gdb "ptype vicar\n"
gdb_expect {
-re "type = const volatile unsigned char.*$gdb_prompt $" { pass "ptype vicar" }
-re ".*$gdb_prompt $" { fail "ptype vicar" }
timeout { fail "(timeout) ptype vicar" }
}
send_gdb "ptype victory\n"
gdb_expect {
-re "type = const volatile char \\*.*$gdb_prompt $" { pass "ptype victory" }
-re ".*$gdb_prompt $" { fail "ptype victory" }
timeout { fail "(timeout) ptype victory" }
}
send_gdb "ptype vicarage\n"
gdb_expect {
-re "type = const volatile unsigned char \\*.*$gdb_prompt $" { pass "ptype vicarage" }
-re ".*$gdb_prompt $" { fail "ptype vicarage" }
timeout { fail "(timeout) ptype vicarage" }
}
send_gdb "ptype vein\n"
gdb_expect {
-re "type = volatile char \\* const.*$gdb_prompt $" { pass "ptype vein" }
-re ".*$gdb_prompt $" { fail "ptype vein" }
timeout { fail "(timeout) ptype vein" }
}
send_gdb "ptype vogue\n"
gdb_expect {
-re "type = volatile unsigned char \\* const.*$gdb_prompt $" { pass "ptype vogue" }
-re ".*$gdb_prompt $" { fail "ptype vogue" }
timeout { fail "(timeout) ptype vogue" }
}
send_gdb "ptype cavern\n"
gdb_expect {
-re "type = const volatile char \\* const.*$gdb_prompt $" { pass "ptype cavern" }
-re ".*$gdb_prompt $" { fail "ptype cavern" }
timeout { fail "(timeout) ptype cavern" }
}
send_gdb "ptype coverlet\n"
gdb_expect {
-re "type = const volatile unsigned char \\* const.*$gdb_prompt $" { pass "ptype coverlet" }
-re ".*$gdb_prompt $" { fail "ptype coverlet" }
timeout { fail "(timeout) ptype coverlet" }
}
send_gdb "ptype caveat\n"
gdb_expect {
-re "type = const char \\* volatile.*$gdb_prompt $" { pass "ptype caveat" }
-re ".*$gdb_prompt $" { fail "ptype caveat" }
timeout { fail "(timeout) ptype caveat" }
}
send_gdb "ptype covenant\n"
gdb_expect {
-re "type = const unsigned char \\* volatile.*$gdb_prompt $" { pass "ptype covenant" }
-re ".*$gdb_prompt $" { fail "ptype covenant" }
timeout { fail "(timeout) ptype covenant" }
}
send_gdb "ptype vizier\n"
gdb_expect {
-re "type = const volatile char \\* volatile.*$gdb_prompt $" { pass "ptype vizier" }
-re ".*$gdb_prompt $" { fail "ptype vizier" }
timeout { fail "(timeout) ptype vizier" }
}
send_gdb "ptype vanadium\n"
gdb_expect {
-re "type = const volatile unsigned char \\* volatile.*$gdb_prompt $" { pass "ptype vanadium" }
-re ".*$gdb_prompt $" { fail "ptype vanadium" }
timeout { fail "(timeout) ptype vanadium" }
}
send_gdb "ptype vane\n"
gdb_expect {
-re "type = char \\* const volatile.*$gdb_prompt $" { pass "ptype vane" }
-re ".*$gdb_prompt $" { fail "ptype vane" }
timeout { fail "(timeout) ptype vane" }
}
send_gdb "ptype veldt\n"
gdb_expect {
-re "type = unsigned char \\* const volatile.*$gdb_prompt $" { pass "ptype veldt" }
-re ".*$gdb_prompt $" { fail "ptype veldt" }
timeout { fail "(timeout) ptype veldt" }
}
send_gdb "ptype cove\n"
gdb_expect {
-re "type = const char \\* const volatile.*$gdb_prompt $" { pass "ptype cove" }
-re ".*$gdb_prompt $" { fail "ptype cove" }
timeout { fail "(timeout) ptype cove" }
}
send_gdb "ptype cavity\n"
gdb_expect {
-re "type = const unsigned char \\* const volatile.*$gdb_prompt $" { pass "ptype cavity" }
-re ".*$gdb_prompt $" { fail "ptype cavity" }
timeout { fail "(timeout) ptype cavity" }
}
send_gdb "ptype vagus\n"
gdb_expect {
-re "type = volatile char \\* const volatile.*$gdb_prompt $" { pass "ptype vagus" }
-re ".*$gdb_prompt $" { fail "ptype vagus" }
timeout { fail "(timeout) ptype vagus" }
}
send_gdb "ptype vagrancy\n"
gdb_expect {
-re "type = volatile unsigned char \\* const volatile.*$gdb_prompt $" { pass "ptype vagrancy" }
-re ".*$gdb_prompt $" { fail "ptype vagrancy" }
timeout { fail "(timeout) ptype vagrancy" }
}
send_gdb "ptype vagary\n"
gdb_expect {
-re "type = const volatile char \\* const volatile.*$gdb_prompt $" { pass "ptype vagary" }
-re ".*$gdb_prompt $" { fail "ptype vagary" }
timeout { fail "(timeout) ptype vagary" }
}
send_gdb "ptype vendor\n"
gdb_expect {
-re "type = const volatile unsigned char \\* const volatile.*$gdb_prompt $" { pass "ptype vendor" }
-re ".*$gdb_prompt $" { fail "ptype vendor" }
timeout { fail "(timeout) ptype vendor" }
}
# test function parameters
send_gdb "ptype qux2\n"
gdb_expect {
-re "type = int \\(volatile unsigned char, const volatile int, volatile short &, volatile long \\*, float \\* volatile, const volatile signed char \\* const volatile\\)" {
pass "ptype qux2"
}
-re ".*$gdb_prompt $" { fail "ptype qux2" }
timeout { fail "(timeout) ptype qux2" }
}
|