Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-break-qualified.exp
CommitLineData
88b9d363 1# Copyright 2020-2022 Free Software Foundation, Inc.
6791b117
PA
2
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.
7#
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.
12#
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/>.
15
16# Test '-break-insert --qualified' and C++ wildmatching.
17#
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.
20
21load_lib mi-support.exp
22set MIFLAGS "-i=mi"
23
24standard_testfile .cc
25
26if {[build_executable $testfile.exp $testfile $srcfile {c++ debug}] == -1} {
27 untested "failed to compile"
28 return -1
29}
30
31set loc_ns_func_line [gdb_get_line_number "location NS::func here"]
32set loc_foo_func_line [gdb_get_line_number "location foo::func here"]
33set loc_func_line [gdb_get_line_number "location func here"]
34
35proc test_break_qualified {} {
36 global hex
37 global loc_ns_func_line loc_foo_func_line loc_func_line
38
39 # We have three functions called "func" in the program. Check
40 # that --qualified only picks the one explicitly specified.
41
42 set bps {}
43 set test "--qualified func"
44 lappend bps [mi_create_breakpoint $test $test \
45 -func "func\\(char\\)" \
46 -file ".*mi-break-qualified.cc" \
47 -line $loc_func_line]
48
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]
54
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]
60
61 # Also check that without --qualified, we get a breakpoint with a
62 # location for each of the functions called "func" in the program.
63
64 # Small helper wrapper around mi_make_breakpoint_loc.
65 proc make_loc_re {func line_no} {
66 global hex
67
68 return [mi_make_breakpoint_loc \
69 -enabled "y" \
70 -func "$func" \
71 -file ".*mi-break-qualified.cc" \
72 -line="$line_no"]
73 }
74
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]
78
79 set test "func"
80 set bp [mi_create_breakpoint_multi $test $test \
81 -original-location "func" \
82 -locations "\\\[$loc1,$loc2,$loc3\\\]"]
83
84 lappend bps $bp
85
86 # List the breakpoints.
87 mi_gdb_test "666-break-list" \
88 "666\\\^done,[mi_make_breakpoint_table $bps]" \
89 "list of breakpoints"
90
91 mi_gdb_test "777-break-delete" \
92 "777\\^done" \
93 "delete temp breakpoints"
94}
95
96mi_gdb_exit
97
98if [mi_gdb_start ""] {
99 return
100}
101
102mi_delete_breakpoints
103mi_gdb_reinitialize_dir $srcdir/$subdir
104mi_gdb_load ${binfile}
105
106test_break_qualified
This page took 0.198143 seconds and 4 git commands to generate.