* NEWS: Mention tracepoint additions.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.trace / tstatus.exp
1 # Copyright 2011 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 set testfile "actions"
18 set executable $testfile
19 set srcfile $testfile.c
20 set binfile $objdir/$subdir/$testfile
21 set expfile tstatus.exp
22
23 if [prepare_for_testing $expfile $executable $srcfile \
24 [list debug]] {
25 untested "failed to prepare for trace tests"
26 return -1
27 }
28
29 if ![runto_main] {
30 fail "Can't run to main to check for trace support"
31 return -1
32 }
33
34 if ![gdb_target_supports_trace] {
35 unsupported "target does not support trace"
36 return -1
37 }
38
39 set libipa $objdir/../gdbserver/libinproctrace.so
40 gdb_load_shlibs $libipa
41
42 # Can't use prepare_for_testing, because that splits compiling into
43 # building objects and then linking, and we'd fail with "linker input
44 # file unused because linking not done" when building the object.
45
46 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
47 executable [list debug shlib=$libipa] ] != "" } {
48 untested "failed to compile ftrace tests"
49 return -1
50 }
51 clean_restart ${executable}
52
53 if ![runto_main] {
54 fail "Can't run to main for ftrace tests"
55 return 0
56 }
57
58 proc run_trace_experiment {} {
59
60 # gdb_test_no_output "set debug remote 1" ""
61
62 gdb_test "continue" \
63 ".*Breakpoint \[0-9\]+, begin .*" \
64 "advance to trace begin"
65
66 gdb_test_no_output "tstart my tracing note" "start trace experiment"
67
68 gdb_test "continue" \
69 ".*Breakpoint \[0-9\]+, end .*" \
70 "advance through tracing"
71
72 # Now play with tstatus a bit.
73 # Since note support is optional, we need to match both with and without
74 # cases.
75
76 gdb_test_multiple "tstatus" "check on trace status" {
77 -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\..*" {
78 pass "tstatus reports trace note"
79 }
80 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Not looking at any trace frame.*" {
81 pass "tstatus does not report any trace note"
82 }
83 }
84
85 gdb_test "set trace-notes different note" "" "change tracing note"
86
87 gdb_test_multiple "tstatus" "check on trace status with diff note" {
88 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Trace notes: different note\.\[\r\n\]+Not looking at any trace frame\..*" {
89 pass "tstatus reports different trace note"
90 }
91 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Not looking at any trace frame.*" {
92 pass "tstatus does not report any different trace note"
93 }
94 }
95
96 gdb_test "set trace-user me me me" "" "change tracing user"
97
98 gdb_test_multiple "tstatus" "check on trace status with diff note" {
99 -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\..*" {
100 pass "tstatus reports trace user"
101 }
102 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Not looking at any trace frame.*" {
103 pass "tstatus does not report trace user"
104 }
105 }
106
107 gdb_test_no_output "tstop because I can" "trace stopped with note"
108
109 gdb_test_multiple "tstatus" "check on trace status after stop" {
110 -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\..*" {
111 pass "tstatus reports trace stop reason"
112 }
113 -re "Trace stopped by a tstop command\..*" {
114 pass "tstatus does not report trace stop reason"
115 }
116 }
117
118 # Tracepoint hit count is optional, so pass it either way.
119
120 gdb_test_multiple "info trace" "show tracepoint state" {
121 -re "actions\.c:\[0-9\]+\[\r\n\]+\[\t ]+tracepoint already hit 1 time\[\r\n\]+\[\t ]+collect parm" {
122 pass "info trace reports tracepoint hit count"
123 }
124 -re "actions\.c:\[0-9\]+\[\r\n\]+\[\t ]+collect parm" {
125 pass "info trace does not report tracepoint hit count"
126 }
127 }
128 }
129
130 proc test_tracepoints {} {
131
132 gdb_test "break begin" ".*" ""
133
134 gdb_test "break end" ".*" ""
135
136 gdb_test "trace gdb_c_test" "Tracepoint .*" \
137 "tracepoint at gdb_c_test"
138
139 gdb_trace_setactions "collect at set_point: define actions" \
140 "" \
141 "collect parm" "^$"
142 set fastgood 0
143
144 gdb_test_multiple "ftrace gdb_recursion_test" "set fast tracepoint" {
145 -re "May not have a fast tracepoint at .*" {
146 pass "4-byte fast tracepoint could not be set"
147 }
148 -re "Fast tracepoint .*" {
149 pass "4-byte fast tracepoint is set"
150 set fastgood 1
151 }
152 }
153
154 if { $fastgood } {
155
156 gdb_trace_setactions "collect at four_byter: define actions" \
157 "" \
158 "collect globvar, anarg" "^$"
159 }
160
161 run_trace_experiment
162
163 }
164
165 gdb_reinitialize_dir $srcdir/$subdir
166
167 if { [gdb_test "info sharedlibrary" ".*libinproctrace\.so.*" "IPA loaded"] != 0 } {
168 untested "Could not find IPA lib loaded"
169 return 1
170 }
171
172 test_tracepoints
This page took 0.050684 seconds and 4 git commands to generate.