Fix more cases of improper test names
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.trace / tstatus.exp
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.
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
15 load_lib "trace-support.exp"
16
17 standard_testfile actions.c
18 set executable $testfile
19 set expfile tstatus.exp
20
21 if [prepare_for_testing "failed to prepare" $executable $srcfile \
22 [list debug]] {
23 return -1
24 }
25
26 if ![runto_main] {
27 fail "can't run to main to check for trace support"
28 return -1
29 }
30
31 if ![gdb_target_supports_trace] {
32 unsupported "target does not support trace"
33 return -1
34 }
35
36 set tstatus_output ""
37
38 proc run_trace_experiment {} {
39 global gdb_prompt
40 global decimal
41 global tstatus_output
42
43 # gdb_test_no_output "set debug remote 1" ""
44
45 gdb_test "continue" \
46 ".*Breakpoint \[0-9\]+, begin .*" \
47 "advance to trace begin"
48
49 gdb_test_no_output "tstart my tracing note" "start trace experiment"
50
51 gdb_test "continue" \
52 ".*Breakpoint \[0-9\]+, end .*" \
53 "advance through tracing"
54
55 # Now play with tstatus a bit.
56
57 # Since support for notes, user, stop reason, etc. is optional, we
58 # need to match both with and without cases.
59
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 $" {
63 pass $test
64 }
65 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Not looking at any trace frame.*\r\n$gdb_prompt $" {
66 unsupported $test
67 }
68 }
69
70 gdb_test "set trace-notes different note" "" "change tracing note"
71
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 $" {
75 pass $test
76 }
77 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Not looking at any trace frame.*\r\n$gdb_prompt $" {
78 unsupported $test
79 }
80 }
81
82 gdb_test "set trace-user me me me" "" "change tracing user"
83
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 $" {
87 pass $test
88 }
89 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Not looking at any trace frame.*\r\n$gdb_prompt $" {
90 unsupported $test
91 }
92 }
93
94 gdb_test_no_output "tstop because I can" "trace stopped with note"
95
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)
100 pass $test
101 }
102 -re "(Trace stopped by a tstop command\.).*\r\n$gdb_prompt $" {
103 set tstatus_output $expect_out(1,string)
104 unsupported $test
105 }
106 }
107
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 $" {
111 pass $test
112 }
113 -re "actions\.c:\[0-9\]+\[\r\n\]+\[\t ]+collect parm.*\r\n$gdb_prompt $" {
114 unsupported $test
115 }
116 }
117 }
118
119 proc test_tracepoints {} {
120 global gdb_prompt
121
122 gdb_test "break begin" ".*" ""
123
124 gdb_test "break end" ".*" ""
125
126 gdb_test "trace gdb_c_test" "Tracepoint .*" \
127 "tracepoint at gdb_c_test"
128
129 gdb_trace_setactions "collect at set_point: define actions" \
130 "" \
131 "collect parm" "^$"
132
133 run_trace_experiment
134
135 }
136
137 test_tracepoints
138
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"
148
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. " {
153 send_gdb "y\n"
154 exp_continue
155 }
156 -re "$gdb_prompt $" {
157 pass "$test"
158 }
159 }
160
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]
164
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"
168
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 $" {
172 }
173 -re ".*\r\n$gdb_prompt $" {
174 gdb_test "tstatus" "Using a trace file\.\r\n${tstatus_output}.*" \
175 "tstatus on ctf target"
176 }
177 }
This page took 0.034558 seconds and 5 git commands to generate.