]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.trace/actions-changed.exp
tracepoint->step_count fixes
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.trace / actions-changed.exp
CommitLineData
c9a6ce02
PA
1# Copyright 2013 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
16load_lib trace-support.exp
17
18standard_testfile
19
20if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
21 return -1
22}
23
24proc test_actions_changed { } {
25 gdb_breakpoint "end"
26
27 gdb_test "trace subr" "Tracepoint .*" \
28 "tracepoint at subr"
29
30 # The first set of tests are regression tests for a GDB bug where
31 # the while-stepping count of a tracepoint would be left stale if
32 # the tracepoint's actions were redefined, and the new action list
33 # had no while-stepping action.
34
35 # First pass, define simple action.
36 with_test_prefix "1" {
37 gdb_trace_setactions "define simple action" \
38 "" \
39 "collect parm" "^$"
40
41 gdb_test_no_output "tstart"
42
43 gdb_test "continue" ".*Breakpoint \[0-9\]+, end \\(i=1\\) .*" \
44 "advance through tracing"
45
46 gdb_test "tstatus" ".*Collected 1 trace frame.*" \
47 "collected 1 trace frame"
48
49 gdb_test_no_output "tstop"
50 }
51
52 # Redefine action, run second trace.
53 with_test_prefix "2" {
54 gdb_trace_setactions "redefine simple action" \
55 "" \
56 "collect keeping, busy" "^$"
57
58 gdb_test_no_output "tstart"
59
60 gdb_test "continue" ".*Breakpoint \[0-9\]+, end \\(i=2\\) .*" \
61 "advance through tracing"
62
63 gdb_test "tstatus" ".*Collected 1 trace frame.*" \
64 "collected 1 trace frame"
65
66 gdb_test_no_output "tstop"
67 }
68
69 # Redefine to stepping action, run third trace.
70 with_test_prefix "3" {
71 gdb_trace_setactions "redefine to stepping action" \
72 "" \
73 "collect parm" "^$" \
74 "while-stepping 5" "^$" \
75 "collect parm" "^$" \
76 "end" "^$"
77
78 gdb_test_no_output "tstart"
79
80 gdb_test "continue" ".*Breakpoint \[0-9\]+, end \\(i=3\\) .*" \
81 "advance through tracing"
82
83 gdb_test "tstatus" ".*Collected 6 trace frames.*" \
84 "collected 6 trace frames"
85
86 gdb_test_no_output "tstop"
87 }
88
89 # Redefine to non-stepping, run fourth trace.
90 with_test_prefix "4" {
91 gdb_trace_setactions "redefine to non-stepping action" \
92 "" \
93 "collect parm" "^$"
94
95 gdb_test_no_output "tstart"
96
97 gdb_test "continue" ".*Breakpoint \[0-9\]+, end \\(i=4\\) .*" \
98 "advance through tracing"
99
100 gdb_test "tstatus" ".*Collected 1 trace frame.*" \
101 "collected 1 trace frame"
102
103 gdb_test_no_output "tstop"
104 }
105
106 # The following tests are related to the above, but use two
107 # tracepoints. They are regression tests for a GDB bug where only
108 # the first tracepoint would end up with the step count set.
109
110 # Store the first tracepoint's number.
111 gdb_test_no_output "set \$prev_tpnum=\$tpnum" "store previous \$tpnum"
112
113 # And here's the second tracepoint.
114 gdb_test "trace subr2" "Tracepoint .*" "tracepoint at subr2"
115
116 # Set a stepping action in both tracepoints, with the "commands"
117 # command.
118 with_test_prefix "5" {
119 gdb_trace_setcommands \
120 "redefine 2 tracepoints to stepping action, using commands" \
121 "\$prev_tpnum-\$tpnum" \
122 "collect parm" "^$" \
123 "while-stepping 5" "^$" \
124 "collect parm" "^$" \
125 "end" "^$"
126
127 gdb_test_no_output "tstart"
128
129 gdb_test "continue" ".*Breakpoint \[0-9\]+, end \\(i=5\\) .*" \
130 "advance through tracing"
131
132 gdb_test "tstatus" ".*Collected 12 trace frames.*" \
133 "collected 12 trace frames"
134
135 gdb_test_no_output "tstop"
136 }
137
138 # Redefine the actions of both tracepoints to non-stepping, also
139 # using the "commands" command.
140 with_test_prefix "6" {
141 gdb_trace_setcommands \
142 "redefine 2 tracepoints to non-stepping action, using commands" \
143 "\$prev_tpnum-\$tpnum" \
144 "collect parm" "^$"
145
146 gdb_test_no_output "tstart"
147
148 gdb_test "continue" ".*Breakpoint \[0-9\]+, end \\(i=6\\) .*" \
149 "advance through tracing"
150
151 gdb_test "tstatus" ".*Collected 2 trace frame.*" \
152 "collected 2 trace frames"
153
154 gdb_test_no_output "tstop"
155 }
156}
157
158# Check whether the target supports tracepoints.
159
160clean_restart $testfile
161
162if ![runto_main] {
163 fail "Can't run to main to check for trace support"
164 return -1
165}
166
167if ![gdb_target_supports_trace] {
168 unsupported "Current target does not support trace"
169 return -1;
170}
171
172test_actions_changed
173
174return 0