]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.trace/mi-traceframe-changed.exp
Update copyright year range in all GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.trace / mi-traceframe-changed.exp
CommitLineData
42a4f53d 1# Copyright 2012-2019 Free Software Foundation, Inc.
201b4506
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
17load_lib mi-support.exp
18set MIFLAGS "-i=mi"
19
20standard_testfile tfile.c
21set executable $testfile
22
32cfb09d
TT
23if {![is_remote host] && ![is_remote target]} {
24 set tfile_basic [standard_output_file tfile-basic.tf]
25 set tfile_dir [file dirname $tfile_basic]/
26 set purely_local 1
27} else {
28 set tfile_basic tfile-basic.tf
29 set tfile_dir ""
30 set purely_local 0
31}
32
201b4506 33if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
32cfb09d
TT
34 executable \
35 [list debug nowarnings \
36 "additional_flags=-DTFILE_DIR=\"$tfile_dir\""]] \
37 != "" } {
5b362f04 38 untested "failed to compile"
201b4506
YQ
39 return -1
40}
41
42# Make sure we are starting fresh.
32cfb09d
TT
43remote_file host delete $tfile_basic
44remote_file target delete $tfile_basic
201b4506 45
0a251e08
YQ
46proc test_tfind_tfile { } {
47 with_test_prefix "tfile" {
48 global binfile
49 global decimal
32cfb09d 50 global tfile_basic
0a251e08
YQ
51
52 if [mi_gdb_start] {
53 return
54 }
55 mi_gdb_load ${binfile}
56
32cfb09d 57 mi_gdb_test "-target-select tfile ${tfile_basic}" \
0a251e08
YQ
58 ".*=breakpoint-created,bkpt=\{number=\"${decimal}\",type=\"tracepoint\",disp=\"keep\",enabled=\"y\",.*,func=\"write_basic_trace_file\".*\\^connected" \
59 "select trace file"
60
61 mi_gdb_test "tfind 0" \
62 ".*=traceframe-changed,num=\"0\",tracepoint=\"${decimal}\".*\\^done" \
63 "tfind 0"
64
65 # No MI notification is sent because traceframe is not changed.
66 mi_gdb_test "tfind 0" \
67 "\\&\"tfind 0\\\\n\"\r\n\~\"Found.*\\^done" \
68 "tfind 0 again"
69
70 mi_gdb_test "tfind end" \
71 ".*=traceframe-changed,end.*\\^done" \
72 "tfind end"
73
74 # No MI notification is send because request is from MI command.
75 mi_gdb_test "-trace-find frame-number 0" \
76 "-trace-find frame-number 0\r\n\\^done,found=\"1\",tracepoint=\"${decimal}\",traceframe=\"0\",frame=\{.*" \
77 "-trace-find frame-number 0"
78
79 mi_gdb_exit
201b4506 80 }
0a251e08 81}
201b4506 82
b4429ea2
YQ
83# If tracefile is generated successfully, copy tracefile to host and
84# run tests.
85if [generate_tracefile $binfile] {
86 if {!$purely_local} {
87 # Copy tracefile from target to host.
88 remote_download host [remote_upload target tfile-basic.tf] \
89 tfile-basic.tf
90 }
91
92 test_tfind_tfile
93}
201b4506
YQ
94
95# Change to a different test case in order to run it on target, and get
96# several traceframes.
97standard_testfile status-stop.c
20e3d738
TT
98append testfile -1
99append binfile -1
201b4506
YQ
100set executable $testfile
101
102if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
103 executable {debug nowarnings}] != "" } {
5b362f04 104 untested "failed to compile"
201b4506
YQ
105 return -1
106}
107
108# Test target supports tracepoints or not.
109
110clean_restart $executable
111
112if ![runto_main] {
bc6c7af4 113 fail "can't run to main to check for trace support"
201b4506
YQ
114 return -1
115}
116
117if ![gdb_target_supports_trace] {
bc6c7af4 118 unsupported "current target does not support trace"
ae59b1da 119 return -1
201b4506
YQ
120}
121
122gdb_exit
123
0a251e08
YQ
124proc test_tfind_remote { } {
125 with_test_prefix "remote" {
126 global decimal
201b4506 127
0a251e08
YQ
128 if [mi_gdb_start] {
129 return
130 }
131 mi_run_to_main
201b4506 132
0a251e08
YQ
133 mi_gdb_test "-break-insert end" "\\^done.*" "break end"
134 mi_gdb_test "-break-insert -a func2" "\\^done.*" "break func2"
135 mi_gdb_test "-trace-start" "=breakpoint-modified,bkpt={.*installed=\"y\".*}.*\\^done.*" \
136 "trace start"
201b4506 137
0a251e08
YQ
138 mi_execute_to "exec-continue" "breakpoint-hit" end "" ".*" ".*" \
139 { "" "disp=\"keep\"" } \
140 "continue to end"
141 mi_gdb_test "-trace-stop" "\\^done.*" "trace stop"
201b4506 142
0a251e08
YQ
143 mi_gdb_test "tfind 0" \
144 ".*=traceframe-changed,num=\"0\",tracepoint=\"${decimal}\".*\\^done" \
145 "tfind 0"
201b4506 146
0a251e08
YQ
147 mi_gdb_test "tfind" \
148 ".*=traceframe-changed,num=\"1\",tracepoint=\"${decimal}\".*\\^done" \
149 "tfind"
201b4506 150
0a251e08
YQ
151 mi_gdb_test "tfind end" \
152 ".*=traceframe-changed,end.*\\^done" \
153 "tfind end"
201b4506 154
0a251e08
YQ
155 mi_gdb_exit
156 }
157}
201b4506
YQ
158
159test_tfind_remote
160
161return 0