1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
# Copyright 2023-2024 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Check for the delivery of '=breakpoint-deleted' notifications when
# breakpoints are deleted. Right now this test only covers
# inferior-specific breakpoints, but it could be extended to cover
# other cases too.
# Multiple inferiors are needed, therefore only native gdb and
# extended gdbserver modes are supported.
require !use_gdb_stub
# Separate UI doesn't work with GDB debug.
require !gdb_debug_enabled
load_lib mi-support.exp
set MIFLAGS "-i=mi"
standard_testfile
if { [build_executable "failed to prepare" $testfile $srcfile] } {
return -1
}
# Helper proc to create a breakpoint location regexp. NUM is the
# regexp to match the number field of this location.
proc make_bp_loc { num } {
return [mi_make_breakpoint_loc \
-number "$num" \
-enabled "y" \
-func "foo" \
-inferior "2"]
}
foreach_mi_ui_mode mode {
mi_gdb_exit
if {$mode eq "separate"} {
set start_ops "separate-mi-tty"
} else {
set start_ops ""
}
if [mi_gdb_start $start_ops] {
return
}
# Load a test binary into inferior 1.
mi_gdb_load ${binfile}
# Setup inferior 2, including loading an exec file.
mi_gdb_test "-add-inferior" \
[multi_line "=thread-group-added,id=\"\[^\"\]+\"" \
"~\"\\\[New inferior 2\\\]\\\\n\"" \
"\~\"Added inferior 2\[^\r\n\]*\\\\n\"" \
"\\^done,inferior=\"\[^\"\]+\"(?:,connection={.*})?" ] \
"mi add inferior 2"
mi_gdb_test "-file-exec-and-symbols --thread-group i2 $::binfile" \
"\\^done" \
"set executable of inferior 2"
# Build regexp for the two locations.
set loc1 [make_bp_loc "$::decimal\\.1"]
set loc2 [make_bp_loc "$::decimal\\.2"]
# Create the inferior-specific breakpoint.
mi_create_breakpoint_multi "-g i2 foo" "create breakpoint in inferior 2" \
-inferior "2" -locations "\\\[$loc1,$loc2\\\]"
set bpnum [mi_get_valueof "/d" "\$bpnum" "INVALID"]
if {$mode eq "separate"} {
# In 'separate' mode we delete the inferior from the CLI, and
# then look for the breakpoint-deleted notification on the MI.
with_spawn_id $gdb_main_spawn_id {
gdb_test "inferior 1" ".*"
gdb_test "remove-inferiors 2" \
"Inferior-specific breakpoint $bpnum deleted - inferior 2 has been removed\\."
}
gdb_test_multiple "" "check for b/p deleted notification on MI" {
-re "=breakpoint-deleted,id=\"$bpnum\"" {
pass $gdb_test_name
}
}
} else {
# In the non-separate mode we delete the inferior from the MI
# and expect to immediately see a breakpoint-deleted
# notification.
mi_gdb_test "-remove-inferior i2" \
[multi_line \
"=thread-group-removed,id=\"i2\"" \
"~\"Inferior-specific breakpoint $bpnum deleted - inferior 2 has been removed\\.\\\\n\"" \
"=breakpoint-deleted,id=\"$bpnum\"" \
"\\^done"]
}
}
|