1 # Copyright 2022-2024 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 the breakpoint script field, including the wrong syntax that GDB
17 # emitted before version 13.1.
19 load_lib mi-support.exp
22 if {[gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable {debug}] != "" } {
26 # Generate the regexp pattern used to match the breakpoint description emitted
27 # in the various breakpoint command results/events.
29 # - EXPECT_FIXED_OUTPUT: If true, expect GDB to output the fixed output for the
30 # script field, else expect it to output the broken pre-mi4 format.
32 proc make_pattern { expect_fixed_output } {
33 if $expect_fixed_output {
34 return "bkpt=\{number=\"${::decimal}\",type=\"breakpoint\",.*,script=\\\[\"abc\",\"def\"\\\],.*"
36 return "bkpt=\{number=\"${::decimal}\",type=\"breakpoint\",.*,script=\\\{\"abc\",\"def\"\\\},.*"
40 # Run the test with the following parameters:
42 # - MI_VERSION: the version of the MI interpreter to use (e.g. "2")
43 # - USE_FIX_FLAG: Whether to issue the -fix-breakpoint-script-output
44 # command after starting GDB
45 # - EXPECT_FIXED_OUTPUT: If true, expect GDB to output the fixed output for the
46 # script field, else expect it to output the broken pre-mi4 format.
48 proc do_test { mi_version use_fix_flag expect_fixed_output } {
49 with_test_prefix "mi_version=${mi_version}" {
50 with_test_prefix "use_fix_flag=${use_fix_flag}" {
51 save_vars { ::MIFLAGS } {
52 set ::MIFLAGS "-i=mi${mi_version}"
54 mi_clean_restart $::binfile
58 mi_gdb_test "-fix-breakpoint-script-output" "\\^done" \
59 "send -fix-multi-location-breakpoint-output"
62 # Create a breakpoint.
63 mi_gdb_test "-break-insert main" ".*" "add breakpoint on main"
65 set pattern [make_pattern $expect_fixed_output]
67 # Add commands. Use the CLI command, so we can verify the
68 # =breakpoint-modified output.
69 mi_gdb_test "commands\nabc\ndef\nend" ".*=breakpoint-modified,$pattern\r\n\\^done" "add breakpoint commands"
71 # Check the -break-info output.
72 mi_gdb_test "-break-info" \
73 "\\^done,BreakpointTable=.*${pattern}" \
84 # mi3 with -fix-breakpoint-script-output
90 # mi4 with -fix-breakpoint-script-output
93 # Whatever MI version is currently the default one, vanilla
96 # Whatever MI version is currently the default one, with
97 # -fix-breakpoint-script-output