1 # Copyright 2011 Free Software Foundation, Inc.
3 # Contributed by Red Hat, originally written by Keith Seitz.
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.
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.
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/>.
18 # This file is part of the gdb testsuite.
20 # A helper proc which sets a breakpoint at FUNC and attempts to
21 # run to the breakpoint.
22 proc test_breakpoint {func result} {
25 # Return to the top of the test function every time.
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.*" \
32 fail "continue to test_function for $func"
34 gdb_breakpoint "$func"
36 "Continuing.\r\n\r\nBreakpoint $DEC+,.*$result.*" \
41 if {[skip_cplus_tests]} { continue }
44 set testfile "static-method"
45 set srcfile $testfile.cc
47 if {[prepare_for_testing $testfile $testfile $srcfile {c++ debug}]} {
52 perror "couldn't run to breakpoint"
56 set ans {(anonymous namespace)}
58 lappend methods "xxx::${ans}::func"
59 lappend methods "xxx::${ans}::A::func"
61 gdb_test_no_output "set listsize 1" ""
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]"
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
76 # Test setting and hitting a breakoint at the function/method.
77 test_breakpoint $test $expected
78 test_breakpoint "'$test'" $expected