]>
Commit | Line | Data |
---|---|---|
60f98dde MS |
1 | # Copyright 2011 |
2 | # Free Software Foundation, Inc. | |
3 | ||
4 | # This program is free software; you can redistribute it and/or modify | |
5 | # it under the terms of the GNU General Public License as published by | |
6 | # the Free Software Foundation; either version 3 of the License, or | |
7 | # (at your option) any later version. | |
8 | # | |
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. | |
13 | # | |
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | ||
17 | # Please email any bugs, comments, and/or additions to this file to: | |
18 | # bug-gdb@gnu.org | |
19 | ||
20 | if $tracelevel then { | |
21 | strace $tracelevel | |
22 | } | |
23 | ||
24 | set testfile "linux-dp" | |
25 | set srcfile ${testfile}.c | |
26 | set binfile ${objdir}/${subdir}/${testfile} | |
27 | if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != ""} { | |
28 | return -1 | |
29 | } | |
30 | ||
31 | gdb_start | |
32 | gdb_reinitialize_dir $srcdir/$subdir | |
33 | gdb_load ${binfile} | |
34 | gdb_test_no_output "set print sevenbit-strings" | |
35 | runto_main | |
36 | ||
37 | # Run until there are some threads. | |
38 | gdb_breakpoint [gdb_get_line_number "linuxthreads.exp: info threads 2"] | |
39 | gdb_continue_to_breakpoint "main thread's sleep" | |
40 | ||
41 | # Create thread names. | |
42 | gdb_test "thread apply 1 thread name threadname_1" \ | |
43 | "Thread 1 .*" \ | |
44 | "name thread 1" | |
45 | ||
46 | gdb_test "thread apply 2 thread name threadname_2" \ | |
47 | "Thread 2 .*" \ | |
48 | "name thread 2" | |
49 | ||
50 | gdb_test "thread apply 3 thread name threadname_3" \ | |
51 | "Thread 3 .*" \ | |
52 | "name thread 3" | |
53 | ||
54 | gdb_test "thread apply 4 thread name threadname_4" \ | |
55 | "Thread 4 .*" \ | |
56 | "name thread 4" | |
57 | ||
58 | gdb_test "thread apply 5 thread name threadname_5" \ | |
59 | "Thread 5 .*" \ | |
60 | "name thread 5" | |
61 | ||
62 | gdb_test "thread apply 6 thread name threadname_6" \ | |
63 | "Thread 6 .*" \ | |
64 | "name thread 6" | |
65 | ||
66 | # Collect thread ids, if any. | |
67 | gdb_test_multiple "info threads" "collect thread id" { | |
68 | -re ". 6 .*\[Tt\]hread (\[0-9a-fA-Fx\]+).* \"threadname_6\" \[^\r\n\]*" { | |
69 | set thread6 $expect_out(1,string) | |
70 | exp_continue | |
71 | } | |
72 | -re ". 5 .*\[Tt\]hread (\[0-9a-fA-Fx\]+).* \"threadname_5\" \[^\r\n\]*" { | |
73 | set thread5 $expect_out(1,string) | |
74 | exp_continue | |
75 | } | |
76 | -re ". 4 .*\[Tt\]hread (\[0-9a-fA-Fx\]+).* \"threadname_4\" \[^\r\n\]*" { | |
77 | set thread4 $expect_out(1,string) | |
78 | exp_continue | |
79 | } | |
80 | -re ". 3 .*\[Tt\]hread (\[0-9a-fA-Fx\]+).* \"threadname_3\" \[^\r\n\]*" { | |
81 | set thread3 $expect_out(1,string) | |
82 | exp_continue | |
83 | } | |
84 | -re ". 2 .*\[Tt\]hread (\[0-9a-fA-Fx\]+).* \"threadname_2\" \[^\r\n\]*" { | |
85 | set thread2 $expect_out(1,string) | |
86 | exp_continue | |
87 | } | |
88 | -re ". 1 .*\[Tt\]hread (\[0-9a-fA-Fx\]+).* \"threadname_1\" \[^\r\n\]*" { | |
89 | set thread1 $expect_out(1,string) | |
90 | exp_continue | |
91 | } | |
92 | -re ".*$gdb_prompt $" { | |
93 | pass "collect thread id" | |
94 | } | |
95 | } | |
96 | ||
97 | if { [info exists thread6] } then { | |
98 | gdb_test "echo $thread6\\n" "$thread6" "got thread ids" | |
99 | } | |
100 | ||
101 | # Collect process ids, if any. | |
102 | gdb_test_multiple "info threads" "collect thread id" { | |
103 | -re ". 6 .*\[Pp\]rocess (\[0-9a-fA-Fx\]+).* \"threadname_6\" \[^\r\n\]*" { | |
104 | set process6 $expect_out(1,string) | |
105 | exp_continue | |
106 | } | |
107 | -re ". 5 .*\[Pp\]rocess (\[0-9a-fA-Fx\]+).* \"threadname_5\" \[^\r\n\]*" { | |
108 | set process5 $expect_out(1,string) | |
109 | exp_continue | |
110 | } | |
111 | -re ". 4 .*\[Pp\]rocess (\[0-9a-fA-Fx\]+).* \"threadname_4\" \[^\r\n\]*" { | |
112 | set process4 $expect_out(1,string) | |
113 | exp_continue | |
114 | } | |
115 | -re ". 3 .*\[Pp\]rocess (\[0-9a-fA-Fx\]+).* \"threadname_3\" \[^\r\n\]*" { | |
116 | set process3 $expect_out(1,string) | |
117 | exp_continue | |
118 | } | |
119 | -re ". 2 .*\[Pp\]rocess (\[0-9a-fA-Fx\]+).* \"threadname_2\" \[^\r\n\]*" { | |
120 | set process2 $expect_out(1,string) | |
121 | exp_continue | |
122 | } | |
123 | -re ". 1 .*\[Pp\]rocess (\[0-9a-fA-Fx\]+).* \"threadname_1\" \[^\r\n\]*" { | |
124 | set process1 $expect_out(1,string) | |
125 | exp_continue | |
126 | } | |
127 | -re ".*$gdb_prompt $" { | |
128 | pass "collect process id" | |
129 | } | |
130 | } | |
131 | ||
132 | if { [info exists process6] } then { | |
133 | gdb_test "echo $process6\\n" "$process6" "got process ids" | |
134 | } | |
135 | ||
136 | # Collect lwp ids, if any. | |
137 | gdb_test_multiple "info threads" "collect thread id" { | |
138 | -re ". 6 .*LWP (\[0-9a-fA-Fx\]+).* \"threadname_6\" \[^\r\n\]*" { | |
139 | set lwp6 $expect_out(1,string) | |
140 | exp_continue | |
141 | } | |
142 | -re ". 5 .*LWP (\[0-9a-fA-Fx\]+).* \"threadname_5\" \[^\r\n\]*" { | |
143 | set lwp5 $expect_out(1,string) | |
144 | exp_continue | |
145 | } | |
146 | -re ". 4 .*LWP (\[0-9a-fA-Fx\]+).* \"threadname_4\" \[^\r\n\]*" { | |
147 | set lwp4 $expect_out(1,string) | |
148 | exp_continue | |
149 | } | |
150 | -re ". 3 .*LWP (\[0-9a-fA-Fx\]+).* \"threadname_3\" \[^\r\n\]*" { | |
151 | set lwp3 $expect_out(1,string) | |
152 | exp_continue | |
153 | } | |
154 | -re ". 2 .*LWP (\[0-9a-fA-Fx\]+).* \"threadname_2\" \[^\r\n\]*" { | |
155 | set lwp2 $expect_out(1,string) | |
156 | exp_continue | |
157 | } | |
158 | -re ". 1 .*LWP (\[0-9a-fA-Fx\]+).* \"threadname_1\" \[^\r\n\]*" { | |
159 | set lwp1 $expect_out(1,string) | |
160 | exp_continue | |
161 | } | |
162 | -re ".*$gdb_prompt $" { | |
163 | pass "collect lwp id" | |
164 | } | |
165 | } | |
166 | ||
167 | if { [info exists lwp6] } then { | |
168 | gdb_test "echo $lwp6\\n" "$lwp6" "got lwp ids" | |
169 | } | |
170 | ||
171 | # | |
172 | # Now: test 'thread find' with names. | |
173 | # | |
174 | ||
175 | gdb_test "thread find threadname_6" \ | |
176 | "Thread 6 has name 'threadname_6'" "find thread name 6" | |
177 | gdb_test "thread find threadname_5" \ | |
178 | "Thread 5 has name 'threadname_5'" "find thread name 5" | |
179 | gdb_test "thread find threadname_4" \ | |
180 | "Thread 4 has name 'threadname_4'" "find thread name 4" | |
181 | gdb_test "thread find threadname_3" \ | |
182 | "Thread 3 has name 'threadname_3'" "find thread name 3" | |
183 | gdb_test "thread find threadname_2" \ | |
184 | "Thread 2 has name 'threadname_2'" "find thread name 2" | |
185 | gdb_test "thread find threadname_1" \ | |
186 | "Thread 1 has name 'threadname_1'" "find thread name 1" | |
187 | ||
188 | # | |
189 | # Test 'thread find' with thread ids, if any. | |
190 | # | |
191 | ||
192 | if { [info exists thread6] } then { | |
193 | gdb_test "thread find $thread6" \ | |
194 | "Thread 6 has .*$thread6.*" "find thread id 6" | |
195 | gdb_test "thread find $thread5" \ | |
196 | "Thread 5 has .*$thread5.*" "find thread id 5" | |
197 | gdb_test "thread find $thread4" \ | |
198 | "Thread 4 has .*$thread4.*" "find thread id 4" | |
199 | gdb_test "thread find $thread3" \ | |
200 | "Thread 3 has .*$thread3.*" "find thread id 3" | |
201 | gdb_test "thread find $thread2" \ | |
202 | "Thread 2 has .*$thread2.*" "find thread id 2" | |
203 | gdb_test "thread find $thread1" \ | |
204 | "Thread 1 has .*$thread1.*" "find thread id 1" | |
205 | } | |
206 | ||
207 | # | |
208 | # Test 'thread find' with process ids, if any. | |
209 | # | |
210 | ||
211 | if { [info exists process6] } then { | |
212 | gdb_test "thread find $process6" \ | |
213 | "Thread 6 has .*$process6.*" "find process id 6" | |
214 | gdb_test "thread find $process5" \ | |
215 | "Thread 5 has .*$process5.*" "find process id 5" | |
216 | gdb_test "thread find $process4" \ | |
217 | "Thread 4 has .*$process4.*" "find process id 4" | |
218 | gdb_test "thread find $process3" \ | |
219 | "Thread 3 has .*$process3.*" "find process id 3" | |
220 | gdb_test "thread find $process2" \ | |
221 | "Thread 2 has .*$process2.*" "find process id 2" | |
222 | gdb_test "thread find $process1" \ | |
223 | "Thread 1 has .*$process1.*" "find process id 1" | |
224 | } | |
225 | ||
226 | # | |
227 | # Test 'thread find' with lwp ids, if any. | |
228 | # | |
229 | ||
230 | if { [info exists lwp6] } then { | |
231 | gdb_test "thread find $lwp6" \ | |
232 | "Thread 6 has .*$lwp6.*" "find lwp id 6" | |
233 | gdb_test "thread find $lwp5" \ | |
234 | "Thread 5 has .*$lwp5.*" "find lwp id 5" | |
235 | gdb_test "thread find $lwp4" \ | |
236 | "Thread 4 has .*$lwp4.*" "find lwp id 4" | |
237 | gdb_test "thread find $lwp3" \ | |
238 | "Thread 3 has .*$lwp3.*" "find lwp id 3" | |
239 | gdb_test "thread find $lwp2" \ | |
240 | "Thread 2 has .*$lwp2.*" "find lwp id 2" | |
241 | gdb_test "thread find $lwp1" \ | |
242 | "Thread 1 has .*$lwp1.*" "find lwp id 1" | |
243 | } | |
244 | ||
245 | # Test no match. | |
246 | ||
247 | gdb_test "thread find foobarbaz" "No threads match .*" "no thread" | |
248 | ||
249 | # | |
250 | # Test regular expression | |
251 | # | |
252 | ||
253 | set see1 0 | |
254 | set see2 0 | |
255 | set see3 0 | |
256 | set see4 0 | |
257 | set see5 0 | |
258 | set see6 0 | |
259 | ||
260 | gdb_test_multiple "thread find threadname_\[345\]" "test regular exp" { | |
261 | -re "Thread 6 has name \[^\r\n\]*" { | |
262 | set see6 1 | |
263 | exp_continue | |
264 | } | |
265 | -re "Thread 5 has name \[^\r\n\]*" { | |
266 | set see5 1 | |
267 | exp_continue | |
268 | } | |
269 | -re "Thread 4 has name \[^\r\n\]*" { | |
270 | set see4 1 | |
271 | exp_continue | |
272 | } | |
273 | -re "Thread 3 has name \[^\r\n\]*" { | |
274 | set see3 1 | |
275 | exp_continue | |
276 | } | |
277 | -re "Thread 2 has name \[^\r\n\]*" { | |
278 | set see2 1 | |
279 | exp_continue | |
280 | } | |
281 | -re "Thread 1 has name \[^\r\n\]*" { | |
282 | set see1 1 | |
283 | exp_continue | |
284 | } | |
285 | -re ".*$gdb_prompt $" { | |
286 | if { $see3 && $see4 && $see5 && !$see1 && !$see2 && !$see6 } then { | |
287 | pass "test regular exp" | |
288 | } else { | |
289 | fail "test regular exp" | |
290 | } | |
291 | } | |
292 | } | |
293 | ||
294 | # | |
295 | # Test info threads on a subset of threads | |
296 | # | |
297 | ||
298 | set see1 0 | |
299 | set see2 0 | |
300 | set see3 0 | |
301 | set see4 0 | |
302 | set see5 0 | |
303 | set see6 0 | |
304 | ||
305 | gdb_test_multiple "info threads 2 4 6" "info threads 2 4 6" { | |
306 | -re ". 6 .*\"threadname_6.*\" \[\r\n\]*" { | |
307 | set see6 1 | |
308 | exp_continue | |
309 | } | |
310 | -re ". 5 .*\"threadname_5.*\" \[\r\n\]*" { | |
311 | set see5 1 | |
312 | exp_continue | |
313 | } | |
314 | -re ". 4 .*\"threadname_4.*\" \[\r\n\]*" { | |
315 | set see4 1 | |
316 | exp_continue | |
317 | } | |
318 | -re ". 3 .*\"threadname_3.*\" \[\r\n\]*" { | |
319 | set see3 1 | |
320 | exp_continue | |
321 | } | |
322 | -re ". 2 .*\"threadname_2.*\" \[\r\n\]*" { | |
323 | set see2 1 | |
324 | exp_continue | |
325 | } | |
326 | -re ". 1 .*\"threadname_1.*\" \[\r\n\]*" { | |
327 | set see1 1 | |
328 | exp_continue | |
329 | } | |
330 | -re ".*$gdb_prompt $" { | |
331 | if { $see2 && $see4 && $see6 && !$see1 && !$see3 && !$see5 } then { | |
332 | pass "info threads 2 4 6" | |
333 | } else { | |
334 | fail "info threads 2 4 6" | |
335 | } | |
336 | } | |
337 | } | |
338 | ||
339 | # | |
340 | # Test info threads on a range | |
341 | # | |
342 | ||
343 | set see1 0 | |
344 | set see2 0 | |
345 | set see3 0 | |
346 | set see4 0 | |
347 | set see5 0 | |
348 | set see6 0 | |
349 | ||
350 | gdb_test_multiple "info threads 3-5" "info threads 3-5" { | |
351 | -re ". 6 .*\"threadname_6.*\" \[\r\n\]*" { | |
352 | set see6 1 | |
353 | exp_continue | |
354 | } | |
355 | -re ". 5 .*\"threadname_5.*\" \[\r\n\]*" { | |
356 | set see5 1 | |
357 | exp_continue | |
358 | } | |
359 | -re ". 4 .*\"threadname_4.*\" \[\r\n\]*" { | |
360 | set see4 1 | |
361 | exp_continue | |
362 | } | |
363 | -re ". 3 .*\"threadname_3.*\" \[\r\n\]*" { | |
364 | set see3 1 | |
365 | exp_continue | |
366 | } | |
367 | -re ". 2 .*\"threadname_2.*\" \[\r\n\]*" { | |
368 | set see2 1 | |
369 | exp_continue | |
370 | } | |
371 | -re ". 1 .*\"threadname_1.*\" \[\r\n\]*" { | |
372 | set see1 1 | |
373 | exp_continue | |
374 | } | |
375 | -re ".*$gdb_prompt $" { | |
376 | if { $see3 && $see4 && $see5 && !$see1 && !$see2 && !$see6 } then { | |
377 | pass "info threads 3-5" | |
378 | } else { | |
379 | fail "info threads 3-5" | |
380 | } | |
381 | } | |
382 | } | |
383 | ||
384 | # Test inverted range | |
385 | ||
386 | gdb_test "info threads 5-3" "inverted range" "test inverted range" | |
387 | ||
388 | # Test degenerate range | |
389 | ||
390 | set see1 0 | |
391 | set see2 0 | |
392 | set see3 0 | |
393 | set see4 0 | |
394 | set see5 0 | |
395 | set see6 0 | |
396 | ||
397 | gdb_test_multiple "info threads 3-3" "info threads 3-3" { | |
398 | -re ". 6 .*\"threadname_6.*\" \[\r\n\]*" { | |
399 | set see6 1 | |
400 | exp_continue | |
401 | } | |
402 | -re ". 5 .*\"threadname_5.*\" \[\r\n\]*" { | |
403 | set see5 1 | |
404 | exp_continue | |
405 | } | |
406 | -re ". 4 .*\"threadname_4.*\" \[\r\n\]*" { | |
407 | set see4 1 | |
408 | exp_continue | |
409 | } | |
410 | -re ". 3 .*\"threadname_3.*\" \[\r\n\]*" { | |
411 | set see3 1 | |
412 | exp_continue | |
413 | } | |
414 | -re ". 2 .*\"threadname_2.*\" \[\r\n\]*" { | |
415 | set see2 1 | |
416 | exp_continue | |
417 | } | |
418 | -re ". 1 .*\"threadname_1.*\" \[\r\n\]*" { | |
419 | set see1 1 | |
420 | exp_continue | |
421 | } | |
422 | -re ".*$gdb_prompt $" { | |
423 | if { $see3 && !$see1 && !$see2 && !$see4 && !$see5 && !$see6 } then { | |
424 | pass "info threads 3-3" | |
425 | } else { | |
426 | fail "info threads 3-3" | |
427 | } | |
428 | } | |
429 | } | |
430 |