1 # Copyright
2020-2021 Free Software Foundation
, Inc.
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.
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.
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
/>.
16 # Test
"thread find" with multiple inferiors/targets. Regression test
19 source $srcdir
/$subdir
/multi
-target.exp.tcl
21 if {![multi_target_prepare
]} {
25 proc test_thread_find
{} {
26 global decimal gdb_prompt
31 untested
"setup failed"
35 # This makes sure we don
't crash. See PR gdb/26631.
36 gdb_test "thread find xxxyyyzzz" \
37 "No threads match 'xxxyyyzzz
'"
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" \
48 for {set i 1} {$i <= $NUM_INFS} {incr i} {
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)
58 -re ".*$gdb_prompt $" {
59 pass "collect target id"
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.
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" {
71 gdb_test "inferior $sel_inf" \
72 "Switching to inferior $sel_inf .*"
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"
83 # Find the threads by target id. Likewise we repeat the search
84 # with each inferior selected.
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" {
90 gdb_test "inferior $sel_inf" \
91 "Switching to inferior $sel_inf .*"
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"