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