PR c++/12750
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / static-method.exp
1 # Copyright 2011 Free Software Foundation, Inc.
2 #
3 # Contributed by Red Hat, originally written by Keith Seitz.
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 # This file is part of the gdb testsuite.
19
20 # A helper proc which sets a breakpoint at FUNC and attempts to
21 # run to the breakpoint.
22 proc test_breakpoint {func result} {
23 set DEC {[0-9]}
24
25 # Return to the top of the test function every time.
26 delete_breakpoints
27 if {![gdb_breakpoint test_function]} {
28 fail "set test_function breakpoint for $func"
29 } elseif {[gdb_test "continue" \
30 "Continuing.\r\n\r\nBreakpoint $DEC+,.*test_function.*" \
31 ""] != 0} {
32 fail "continue to test_function for $func"
33 } else {
34 gdb_breakpoint "$func"
35 gdb_test "continue" \
36 "Continuing.\r\n\r\nBreakpoint $DEC+,.*$result.*" \
37 "continue to $func"
38 }
39 }
40
41 if {[skip_cplus_tests]} { continue }
42
43 # Tests for c++/12750
44 set testfile "static-method"
45 set srcfile $testfile.cc
46
47 if {[prepare_for_testing $testfile $testfile $srcfile {c++ debug}]} {
48 return -1
49 }
50
51 if {![runto_main]} {
52 perror "couldn't run to breakpoint"
53 continue
54 }
55
56 set ans {(anonymous namespace)}
57 set methods {}
58 lappend methods "xxx::${ans}::func"
59 lappend methods "xxx::${ans}::A::func"
60
61 gdb_test_no_output "set listsize 1" ""
62
63 foreach test $methods {
64 # The result we expect is the source code name of the symbol,
65 # i.e., without "(anonymous namespace)".
66 regsub -all [string_to_regexp "${ans}::"] $test "" expected
67 set result ".*// [string_to_regexp $expected]"
68
69 # Test whether the function/method can be "list"ed
70 # with the filename pre-pended.
71 gdb_test "list ${srcfile}:$test" $result
72 gdb_test "list '${srcfile}:$test'" $result
73 gdb_test "list '${srcfile}':$test'" $result
74 gdb_test "list ${srcfile}:'$test'" $result
75
76 # Test setting and hitting a breakoint at the function/method.
77 test_breakpoint $test $expected
78 test_breakpoint "'$test'" $expected
79 }
80
81 gdb_exit
82 return 0
This page took 0.033515 seconds and 5 git commands to generate.