]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.mi/list-thread-groups-available.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.mi / list-thread-groups-available.exp
CommitLineData
1d506c26 1# Copyright 2017-2024 Free Software Foundation, Inc.
4c71c105
SM
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 that -list-thread-groups --available works.
17
18load_lib mi-support.exp
19set MIFLAGS "-i=mi"
20
21standard_testfile
22
50ab6ace 23# Support for XML is needed to run this test.
b963a97f 24require allow_xml_test
eacd2289 25require can_spawn_for_attach
50ab6ace 26
4c71c105
SM
27if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
28 untested "failed to compile"
29 return -1
30}
31
32if [mi_gdb_start] {
cdd42066 33 return
4c71c105
SM
34}
35
4c71c105
SM
36set string_re {(?:[^\\"]|\\.)*}
37
38set id_re "id=\"$decimal\""
39set type_re "type=\"process\""
40set description_re "description=\"$string_re\""
41set user_re "user=\"$string_re\""
67943c00
AB
42
43# The CORES_RE regexp allows a process to be running on zero or more
44# cores. The former can happen if a process exits while GDB is
45# reading information out of /proc.
46set cores_re "cores=\\\[(\"$decimal\"(,\"$decimal\")*)?\\\]"
4c71c105
SM
47
48# List all available processes.
49set process_entry_re "{${id_re},${type_re}(,$description_re)?(,$user_re)?(,$cores_re)?}"
50
9223170f
SM
51# The list can be long, so read entries one by one to avoid hitting the
52# timeout (especially when running with check-read1).
1ef44e86
TV
53set cmd "-list-thread-groups --available"
54set test "list available thread groups"
55gdb_test_multiple $cmd $test -prompt "$mi_gdb_prompt" {
9223170f
SM
56 -re "\\^done,groups=\\\[" {
57 # The beginning of the response.
58 exp_continue
59 }
60
61 -re "${process_entry_re}," {
62 # All entries except the last one.
63 exp_continue
64 }
65
66 -re "${process_entry_re}\\\]\r\n${mi_gdb_prompt}" {
67 # The last entry.
68 pass $gdb_test_name
69 }
1ef44e86 70}
4c71c105
SM
71
72# List specific processes, make sure there are two entries.
73set spawn_id_1 [remote_spawn target $binfile]
74set pid_1 [spawn_id_get_pid $spawn_id_1]
75set id_re_1 "id=\"$pid_1\""
76
77set spawn_id_2 [remote_spawn target $binfile]
78set pid_2 [spawn_id_get_pid $spawn_id_2]
79set id_re_2 "id=\"$pid_2\""
80
67943c00
AB
81# Unlike the earlier CORES_RE this list must contain at least one
82# core. Given that we know these processes will not exit while GDB is
83# reading their information from /proc we can expect at least one core
84# for each process.
85set cores_re "cores=\\\[\"$decimal\"(,\"$decimal\")*\\\]"
86
4c71c105
SM
87set process_entry_re_1 "{${id_re_1},${type_re}(,$description_re)?(,$user_re)?(,$cores_re)?}"
88set process_entry_re_2 "{${id_re_2},${type_re}(,$description_re)?(,$user_re)?(,$cores_re)?}"
89
90set process_list_re "(${process_entry_re_1},${process_entry_re_2}|${process_entry_re_2},${process_entry_re_1})"
91
92mi_gdb_test \
93 "-list-thread-groups --available i${pid_1} i${pid_2}" \
94 "\\^done,groups=\\\[${process_list_re}\\\]" \
95 "list available thread groups with filter"
96
97kill_wait_spawned_process $spawn_id_1
98kill_wait_spawned_process $spawn_id_2