]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.trace/disconnected-tracing.exp
gdb/testsuite/
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.trace / disconnected-tracing.exp
CommitLineData
8acc9f48 1# Copyright 2012-2013 Free Software Foundation, Inc.
c772f8e7
HZ
2#
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16# Test of disconnected-tracing.
17
18load_lib "trace-support.exp";
19
497a5eb0 20standard_testfile
61e44cfa 21set executable $testfile
c772f8e7
HZ
22set expfile $testfile.exp
23set gdbserver_reconnect_p 1
24
25if { [info proc gdb_reconnect] == "" } {
26 unsupported "target does not support reconnect"
27 return -1
28}
29
30if [prepare_for_testing $expfile $executable $srcfile \
31 {debug nowarnings}] {
32 untested "failed to prepare for trace tests"
33 return -1
34}
35
36if ![runto_main] {
37 fail "can't run to main to check for trace support"
38 return -1
39}
40
41if ![gdb_target_supports_trace] {
42 unsupported "target does not support trace"
ae59b1da 43 return -1
c772f8e7
HZ
44}
45
8d735b87 46# Disconnect in tracing.
c772f8e7 47
8d735b87
YQ
48proc disconnected_tracing { } { with_test_prefix "trace" {
49 global executable
5ae4861a
YQ
50 global decimal
51 global srcfile
c772f8e7 52
8d735b87
YQ
53 # Start with a fresh gdb.
54 clean_restart ${executable}
55 if ![runto_main] {
56 fail "Can't run to main"
57 return -1
58 }
59
60 gdb_test_no_output "set confirm off"
61 gdb_test_no_output "set disconnected-tracing on"
5ae4861a
YQ
62 gdb_test "trace start" ".*"
63 gdb_trace_setactions "collect on tracepoint 2" "2" \
64 "collect foo" "^$"
65 gdb_test "break end" "Breakpoint ${decimal} at .*"
66
8d735b87
YQ
67 gdb_test_no_output "tstart"
68
5ae4861a
YQ
69 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*"
70 gdb_test_no_output "tstop"
71
72 gdb_test "info tracepoints" ".*in start at.*" \
73 "first info tracepoints"
8d735b87
YQ
74
75 gdb_test "disconnect" "Ending remote debugging\\." "first disconnect"
76 if { [gdb_reconnect] == 0 } {
77 pass "first reconnect after unload"
78 } else {
79 fail "first reconnect after unload"
80 return 0
81 }
5ae4861a
YQ
82 gdb_test "info tracepoints" ".*in start at.*" \
83 "second info tracepoints"
8d735b87
YQ
84
85 delete_breakpoints
5ae4861a
YQ
86 gdb_test "info tracepoints" ".*No tracepoints..*" \
87 "third info tracepoints"
8d735b87
YQ
88
89 gdb_test "disconnect" "Ending remote debugging\\." "second disconnect"
90 if { [gdb_reconnect] == 0 } {
91 pass "second reconnect after unload"
92 } else {
93 fail "second reconnect after unload"
94 return 0
95 }
5ae4861a
YQ
96 gdb_test "tstatus"
97 gdb_test "info tracepoints" \
98 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
99\[0-9\]+\[\t \]+tracepoint keep y.* in start at .*$srcfile:\[0-9\]+.
100\[\t \]+tracepoint already hit 1 time.
101\[\t \]+trace buffer usage ${decimal} bytes.
102\[\t \]+collect foo.*" \
103 "fourth info tracepoints"
8d735b87
YQ
104}}
105
106disconnected_tracing
107
108# Disconnected in tfind
109
110proc disconnected_tfind { } { with_test_prefix "tfind" {
111 global executable
112 global decimal
113
114 # Start with a fresh gdb.
115 clean_restart ${executable}
116 if ![runto_main] {
117 fail "Can't run to main"
118 return -1
119 }
120
121 gdb_test_no_output "set confirm off"
122 gdb_test_no_output "set disconnected-tracing on"
123 gdb_test "trace start" ".*"
124 gdb_test_no_output "tstart"
125
126 gdb_test "break end" "Breakpoint ${decimal} at .*"
127 gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*"
128 gdb_test_no_output "tstop"
129
130 gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0"
131 gdb_test "p \$trace_frame" ".*\\\$${decimal} = 0.*" \
132 "p \$trace_frame before disconnected"
133 gdb_test "p \$tracepoint" ".*\\\$${decimal} = 2.*" \
134 "p \$tracepoint before disconnected"
135
136 gdb_test "disconnect" "Ending remote debugging\\." "first disconnect"
137
138 gdb_test "p \$trace_frame" ".*\\\$${decimal} = -1.*"
139 gdb_test "p \$tracepoint" ".*\\\$${decimal} = -1.*"
140 gdb_test "p \$trace_line" ".*\\\$${decimal} = -1.*"
141 gdb_test "p \$trace_file" ".*\\\$${decimal} = void.*"
142 gdb_test "p \$trace_func" ".*\\\$${decimal} = void.*"
143}}
c772f8e7 144
8d735b87 145disconnected_tfind