]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.mi/mi-breakpoint-multiple-locations.exp
4fb89488010caac4f5f985d4ea2721abcda6ee30
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-breakpoint-multiple-locations.exp
1 # Copyright 2018-2019 Free Software Foundation, Inc.
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
18 load_lib mi-support.exp
19 standard_testfile .cc
20
21 if {[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
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}\",.*\}\\\]\}"
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
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}"
58
59 gdb_exit
60 if {[mi_gdb_start]} {
61 return
62 }
63
64 mi_run_to_main
65
66 if $use_fix_flag {
67 mi_gdb_test "-fix-multi-location-breakpoint-output" "\\^done" \
68 "send -fix-multi-location-breakpoint-output"
69 }
70
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}" \
77 "\\^done" ] \
78 "break add"
79
80 # Check the -break-info output.
81 mi_gdb_test "-break-info" \
82 "\\^done,BreakpointTable=\{.*,body=\\\[${pattern}\\\]\}" \
83 "-break-info"
84
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"
88
89 # Modify enableness through MI commands shouldn't trigger MI
90 # notification.
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"
93
94 # Modify enableness through CLI commands should trigger MI
95 # notification.
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}" \
100 "\\^done" ] \
101 "dis 2.2"
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}" \
106 "\\^done" ] \
107 "en 2.2"
108
109 mi_gdb_exit
110 }
111 }
112 }
113
114 # Vanilla mi2
115 do_test 2 0 0
116
117 # mi2 with -fix-multi-location-breakpoint-output
118 do_test 2 1 1
119
120 # Vanilla mi3
121 do_test 3 0 1
122
123 # mi3 with -fix-multi-location-breakpoint-output
124 do_test 3 1 1
125
126 # Whatever MI version is currently the default one, vanilla
127 do_test "" 0 1
128
129 # Whatever MI version is currently the default one, with
130 # -fix-multi-location-breakpoint-output
131 do_test "" 1 1