Testsuite: Fix ambiguous "break" due to libinproctrace
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.trace / tstatus.exp
CommitLineData
e2882c85 1# Copyright 2011-2018 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
5b362f04 21if [prepare_for_testing "failed to prepare" $executable $srcfile \
f196051f 22 [list debug]] {
f196051f
SS
23 return -1
24}
25
26if ![runto_main] {
bc6c7af4 27 fail "can't run to main to check for trace support"
f196051f
SS
28 return -1
29}
30
31if ![gdb_target_supports_trace] {
32 unsupported "target does not support trace"
33 return -1
34}
35
e2be70a0
YQ
36set tstatus_output ""
37
f196051f 38proc run_trace_experiment {} {
968643aa 39 global gdb_prompt
5ae4861a 40 global decimal
e2be70a0 41 global tstatus_output
f196051f
SS
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.
f196051f 56
049109b0
PA
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 {
968643aa 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 $" {
049109b0 63 pass $test
f196051f 64 }
968643aa 65 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Not looking at any trace frame.*\r\n$gdb_prompt $" {
049109b0 66 unsupported $test
f196051f
SS
67 }
68 }
69
70 gdb_test "set trace-notes different note" "" "change tracing note"
71
049109b0
PA
72 set test "tstatus reports different trace note"
73 gdb_test_multiple "tstatus" $test {
968643aa 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 $" {
049109b0 75 pass $test
f196051f 76 }
968643aa 77 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Not looking at any trace frame.*\r\n$gdb_prompt $" {
049109b0 78 unsupported $test
f196051f
SS
79 }
80 }
81
82 gdb_test "set trace-user me me me" "" "change tracing user"
83
049109b0
PA
84 set test "tstatus reports trace user"
85 gdb_test_multiple "tstatus" $test {
968643aa 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 $" {
049109b0 87 pass $test
f196051f 88 }
968643aa 89 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Not looking at any trace frame.*\r\n$gdb_prompt $" {
049109b0 90 unsupported $test
f196051f
SS
91 }
92 }
93
94 gdb_test_no_output "tstop because I can" "trace stopped with note"
95
049109b0
PA
96 set test "tstatus reports trace stop reason"
97 gdb_test_multiple "tstatus" $test {
e2be70a0
YQ
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)
049109b0 100 pass $test
f196051f 101 }
e2be70a0
YQ
102 -re "(Trace stopped by a tstop command\.).*\r\n$gdb_prompt $" {
103 set tstatus_output $expect_out(1,string)
049109b0 104 unsupported $test
f196051f
SS
105 }
106 }
107
049109b0
PA
108 set test "info trace reports tracepoint hit count and traceframe usage"
109 gdb_test_multiple "info trace" $test {
5ae4861a 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 $" {
049109b0 111 pass $test
f196051f 112 }
968643aa 113 -re "actions\.c:\[0-9\]+\[\r\n\]+\[\t ]+collect parm.*\r\n$gdb_prompt $" {
049109b0 114 unsupported $test
f196051f
SS
115 }
116 }
117}
118
119proc test_tracepoints {} {
968643aa 120 global gdb_prompt
f196051f 121
194ed413 122 gdb_breakpoint "begin" qualified
f196051f 123
194ed413 124 gdb_breakpoint "end" qualified
f196051f
SS
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" "^$"
f196051f
SS
132
133 run_trace_experiment
134
135}
136
f196051f 137test_tracepoints
e2be70a0
YQ
138
139set tracefile [standard_output_file ${testfile}]
140# Save trace frames to tfile.
141gdb_test "tsave ${tracefile}.tf" \
142 "Trace data saved to file '${tracefile}.tf'.*" \
143 "save tfile trace file"
393fd4c3
YQ
144# Save trace frames to CTF.
145gdb_test "tsave -ctf ${tracefile}.ctf" \
146 "Trace data saved to directory '${tracefile}.ctf'.*" \
147 "save ctf trace file"
e2be70a0
YQ
148
149# Change target to tfile.
150set test "change to tfile target"
151gdb_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\)"
162set tstatus_output [string map {\( \\(} $tstatus_output]
163set tstatus_output [string map {\) \\)} $tstatus_output]
164
165# The status should be identical to the status of live inferior.
166gdb_test "tstatus" "Using a trace file\.\r\n${tstatus_output}.*" \
167 "tstatus on tfile target"
393fd4c3
YQ
168
169# Change target to ctf if GDB supports.
170gdb_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 1.181987 seconds and 4 git commands to generate.