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