aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.compile/compile-ops.exp
blob: 9c36c36d8a464810878f377342b14ae591919dbd (plain)
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
417
418
419
420
421
422
423
424
# Copyright 2014-2018 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 3 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, see <http://www.gnu.org/licenses/>.

# Some coverage testing of DWARF operators for the compiler
# integration.

load_lib dwarf.exp

# This test can only be run on targets which support DWARF-2 and use gas.
if {![dwarf2_support]} {
    return 0
}

standard_testfile .c gdbjit-ops.S

#
# A port of the pr10770.c test code to the DWARF assembler format.
#

set assert_tos_non0 {
    bra 3
    skip -3
}

set assert_tos_0 [subst {
    lit0
    eq
    $assert_tos_non0
}]

set program [subst {
    lit0
    nop
    $assert_tos_0
    lit1
    const1u 1
    eq
    $assert_tos_non0
    lit16
    const2u 16
    eq
    $assert_tos_non0
    lit31
    const4u 31
    ne
    $assert_tos_0
    lit1
    neg
    const1s -1
    eq
    $assert_tos_non0
    lit16
    neg
    const2s -16
    ne
    $assert_tos_0
    lit31
    const4s -31
    neg
    ne
    $assert_tos_0
    lit7
    dup
    plus_uconst 2
    lit9
    eq
    $assert_tos_non0
    lit7
    eq
    $assert_tos_non0
    lit20
    lit1
    drop
    lit20
    eq
    $assert_tos_non0
    lit17
    lit19
    over
    lit17
    eq
    $assert_tos_non0
    lit19
    eq
    $assert_tos_non0
    lit17
    eq
    $assert_tos_non0
    lit1
    lit2
    lit3
    lit4
    pick 2
    lit2
    eq
    $assert_tos_non0
    lit4
    eq
    $assert_tos_non0
    lit3
    eq
    $assert_tos_non0
    pick 0
    lit2
    eq
    $assert_tos_non0
    lit2
    eq
    $assert_tos_non0
    lit1
    eq
    $assert_tos_non0
    lit6
    lit12
    swap
    lit6
    eq
    $assert_tos_non0
    lit12
    eq
    $assert_tos_non0
    lit7
    lit8
    lit9
    rot
    lit8
    eq
    $assert_tos_non0
    lit7
    eq
    $assert_tos_non0
    lit9
    eq
    $assert_tos_non0
    lit7
    abs
    lit7
    eq
    $assert_tos_non0
    const1s -123
    abs
    const1u 123
    eq
    $assert_tos_non0
    lit3
    lit6
    and
    lit2
    eq
    $assert_tos_non0
    lit3
    lit6
    or
    lit7
    eq
    $assert_tos_non0
    lit17
    lit2
    minus
    lit15
    eq
    $assert_tos_non0
    # Divide is signed truncating toward zero.
    const1s -6
    const1s -2
    div
    lit3
    eq
    $assert_tos_non0
    const1s -7
    const1s 3
    div
    const1s -2
    eq
    $assert_tos_non0
    # Modulo is unsigned.
    const1s -6
    const1s -4
    mod
    const1s -6
    eq
    $assert_tos_non0
    const1s -6
    lit4
    mod
    lit2
    eq
    $assert_tos_non0
    lit6
    const1s -4
    mod
    lit6
    eq
    $assert_tos_non0
    # Signed modulo can be implemented using 'over over div mul minus'.
    const1s -6
    const1s -4
    over
    over
    div
    mul
    minus
    const1s -2
    eq
    $assert_tos_non0
    const1s -7
    lit3
    over
    over
    div
    mul
    minus
    const1s -1
    eq
    $assert_tos_non0
    lit7
    const1s -3
    over
    over
    div
    mul
    minus
    lit1
    eq
    $assert_tos_non0
    lit16
    lit31
    plus_uconst 1
    mul
    const2u 512
    eq
    $assert_tos_non0
    lit5
    not
    lit31
    and
    lit26
    eq
    $assert_tos_non0
    lit12
    lit31
    plus
    const1u 43
    eq
    $assert_tos_non0
    const1s -6
    lit2
    plus
    const1s -4
    eq
    $assert_tos_non0
    const1s -6
    plus_uconst 3
    const1s -3
    eq
    $assert_tos_non0
    lit16
    lit4
    shl
    const2u 256
    eq
    $assert_tos_non0
    lit16
    lit3
    shr
    lit2
    eq
    $assert_tos_non0
    const1s -16
    lit3
    shra
    const1s -2
    eq
    $assert_tos_non0
    lit3
    lit6
    xor
    lit5
    eq
    $assert_tos_non0
    lit3
    lit6
    le
    $assert_tos_non0
    lit3
    lit3
    le
    $assert_tos_non0
    lit6
    lit3
    le
    $assert_tos_0
    lit3
    lit6
    lt
    $assert_tos_non0
    lit3
    lit3
    lt
    $assert_tos_0
    lit6
    lit3
    lt
    $assert_tos_0
    lit3
    lit6
    ge
    $assert_tos_0
    lit3
    lit3
    ge
    $assert_tos_non0
    lit6
    lit3
    ge
    $assert_tos_non0
    lit3
    lit6
    gt
    $assert_tos_0
    lit3
    lit3
    gt
    $assert_tos_0
    lit6
    lit3
    gt
    $assert_tos_non0
    const1s -6
    lit1
    shr
    lit0
    gt
    $assert_tos_non0
    const1s -6
    lit1
    shra
    lit0
    lt
    $assert_tos_non0
    # Finally some result.
    addr ptr
}]

# Make some DWARF for the test.
set asm_file [standard_output_file $srcfile2]
Dwarf::assemble $asm_file {
    # Creating a CU with 4-byte addresses lets this test link on both
    # 32- and 64-bit machines.
    cu { addr_size 4 } {

	declare_labels int_label
	extern func_start func_end ptr

	compile_unit {
	    {name file1.txt}
	    {language @DW_LANG_C}
	    {low_pc func_start addr}
	    {high_pc func_end addr}
	} {
	    global program

	    int_label: base_type {
		{name int}
		{byte_size 4 sdata}
		{encoding @DW_ATE_signed}
	    }

	    subprogram {
		{external 1 flag}
		{name func}
		{low_pc func_start addr}
		{high_pc func_end addr}
	    } {
		formal_parameter {
		    {name param}
		    {variable_parameter 1 flag}
		    {type :$int_label}
		    {location $program SPECIAL_expr}
		}

		formal_parameter {
		    {name optimized_out}
		    {variable_parameter 1 flag}
		    {type :$int_label}
		}
	    }
	}
    }
}

if { [prepare_for_testing "failed to prepare" ${testfile} \
	  [list $srcfile $asm_file] {nodebug}] } {
    return -1
}

if ![runto func] {
    return -1
}

if {[skip_compile_feature_tests]} {
    untested "compile command not supported (could not find libcc1 shared library?)"
    return -1
}

# If we have a bug, this will hang.
gdb_test_no_output "compile code (void) param"

# We can't access optimized-out variables, but their presence should
# not affect compilations that don't refer to them.
gdb_test "compile code optimized_out" \
    ".*optimized out.*Compilation failed."