]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.mi/new-ui-bp-deleted.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.mi / new-ui-bp-deleted.exp
1 # Copyright 2023-2024 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 # Check for the delivery of '=breakpoint-deleted' notifications when
17 # breakpoints are deleted. Right now this test only covers
18 # inferior-specific breakpoints, but it could be extended to cover
19 # other cases too.
20
21 # Multiple inferiors are needed, therefore only native gdb and
22 # extended gdbserver modes are supported.
23 require !use_gdb_stub
24
25 # Separate UI doesn't work with GDB debug.
26 require !gdb_debug_enabled
27
28 load_lib mi-support.exp
29 set MIFLAGS "-i=mi"
30
31 standard_testfile
32
33 if { [build_executable "failed to prepare" $testfile $srcfile] } {
34 return -1
35 }
36
37 # Helper proc to create a breakpoint location regexp. NUM is the
38 # regexp to match the number field of this location.
39 proc make_bp_loc { num } {
40 return [mi_make_breakpoint_loc \
41 -number "$num" \
42 -enabled "y" \
43 -func "foo" \
44 -inferior "2"]
45 }
46
47 foreach_mi_ui_mode mode {
48 mi_gdb_exit
49
50 if {$mode eq "separate"} {
51 set start_ops "separate-mi-tty"
52 } else {
53 set start_ops ""
54 }
55
56 if [mi_gdb_start $start_ops] {
57 return
58 }
59
60 # Load a test binary into inferior 1.
61 mi_gdb_load ${binfile}
62
63 # Setup inferior 2, including loading an exec file.
64 mi_gdb_test "-add-inferior" \
65 [multi_line "=thread-group-added,id=\"\[^\"\]+\"" \
66 "~\"\\\[New inferior 2\\\]\\\\n\"" \
67 "\~\"Added inferior 2\[^\r\n\]*\\\\n\"" \
68 "\\^done,inferior=\"\[^\"\]+\"(?:,connection={.*})?" ] \
69 "mi add inferior 2"
70 mi_gdb_test "-file-exec-and-symbols --thread-group i2 $::binfile" \
71 "\\^done" \
72 "set executable of inferior 2"
73
74 # Build regexp for the two locations.
75 set loc1 [make_bp_loc "$::decimal\\.1"]
76 set loc2 [make_bp_loc "$::decimal\\.2"]
77
78 # Create the inferior-specific breakpoint.
79 mi_create_breakpoint_multi "-g i2 foo" "create breakpoint in inferior 2" \
80 -inferior "2" -locations "\\\[$loc1,$loc2\\\]"
81 set bpnum [mi_get_valueof "/d" "\$bpnum" "INVALID"]
82
83 if {$mode eq "separate"} {
84 # In 'separate' mode we delete the inferior from the CLI, and
85 # then look for the breakpoint-deleted notification on the MI.
86 with_spawn_id $gdb_main_spawn_id {
87 gdb_test "inferior 1" ".*"
88 gdb_test "remove-inferiors 2" \
89 "Inferior-specific breakpoint $bpnum deleted - inferior 2 has been removed\\."
90 }
91
92 gdb_test_multiple "" "check for b/p deleted notification on MI" {
93 -re "=breakpoint-deleted,id=\"$bpnum\"" {
94 pass $gdb_test_name
95 }
96 }
97 } else {
98 # In the non-separate mode we delete the inferior from the MI
99 # and expect to immediately see a breakpoint-deleted
100 # notification.
101 mi_gdb_test "-remove-inferior i2" \
102 [multi_line \
103 "=thread-group-removed,id=\"i2\"" \
104 "~\"Inferior-specific breakpoint $bpnum deleted - inferior 2 has been removed\\.\\\\n\"" \
105 "=breakpoint-deleted,id=\"$bpnum\"" \
106 "\\^done"]
107 }
108 }