blob: 6409d3388e2fa53e9458aa79aa2662baf2fdead3 (
plain)
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
|
# Copyright 2020-2021 Free Software Foundation, Inc.
# 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/>.
# Test '-break-insert --qualified' and C++ wildmatching.
#
# The goal is not to test GDB functionality, which is done by other
# tests, but to verify the correct output response to MI operations.
load_lib mi-support.exp
set MIFLAGS "-i=mi"
standard_testfile .cc
if {[build_executable $testfile.exp $testfile $srcfile {c++ debug}] == -1} {
untested "failed to compile"
return -1
}
set loc_ns_func_line [gdb_get_line_number "location NS::func here"]
set loc_foo_func_line [gdb_get_line_number "location foo::func here"]
set loc_func_line [gdb_get_line_number "location func here"]
proc test_break_qualified {} {
global hex
global loc_ns_func_line loc_foo_func_line loc_func_line
# We have three functions called "func" in the program. Check
# that --qualified only picks the one explicitly specified.
set bps {}
set test "--qualified func"
lappend bps [mi_create_breakpoint $test $test \
-func "func\\(char\\)" \
-file ".*mi-break-qualified.cc" \
-line $loc_func_line]
set test "--qualified NS::func"
lappend bps [mi_create_breakpoint $test $test \
-func "NS::func\\(int\\)" \
-file ".*mi-break-qualified.cc" \
-line $loc_ns_func_line]
set test "--qualified foo::func"
lappend bps [mi_create_breakpoint $test $test \
-func "foo::func\\(long\\)" \
-file ".*mi-break-qualified.cc" \
-line $loc_foo_func_line]
# Also check that without --qualified, we get a breakpoint with a
# location for each of the functions called "func" in the program.
# Small helper wrapper around mi_make_breakpoint_loc.
proc make_loc_re {func line_no} {
global hex
return [mi_make_breakpoint_loc \
-enabled "y" \
-func "$func" \
-file ".*mi-break-qualified.cc" \
-line="$line_no"]
}
set loc1 [make_loc_re "NS::func\\(int\\)" $loc_ns_func_line]
set loc2 [make_loc_re "foo::func\\(long\\)" $loc_foo_func_line]
set loc3 [make_loc_re "func\\(char\\)" $loc_func_line]
set test "func"
set bp [mi_create_breakpoint_multi $test $test \
-original-location "func" \
-locations "\\\[$loc1,$loc2,$loc3\\\]"]
lappend bps $bp
# List the breakpoints.
mi_gdb_test "666-break-list" \
"666\\\^done,[mi_make_breakpoint_table $bps]" \
"list of breakpoints"
mi_gdb_test "777-break-delete" \
"777\\^done" \
"delete temp breakpoints"
}
mi_gdb_exit
if [mi_gdb_start ""] {
return
}
mi_delete_breakpoints
mi_gdb_reinitialize_dir $srcdir/$subdir
mi_gdb_load ${binfile}
test_break_qualified
|