1 # Copyright 2012-2022 Free Software Foundation, Inc.
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.
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.
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/>.
16 load_lib trace-support.exp
17 load_lib mi-support.exp
20 standard_testfile tfile.c
21 set executable $testfile
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]/
28 set tfile_basic tfile-basic.tf
33 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
35 [list debug nowarnings nopie\
36 "additional_flags=-DTFILE_DIR=\"$tfile_dir\""]] \
38 untested "failed to compile"
42 # Make sure we are starting fresh.
43 remote_file host delete $tfile_basic
44 remote_file target delete $tfile_basic
46 proc test_tfind_tfile { } {
47 with_test_prefix "tfile" {
52 mi_clean_restart $binfile
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" \
58 mi_gdb_test "tfind 0" \
59 ".*=traceframe-changed,num=\"0\",tracepoint=\"${decimal}\".*\\^done" \
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" \
67 mi_gdb_test "tfind end" \
68 ".*=traceframe-changed,end.*\\^done" \
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"
80 # If tracefile is generated successfully, copy tracefile to host and
82 if [generate_tracefile $binfile] {
84 # Copy tracefile from target to host.
85 remote_download host [remote_upload target tfile-basic.tf] \
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
97 set executable $testfile
99 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
100 executable {debug nowarnings}] != "" } {
101 untested "failed to compile"
105 # Test target supports tracepoints or not.
107 clean_restart $executable
110 fail "can't run to main to check for trace support"
114 if ![gdb_target_supports_trace] {
115 unsupported "current target does not support trace"
121 proc test_tfind_remote { } {
122 with_test_prefix "remote" {
126 mi_clean_restart $binfile
129 mi_gdb_test "-break-insert end" "\\^done.*" "break end"
130 mi_gdb_test "-break-insert -a func2" "\\^done.*" "break func2"
131 mi_gdb_test "-trace-start" "=breakpoint-modified,bkpt={.*installed=\"y\".*}.*\\^done.*" \
134 mi_execute_to "exec-continue" "breakpoint-hit" end "" ".*" ".*" \
135 { "" "disp=\"keep\"" } \
137 mi_gdb_test "-trace-stop" "\\^done.*" "trace stop"
139 mi_gdb_test "tfind 0" \
140 ".*=traceframe-changed,num=\"0\",tracepoint=\"${decimal}\".*\\^done" \
143 mi_gdb_test "tfind" \
144 ".*=traceframe-changed,num=\"1\",tracepoint=\"${decimal}\".*\\^done" \
147 mi_gdb_test "tfind end" \
148 ".*=traceframe-changed,end.*\\^done" \