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