1 # Copyright 2013-2020 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 if ![gdb_trace_common_supports_arch] {
21 unsupported "no trace-common.h support for arch"
25 if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
29 proc test_actions_changed { } {
30 gdb_breakpoint "end" qualified
32 gdb_test "trace subr" "Tracepoint .*" \
35 # The first set of tests are regression tests for a GDB bug where
36 # the while-stepping count of a tracepoint would be left stale if
37 # the tracepoint's actions were redefined, and the new action list
38 # had no while-stepping action.
40 # First pass, define simple action.
41 with_test_prefix "1" {
42 gdb_trace_setactions "define simple action" \
46 gdb_test_no_output "tstart"
48 gdb_test "continue" ".*Breakpoint \[0-9\]+, end \\(i=1\\) .*" \
49 "advance through tracing"
51 gdb_test "tstatus" ".*Collected 1 trace frame.*" \
52 "collected 1 trace frame"
54 gdb_test_no_output "tstop"
57 # Redefine action, run second trace.
58 with_test_prefix "2" {
59 gdb_trace_setactions "redefine simple action" \
61 "collect keeping, busy" "^$"
63 gdb_test_no_output "tstart"
65 gdb_test "continue" ".*Breakpoint \[0-9\]+, end \\(i=2\\) .*" \
66 "advance through tracing"
68 gdb_test "tstatus" ".*Collected 1 trace frame.*" \
69 "collected 1 trace frame"
71 gdb_test_no_output "tstop"
74 # Redefine to stepping action, run third trace.
75 with_test_prefix "3" {
76 gdb_trace_setactions "redefine to stepping action" \
79 "while-stepping 5" "^$" \
83 gdb_test_no_output "tstart"
85 gdb_test "continue" ".*Breakpoint \[0-9\]+, end \\(i=3\\) .*" \
86 "advance through tracing"
88 gdb_test "tstatus" ".*Collected 6 trace frames.*" \
89 "collected 6 trace frames"
91 gdb_test_no_output "tstop"
94 # Redefine to non-stepping, run fourth trace.
95 with_test_prefix "4" {
96 gdb_trace_setactions "redefine to non-stepping action" \
100 gdb_test_no_output "tstart"
102 gdb_test "continue" ".*Breakpoint \[0-9\]+, end \\(i=4\\) .*" \
103 "advance through tracing"
105 gdb_test "tstatus" ".*Collected 1 trace frame.*" \
106 "collected 1 trace frame"
108 gdb_test_no_output "tstop"
111 # The following tests are related to the above, but use two
112 # tracepoints. They are regression tests for a GDB bug where only
113 # the first tracepoint would end up with the step count set.
115 # Store the first tracepoint's number.
116 gdb_test_no_output "set \$prev_tpnum=\$tpnum" "store previous \$tpnum"
118 # And here's the second tracepoint.
119 gdb_test "trace subr2" "Tracepoint .*" "tracepoint at subr2"
121 # Set a stepping action in both tracepoints, with the "commands"
123 with_test_prefix "5" {
124 gdb_trace_setcommands \
125 "redefine 2 tracepoints to stepping action, using commands" \
126 "\$prev_tpnum-\$tpnum" \
127 "collect parm" "^$" \
128 "while-stepping 5" "^$" \
129 "collect parm" "^$" \
132 gdb_test_no_output "tstart"
134 gdb_test "continue" ".*Breakpoint \[0-9\]+, end \\(i=5\\) .*" \
135 "advance through tracing"
137 gdb_test "tstatus" ".*Collected 12 trace frames.*" \
138 "collected 12 trace frames"
140 gdb_test_no_output "tstop"
143 # Redefine the actions of both tracepoints to non-stepping, also
144 # using the "commands" command.
145 with_test_prefix "6" {
146 gdb_trace_setcommands \
147 "redefine 2 tracepoints to non-stepping action, using commands" \
148 "\$prev_tpnum-\$tpnum" \
151 gdb_test_no_output "tstart"
153 gdb_test "continue" ".*Breakpoint \[0-9\]+, end \\(i=6\\) .*" \
154 "advance through tracing"
156 gdb_test "tstatus" ".*Collected 2 trace frame.*" \
157 "collected 2 trace frames"
159 gdb_test_no_output "tstop"
163 # Check whether the target supports tracepoints.
165 clean_restart $testfile
168 fail "can't run to main to check for trace support"
172 if ![gdb_target_supports_trace] {
173 unsupported "current target does not support trace"