1 # Copyright 1998-2024 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 # This file was written by Michael Snyder (msnyder@cygnus.com)
18 load_lib "trace-support.exp"
20 standard_testfile actions.c
21 require gdb_trace_common_supports_arch
22 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" $binfile \
23 executable {debug nowarnings}] != "" } {
24 untested "failed to compile"
32 # test while-stepping command
35 gdb_delete_tracepoints
36 set trcpt1 [gdb_gettpnum gdb_c_test]
38 fail "could not find gdb_c_test function"
42 # 5.12 basic while-stepping command (collect regs)
44 gdb_test "info tracepoints" \
45 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
46 \[0-9\]+\[\t \]+tracepoint keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
47 \[\t \]+not installed on target" \
48 "5.12: set a tracepoint, stepcount is zero"
52 gdb_trace_setactions "5.12: set stepcount to $stepcount" \
54 "while-stepping $stepcount" "" \
55 "collect \$regs" "^$" \
58 gdb_test "info tracepoints" \
59 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
60 \[0-9\]+\[\t \]+tracepoint keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
61 \[\t \]+while-stepping 12.*" \
62 "5.12: info trace shows \"while-stepping\""
64 # 5.13 step out of context while collecting local variable
65 # [deferred to dynamic test section]
67 proc while_stepping_bogus_arg { bogus msgstring } {
70 gdb_trace_setactions "$msgstring" \
72 "while-stepping $bogus" ".*while-stepping step count"
75 # 5.14 while-stepping (no argument)
77 while_stepping_bogus_arg "" "5.14: while-stepping null stepcount"
79 # 5.15 while-stepping (zero stepcount)
81 while_stepping_bogus_arg "0" "5.15: while-stepping rejects zero stepcount"
83 # 5.16 while-stepping without collecting anything
84 gdb_trace_setactions "5.16: step without collecting anything" \
86 "while-stepping $stepcount" "^$" \
89 gdb_test "info tracepoints" \
90 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
91 \[0-9\]+\[\t \]+tracepoint keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
92 .*while-stepping $stepcount.*
94 "5.16: confirm actions, step without collecting anything"
96 # Can't use runto_main here, because that would delete the tracepoints
99 # Load the binary to the target too.
102 gdb_breakpoint "main"
104 if {[gdb_test "" "Breakpoint .*" "run to main"] != 0} {
108 if ![gdb_target_supports_trace] {
109 unsupported "target does not support trace"
113 gdb_trace_setactions "set stepcount to $stepcount" \
115 "while-stepping $stepcount" "" \
116 "collect \$regs " "^$" \
117 "collect \$locals " "^$" \
120 proc check_tracepoint { data_source } {
121 with_test_prefix "$data_source" {
125 gdb_test "info tracepoints" \
126 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
127 \[0-9\]+\[\t \]+tracepoint keep y.* in gdb_c_test at .*$srcfile:\[0-9\]+.
128 \[\t \]+while-stepping $stepcount.*
129 \[\t \]+collect \\\$regs.*
130 \[\t \]+collect \\\$locals.*
135 gdb_test_no_output "tstart"
136 check_tracepoint "live"
137 gdb_test_no_output "tstop"
138 set tracefile [standard_output_file ${testfile}]
139 gdb_test "tsave ${tracefile}.tf" \
140 "Trace data saved to file '${tracefile}.tf'\\." \
141 "save tfile trace file"
142 gdb_test "tsave -ctf ${tracefile}.ctf" \
143 "Trace data saved to directory '${tracefile}.ctf'\\." \
144 "save ctf trace file"
146 # Restart GDB and read the trace data in tfile target.
148 gdb_file_cmd $binfile
149 gdb_test "target tfile ${tracefile}.tf" ".*" \
150 "change to tfile target"
151 check_tracepoint "tfile"
153 # Try to read ctf data if GDB supports.
154 set gdb_can_read_ctf_data 0
155 gdb_test_multiple "target ctf" "" {
156 -re "Undefined target command: \"ctf\"\. Try \"help target\"\.\r\n$gdb_prompt $" {
157 set gdb_can_read_ctf_data 0
159 -re "No CTF directory specified.*\r\n$gdb_prompt $" {
160 set gdb_can_read_ctf_data 1
164 if { $gdb_can_read_ctf_data } {
166 gdb_file_cmd $binfile
167 gdb_test "target ctf ${tracefile}.ctf" ".*" \
168 "change to ctf target"
169 check_tracepoint "ctf"