Commit | Line | Data |
---|---|---|
45814d45 YQ |
1 | # Copyright 2012 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 | load_lib trace-support.exp | |
17 | ||
18 | if {[skip_shlib_tests]} { | |
19 | return 0 | |
20 | } | |
21 | ||
22 | standard_testfile pending.c | |
23 | set libfile1 "pendshr1" | |
24 | set libfile2 "pendshr2" | |
25 | set executable $testfile | |
26 | set libsrc1 $srcdir/$subdir/$libfile1.c | |
27 | set libsrc2 $srcdir/$subdir/$libfile2.c | |
28 | set lib_sl1 [standard_output_file pendshr1.sl] | |
29 | set lib_sl2 [standard_output_file pendshr2.sl] | |
30 | ||
31 | set lib_opts [gdb_target_symbol_prefix_flags] | |
32 | ||
33 | if { [gdb_compile_shlib $libsrc1 $lib_sl1 $lib_opts] != "" | |
34 | || [gdb_compile_shlib $libsrc2 $lib_sl2 $lib_opts] != ""} { | |
35 | untested "Could not compile either $libsrc1 or $libsrc2" | |
36 | return -1 | |
37 | } | |
38 | ||
39 | set exec_opts [list debug shlib=$lib_sl1 shlib_load] | |
40 | if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != "" } { | |
41 | untested "Failed to compile $srcfile" | |
42 | return -1 | |
43 | } | |
44 | ||
45 | load_lib mi-support.exp | |
46 | set MIFLAGS "-i=mi" | |
47 | ||
48 | # Test when GDB connects to a disconnected stub, existing tracepoints in | |
49 | # remote stub can be uploaded to GDB, and GDB emits MI notification if | |
50 | # new tracepoints are created. | |
51 | ||
52 | proc test_reconnect { } { with_test_prefix "reconnect" { | |
53 | ||
54 | global gdbserver_reconnect_p | |
55 | global gdb_prompt | |
56 | global executable | |
57 | global lib_sl1 lib_sl2 | |
58 | ||
59 | set gdbserver_reconnect_p 1 | |
60 | if { [info proc gdb_reconnect] == "" } { | |
61 | return 0 | |
62 | } | |
63 | ||
64 | clean_restart $executable | |
65 | gdb_load_shlibs $lib_sl1 | |
66 | gdb_load_shlibs $lib_sl2 | |
67 | if ![runto_main] then { | |
68 | fail "Can't run to main" | |
69 | return 0 | |
70 | } | |
71 | gdb_test "trace marker" "Tracepoint.*at.* file .*" \ | |
72 | "tracepointpoint on marker" | |
73 | gdb_test_no_output "tstart" "start trace experiment" | |
74 | ||
75 | set test "disconnect" | |
76 | gdb_test_multiple "disconnect" $test { | |
77 | -re "Trace is running but will stop on detach; detach anyway\\? \\(y or n\\) $" { | |
78 | pass $test | |
79 | ||
80 | set test "disconnected" | |
81 | gdb_test_multiple "y" $test { | |
82 | -re "$gdb_prompt $" { | |
83 | pass "$test" | |
84 | } | |
85 | } | |
86 | } | |
87 | } | |
88 | ||
89 | gdb_exit | |
90 | ||
91 | if [mi_gdb_start] { | |
92 | return | |
93 | } | |
94 | ||
95 | global srcdir | |
96 | global subdir | |
97 | global binfile | |
98 | ||
99 | mi_gdb_reinitialize_dir $srcdir/$subdir | |
100 | mi_gdb_load ${binfile} | |
101 | ||
102 | global gdbserver_protocol | |
103 | global gdbserver_gdbport | |
104 | ||
105 | send_gdb "47-target-select $gdbserver_protocol $gdbserver_gdbport\n" | |
106 | ||
107 | global mi_gdb_prompt | |
108 | set test "tracepoint created" | |
109 | gdb_expect { | |
110 | -re "=breakpoint-created,bkpt=\{number=\"1\",type=\"tracepoint\",disp=\"keep\",enabled=\"y\",.*,func=\"marker\".*${mi_gdb_prompt}" { | |
111 | pass $test | |
112 | } | |
113 | timeout { | |
114 | fail $test | |
115 | } | |
116 | } | |
117 | ||
118 | set gdbserver_reconnect_p 0 | |
119 | }} | |
120 | ||
121 | ||
122 | # Test 'breakpoint-modified' notification is emited when pending tracepoints are | |
123 | # resolved. | |
124 | ||
125 | proc test_pending_resolved { } { with_test_prefix "pending resolved" { | |
126 | global decimal hex | |
127 | global executable | |
128 | global srcdir | |
129 | global subdir | |
130 | global binfile | |
131 | global lib_sl1 lib_sl2 | |
132 | global mi_gdb_prompt | |
133 | ||
134 | gdb_exit | |
135 | if [mi_gdb_start] { | |
136 | continue | |
137 | } | |
138 | ||
139 | mi_gdb_reinitialize_dir $srcdir/$subdir | |
140 | mi_gdb_load ${binfile} | |
141 | mi_load_shlibs $lib_sl1 $lib_sl2 | |
142 | ||
143 | # Create a pending tracepoint on pendfunc2 | |
144 | mi_gdb_test "-break-insert -a -f pendfunc2" \ | |
145 | {.*\^done,bkpt=.*addr=\"<PENDING>\".*} \ | |
146 | "insert breakpoint on pendfunc2" | |
147 | # Insert breakpoint on marker | |
148 | mi_gdb_test "-break-insert marker" {.*\^done,bkpt=.*} \ | |
149 | "insert breakpoint on marker" | |
150 | ||
151 | mi_run_cmd | |
152 | mi_expect_stop "breakpoint-hit" "marker" ""\ | |
153 | ".*" ".*" {"" "disp=\"keep\""} \ | |
154 | "continue to marker breakpoint" | |
155 | mi_gdb_test "-trace-start" {\^done} "trace start" | |
156 | ||
157 | mi_send_resuming_command "exec-continue" "continuing execution to marker 1" | |
158 | ||
159 | set test "tracepoint on pendfunc2 resolved" | |
160 | gdb_expect { | |
161 | -re ".*=breakpoint-modified,bkpt=\{number=\"1\",type=\"tracepoint\".*.*times=\"0\"" { | |
162 | pass "$test" | |
163 | } | |
164 | -re ".*${mi_gdb_prompt}$" { | |
165 | fail $test | |
166 | } | |
167 | timeout { | |
168 | fail "$test (timeout)" | |
169 | } | |
170 | } | |
171 | mi_expect_stop "breakpoint-hit" "marker" ".*" ".*" ".*" \ | |
172 | {"" "disp=\"keep\""} "continue to marker" | |
173 | ||
174 | ||
175 | mi_gdb_test "-trace-stop" {\^done,.*} "trace stop" | |
176 | mi_gdb_test "-trace-find frame-number 0" \ | |
177 | "-trace-find frame-number 0\r\n\\^done,found=\"1\",tracepoint=\"${decimal}\",traceframe=\"0\",frame=\{.*" \ | |
178 | "-trace-find frame-number 0" | |
179 | mi_gdb_test "-trace-find none" {\^done,found="0"} "back to live inferior" | |
180 | ||
181 | mi_send_resuming_command "exec-continue" "continuing to exit" | |
182 | set test "tracepoint on pendfunc2 becomes pending again" | |
183 | gdb_expect { | |
184 | -re ".*=breakpoint-modified,bkpt=\{number=\"1\",type=\"tracepoint\".*addr=\"<PENDING>\",.*times=\"0\"" { | |
185 | pass "$test" | |
186 | } | |
187 | -re ".*${mi_gdb_prompt}$" { | |
188 | fail $test | |
189 | } | |
190 | timeout { | |
191 | fail "$test (timeout)" | |
192 | } | |
193 | } | |
194 | ||
195 | mi_expect_stop "exited-normally" "" "" "" "" "" "" | |
196 | }} | |
197 | ||
198 | # Test target supports tracepoints or not. | |
199 | ||
200 | clean_restart $executable | |
201 | ||
202 | gdb_load_shlibs $lib_sl1 | |
203 | gdb_load_shlibs $lib_sl2 | |
204 | ||
205 | if ![runto_main] { | |
206 | fail "Can't run to main to check for trace support" | |
207 | return -1 | |
208 | } | |
209 | ||
210 | if ![gdb_target_supports_trace] { | |
211 | unsupported "Current target does not support trace" | |
212 | return -1; | |
213 | } | |
214 | ||
215 | gdb_exit | |
216 | ||
217 | test_reconnect | |
218 | ||
219 | test_pending_resolved | |
220 | ||
221 | return 0 |