1 # Copyright 2020-2021 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 # Test '-break-insert --qualified' and C++ wildmatching.
18 # The goal is not to test GDB functionality, which is done by other
19 # tests, but to verify the correct output response to MI operations.
21 load_lib mi-support.exp
26 if {[build_executable $testfile.exp $testfile $srcfile {c++ debug}] == -1} {
27 untested "failed to compile"
31 set loc_ns_func_line [gdb_get_line_number "location NS::func here"]
32 set loc_foo_func_line [gdb_get_line_number "location foo::func here"]
33 set loc_func_line [gdb_get_line_number "location func here"]
35 proc test_break_qualified {} {
37 global loc_ns_func_line loc_foo_func_line loc_func_line
39 # We have three functions called "func" in the program. Check
40 # that --qualified only picks the one explicitly specified.
43 set test "--qualified func"
44 lappend bps [mi_create_breakpoint $test $test \
45 -func "func\\(char\\)" \
46 -file ".*mi-break-qualified.cc" \
49 set test "--qualified NS::func"
50 lappend bps [mi_create_breakpoint $test $test \
51 -func "NS::func\\(int\\)" \
52 -file ".*mi-break-qualified.cc" \
53 -line $loc_ns_func_line]
55 set test "--qualified foo::func"
56 lappend bps [mi_create_breakpoint $test $test \
57 -func "foo::func\\(long\\)" \
58 -file ".*mi-break-qualified.cc" \
59 -line $loc_foo_func_line]
61 # Also check that without --qualified, we get a breakpoint with a
62 # location for each of the functions called "func" in the program.
64 # Small helper wrapper around mi_make_breakpoint_loc.
65 proc make_loc_re {func line_no} {
68 return [mi_make_breakpoint_loc \
71 -file ".*mi-break-qualified.cc" \
75 set loc1 [make_loc_re "NS::func\\(int\\)" $loc_ns_func_line]
76 set loc2 [make_loc_re "foo::func\\(long\\)" $loc_foo_func_line]
77 set loc3 [make_loc_re "func\\(char\\)" $loc_func_line]
80 set bp [mi_create_breakpoint_multi $test $test \
81 -original-location "func" \
82 -locations "\\\[$loc1,$loc2,$loc3\\\]"]
86 # List the breakpoints.
87 mi_gdb_test "666-break-list" \
88 "666\\\^done,[mi_make_breakpoint_table $bps]" \
91 mi_gdb_test "777-break-delete" \
93 "delete temp breakpoints"
98 if [mi_gdb_start ""] {
102 mi_delete_breakpoints
103 mi_gdb_reinitialize_dir $srcdir/$subdir
104 mi_gdb_load ${binfile}