]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.trace/tstatus.exp
Update years in copyright notice for the GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.trace / tstatus.exp
1 # Copyright 2011-2013 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 $expfile $executable $srcfile \
22 [list debug]] {
23 untested "failed to prepare for trace tests"
24 return -1
25 }
26
27 if ![runto_main] {
28 fail "Can't run to main to check for trace support"
29 return -1
30 }
31
32 if ![gdb_target_supports_trace] {
33 unsupported "target does not support trace"
34 return -1
35 }
36
37 set libipa [get_in_proc_agent]
38 gdb_load_shlibs $libipa
39
40 # Can't use prepare_for_testing, because that splits compiling into
41 # building objects and then linking, and we'd fail with "linker input
42 # file unused because linking not done" when building the object.
43
44 if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
45 executable [list debug shlib=$libipa] ] != "" } {
46 untested "failed to compile ftrace tests"
47 return -1
48 }
49 clean_restart ${executable}
50
51 if ![runto_main] {
52 fail "Can't run to main for ftrace tests"
53 return 0
54 }
55
56 proc run_trace_experiment {} {
57 global gdb_prompt
58
59 # gdb_test_no_output "set debug remote 1" ""
60
61 gdb_test "continue" \
62 ".*Breakpoint \[0-9\]+, begin .*" \
63 "advance to trace begin"
64
65 gdb_test_no_output "tstart my tracing note" "start trace experiment"
66
67 gdb_test "continue" \
68 ".*Breakpoint \[0-9\]+, end .*" \
69 "advance through tracing"
70
71 # Now play with tstatus a bit.
72 # Since note support is optional, we need to match both with and without
73 # cases.
74
75 gdb_test_multiple "tstatus" "check on trace status" {
76 -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 $" {
77 pass "tstatus reports trace note"
78 }
79 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Not looking at any trace frame.*\r\n$gdb_prompt $" {
80 pass "tstatus does not report any trace note"
81 }
82 }
83
84 gdb_test "set trace-notes different note" "" "change tracing note"
85
86 gdb_test_multiple "tstatus" "check on trace status with diff note" {
87 -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 $" {
88 pass "tstatus reports different trace note"
89 }
90 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Not looking at any trace frame.*\r\n$gdb_prompt $" {
91 pass "tstatus does not report any different trace note"
92 }
93 }
94
95 gdb_test "set trace-user me me me" "" "change tracing user"
96
97 gdb_test_multiple "tstatus" "check on trace status with diff note" {
98 -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 $" {
99 pass "tstatus reports trace user"
100 }
101 -re "Trace is running.*Trace will stop if GDB disconnects\.\[\r\n\]+Not looking at any trace frame.*\r\n$gdb_prompt $" {
102 pass "tstatus does not report trace user"
103 }
104 }
105
106 gdb_test_no_output "tstop because I can" "trace stopped with note"
107
108 gdb_test_multiple "tstatus" "check on trace status after stop" {
109 -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 $" {
110 pass "tstatus reports trace stop reason"
111 }
112 -re "Trace stopped by a tstop command\..*\r\n$gdb_prompt $" {
113 pass "tstatus does not report trace stop reason"
114 }
115 }
116
117 # Tracepoint hit count is optional, so pass it either way.
118
119 gdb_test_multiple "info trace" "show tracepoint state" {
120 -re "actions\.c:\[0-9\]+\[\r\n\]+\[\t ]+tracepoint already hit 1 time\[\r\n\]+\[\t ]+collect parm.*\r\n$gdb_prompt $" {
121 pass "info trace reports tracepoint hit count"
122 }
123 -re "actions\.c:\[0-9\]+\[\r\n\]+\[\t ]+collect parm.*\r\n$gdb_prompt $" {
124 pass "info trace does not report tracepoint hit count"
125 }
126 }
127 }
128
129 proc test_tracepoints {} {
130 global gdb_prompt
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 .*\r\n$gdb_prompt $" {
146 pass "4-byte fast tracepoint could not be set"
147 }
148 -re "Fast tracepoint .*\r\n$gdb_prompt $" {
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" ".*${libipa}.*" "IPA loaded"] != 0 } {
168 untested "Could not find IPA lib loaded"
169 return 1
170 }
171
172 test_tracepoints