]>
Commit | Line | Data |
---|---|---|
3666a048 | 1 | # Copyright 2020-2021 Free Software Foundation, Inc. |
e8ef12b9 PA |
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 "thread find" with multiple inferiors/targets. Regression test | |
17 | # for PR gdb/26631. | |
18 | ||
19 | source $srcdir/$subdir/multi-target.exp.tcl | |
20 | ||
21 | if {![multi_target_prepare]} { | |
22 | return | |
23 | } | |
24 | ||
25 | proc test_thread_find {} { | |
26 | global decimal gdb_prompt | |
27 | ||
28 | set NUM_INFS 6 | |
29 | ||
30 | if {![setup "off"]} { | |
31 | untested "setup failed" | |
32 | return | |
33 | } | |
34 | ||
35 | # This makes sure we don't crash. See PR gdb/26631. | |
36 | gdb_test "thread find xxxyyyzzz" \ | |
37 | "No threads match 'xxxyyyzzz'" | |
38 | ||
39 | # Create thread names. | |
40 | for {set i 1} {$i <= $NUM_INFS} {incr i} { | |
41 | gdb_test "thread apply $i.1 thread name threadname_$i" \ | |
42 | "Thread $i.1 .*" \ | |
43 | "name thread $i" | |
44 | } | |
45 | ||
46 | # Collect target ids. | |
47 | ||
48 | for {set i 1} {$i <= $NUM_INFS} {incr i} { | |
49 | set target_id($i) "" | |
50 | } | |
51 | set any "\[^\r\n\]*" | |
52 | gdb_test_multiple "info threads" "collect thread id" { | |
53 | -re ". ($decimal).$decimal (Thread ${any}) \"threadname_\[0-9\]+\" $any" { | |
54 | set thr_num $expect_out(1,string) | |
55 | set target_id($thr_num) $expect_out(2,string) | |
56 | exp_continue | |
57 | } | |
58 | -re ".*$gdb_prompt $" { | |
59 | pass "collect target id" | |
60 | } | |
61 | } | |
62 | ||
63 | # Find the threads by name. Note we repeat the search with each | |
64 | # inferior selected, so that we're sure that GDB doesn't get | |
65 | # confused with which target stack to consult. | |
66 | ||
67 | with_test_prefix "find by name" { | |
68 | for {set sel_inf 1} {$sel_inf <= $NUM_INFS} {incr sel_inf} { | |
69 | with_test_prefix "inf $sel_inf" { | |
70 | ||
71 | gdb_test "inferior $sel_inf" \ | |
72 | "Switching to inferior $sel_inf .*" | |
73 | ||
74 | for {set find_inf 1} {$find_inf <= $NUM_INFS} {incr find_inf} { | |
75 | gdb_test "thread find threadname_$find_inf" \ | |
76 | "Thread $find_inf.1 has name 'threadname_$find_inf'" \ | |
77 | "find thread name $find_inf" | |
78 | } | |
79 | } | |
80 | } | |
81 | } | |
82 | ||
83 | # Find the threads by target id. Likewise we repeat the search | |
84 | # with each inferior selected. | |
85 | ||
86 | with_test_prefix "find by target id" { | |
87 | for {set sel_inf 1} {$sel_inf <= $NUM_INFS} {incr sel_inf} { | |
88 | with_test_prefix "inf $sel_inf" { | |
89 | ||
90 | gdb_test "inferior $sel_inf" \ | |
91 | "Switching to inferior $sel_inf .*" | |
92 | ||
93 | for {set find_inf 1} {$find_inf <= $NUM_INFS} {incr find_inf} { | |
94 | set target_id_re [string_to_regexp $target_id($find_inf)] | |
95 | gdb_test "thread find $target_id($find_inf)" \ | |
96 | "Thread $find_inf.1 has target id '$target_id_re'.*" \ | |
97 | "find thread target id $find_inf" | |
98 | } | |
99 | } | |
100 | } | |
101 | } | |
102 | } | |
103 | ||
104 | test_thread_find | |
105 | ||
106 | multi_target_cleanup |