gdb/testsuite/
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.trace / disconnected-tracing.exp
1 # Copyright 2012-2013 Free Software Foundation, Inc.
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
18 load_lib "trace-support.exp";
19
20 standard_testfile
21 set executable $testfile
22 set expfile $testfile.exp
23 set gdbserver_reconnect_p 1
24
25 if { [info proc gdb_reconnect] == "" } {
26 unsupported "target does not support reconnect"
27 return -1
28 }
29
30 if [prepare_for_testing $expfile $executable $srcfile \
31 {debug nowarnings}] {
32 untested "failed to prepare for trace tests"
33 return -1
34 }
35
36 if ![runto_main] {
37 fail "can't run to main to check for trace support"
38 return -1
39 }
40
41 if ![gdb_target_supports_trace] {
42 unsupported "target does not support trace"
43 return -1
44 }
45
46 # Disconnect in tracing.
47
48 proc disconnected_tracing { } { with_test_prefix "trace" {
49 global executable
50 global decimal
51 global srcfile
52
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"
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
67 gdb_test_no_output "tstart"
68
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"
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 }
82 gdb_test "info tracepoints" ".*in start at.*" \
83 "second info tracepoints"
84
85 delete_breakpoints
86 gdb_test "info tracepoints" ".*No tracepoints..*" \
87 "third info tracepoints"
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 }
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"
104 }}
105
106 disconnected_tracing
107
108 # Disconnected in tfind
109
110 proc 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 }}
144
145 disconnected_tfind
This page took 0.0353 seconds and 4 git commands to generate.