]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.multi/multi-target-info-inferiors.exp
gdb: Make global feature array a per-remote target array
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.multi / multi-target-info-inferiors.exp
1 # Copyright 2017-2023 Free Software Foundation, Inc.
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 "info inferiors" and "info connections" with multiple targets.
17
18 load_lib gdb-python.exp
19
20 source $srcdir/$subdir/multi-target.exp.tcl
21
22 if {![multi_target_prepare]} {
23 return
24 }
25
26 # Cache the result of calling allow_python_tests into a local variable.
27 set run_python_tests [allow_python_tests]
28
29 # Test "info inferiors" and "info connections". MULTI_PROCESS
30 # indicates whether the multi-process feature of remote targets is
31 # turned off or on.
32 proc test_info_inferiors {multi_process} {
33
34 setup "off" $multi_process
35
36 if { $::run_python_tests } {
37 gdb_test_no_output "source ${::remote_python_file}" "load python file"
38 }
39
40 # Get the description for inferior INF for when the current
41 # inferior id is CURRENT.
42 proc inf_desc {inf current} {
43 set ws "\[ \t\]+"
44 global decimal
45 upvar multi_process multi_process
46
47 if {($multi_process == "off") && ($inf == 2 || $inf == 5)} {
48 set desc "Remote target"
49 } else {
50 set desc "process ${decimal}"
51 }
52
53 set desc "${inf}${ws}${desc}${ws}"
54 if {$inf == $current} {
55 return "\\* $desc"
56 } else {
57 return " $desc"
58 }
59 }
60
61 # Get the "Num" column for CONNECTION for when the current
62 # inferior id is CURRENT_INF.
63 proc connection_num {connection current_inf} {
64 switch $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}
69 }
70 if {$connection == $current_connection} {
71 return "\\* $connection"
72 } else {
73 return " $connection"
74 }
75 }
76
77 set ws "\[ \t\]+"
78 global decimal binfile
79
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.*"
85
86 gdb_test "info connections" \
87 [multi_line \
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}" \
94 ]
95
96 if { $::run_python_tests } {
97 gdb_test "python info_connections()" \
98 [multi_line \
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" \
105 ]
106 }
107
108 gdb_test "info inferiors" \
109 [multi_line \
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}" \
117 ]
118
119 if { $::run_python_tests } {
120 gdb_test "python info_inferiors()" \
121 [multi_line \
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" \
128 ]
129 }
130 }
131 }
132 }
133
134 if { $run_python_tests } {
135 set remote_python_file [gdb_remote_download host \
136 ${srcdir}/${subdir}/${testfile}.py]
137 }
138
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
143 }
144 }
145
146 multi_target_cleanup