1 # Copyright 2011-2016 Free Software Foundation, Inc.
2 # This program is free software; you can redistribute it and/or modify
3 # it under the terms of the GNU General Public License as published by
4 # the Free Software Foundation; either version 3 of the License, or
5 # (at your option) any later version.
7 # This program is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 # GNU General Public License for more details.
12 # You should have received a copy of the GNU General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 load_lib "trace-support.exp"
17 standard_testfile actions.c
18 set executable $testfile
19 set expfile tstatus.exp
21 if [prepare_for_testing "failed to prepare" $executable $srcfile \
27 fail "can't run to main to check for trace support"
31 if ![gdb_target_supports_trace] {
32 unsupported "target does not support trace"
38 proc run_trace_experiment {} {
43 # gdb_test_no_output "set debug remote 1" ""
46 ".*Breakpoint \[0-9\]+, begin .*" \
47 "advance to trace begin"
49 gdb_test_no_output "tstart my tracing note" "start trace experiment"
52 ".*Breakpoint \[0-9\]+, end .*" \
53 "advance through tracing"
55 # Now play with tstatus a bit.
57 # Since support for notes, user, stop reason, etc. is optional, we
58 # need to match both with and without cases.
60 set test "tstatus reports trace note"
61 gdb_test_multiple "tstatus" $test {
62 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Trace notes: my tracing note\.\[\r\n\]+Not looking at any trace frame\..*\r\n$gdb_prompt $" {
65 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Not looking at any trace frame.*\r\n$gdb_prompt $" {
70 gdb_test "set trace-notes different note" "" "change tracing note"
72 set test "tstatus reports different trace note"
73 gdb_test_multiple "tstatus" $test {
74 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Trace notes: different note\.\[\r\n\]+Not looking at any trace frame\..*\r\n$gdb_prompt $" {
77 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Not looking at any trace frame.*\r\n$gdb_prompt $" {
82 gdb_test "set trace-user me me me" "" "change tracing user"
84 set test "tstatus reports trace user"
85 gdb_test_multiple "tstatus" $test {
86 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Trace user is me me me\.\[\r\n\]+Trace notes: different note\.\[\r\n\]+Not looking at any trace frame\..*\r\n$gdb_prompt $" {
89 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Not looking at any trace frame.*\r\n$gdb_prompt $" {
94 gdb_test_no_output "tstop because I can" "trace stopped with note"
96 set test "tstatus reports trace stop reason"
97 gdb_test_multiple "tstatus" $test {
98 -re "(Trace stopped by a tstop command \\(because I can\\)\..*Trace will stop if GDB disconnects\.\[\r\n\]+Trace user is me me me\.\[\r\n\]+Trace notes: different note\.\[\r\n\]+Not looking at any trace frame\.).*\r\n$gdb_prompt $" {
99 set tstatus_output $expect_out(1,string)
102 -re "(Trace stopped by a tstop command\.).*\r\n$gdb_prompt $" {
103 set tstatus_output $expect_out(1,string)
108 set test "info trace reports tracepoint hit count and traceframe usage"
109 gdb_test_multiple "info trace" $test {
110 -re "actions\.c:\[0-9\]+\[\r\n\]+\[\t ]+tracepoint already hit 1 time\[\r\n\]+\[\t ]+trace buffer usage ${decimal} bytes\.\[\r\n\]+\[\t ]+collect parm.*\r\n$gdb_prompt $" {
113 -re "actions\.c:\[0-9\]+\[\r\n\]+\[\t ]+collect parm.*\r\n$gdb_prompt $" {
119 proc test_tracepoints {} {
122 gdb_test "break begin" ".*" ""
124 gdb_test "break end" ".*" ""
126 gdb_test "trace gdb_c_test" "Tracepoint .*" \
127 "tracepoint at gdb_c_test"
129 gdb_trace_setactions "collect at set_point: define actions" \
139 set tracefile [standard_output_file ${testfile}]
140 # Save trace frames to tfile.
141 gdb_test "tsave ${tracefile}.tf" \
142 "Trace data saved to file '${tracefile}.tf'.*" \
143 "save tfile trace file"
144 # Save trace frames to CTF.
145 gdb_test "tsave -ctf ${tracefile}.ctf" \
146 "Trace data saved to directory '${tracefile}.ctf'.*" \
147 "save ctf trace file"
149 # Change target to tfile.
150 set test "change to tfile target"
151 gdb_test_multiple "target tfile ${tracefile}.tf" "$test" {
152 -re "A program is being debugged already. Kill it. .y or n. " {
156 -re "$gdb_prompt $" {
161 # Convert "(because I can) to "\(because I can\)"
162 set tstatus_output [string map {\( \\(} $tstatus_output]
163 set tstatus_output [string map {\) \\)} $tstatus_output]
165 # The status should be identical to the status of live inferior.
166 gdb_test "tstatus" "Using a trace file\.\r\n${tstatus_output}.*" \
167 "tstatus on tfile target"
169 # Change target to ctf if GDB supports.
170 gdb_test_multiple "target ctf ${tracefile}.ctf" "" {
171 -re "Undefined target command: \"ctf ${tracefile}.ctf\"\. Try \"help target\"\.\r\n$gdb_prompt $" {
173 -re ".*\r\n$gdb_prompt $" {
174 gdb_test "tstatus" "Using a trace file\.\r\n${tstatus_output}.*" \
175 "tstatus on ctf target"