]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.trace/mi-tracepoint-changed.exp
Update years in copyright notice for the GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.trace / mi-tracepoint-changed.exp
CommitLineData
8acc9f48 1# Copyright 2012-2013 Free Software Foundation, Inc.
45814d45
YQ
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
16load_lib trace-support.exp
17
18if {[skip_shlib_tests]} {
19 return 0
20}
21
22standard_testfile pending.c
23set libfile1 "pendshr1"
24set libfile2 "pendshr2"
25set executable $testfile
26set libsrc1 $srcdir/$subdir/$libfile1.c
27set libsrc2 $srcdir/$subdir/$libfile2.c
28set lib_sl1 [standard_output_file pendshr1.sl]
29set lib_sl2 [standard_output_file pendshr2.sl]
30
31set lib_opts [gdb_target_symbol_prefix_flags]
32
33if { [gdb_compile_shlib $libsrc1 $lib_sl1 $lib_opts] != ""
34 || [gdb_compile_shlib $libsrc2 $lib_sl2 $lib_opts] != ""} {
35 untested "Could not compile either $libsrc1 or $libsrc2"
36 return -1
37}
38
39set exec_opts [list debug shlib=$lib_sl1 shlib_load]
40if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != "" } {
41 untested "Failed to compile $srcfile"
42 return -1
43}
44
45load_lib mi-support.exp
46set MIFLAGS "-i=mi"
47
48# Test when GDB connects to a disconnected stub, existing tracepoints in
49# remote stub can be uploaded to GDB, and GDB emits MI notification if
50# new tracepoints are created.
51
52proc test_reconnect { } { with_test_prefix "reconnect" {
53
54 global gdbserver_reconnect_p
55 global gdb_prompt
56 global executable
57 global lib_sl1 lib_sl2
58
59 set gdbserver_reconnect_p 1
60 if { [info proc gdb_reconnect] == "" } {
61 return 0
62 }
63
64 clean_restart $executable
65 gdb_load_shlibs $lib_sl1
66 gdb_load_shlibs $lib_sl2
67 if ![runto_main] then {
68 fail "Can't run to main"
69 return 0
70 }
f0b6d50a
YQ
71 # Create tracepoints on marker and main, and leave them in the
72 # remote stub.
45814d45 73 gdb_test "trace marker" "Tracepoint.*at.* file .*" \
f0b6d50a
YQ
74 "tracepoint on marker"
75 gdb_test "trace main" "Tracepoint.*at.* file .*" \
76 "tracepoint on main"
45814d45
YQ
77 gdb_test_no_output "tstart" "start trace experiment"
78
79 set test "disconnect"
80 gdb_test_multiple "disconnect" $test {
81 -re "Trace is running but will stop on detach; detach anyway\\? \\(y or n\\) $" {
82 pass $test
83
84 set test "disconnected"
85 gdb_test_multiple "y" $test {
86 -re "$gdb_prompt $" {
87 pass "$test"
88 }
89 }
90 }
91 }
92
93 gdb_exit
94
95 if [mi_gdb_start] {
96 return
97 }
98
99 global srcdir
100 global subdir
101 global binfile
102
103 mi_gdb_reinitialize_dir $srcdir/$subdir
104 mi_gdb_load ${binfile}
105
106 global gdbserver_protocol
107 global gdbserver_gdbport
108
f0b6d50a
YQ
109 # Create tracepoints on marker and pendfunc2.
110 mi_gdb_test "-break-insert -a -f pendfunc2" \
111 {.*\^done,bkpt=.*addr=\"<PENDING>\".*} \
112 "insert tracepoint on pendfunc2"
113 mi_gdb_test "-break-insert -a marker" {.*\^done,bkpt=.*\".*} \
114 "insert tracepoint on marker"
115
116 # Connect to the remote stub again, and make sure GDB merges the
117 # tracepoints of both sides correctly.
45814d45
YQ
118 send_gdb "47-target-select $gdbserver_protocol $gdbserver_gdbport\n"
119
120 global mi_gdb_prompt
121 set test "tracepoint created"
122 gdb_expect {
f0b6d50a
YQ
123 -re "=breakpoint-created,bkpt=\{number=\"1\",type=\"tracepoint\"" {
124 # Tracepoint 1 in GDB, which has already existed before
125 # connecting, should have been merged with a tracepoint on
126 # the target, so we shouldn't see a =breakpoint-created
127 # notification for it.
128 fail "$test: 1"
129 exp_continue
130 }
131 -re "=breakpoint-created,bkpt=\{number=\"2\",type=\"tracepoint\"" {
132 # Similar to above.
133 fail "$test: 2"
134 exp_continue
135 }
f2a8bc8a 136 -re "=breakpoint-created,bkpt=\{number=\"3\",type=\"tracepoint\",disp=\"keep\",enabled=\"y\",\[^\n\]+,func=\"main\"\[^\n\]+,installed=\"y\"" {
f0b6d50a
YQ
137 # A tracepoint on main was defined in the stub, not in GDB,
138 # so we should see a =breakpoint-created notification.
45814d45
YQ
139 pass $test
140 }
f2a8bc8a
YQ
141 }
142 # Tracepoint on marker is defined. After the sync, we know that
143 # the tracepoint is in remote stub. Mark it 'installed'.
144 set test "tracepoint on marker is installed"
145 gdb_expect {
146 -re "=breakpoint-modified,bkpt=\{number=\"2\".*,func=\"marker\".*installed=\"y\".*${mi_gdb_prompt}$" {
147 pass "$test"
45814d45
YQ
148 }
149 }
f0b6d50a
YQ
150 # Check that tracepoint 1 is still pending.
151 mi_gdb_test "-break-info 1" \
152 {.*\^done,BreakpointTable=.*addr=\"<PENDING>\".*} \
153 "break-info 1"
45814d45
YQ
154
155 set gdbserver_reconnect_p 0
156}}
157
158
159# Test 'breakpoint-modified' notification is emited when pending tracepoints are
160# resolved.
161
162proc test_pending_resolved { } { with_test_prefix "pending resolved" {
163 global decimal hex
164 global executable
165 global srcdir
166 global subdir
167 global binfile
168 global lib_sl1 lib_sl2
169 global mi_gdb_prompt
170
171 gdb_exit
172 if [mi_gdb_start] {
173 continue
174 }
175
176 mi_gdb_reinitialize_dir $srcdir/$subdir
177 mi_gdb_load ${binfile}
178 mi_load_shlibs $lib_sl1 $lib_sl2
179
180 # Create a pending tracepoint on pendfunc2
181 mi_gdb_test "-break-insert -a -f pendfunc2" \
182 {.*\^done,bkpt=.*addr=\"<PENDING>\".*} \
183 "insert breakpoint on pendfunc2"
184 # Insert breakpoint on marker
185 mi_gdb_test "-break-insert marker" {.*\^done,bkpt=.*} \
186 "insert breakpoint on marker"
187
188 mi_run_cmd
189 mi_expect_stop "breakpoint-hit" "marker" ""\
190 ".*" ".*" {"" "disp=\"keep\""} \
191 "continue to marker breakpoint"
192 mi_gdb_test "-trace-start" {\^done} "trace start"
193
194 mi_send_resuming_command "exec-continue" "continuing execution to marker 1"
195
f2a8bc8a
YQ
196 # It is expected to get two "=breakpoint-modified" notifications.
197 # Pending tracepoint is resolved.
45814d45
YQ
198 set test "tracepoint on pendfunc2 resolved"
199 gdb_expect {
f2a8bc8a 200 -re "=breakpoint-modified,bkpt=\{number=\"1\",type=\"tracepoint\".*.*times=\"0\".*installed=\"n\"" {
45814d45
YQ
201 pass "$test"
202 }
f2a8bc8a
YQ
203 }
204 # Resolved tracepoint is installed.
205 set test "tracepoint on pendfunc2 installed"
206 gdb_expect {
207 -re "=breakpoint-modified,bkpt=\{number=\"1\",type=\"tracepoint\".*.*times=\"0\".*installed=\"y\"" {
208 pass "$test"
45814d45
YQ
209 }
210 }
f2a8bc8a 211
45814d45
YQ
212 mi_expect_stop "breakpoint-hit" "marker" ".*" ".*" ".*" \
213 {"" "disp=\"keep\""} "continue to marker"
214
215
216 mi_gdb_test "-trace-stop" {\^done,.*} "trace stop"
217 mi_gdb_test "-trace-find frame-number 0" \
218 "-trace-find frame-number 0\r\n\\^done,found=\"1\",tracepoint=\"${decimal}\",traceframe=\"0\",frame=\{.*" \
219 "-trace-find frame-number 0"
220 mi_gdb_test "-trace-find none" {\^done,found="0"} "back to live inferior"
221
222 mi_send_resuming_command "exec-continue" "continuing to exit"
223 set test "tracepoint on pendfunc2 becomes pending again"
224 gdb_expect {
225 -re ".*=breakpoint-modified,bkpt=\{number=\"1\",type=\"tracepoint\".*addr=\"<PENDING>\",.*times=\"0\"" {
226 pass "$test"
227 }
228 -re ".*${mi_gdb_prompt}$" {
229 fail $test
230 }
231 timeout {
232 fail "$test (timeout)"
233 }
234 }
235
236 mi_expect_stop "exited-normally" "" "" "" "" "" ""
237}}
238
239# Test target supports tracepoints or not.
240
241clean_restart $executable
242
243gdb_load_shlibs $lib_sl1
244gdb_load_shlibs $lib_sl2
245
246if ![runto_main] {
247 fail "Can't run to main to check for trace support"
248 return -1
249}
250
251if ![gdb_target_supports_trace] {
252 unsupported "Current target does not support trace"
253 return -1;
254}
255
256gdb_exit
257
258test_reconnect
259
260test_pending_resolved
261
262return 0