GDB copyright headers update after running GDB's copyright.py script.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.trace / tstatus.exp
CommitLineData
618f726f 1# Copyright 2011-2016 Free Software Foundation, Inc.
f196051f
SS
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.
6#
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.
11#
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/>.
14
15load_lib "trace-support.exp"
16
497a5eb0 17standard_testfile actions.c
f196051f 18set executable $testfile
f196051f
SS
19set expfile tstatus.exp
20
21if [prepare_for_testing $expfile $executable $srcfile \
22 [list debug]] {
23 untested "failed to prepare for trace tests"
24 return -1
25}
26
27if ![runto_main] {
28 fail "Can't run to main to check for trace support"
29 return -1
30}
31
32if ![gdb_target_supports_trace] {
33 unsupported "target does not support trace"
34 return -1
35}
36
e2be70a0
YQ
37set tstatus_output ""
38
f196051f 39proc run_trace_experiment {} {
968643aa 40 global gdb_prompt
5ae4861a 41 global decimal
e2be70a0 42 global tstatus_output
f196051f
SS
43
44# gdb_test_no_output "set debug remote 1" ""
45
46 gdb_test "continue" \
47 ".*Breakpoint \[0-9\]+, begin .*" \
48 "advance to trace begin"
49
50 gdb_test_no_output "tstart my tracing note" "start trace experiment"
51
52 gdb_test "continue" \
53 ".*Breakpoint \[0-9\]+, end .*" \
54 "advance through tracing"
55
56 # Now play with tstatus a bit.
f196051f 57
049109b0
PA
58 # Since support for notes, user, stop reason, etc. is optional, we
59 # need to match both with and without cases.
60
61 set test "tstatus reports trace note"
62 gdb_test_multiple "tstatus" $test {
968643aa 63 -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 $" {
049109b0 64 pass $test
f196051f 65 }
968643aa 66 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Not looking at any trace frame.*\r\n$gdb_prompt $" {
049109b0 67 unsupported $test
f196051f
SS
68 }
69 }
70
71 gdb_test "set trace-notes different note" "" "change tracing note"
72
049109b0
PA
73 set test "tstatus reports different trace note"
74 gdb_test_multiple "tstatus" $test {
968643aa 75 -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 $" {
049109b0 76 pass $test
f196051f 77 }
968643aa 78 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Not looking at any trace frame.*\r\n$gdb_prompt $" {
049109b0 79 unsupported $test
f196051f
SS
80 }
81 }
82
83 gdb_test "set trace-user me me me" "" "change tracing user"
84
049109b0
PA
85 set test "tstatus reports trace user"
86 gdb_test_multiple "tstatus" $test {
968643aa 87 -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 $" {
049109b0 88 pass $test
f196051f 89 }
968643aa 90 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Not looking at any trace frame.*\r\n$gdb_prompt $" {
049109b0 91 unsupported $test
f196051f
SS
92 }
93 }
94
95 gdb_test_no_output "tstop because I can" "trace stopped with note"
96
049109b0
PA
97 set test "tstatus reports trace stop reason"
98 gdb_test_multiple "tstatus" $test {
e2be70a0
YQ
99 -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 $" {
100 set tstatus_output $expect_out(1,string)
049109b0 101 pass $test
f196051f 102 }
e2be70a0
YQ
103 -re "(Trace stopped by a tstop command\.).*\r\n$gdb_prompt $" {
104 set tstatus_output $expect_out(1,string)
049109b0 105 unsupported $test
f196051f
SS
106 }
107 }
108
049109b0
PA
109 set test "info trace reports tracepoint hit count and traceframe usage"
110 gdb_test_multiple "info trace" $test {
5ae4861a 111 -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 $" {
049109b0 112 pass $test
f196051f 113 }
968643aa 114 -re "actions\.c:\[0-9\]+\[\r\n\]+\[\t ]+collect parm.*\r\n$gdb_prompt $" {
049109b0 115 unsupported $test
f196051f
SS
116 }
117 }
118}
119
120proc test_tracepoints {} {
968643aa 121 global gdb_prompt
f196051f
SS
122
123 gdb_test "break begin" ".*" ""
124
125 gdb_test "break end" ".*" ""
126
127 gdb_test "trace gdb_c_test" "Tracepoint .*" \
128 "tracepoint at gdb_c_test"
129
130 gdb_trace_setactions "collect at set_point: define actions" \
131 "" \
132 "collect parm" "^$"
f196051f
SS
133
134 run_trace_experiment
135
136}
137
f196051f 138test_tracepoints
e2be70a0
YQ
139
140set tracefile [standard_output_file ${testfile}]
141# Save trace frames to tfile.
142gdb_test "tsave ${tracefile}.tf" \
143 "Trace data saved to file '${tracefile}.tf'.*" \
144 "save tfile trace file"
393fd4c3
YQ
145# Save trace frames to CTF.
146gdb_test "tsave -ctf ${tracefile}.ctf" \
147 "Trace data saved to directory '${tracefile}.ctf'.*" \
148 "save ctf trace file"
e2be70a0
YQ
149
150# Change target to tfile.
151set test "change to tfile target"
152gdb_test_multiple "target tfile ${tracefile}.tf" "$test" {
153 -re "A program is being debugged already. Kill it. .y or n. " {
154 send_gdb "y\n"
155 exp_continue
156 }
157 -re "$gdb_prompt $" {
158 pass "$test"
159 }
160}
161
162# Convert "(because I can) to "\(because I can\)"
163set tstatus_output [string map {\( \\(} $tstatus_output]
164set tstatus_output [string map {\) \\)} $tstatus_output]
165
166# The status should be identical to the status of live inferior.
167gdb_test "tstatus" "Using a trace file\.\r\n${tstatus_output}.*" \
168 "tstatus on tfile target"
393fd4c3
YQ
169
170# Change target to ctf if GDB supports.
171gdb_test_multiple "target ctf ${tracefile}.ctf" "" {
172 -re "Undefined target command: \"ctf ${tracefile}.ctf\"\. Try \"help target\"\.\r\n$gdb_prompt $" {
173 }
174 -re ".*\r\n$gdb_prompt $" {
175 gdb_test "tstatus" "Using a trace file\.\r\n${tstatus_output}.*" \
176 "tstatus on ctf target"
177 }
178}
This page took 0.502217 seconds and 4 git commands to generate.