1# Copyright 2013-2019 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 ![gdb_trace_common_supports_arch] { 21 unsupported "no trace-common.h support for arch" 22 return -1 23} 24 25if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { 26 return -1 27} 28 29proc test_actions_changed { } { 30 gdb_breakpoint "end" qualified 31 32 gdb_test "trace subr" "Tracepoint .*" \ 33 "tracepoint at subr" 34 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. 39 40 # First pass, define simple action. 41 with_test_prefix "1" { 42 gdb_trace_setactions "define simple action" \ 43 "" \ 44 "collect parm" "^$" 45 46 gdb_test_no_output "tstart" 47 48 gdb_test "continue" ".*Breakpoint \[0-9\]+, end \\(i=1\\) .*" \ 49 "advance through tracing" 50 51 gdb_test "tstatus" ".*Collected 1 trace frame.*" \ 52 "collected 1 trace frame" 53 54 gdb_test_no_output "tstop" 55 } 56 57 # Redefine action, run second trace. 58 with_test_prefix "2" { 59 gdb_trace_setactions "redefine simple action" \ 60 "" \ 61 "collect keeping, busy" "^$" 62 63 gdb_test_no_output "tstart" 64 65 gdb_test "continue" ".*Breakpoint \[0-9\]+, end \\(i=2\\) .*" \ 66 "advance through tracing" 67 68 gdb_test "tstatus" ".*Collected 1 trace frame.*" \ 69 "collected 1 trace frame" 70 71 gdb_test_no_output "tstop" 72 } 73 74 # Redefine to stepping action, run third trace. 75 with_test_prefix "3" { 76 gdb_trace_setactions "redefine to stepping action" \ 77 "" \ 78 "collect parm" "^$" \ 79 "while-stepping 5" "^$" \ 80 "collect parm" "^$" \ 81 "end" "^$" 82 83 gdb_test_no_output "tstart" 84 85 gdb_test "continue" ".*Breakpoint \[0-9\]+, end \\(i=3\\) .*" \ 86 "advance through tracing" 87 88 gdb_test "tstatus" ".*Collected 6 trace frames.*" \ 89 "collected 6 trace frames" 90 91 gdb_test_no_output "tstop" 92 } 93 94 # Redefine to non-stepping, run fourth trace. 95 with_test_prefix "4" { 96 gdb_trace_setactions "redefine to non-stepping action" \ 97 "" \ 98 "collect parm" "^$" 99 100 gdb_test_no_output "tstart" 101 102 gdb_test "continue" ".*Breakpoint \[0-9\]+, end \\(i=4\\) .*" \ 103 "advance through tracing" 104 105 gdb_test "tstatus" ".*Collected 1 trace frame.*" \ 106 "collected 1 trace frame" 107 108 gdb_test_no_output "tstop" 109 } 110 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. 114 115 # Store the first tracepoint's number. 116 gdb_test_no_output "set \$prev_tpnum=\$tpnum" "store previous \$tpnum" 117 118 # And here's the second tracepoint. 119 gdb_test "trace subr2" "Tracepoint .*" "tracepoint at subr2" 120 121 # Set a stepping action in both tracepoints, with the "commands" 122 # command. 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" "^$" \ 130 "end" "^$" 131 132 gdb_test_no_output "tstart" 133 134 gdb_test "continue" ".*Breakpoint \[0-9\]+, end \\(i=5\\) .*" \ 135 "advance through tracing" 136 137 gdb_test "tstatus" ".*Collected 12 trace frames.*" \ 138 "collected 12 trace frames" 139 140 gdb_test_no_output "tstop" 141 } 142 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" \ 149 "collect parm" "^$" 150 151 gdb_test_no_output "tstart" 152 153 gdb_test "continue" ".*Breakpoint \[0-9\]+, end \\(i=6\\) .*" \ 154 "advance through tracing" 155 156 gdb_test "tstatus" ".*Collected 2 trace frame.*" \ 157 "collected 2 trace frames" 158 159 gdb_test_no_output "tstop" 160 } 161} 162 163# Check whether the target supports tracepoints. 164 165clean_restart $testfile 166 167if ![runto_main] { 168 fail "can't run to main to check for trace support" 169 return -1 170} 171 172if ![gdb_target_supports_trace] { 173 unsupported "current target does not support trace" 174 return -1 175} 176 177test_actions_changed 178 179return 0 180