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