1 # Copyright 2018-2019 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 # Tests various things related to breakpoints with multiple locations.
18 load_lib mi-support.exp
21 if {[gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable {debug c++}] != "" } {
25 # Generate the regexp pattern used to match the breakpoint description emitted
26 # in the various breakpoint command results/events.
28 # - EXPECT_FIXED_OUTPUT: If true (non-zero), we expect GDB to output the fixed
29 # output for multi-locations breakpoint, else we expect it to output the
30 # broken pre-mi3 format.
31 # - BP_NUM is the expected breakpoint number
32 # - LOC1_EN and LOC2_EN are the expected value of the enabled field, for the
36 proc make_breakpoints_pattern { expect_fixed_output bp_num loc1_en loc2_en } {
37 if $expect_fixed_output {
38 return "bkpt=\{number=\"${bp_num}\",type=\"breakpoint\",.*,locations=\\\[\{number=\"${bp_num}\\.1\",enabled=\"${loc1_en}\",.*\},\{number=\"${bp_num}\\.2\",enabled=\"${loc2_en}\",.*\}\\\]\}"
40 return "bkpt=\{number=\"${bp_num}\",type=\"breakpoint\",.*\},\{number=\"${bp_num}\\.1\",enabled=\"${loc1_en}\",.*\},\{number=\"${bp_num}\\.2\",enabled=\"${loc2_en}\",.*\}"
44 # Run the test with the following parameters:
46 # - MI_VERSION: the version of the MI interpreter to use (e.g. "2")
47 # - USE_FIX_FLAG: Whether to issue the -fix-multi-location-breakpoint-output
48 # command after starting GDB
49 # - EXPECT_FIXED_OUTPUT: If true (non-zero), we expect GDB to output the fixed
50 # output for multi-locations breakpoint, else we expect it to output the
51 # broken pre-mi3 format.
53 proc do_test { mi_version use_fix_flag expect_fixed_output } {
54 with_test_prefix "mi_version=${mi_version}" {
55 with_test_prefix "use_fix_flag=${use_fix_flag}" {
56 global MIFLAGS decimal
57 set MIFLAGS "-i=mi${mi_version}"
67 mi_gdb_test "-fix-multi-location-breakpoint-output" "\\^done" \
68 "send -fix-multi-location-breakpoint-output"
71 # Check the breakpoint-created event.
72 set pattern [make_breakpoints_pattern $expect_fixed_output 2 y y]
73 mi_gdb_test "break add" \
74 [multi_line "&\"break add\\\\n\"" \
75 "~\"Breakpoint ${decimal} at.*\\(2 locations\\)\\\\n\"" \
76 "=breakpoint-created,${pattern}" \
80 # Check the -break-info output.
81 mi_gdb_test "-break-info" \
82 "\\^done,BreakpointTable=\{.*,body=\\\[${pattern}\\\]\}" \
85 # Check the -break-insert response.
86 set pattern [make_breakpoints_pattern $expect_fixed_output 3 y y]
87 mi_gdb_test "-break-insert add" "\\^done,${pattern}" "insert breakpoint with MI command"
89 # Modify enableness through MI commands shouldn't trigger MI
91 mi_gdb_test "-break-disable 2.2" "\\^done" "-break-disable 2.2"
92 mi_gdb_test "-break-enable 2.2" "\\^done" "-break-enable 2.2"
94 # Modify enableness through CLI commands should trigger MI
96 set pattern [make_breakpoints_pattern $expect_fixed_output 2 y n]
97 mi_gdb_test "dis 2.2" \
98 [multi_line "&\"dis 2.2\\\\n\"" \
99 "=breakpoint-modified,${pattern}" \
102 set pattern [make_breakpoints_pattern $expect_fixed_output 2 y y]
103 mi_gdb_test "en 2.2" \
104 [multi_line "&\"en 2.2\\\\n\"" \
105 "=breakpoint-modified,${pattern}" \
117 # mi2 with -fix-multi-location-breakpoint-output
123 # mi3 with -fix-multi-location-breakpoint-output
126 # Whatever MI version is currently the default one, vanilla
129 # Whatever MI version is currently the default one, with
130 # -fix-multi-location-breakpoint-output