1 # Copyright 2017-2023 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 "info inferiors" and "info connections" with multiple targets.
18 load_lib gdb-python.exp
20 source $srcdir/$subdir/multi-target.exp.tcl
22 if {![multi_target_prepare]} {
26 # Cache the result of calling allow_python_tests into a local variable.
27 set run_python_tests [allow_python_tests]
29 # Test "info inferiors" and "info connections". MULTI_PROCESS
30 # indicates whether the multi-process feature of remote targets is
32 proc test_info_inferiors {multi_process} {
34 setup "off" $multi_process
36 if { $::run_python_tests } {
37 gdb_test_no_output "source ${::remote_python_file}" "load python file"
40 # Get the description for inferior INF for when the current
41 # inferior id is CURRENT.
42 proc inf_desc {inf current} {
45 upvar multi_process multi_process
47 if {($multi_process == "off") && ($inf == 2 || $inf == 5)} {
48 set desc "Remote target"
50 set desc "process ${decimal}"
53 set desc "${inf}${ws}${desc}${ws}"
54 if {$inf == $current} {
61 # Get the "Num" column for CONNECTION for when the current
62 # inferior id is CURRENT_INF.
63 proc connection_num {connection current_inf} {
65 "4" { set current_connection "1"}
66 "5" { set current_connection "4"}
67 "6" { set current_connection "5"}
68 default { set current_connection $current_inf}
70 if {$connection == $current_connection} {
71 return "\\* $connection"
78 global decimal binfile
80 # Test "info connections" and "info inferior" by switching to each
81 # inferior one by one.
82 for {set inf 1} {$inf <= 6} {incr inf} {
83 with_test_prefix "inferior $inf" {
84 gdb_test "inferior $inf" "Switching to inferior $inf.*"
86 gdb_test "info connections" \
88 "Num${ws}What${ws}Description${ws}" \
89 "[connection_num 1 $inf]${ws}native${ws}Native process${ws}" \
90 "[connection_num 2 $inf]${ws}extended-remote localhost:$decimal${ws}Extended remote target using gdb-specific protocol${ws}" \
91 "[connection_num 3 $inf]${ws}core${ws}Local core dump file${ws}" \
92 "[connection_num 4 $inf]${ws}extended-remote localhost:$decimal${ws}Extended remote target using gdb-specific protocol${ws}" \
93 "[connection_num 5 $inf]${ws}core${ws}Local core dump file${ws}" \
96 if { $::run_python_tests } {
97 gdb_test "python info_connections()" \
99 "Num${ws}What${ws}Description" \
100 "[connection_num 1 $inf]${ws}native${ws}Native process" \
101 "[connection_num 2 $inf]${ws}extended-remote localhost:$decimal${ws}Extended remote target using gdb-specific protocol" \
102 "[connection_num 3 $inf]${ws}core${ws}Local core dump file" \
103 "[connection_num 4 $inf]${ws}extended-remote localhost:$decimal${ws}Extended remote target using gdb-specific protocol" \
104 "[connection_num 5 $inf]${ws}core${ws}Local core dump file" \
108 gdb_test "info inferiors" \
110 "Num${ws}Description${ws}Connection${ws}Executable${ws}" \
111 "[inf_desc 1 $inf]1 \\(native\\)${ws}${binfile}${ws}" \
112 "[inf_desc 2 $inf]2 \\(extended-remote localhost:$decimal\\)${ws}${binfile}${ws}" \
113 "[inf_desc 3 $inf]3 \\(core\\)${ws}${binfile}${ws}" \
114 "[inf_desc 4 $inf]1 \\(native\\)${ws}${binfile}${ws}" \
115 "[inf_desc 5 $inf]4 \\(extended-remote localhost:$decimal\\)${ws}${binfile}${ws}" \
116 "[inf_desc 6 $inf]5 \\(core\\)${ws}${binfile}${ws}" \
119 if { $::run_python_tests } {
120 gdb_test "python info_inferiors()" \
122 "Inferior 1, Connection #1: native" \
123 "Inferior 2, Connection #2: extended-remote localhost:$decimal" \
124 "Inferior 3, Connection #3: core" \
125 "Inferior 4, Connection #1: native" \
126 "Inferior 5, Connection #4: extended-remote localhost:$decimal" \
127 "Inferior 6, Connection #5: core" \
134 if { $run_python_tests } {
135 set remote_python_file [gdb_remote_download host \
136 ${srcdir}/${subdir}/${testfile}.py]
139 # Test "info inferiors" and "info connections" commands.
140 with_test_prefix "info-inferiors" {
141 foreach_with_prefix multi_process {"on" "off"} {
142 test_info_inferiors $multi_process