1 # Copyright 2013-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 load_lib trace-support.exp
20 require gdb_trace_common_supports_arch
22 if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
26 proc test_actions_changed { } {
27 gdb_breakpoint "end" qualified
29 gdb_test "trace subr" "Tracepoint .*" \
32 # The first set of tests are regression tests for a GDB bug where
33 # the while-stepping count of a tracepoint would be left stale if
34 # the tracepoint's actions were redefined, and the new action list
35 # had no while-stepping action.
37 # First pass, define simple action.
38 with_test_prefix "1" {
39 gdb_trace_setactions "define simple action" \
43 gdb_test_no_output "tstart"
45 gdb_test "continue" ".*Breakpoint \[0-9\]+, end \\(i=1\\) .*" \
46 "advance through tracing"
48 gdb_test "tstatus" ".*Collected 1 trace frame.*" \
49 "collected 1 trace frame"
51 gdb_test_no_output "tstop"
54 # Redefine action, run second trace.
55 with_test_prefix "2" {
56 gdb_trace_setactions "redefine simple action" \
58 "collect keeping, busy" "^$"
60 gdb_test_no_output "tstart"
62 gdb_test "continue" ".*Breakpoint \[0-9\]+, end \\(i=2\\) .*" \
63 "advance through tracing"
65 gdb_test "tstatus" ".*Collected 1 trace frame.*" \
66 "collected 1 trace frame"
68 gdb_test_no_output "tstop"
71 # Redefine to stepping action, run third trace.
72 with_test_prefix "3" {
73 gdb_trace_setactions "redefine to stepping action" \
76 "while-stepping 5" "^$" \
80 gdb_test_no_output "tstart"
82 gdb_test "continue" ".*Breakpoint \[0-9\]+, end \\(i=3\\) .*" \
83 "advance through tracing"
85 gdb_test "tstatus" ".*Collected 6 trace frames.*" \
86 "collected 6 trace frames"
88 gdb_test_no_output "tstop"
91 # Redefine to non-stepping, run fourth trace.
92 with_test_prefix "4" {
93 gdb_trace_setactions "redefine to non-stepping action" \
97 gdb_test_no_output "tstart"
99 gdb_test "continue" ".*Breakpoint \[0-9\]+, end \\(i=4\\) .*" \
100 "advance through tracing"
102 gdb_test "tstatus" ".*Collected 1 trace frame.*" \
103 "collected 1 trace frame"
105 gdb_test_no_output "tstop"
108 # The following tests are related to the above, but use two
109 # tracepoints. They are regression tests for a GDB bug where only
110 # the first tracepoint would end up with the step count set.
112 # Store the first tracepoint's number.
113 gdb_test_no_output "set \$prev_tpnum=\$tpnum" "store previous \$tpnum"
115 # And here's the second tracepoint.
116 gdb_test "trace subr2" "Tracepoint .*" "tracepoint at subr2"
118 # Set a stepping action in both tracepoints, with the "commands"
120 with_test_prefix "5" {
121 gdb_trace_setcommands \
122 "redefine 2 tracepoints to stepping action, using commands" \
123 "\$prev_tpnum-\$tpnum" \
124 "collect parm" "^$" \
125 "while-stepping 5" "^$" \
126 "collect parm" "^$" \
129 gdb_test_no_output "tstart"
131 gdb_test "continue" ".*Breakpoint \[0-9\]+, end \\(i=5\\) .*" \
132 "advance through tracing"
134 gdb_test "tstatus" ".*Collected 12 trace frames.*" \
135 "collected 12 trace frames"
137 gdb_test_no_output "tstop"
140 # Redefine the actions of both tracepoints to non-stepping, also
141 # using the "commands" command.
142 with_test_prefix "6" {
143 gdb_trace_setcommands \
144 "redefine 2 tracepoints to non-stepping action, using commands" \
145 "\$prev_tpnum-\$tpnum" \
148 gdb_test_no_output "tstart"
150 gdb_test "continue" ".*Breakpoint \[0-9\]+, end \\(i=6\\) .*" \
151 "advance through tracing"
153 gdb_test "tstatus" ".*Collected 2 trace frame.*" \
154 "collected 2 trace frames"
156 gdb_test_no_output "tstop"
160 # Check whether the target supports tracepoints.
162 clean_restart $testfile
168 if ![gdb_target_supports_trace] {
169 unsupported "current target does not support trace"