Commit | Line | Data |
---|---|---|
618f726f | 1 | # Copyright 2012-2016 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 | ||
4ec70201 | 18 | load_lib "trace-support.exp" |
c772f8e7 | 19 | |
497a5eb0 | 20 | standard_testfile |
61e44cfa | 21 | set executable $testfile |
c772f8e7 HZ |
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" | |
ae59b1da | 43 | return -1 |
c772f8e7 HZ |
44 | } |
45 | ||
8d735b87 | 46 | # Disconnect in tracing. |
c772f8e7 | 47 | |
0a251e08 YQ |
48 | proc disconnected_tracing { } { |
49 | with_test_prefix "trace" { | |
50 | global executable | |
51 | global decimal | |
52 | global srcfile | |
53 | ||
54 | # Start with a fresh gdb. | |
55 | clean_restart ${executable} | |
56 | if ![runto_main] { | |
bc6c7af4 | 57 | fail "can't run to main" |
0a251e08 YQ |
58 | return -1 |
59 | } | |
60 | ||
61 | gdb_test_no_output "set confirm off" | |
62 | gdb_test_no_output "set disconnected-tracing on" | |
63 | gdb_test "trace start" ".*" | |
64 | gdb_trace_setactions "collect on tracepoint 2" "2" \ | |
65 | "collect foo" "^$" | |
66 | gdb_test "break end" "Breakpoint ${decimal} at .*" | |
67 | ||
68 | gdb_test_no_output "tstart" | |
69 | ||
70 | gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" | |
71 | gdb_test_no_output "tstop" | |
72 | ||
73 | gdb_test "info tracepoints" ".*in start at.*" \ | |
74 | "first info tracepoints" | |
75 | ||
76 | gdb_test "disconnect" "Ending remote debugging\\." "first disconnect" | |
77 | if { [gdb_reconnect] == 0 } { | |
78 | pass "first reconnect after unload" | |
79 | } else { | |
80 | fail "first reconnect after unload" | |
81 | return 0 | |
82 | } | |
83 | gdb_test "info tracepoints" ".*in start at.*" \ | |
84 | "second info tracepoints" | |
85 | ||
86 | delete_breakpoints | |
87 | gdb_test "info tracepoints" ".*No tracepoints..*" \ | |
88 | "third info tracepoints" | |
89 | ||
90 | gdb_test "disconnect" "Ending remote debugging\\." "second disconnect" | |
91 | if { [gdb_reconnect] == 0 } { | |
92 | pass "second reconnect after unload" | |
93 | } else { | |
94 | fail "second reconnect after unload" | |
95 | return 0 | |
96 | } | |
97 | gdb_test "tstatus" | |
98 | gdb_test "info tracepoints" \ | |
99 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
5ae4861a YQ |
100 | \[0-9\]+\[\t \]+tracepoint keep y.* in start at .*$srcfile:\[0-9\]+. |
101 | \[\t \]+tracepoint already hit 1 time. | |
102 | \[\t \]+trace buffer usage ${decimal} bytes. | |
103 | \[\t \]+collect foo.*" \ | |
0a251e08 YQ |
104 | "fourth info tracepoints" |
105 | } | |
106 | } | |
8d735b87 YQ |
107 | |
108 | disconnected_tracing | |
109 | ||
110 | # Disconnected in tfind | |
111 | ||
0a251e08 YQ |
112 | proc disconnected_tfind { } { |
113 | with_test_prefix "tfind" { | |
114 | global executable | |
115 | global decimal | |
116 | ||
117 | # Start with a fresh gdb. | |
118 | clean_restart ${executable} | |
119 | if ![runto_main] { | |
bc6c7af4 | 120 | fail "can't run to main" |
0a251e08 YQ |
121 | return -1 |
122 | } | |
123 | ||
124 | gdb_test_no_output "set confirm off" | |
125 | gdb_test_no_output "set disconnected-tracing on" | |
126 | gdb_test "trace start" ".*" | |
127 | gdb_test_no_output "tstart" | |
128 | ||
129 | gdb_test "break end" "Breakpoint ${decimal} at .*" | |
130 | gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" | |
131 | gdb_test_no_output "tstop" | |
132 | ||
133 | gdb_test "tfind" "Found trace frame 0, tracepoint .*" "tfind frame 0" | |
134 | gdb_test "p \$trace_frame" ".*\\\$${decimal} = 0.*" \ | |
135 | "p \$trace_frame before disconnected" | |
136 | gdb_test "p \$tracepoint" ".*\\\$${decimal} = 2.*" \ | |
137 | "p \$tracepoint before disconnected" | |
138 | ||
139 | gdb_test "disconnect" "Ending remote debugging\\." "first disconnect" | |
140 | ||
141 | gdb_test "p \$trace_frame" ".*\\\$${decimal} = -1.*" | |
142 | gdb_test "p \$tracepoint" ".*\\\$${decimal} = -1.*" | |
143 | gdb_test "p \$trace_line" ".*\\\$${decimal} = -1.*" | |
144 | gdb_test "p \$trace_file" ".*\\\$${decimal} = void.*" | |
145 | gdb_test "p \$trace_func" ".*\\\$${decimal} = void.*" | |
8d735b87 | 146 | } |
0a251e08 | 147 | } |
c772f8e7 | 148 | |
8d735b87 | 149 | disconnected_tfind |
a35cfb40 MR |
150 | |
151 | # Reconnect for a clean gdbserver shutdown. | |
152 | gdb_reconnect |