1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
# Copyright 2011-2015 Free Software Foundation, Inc.
#
# Contributed by Red Hat, originally written by Keith Seitz.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# This file is part of the gdb testsuite.
proc add {var name params expected {kind {func}}} {
upvar $var result
if {[string compare $kind "template"] == 0} {
set method_name "${name}<$expected>"
} else {
set method_name "$name"
}
set expect ".*// ${method_name}\\($expected\\)"
lappend result [list "${method_name}($params)" $expect]
}
if {[skip_cplus_tests]} { continue }
# Tests for c++/12266 et al
standard_testfile .cc
if {[prepare_for_testing $testfile $testfile $srcfile {c++ debug}]} {
return -1
}
if {![runto_main]} {
perror "couldn't run to breakpoint"
continue
}
array set typedefs {
"my_other_type" {"my_other_type" "my_type" "const char* const*"}
"my_other_type_2" {"my_other_type_2" "my_type_2" "int"}
"CORE_ADDR" { "CORE_ADDR" "unsigned long" }
"_BAR_" { "_BAR_" "a::b::BAR" "a::b::c::d::bar" }
"aenum" { "aenum" "anon_enum" }
"astruct" { "astruct" "anon_struct" }
"aunion" { "aunion" "anon_union" }
}
set methods {}
# Add the simple, one-parameter methods
foreach meth {A::FOO::test A::FOO::foo} {
foreach type {my_other_type my_other_type_2} {
foreach t $typedefs($type) {
add methods $meth $t $type
}
}
}
# Add two-parameter methods
foreach meth {A::FOO::test A::FOO::foo} {
set type "my_other_type_2, const my_other_type"
foreach t1 $typedefs(my_other_type_2) {
foreach t2 $typedefs(my_other_type) {
add methods $meth "$t1, const $t2" $type
add methods $meth "$t1, $t2" $type
}
}
}
# Add three-parameter methods/functions
foreach meth {A::FOO::test A::FOO::foo B::test test} {
set type "aenum, astruct const&, aunion const\\*\\*\\*"
foreach t1 $typedefs(aenum) {
foreach t2 $typedefs(astruct) {
foreach t3 $typedefs(aunion) {
add methods $meth "$t1, $t2 const&, $t3 const***" $type
}
}
}
}
# Add the array-of-function pointer methods
set type "fptr1\\*"
foreach meth {A::FOO::test A::FOO::foo} {
add methods $meth "fptr1*" $type
foreach t $typedefs(my_other_type) {
add methods $meth "void (**) ($t)" $type
}
}
# Add the function pointer methods
set type "fptr3"
foreach meth {A::FOO::test A::FOO::foo} {
add methods $meth "fptr3" $type
foreach t1 $typedefs(my_other_type) {
add methods $meth "void (*)(fptr2, $t1)" $type
foreach t2 $typedefs(my_other_type_2) {
add methods $meth "void (*)(void (*)(fptr1, $t2), $t1)" $type
foreach t3 $typedefs(my_other_type) {
add methods $meth \
"void (*)(void (*)(void (*) ($t3), $t2), $t1)" $type
}
}
}
}
set type1 "my_other_type"
set type2 "my_other_type, my_other_type_2"
foreach meth {"test" "B::test"} {
foreach t1 $typedefs(my_other_type) {
add methods $meth $t1 $type1
foreach t2 $typedefs(my_other_type_2) {
add methods $meth "$t1, $t2" $type2 template
}
}
}
# Miscellaneous tests
set type {CORE_ADDR \(\*\) \[10\]}
foreach meth {A::FOO::foo A::FOO::test} {
foreach t $typedefs(CORE_ADDR) {
add methods $meth "$t (*) \[10\]" $type
}
}
foreach t $typedefs(_BAR_) {
add methods "test" "$t&" {_BAR_&}
}
gdb_test_no_output "set listsize 1" ""
# Finally, for each method in the list METHODS, check whether
# the user can "list" it and "break" on it (both quoted and unquoted).
foreach test $methods {
set func [lindex $test 0]
set result [lindex $test 1]
gdb_test "list $func" $result
gdb_test "list '$func'" $result
if {[gdb_breakpoint $func]} {
pass "break $func"
}
if {[gdb_breakpoint '$func']} {
pass "break '$func'"
}
}
gdb_exit
return 0
|