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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
# Copyright 2012 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/>.
load_lib trace-support.exp
load_lib mi-support.exp
standard_testfile actions.c
if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
executable {debug nowarnings}] != "" } {
untested mi-tsv-changed.exp
return -1
}
# Test notifications on creating and deleting TSV.
proc test_create_delete_tsv { } {with_test_prefix "create delete" {
global binfile
global decimal
if [mi_gdb_start] {
return
}
mi_gdb_load ${binfile}
mi_gdb_test "tvariable \$tvar1" \
".*=tsv-created,name=\"tvar1\",value=\"0\"\\\\n.*\\^done" \
"tvariable \$tvar1"
mi_gdb_test "tvariable \$tvar2 = 45" \
".*=tsv-created,name=\"tvar2\",value=\"45\"\\\\n.*\\^done" \
"tvariable \$tvar2"
mi_gdb_test "delete tvariable \$tvar2" \
".*=tsv-deleted,name=\"tvar2\"\\\\n.*\\^done" \
"delete tvariable \$tvar2"
mi_gdb_test "delete tvariable" \
".*=tsv-deleted\\\\n.*\\^done" \
"delete all tvariables"
}}
# Test when GDB connects to a disconnected stub, existing TSVs in
# remote stub can be uploaded to GDB, and GDB emits MI notification
# for new uploaded TSVs.
proc test_upload_tsv { } { with_test_prefix "upload" {
global gdbserver_reconnect_p
global gdb_prompt
global testfile
global decimal
set gdbserver_reconnect_p 1
if { [info proc gdb_reconnect] == "" } {
return 0
}
clean_restart $testfile
if ![runto_main] then {
fail "Can't run to main"
return 0
}
gdb_test "tvariable \$tvar1" \
"Trace state variable \\\$tvar1 created, with initial value 0." \
"Create a trace state variable"
gdb_test "tvariable \$tvar2 = 45" \
"Trace state variable \\\$tvar2 created, with initial value 45." \
"Create a trace state variable with initial value"
# Define a tracepoint otherwise tracing cannot be started.
gdb_test "trace main" "Tracepoint $decimal at .*"
gdb_test_no_output "tstart" "start trace experiment"
set test "disconnect"
gdb_test_multiple "disconnect" $test {
-re "Trace is running but will stop on detach; detach anyway\\? \\(y or n\\) $" {
pass $test
set test "disconnected"
gdb_test_multiple "y" $test {
-re "$gdb_prompt $" {
pass "$test"
}
}
}
}
gdb_exit
if [mi_gdb_start] {
return
}
global srcdir
global subdir
global binfile
mi_gdb_reinitialize_dir $srcdir/$subdir
mi_gdb_load ${binfile}
global gdbserver_protocol
global gdbserver_gdbport
send_gdb "47-target-select $gdbserver_protocol $gdbserver_gdbport\n"
global mi_gdb_prompt
set tsv1_created 0
set tsv2_created 0
gdb_expect {
-re "=tsv-created,name=\"tvar1\",value=\"0\"" {
set tsv1_created 1
exp_continue
}
-re "=tsv-created,name=\"tvar2\",value=\"45\"" {
set tsv2_created 1
exp_continue
}
-re ".*${mi_gdb_prompt}" {
}
}
if $tsv1_created {
pass "tsv1 created"
} else {
fail "tsv1 created"
}
if $tsv2_created {
pass "tsv2 created"
} else {
fail "tsv2 created"
}
set gdbserver_reconnect_p 0
}}
test_create_delete_tsv
# Test target supports tracepoints or not.
clean_restart $testfile
if ![runto_main] {
fail "Can't run to main to check for trace support"
return -1
}
if ![gdb_target_supports_trace] {
unsupported "Current target does not support trace"
return -1;
}
gdb_exit
test_upload_tsv
return 0
|