OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [gdb/] [testsuite/] [gdb.base/] [macscp.exp] - Blame information for rev 862

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 227 jeremybenn
# Test macro scoping.
2
# Copyright 2002, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
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
6
# the Free Software Foundation; either version 3 of the License, or
7
# (at your option) any later version.
8
#
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.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program.  If not, see .
16
 
17
if $tracelevel then {
18
    strace $tracelevel
19
}
20
 
21
set prms_id 0
22
set bug_id 0
23
 
24
set srcfile macscp1.c
25
set testfile "macscp"
26
set objfile ${objdir}/${subdir}/${testfile}.o
27
set binfile ${objdir}/${subdir}/${testfile}
28
 
29
set options { debug additional_flags=-DFROM_COMMANDLINE=ARG}
30
 
31
get_compiler_info ${binfile}
32
if [test_compiler_info gcc*] {
33
    lappend options additional_flags=-g3
34
}
35
 
36
# Generate the intermediate object file.  This is required by Darwin to
37
# have access to the .debug_macinfo section.
38
if  {[gdb_compile "${srcdir}/${subdir}/macscp1.c" "${objfile}" \
39
          object $options] != ""
40
     || [gdb_compile "${objfile}" "${binfile}" executable $options] != "" } {
41
    untested macscp.exp
42
    return -1
43
}
44
 
45
gdb_exit
46
gdb_start
47
gdb_reinitialize_dir $srcdir/$subdir
48
gdb_load ${binfile}
49
 
50
 
51
# Ask GDB to show the current definition of MACRO, and return a list
52
# describing the result.
53
#
54
# The return value has the form {FILE1 FILE2 ... DEF}, which means
55
# that MACRO has the definition `DEF', and was defined in `FILE1',
56
# which was included from `FILE2', included from ... .
57
#
58
# If GDB says that MACRO has no definition, return the string `undefined'.
59
#
60
# If GDB complains that it doesn't have any information about
61
# preprocessor macro definitions, return the string `no-macro-info'.
62
#
63
# If expect times out waiting for GDB, we return the string `timeout'.
64
#
65
# If GDB's output doesn't otherwise match what we're expecting, we
66
# return the empty string.
67
 
68
proc info_macro {macro} {
69
    global gdb_prompt
70
 
71
    set filepat {macscp[0-9]+\.[ch]}
72
    set definition {}
73
    set location {}
74
 
75
    # Line number zero is set for macros defined from the compiler command-line.
76
    # Such macros are not being tested by this function.
77
    set nonzero {[1-9][0-9]*}
78
 
79
    send_gdb "info macro ${macro}\n"
80
 
81
    set debug_me 0
82
 
83
    if {$debug_me} {exp_internal 1}
84
    gdb_expect {
85
        -re "Defined at \[^\r\n\]*(${filepat}):${nonzero}\[\r\n\]" {
86
            # `location' and `definition' should be empty when we see
87
            # this message.
88
            if {[llength $location] == 0 && [llength $definition] == 0} {
89
                set location $expect_out(1,string)
90
                exp_continue
91
            } else {
92
                # Exit this expect loop, with a result indicating failure.
93
                set definition {}
94
            }
95
        }
96
        -re "The symbol `${macro}' has no definition as a C/C\\+\\+ preprocessor macro\[^\r\n\]*\[\r\n\]" {
97
            # `location' and `definition' should be empty when we see
98
            # this message.
99
            if {[llength $location] == 0 && [llength $definition] == 0} {
100
                set definition undefined
101
                exp_continue
102
            } else {
103
                # Exit this expect loop, with a result indicating failure.
104
                set definition {}
105
            }
106
        }
107
        -re "^\[\r\n\]*  included at \[^\r\n\]*(${filepat}):${nonzero}\[\r\n\]" {
108
            # `location' should *not* be empty when we see this
109
            # message.  It should have recorded at least the initial
110
            # `Defined at ' message (for definitions) or ` at' message
111
            # (for undefined symbols).
112
            if {[llength $location] != 0} {
113
                lappend location $expect_out(1,string)
114
                exp_continue
115
            } else {
116
                # Exit this expect loop, with a result indicating failure.
117
                set definition {}
118
            }
119
        }
120
        -re "^\[\r\n\]*at \[^\r\n\]*(${filepat}):${nonzero}\[\r\n\]" {
121
            # This appears after a `has no definition' message.
122
            # `location' should be empty when we see it.
123
            if {[string compare $definition undefined] == 0 \
124
                    && [llength $location] == 0} {
125
                set location $expect_out(1,string)
126
                exp_continue
127
            } else {
128
                # Exit this expect loop, with a result indicating failure.
129
                set definition {}
130
            }
131
        }
132
        -re "#define ${macro} (\[^\r\n\]*)\[\r\n\]" {
133
            # `definition' should be empty when we see this message.
134
            if {[string compare $definition ""] == 0} {
135
                set definition $expect_out(1,string)
136
                exp_continue
137
            } else {
138
                # Exit this expect loop, with a result indicating failure.
139
                set definition {}
140
            }
141
        }
142
        -re "has no preprocessor macro information.*$gdb_prompt $" {
143
            set definition no-macro-info
144
        }
145
        -re "$gdb_prompt $" {
146
            # Exit the expect loop; let the existing value of `definition'
147
            # indicate failure or success.
148
        }
149
        timeout {
150
            set definition timeout
151
        }
152
    }
153
    if {$debug_me} {exp_internal 0}
154
 
155
    switch -exact -- $definition {
156
        no-macro-info { return no-macro-info }
157
        timeout { return timeout }
158
        undefined { return undefined }
159
        default {
160
            if {[llength $location] >= 1} {
161
                return [concat $location [list $definition]]
162
            } else {
163
                return {}
164
            }
165
        }
166
    }
167
}
168
 
169
 
170
# Call info_macro to show the definition of MACRO.  Expect a result of
171
# EXPECTED.  Use WHERE in pass/fail messages to identify the context.
172
# Return non-zero if we should abort the entire test file, or zero if
173
# we can continue.
174
proc check_macro {macro expected where} {
175
    set func_def [info_macro $macro]
176
    if {[string compare $func_def $expected] == 0} {
177
        pass "info macro $macro $where"
178
    } else {
179
        switch -exact -- $func_def {
180
            no-macro-info {
181
                xfail "executable includes no macro debugging information"
182
                return 1
183
            }
184
            undefined {
185
                fail "info macro $macro $where (undefined)"
186
                return 1
187
            }
188
            timeout {
189
                fail "info macro $macro $where (timeout)"
190
            }
191
            default {
192
                fail "info macro $macro $where"
193
            }
194
        }
195
    }
196
    return 0
197
}
198
 
199
 
200
# List the function FUNC, and then show the definition of MACRO,
201
# expecting the result EXPECTED.
202
proc list_and_check_macro {func macro expected} {
203
    gdb_test "list $func" ".*${func}.*" "list $func for $macro"
204
    return [check_macro $macro $expected "after `list $func'"]
205
}
206
 
207
gdb_test "list main" ".*main.*" "list main for support check"
208
set macro_support "unknown"
209
gdb_test_multiple "info source" "Test macro information"  {
210
    -re "Includes preprocessor macro info\..*$gdb_prompt $" {
211
        set macro_support 1
212
        verbose "Source has macro information"
213
    }
214
    -re "Does not include preprocessor macro info\..*$gdb_prompt $" {
215
        set macro_support 0
216
        verbose "Source has no macro information"
217
    }
218
    default {
219
        warning "couldn't check macro support (no valid response)."
220
    }
221
}
222
if {$macro_support == 0} {
223
    unsupported "Skipping test because debug information does not include macro information."
224
    return 0
225
}
226
 
227
list_and_check_macro main WHERE {macscp1.c {before macscp1_3}}
228
list_and_check_macro macscp2_2 WHERE {macscp2.h macscp1.c {before macscp2_2}}
229
list_and_check_macro macscp3_2 WHERE {macscp3.h macscp1.c {before macscp3_2}}
230
 
231
 
232
# Assuming the current position inside program by `list' from above.
233
gdb_test "info macro FROM_COMMANDLINE" \
234
         "Defined at \[^\r\n\]*:0\r\n-DFROM_COMMANDLINE=ARG"
235
 
236
 
237
# Although GDB's macro table structures distinguish between multiple
238
# #inclusions of the same file, GDB's other structures don't.  So the
239
# `list' command here doesn't reliably select one #inclusion or the
240
# other, even though it could.  It would be nice to eventually change
241
# GDB's structures to handle this correctly.
242
gdb_test "list macscp4_2_from_macscp2" ".*macscp4_2_, MACSCP4_INCLUSION.*"
243
switch -exact -- [info_macro WHERE] {
244
    {macscp4.h macscp2.h macscp1.c {before macscp4_2_..., from macscp2.h}} {
245
        pass "info macro WHERE after `list macscp_4_2_from_macscp2'"
246
    }
247
    {macscp4.h macscp3.h macscp1.c {before macscp4_2_..., from macscp3.h}} {
248
        setup_kfail *-*-* "gdb/555"
249
        fail "info macro WHERE after `list macscp_4_2_from_macscp2' (gdb/555)"
250
    }
251
    timeout {
252
        fail "info macro WHERE after `list macscp_4_2_from_macscp2' (timeout)"
253
    }
254
    default { fail "info macro WHERE after `list macscp_4_2_from_macscp2'" }
255
}
256
 
257
gdb_test "list macscp4_2_from_macscp3" ".*macscp4_2_, MACSCP4_INCLUSION.*"
258
switch -exact -- [info_macro WHERE] {
259
    {macscp4.h macscp3.h macscp1.c {before macscp4_2_..., from macscp3.h}} {
260
        pass "info macro WHERE after `list macscp_4_2_from_macscp3'"
261
    }
262
    {macscp4.h macscp2.h macscp1.c {before macscp4_2_..., from macscp2.h}} {
263
        setup_kfail *-*-* "gdb/555"
264
        fail "info macro WHERE after `list macscp_4_2_from_macscp3' (gdb/555)"
265
    }
266
    timeout {
267
        fail "info macro WHERE after `list macscp_4_2_from_macscp3' (timeout)"
268
    }
269
    default { fail "info macro WHERE after `list macscp_4_2_from_macscp3'" }
270
}
271
 
272
 
273
#### Test the selection of the macro scope by the current frame.
274
 
275
### A table of functions, in the order they will be reached, which is
276
### also the order they appear in the preprocessed output.  Each entry
277
### has the form {FUNCNAME WHERE KFAILWHERE}, where:
278
### - FUNCNAME is the name of the function,
279
### - WHERE is the definition we expect to see for the macro `WHERE', as
280
###   returned by `info_macro', and
281
### - KFAILWHERE is an alternate definition which should be reported
282
###   as a `known failure', due to GDB's inability to distinguish multiple
283
###   #inclusions of the same file.
284
### KFAILWHERE may be omitted.
285
 
286
set funcs {
287
    {
288
        macscp1_1
289
        {macscp1.c {before macscp1_1}}
290
    }
291
    {
292
        macscp2_1
293
        {macscp2.h macscp1.c {before macscp2_1}}
294
    }
295
    {
296
        macscp4_1_from_macscp2
297
        {macscp4.h macscp2.h macscp1.c {before macscp4_1_..., from macscp2.h}}
298
        {macscp4.h macscp3.h macscp1.c {before macscp4_1_..., from macscp3.h}}
299
    }
300
    {
301
        macscp4_2_from_macscp2
302
        {macscp4.h macscp2.h macscp1.c {before macscp4_2_..., from macscp2.h}}
303
        {macscp4.h macscp3.h macscp1.c {before macscp4_2_..., from macscp3.h}}
304
    }
305
    {
306
        macscp2_2
307
        {macscp2.h macscp1.c {before macscp2_2}}
308
    }
309
    {
310
        macscp1_2
311
        {macscp1.c {before macscp1_2}}
312
    }
313
    {
314
        macscp3_1
315
        {macscp3.h macscp1.c {before macscp3_1}}
316
    }
317
    {
318
        macscp4_1_from_macscp3
319
        {macscp4.h macscp3.h macscp1.c {before macscp4_1_..., from macscp3.h}}
320
        {macscp4.h macscp2.h macscp1.c {before macscp4_1_..., from macscp2.h}}
321
    }
322
    {
323
        macscp4_2_from_macscp3
324
        {macscp4.h macscp3.h macscp1.c {before macscp4_2_..., from macscp3.h}}
325
        {macscp4.h macscp2.h macscp1.c {before macscp4_2_..., from macscp2.h}}
326
    }
327
    {
328
        macscp3_2
329
        {macscp3.h macscp1.c {before macscp3_2}}
330
    }
331
    {
332
        macscp1_3
333
        {macscp1.c {before macscp1_3}}
334
    }
335
}
336
 
337
proc maybe_kfail { func test_name } {
338
    # We can't get the right scope info when we're stopped in
339
    # the macro4_ functions.
340
    if {[string match macscp4_* $func]} {
341
        kfail gdb/555 "$test_name"
342
    } else {
343
        fail "$test_name"
344
    }
345
}
346
 
347
# Start the program running.
348
if {! [runto_main]} {
349
    fail "macro tests suppressed: couldn't run to main"
350
    return 0
351
}
352
 
353
# Set a breakpoint on each of the functions.
354
foreach func_entry $funcs {
355
    set func [lindex $func_entry 0]
356
    gdb_test "break $func" "Breakpoint.*"
357
}
358
 
359
# Run to each of the breakpoints and check the definition (or lack
360
# thereof) of each macro.
361
for {set i 0} {$i < [llength $funcs]} {incr i} {
362
    set func_entry [lindex $funcs $i]
363
    set func [lindex $func_entry 0]
364
    set expected [lindex $func_entry 1]
365
    set kfail_expected [lindex $func_entry 2]
366
 
367
    # Run to the breakpoint for $func.
368
    gdb_test "continue" "Breakpoint $decimal, $func .*" "continue to $func"
369
 
370
    # Check the macro WHERE.
371
    set result [info_macro WHERE]
372
    if {[string compare $result $expected] == 0} {
373
        pass "info macro WHERE stopped in $func"
374
    } elseif {[string compare $result $kfail_expected] == 0} {
375
        setup_kfail *-*-* "gdb/555"
376
        fail "info macro WHERE stopped in $func (gdb/555)"
377
    } elseif {[string compare $result timeout] == 0} {
378
        fail "info macro WHERE stopped in $func (timeout)"
379
    } else {
380
        fail "info macro WHERE stopped in $func"
381
    }
382
 
383
    # Check that the BEFORE_ macros for all prior functions are
384
    # #defined, and that those for all subsequent functions are not.
385
    for {set j 0} {$j < [llength $funcs]} {incr j} {
386
        if {$j != $i} {
387
            set func_j_entry [lindex $funcs $j]
388
            set func_j [lindex $func_j_entry 0]
389
 
390
            set before_macro "BEFORE_[string toupper $func_j]"
391
            set test_name \
392
                    "$before_macro defined/undefined when stopped at $func"
393
            set result [info_macro $before_macro]
394
 
395
            if {$j < $i} {
396
                if {[llength $result] >= 2 && \
397
                        [string compare [lindex $result end] {}] == 0} {
398
                    pass $test_name
399
                } elseif {[string compare $result timeout] == 0} {
400
                    fail "$test_name (timeout)"
401
                } else {
402
                    maybe_kfail $func "$test_name"
403
                }
404
            } elseif {$j > $i} {
405
                switch -- [lindex $result end] {
406
                    undefined { pass $test_name }
407
                    timeout { fail "$test_name (timeout)" }
408
                    default {
409
                        maybe_kfail $func "$test_name"
410
                    }
411
                }
412
            }
413
 
414
            set until_macro "UNTIL_[string toupper $func_j]"
415
            set test_name \
416
                    "$until_macro defined/undefined when stopped at $func"
417
            set result [info_macro $until_macro]
418
 
419
            if {$j <= $i} {
420
                switch -- [lindex $result end] {
421
                    undefined { pass $test_name }
422
                    timeout { fail "$test_name (timeout)" }
423
                    default {
424
                        maybe_kfail $func "$test_name"
425
                    }
426
                }
427
            } elseif {$j > $i} {
428
                if {[llength $result] >= 2 && \
429
                        [string compare [lindex $result end] {}] == 0} {
430
                    pass $test_name
431
                } elseif {[string compare $result timeout] == 0} {
432
                    fail "$test_name (timeout)"
433
                } else {
434
                    maybe_kfail $func "$test_name"
435
                }
436
            }
437
        }
438
    }
439
}
440
 
441
gdb_test "break [gdb_get_line_number "set breakpoint here"]" \
442
    "Breakpoint.*at.* file .*, line.*" \
443
    "breakpoint macscp_expr"
444
 
445
gdb_test "continue" "foo = 0;.*" "continue to macsp_expr"
446
 
447
gdb_test "print address.addr" \
448
  " = 0" \
449
  "print address.addr"
450
 
451
gdb_test "print MACRO_TO_EXPAND" \
452
    "No symbol \"MACRO_TO_EXPAND\" in current context\." \
453
    "print expression with macro before define."
454
 
455
gdb_test "next" "foo = 1;" "next to definition 1"
456
 
457
gdb_test "print MACRO_TO_EXPAND" \
458
    " = 0" \
459
    "print expression with macro in scope."
460
 
461
gdb_test "macro define MACRO_TO_EXPAND 72" \
462
  "" \
463
  "user macro override"
464
 
465
gdb_test "print MACRO_TO_EXPAND" \
466
  " = 72" \
467
  "choose user macro"
468
 
469
gdb_test "macro undef MACRO_TO_EXPAND" \
470
  "" \
471
  "remove user override"
472
 
473
gdb_test "print MACRO_TO_EXPAND" \
474
    " = 0" \
475
    "print expression with macro after removing override"
476
 
477
gdb_test "next" "foo = 2;" "next to definition 2"
478
 
479
gdb_test "print MACRO_TO_EXPAND" \
480
    "No symbol \"MACRO_TO_EXPAND\" in current context\." \
481
    "print expression with macro after undef."
482
 
483
gdb_test "macro define MACRO_TO_EXPAND 5" \
484
  "" \
485
  "basic macro define"
486
 
487
gdb_test "print MACRO_TO_EXPAND" \
488
  " = 5" \
489
  "expansion of defined macro"
490
 
491
gdb_test "macro list" \
492
  "macro define MACRO_TO_EXPAND 5" \
493
  "basic macro list"
494
 
495
gdb_test "macro define MACRO_TO_EXPAND(x) x" \
496
  "" \
497
  "basic redefine, macro with args"
498
 
499
gdb_test "print MACRO_TO_EXPAND (7)" \
500
  " = 7" \
501
  "expansion of macro with arguments"
502
 
503
gdb_test "macro undef MACRO_TO_EXPAND" \
504
  "" \
505
  "basic macro undef"
506
 
507
gdb_test "print MACRO_TO_EXPAND" \
508
    "No symbol \"MACRO_TO_EXPAND\" in current context\." \
509
    "print expression with macro after user undef."
510
 
511
# Regression test; this used to crash.
512
gdb_test "macro define" \
513
    "usage: macro define.*" \
514
    "macro define with no arguments"
515
 
516
# Regression test; this used to crash.
517
gdb_test "macro undef" \
518
    "usage: macro undef.*" \
519
    "macro undef with no arguments"
520
 
521
# Completion tests.
522
 
523
# The macro FIFTY_SEVEN is in scope at this point.
524
send_gdb "p FIFTY_\t"
525
gdb_expect  {
526
        -re "^p FIFTY_SEVEN $"\
527
            { send_gdb "\n"
528
              gdb_expect {
529
                      -re "^.* = 57.*$gdb_prompt $"\
530
                                        { pass "complete 'p FIFTY_SEVEN'"}
531
                      -re ".*$gdb_prompt $" { fail "complete 'p FIFTY_SEVEN'"}
532
                      timeout           {fail "(timeout) complete 'p FIFTY_SEVEN'"}
533
                     }
534
            }
535
        -re ".*$gdb_prompt $"       { fail "complete 'p FIFTY_SEVEN'" }
536
        timeout         { fail "(timeout) complete 'p FIFTY_SEVEN' 2" }
537
        }
538
 
539
# The macro TWENTY_THREE is not in scope.
540
send_gdb "p TWENTY_\t"
541
gdb_expect  {
542
        -re "^p TWENTY_\\\x07$"\
543
            { send_gdb "\n"
544
              gdb_expect {
545
                      -re "No symbol \"TWENTY_\" in current context\\..*$gdb_prompt $"\
546
                                        { pass "complete 'p TWENTY_'"}
547
                      -re ".*$gdb_prompt $" { fail "complete 'p TWENTY_'"}
548
                      timeout           {fail "(timeout) complete 'p TWENTY_'"}
549
                     }
550
            }
551
        -re ".*$gdb_prompt $"       { fail "complete 'p TWENTY_'" }
552
        timeout         { fail "(timeout) complete 'p TWENTY_' 2" }
553
        }
554
 
555
# The macro FORTY_EIGHT was undefined and thus is not in scope.
556
send_gdb "p FORTY_\t"
557
gdb_expect  {
558
        -re "^p FORTY_\\\x07$"\
559
            { send_gdb "\n"
560
              gdb_expect {
561
                      -re "No symbol \"FORTY_\" in current context\\..*$gdb_prompt $"\
562
                                        { pass "complete 'p FORTY_'"}
563
                      -re ".*$gdb_prompt $" { fail "complete 'p FORTY_'"}
564
                      timeout           {fail "(timeout) complete 'p FORTY_'"}
565
                     }
566
            }
567
        -re ".*$gdb_prompt $"       { fail "complete 'p FORTY_'" }
568
        timeout         { fail "(timeout) complete 'p FORTY_' 2" }
569
        }
570
 
571
gdb_test "macro define TWENTY_THREE 25" \
572
  "" \
573
  "defining TWENTY_THREE"
574
 
575
# User-defined macros are always in scope.
576
send_gdb "p TWENTY_\t"
577
gdb_expect  {
578
        -re "^p TWENTY_THREE $"\
579
            { send_gdb "\n"
580
              gdb_expect {
581
                      -re "^.* = 25.*$gdb_prompt $"\
582
                                        { pass "complete 'p TWENTY_THREE'"}
583
                      -re ".*$gdb_prompt $" { fail "complete 'p TWENTY_THREE'"}
584
                      timeout           {fail "(timeout) complete 'p TWENTY_THREE'"}
585
                     }
586
            }
587
        -re ".*$gdb_prompt $"       { fail "complete 'p TWENTY_THREE'" }
588
        timeout         { fail "(timeout) complete 'p TWENTY_THREE' 2" }
589
        }
590
 
591
# Splicing tests.
592
 
593
gdb_test "macro expand SPLICE(x, y)" \
594
  "expands to: xy" \
595
  "basic macro splicing"
596
 
597
gdb_test "macro define robotinvasion 2010" \
598
  "" \
599
  "define splice helper"
600
 
601
gdb_test "macro expand SPLICE(robot, invasion)" \
602
  "expands to: *2010" \
603
  "splicing plus expansion"
604
 
605
# Varargs tests.
606
 
607
gdb_test "macro define va_c99(...) varfunc (fixedarg, __VA_ARGS__)" \
608
  "" \
609
  "define first varargs helper"
610
 
611
gdb_test "macro define va2_c99(x, y, ...) varfunc (fixedarg, x, y, __VA_ARGS__)" \
612
  "" \
613
  "define second varargs helper"
614
 
615
gdb_test "macro define va_gnu(args...) varfunc (fixedarg, args)" \
616
  "" \
617
  "define third varargs helper"
618
 
619
gdb_test "macro define va2_gnu(args...) varfunc (fixedarg, ## args)" \
620
  "" \
621
  "define fourth varargs helper"
622
 
623
gdb_test "macro expand va_c99(one, two, three)" \
624
  "expands to: *varfunc \\(fixedarg, *one, two, three\\)" \
625
  "c99 varargs expansion"
626
 
627
gdb_test "macro expand va_c99()" \
628
  "expands to: *varfunc \\(fixedarg, *\\)" \
629
  "c99 varargs expansion without an argument"
630
 
631
gdb_test "macro expand va2_c99(one, two, three, four)" \
632
  "expands to: *varfunc \\(fixedarg, *one, two, three, four\\)" \
633
  "c99 varargs expansion, multiple formal arguments"
634
 
635
gdb_test "macro expand va_gnu(one, two, three, four)" \
636
  "expands to: *varfunc \\(fixedarg, *one, two, three, four\\)" \
637
  "gnu varargs expansion"
638
 
639
gdb_test "macro expand va_gnu()" \
640
  "expands to: *varfunc \\(fixedarg, *\\)" \
641
  "gnu varargs expansion without an argument"
642
 
643
gdb_test "macro expand va2_gnu()" \
644
  "expands to: *varfunc \\(fixedarg\\)" \
645
  "gnu varargs expansion special splicing without an argument"
646
 
647
# Stringification tests.
648
 
649
gdb_test "macro define str(x) #x" \
650
  "" \
651
  "define stringification macro"
652
 
653
gdb_test "macro define maude 5" \
654
  "" \
655
  "define first stringification helper"
656
 
657
gdb_test "macro define xstr(x) str(x)" \
658
  "" \
659
  "define second stringification helper"
660
 
661
gdb_test "print str(5)" \
662
  " = \"5\"" \
663
  "simple stringify"
664
 
665
gdb_test "print str(hi bob)" \
666
  " = \"hi bob\"" \
667
  "stringify with one space"
668
 
669
gdb_test "print str(  hi  bob  )" \
670
  " = \"hi bob\"" \
671
  "stringify with many spaces"
672
 
673
gdb_test "print str(hi \"bob\")" \
674
  " = \"hi \\\\\"bob\\\\\"\"" \
675
  "stringify with quotes"
676
 
677
gdb_test "print str(hi \\bob\\)" \
678
  " = \"hi \\\\\\\\bob\\\\\\\\\"" \
679
  "stringify with backslashes"
680
 
681
gdb_test "print str(maude)" \
682
  " = \"maude\"" \
683
  "stringify without substitution"
684
 
685
gdb_test "print xstr(maude)" \
686
  " = \"5\"" \
687
  "stringify with substitution"
688
 
689
# Regression test for pp-number bug.
690
gdb_test "macro define si_addr fields.fault.si_addr" \
691
  "" \
692
  "define si_addr macro"
693
gdb_test "macro expand siginfo.si_addr" \
694
  "expands to: siginfo.fields.fault.si_addr" \
695
  "macro expand siginfo.si_addr"

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.