Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-breakpoint-multiple-locations.exp
CommitLineData
88b9d363 1# Copyright 2018-2022 Free Software Foundation, Inc.
b4be1b06
SM
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# Tests various things related to breakpoints with multiple locations.
17
18load_lib mi-support.exp
19standard_testfile .cc
20
21if {[gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable {debug c++}] != "" } {
22 return -1
23}
24
25# Generate the regexp pattern used to match the breakpoint description emitted
26# in the various breakpoint command results/events.
27#
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
33# two locations.
34
35
36proc 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}\",.*\}\\\]\}"
39 } else {
40 return "bkpt=\{number=\"${bp_num}\",type=\"breakpoint\",.*\},\{number=\"${bp_num}\\.1\",enabled=\"${loc1_en}\",.*\},\{number=\"${bp_num}\\.2\",enabled=\"${loc2_en}\",.*\}"
41 }
42}
43
44# Run the test with the following parameters:
45#
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.
52
53proc 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}" {
b75d55d4 56 global MIFLAGS decimal binfile
b4be1b06
SM
57 set MIFLAGS "-i=mi${mi_version}"
58
b75d55d4 59 mi_clean_restart $binfile
b4be1b06 60
b75d55d4 61 mi_runto_main
b4be1b06
SM
62
63 if $use_fix_flag {
64 mi_gdb_test "-fix-multi-location-breakpoint-output" "\\^done" \
65 "send -fix-multi-location-breakpoint-output"
66 }
67
68 # Check the breakpoint-created event.
69 set pattern [make_breakpoints_pattern $expect_fixed_output 2 y y]
70 mi_gdb_test "break add" \
71 [multi_line "&\"break add\\\\n\"" \
72 "~\"Breakpoint ${decimal} at.*\\(2 locations\\)\\\\n\"" \
73 "=breakpoint-created,${pattern}" \
74 "\\^done" ] \
75 "break add"
76
77 # Check the -break-info output.
78 mi_gdb_test "-break-info" \
79 "\\^done,BreakpointTable=\{.*,body=\\\[${pattern}\\\]\}" \
80 "-break-info"
81
82 # Check the -break-insert response.
83 set pattern [make_breakpoints_pattern $expect_fixed_output 3 y y]
84 mi_gdb_test "-break-insert add" "\\^done,${pattern}" "insert breakpoint with MI command"
85
86 # Modify enableness through MI commands shouldn't trigger MI
87 # notification.
88 mi_gdb_test "-break-disable 2.2" "\\^done" "-break-disable 2.2"
89 mi_gdb_test "-break-enable 2.2" "\\^done" "-break-enable 2.2"
90
91 # Modify enableness through CLI commands should trigger MI
92 # notification.
93 set pattern [make_breakpoints_pattern $expect_fixed_output 2 y n]
94 mi_gdb_test "dis 2.2" \
95 [multi_line "&\"dis 2.2\\\\n\"" \
96 "=breakpoint-modified,${pattern}" \
97 "\\^done" ] \
98 "dis 2.2"
99 set pattern [make_breakpoints_pattern $expect_fixed_output 2 y y]
100 mi_gdb_test "en 2.2" \
101 [multi_line "&\"en 2.2\\\\n\"" \
102 "=breakpoint-modified,${pattern}" \
103 "\\^done" ] \
104 "en 2.2"
105
106 mi_gdb_exit
107 }
108 }
109}
110
111# Vanilla mi2
112do_test 2 0 0
113
114# mi2 with -fix-multi-location-breakpoint-output
115do_test 2 1 1
116
117# Vanilla mi3
118do_test 3 0 1
119
120# mi3 with -fix-multi-location-breakpoint-output
121do_test 3 1 1
122
123# Whatever MI version is currently the default one, vanilla
124do_test "" 0 1
125
126# Whatever MI version is currently the default one, with
127# -fix-multi-location-breakpoint-output
128do_test "" 1 1
This page took 0.499646 seconds and 4 git commands to generate.