Commit | Line | Data |
---|---|---|
88b9d363 | 1 | # Copyright 2017-2022 Free Software Foundation, Inc. |
e11daf7a 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 "info inferiors" and "info connections" with multiple targets. | |
17 | ||
18 | source $srcdir/$subdir/multi-target.exp.tcl | |
19 | ||
20 | if {![multi_target_prepare]} { | |
21 | return | |
22 | } | |
23 | ||
24 | # Test "info inferiors" and "info connections". MULTI_PROCESS | |
25 | # indicates whether the multi-process feature of remote targets is | |
26 | # turned off or on. | |
27 | proc test_info_inferiors {multi_process} { | |
28 | setup "off" | |
29 | ||
30 | gdb_test_no_output \ | |
31 | "set remote multiprocess-feature-packet $multi_process" | |
32 | ||
33 | # Get the description for inferior INF for when the current | |
34 | # inferior id is CURRENT. | |
35 | proc inf_desc {inf current} { | |
36 | set ws "\[ \t\]+" | |
37 | global decimal | |
38 | upvar multi_process multi_process | |
39 | ||
40 | if {($multi_process == "off") && ($inf == 2 || $inf == 5)} { | |
41 | set desc "Remote target" | |
42 | } else { | |
43 | set desc "process ${decimal}" | |
44 | } | |
45 | ||
46 | set desc "${inf}${ws}${desc}${ws}" | |
47 | if {$inf == $current} { | |
48 | return "\\* $desc" | |
49 | } else { | |
50 | return " $desc" | |
51 | } | |
52 | } | |
53 | ||
54 | # Get the "Num" column for CONNECTION for when the current | |
55 | # inferior id is CURRENT_INF. | |
56 | proc connection_num {connection current_inf} { | |
57 | switch $current_inf { | |
58 | "4" { set current_connection "1"} | |
59 | "5" { set current_connection "4"} | |
60 | "6" { set current_connection "5"} | |
61 | default { set current_connection $current_inf} | |
62 | } | |
63 | if {$connection == $current_connection} { | |
64 | return "\\* $connection" | |
65 | } else { | |
66 | return " $connection" | |
67 | } | |
68 | } | |
69 | ||
70 | set ws "\[ \t\]+" | |
71 | global decimal binfile | |
72 | ||
73 | # Test "info connections" and "info inferior" by switching to each | |
74 | # inferior one by one. | |
75 | for {set inf 1} {$inf <= 6} {incr inf} { | |
76 | with_test_prefix "inferior $inf" { | |
77 | gdb_test "inferior $inf" "Switching to inferior $inf.*" | |
78 | ||
79 | gdb_test "info connections" \ | |
80 | [multi_line \ | |
81 | "Num${ws}What${ws}Description${ws}" \ | |
82 | "[connection_num 1 $inf]${ws}native${ws}Native process${ws}" \ | |
83 | "[connection_num 2 $inf]${ws}extended-remote localhost:$decimal${ws}Extended remote serial target in gdb-specific protocol${ws}" \ | |
84 | "[connection_num 3 $inf]${ws}core${ws}Local core dump file${ws}" \ | |
85 | "[connection_num 4 $inf]${ws}extended-remote localhost:$decimal${ws}Extended remote serial target in gdb-specific protocol${ws}" \ | |
86 | "[connection_num 5 $inf]${ws}core${ws}Local core dump file${ws}" \ | |
87 | ] | |
88 | ||
89 | gdb_test "info inferiors" \ | |
90 | [multi_line \ | |
91 | "Num${ws}Description${ws}Connection${ws}Executable${ws}" \ | |
92 | "[inf_desc 1 $inf]1 \\(native\\)${ws}${binfile}${ws}" \ | |
93 | "[inf_desc 2 $inf]2 \\(extended-remote localhost:$decimal\\)${ws}${binfile}${ws}" \ | |
94 | "[inf_desc 3 $inf]3 \\(core\\)${ws}${binfile}${ws}" \ | |
95 | "[inf_desc 4 $inf]1 \\(native\\)${ws}${binfile}${ws}" \ | |
96 | "[inf_desc 5 $inf]4 \\(extended-remote localhost:$decimal\\)${ws}${binfile}${ws}" \ | |
97 | "[inf_desc 6 $inf]5 \\(core\\)${ws}${binfile}${ws}" \ | |
98 | ] | |
99 | } | |
100 | } | |
101 | } | |
102 | ||
103 | # Test "info inferiors" and "info connections" commands. | |
104 | with_test_prefix "info-inferiors" { | |
105 | foreach_with_prefix multi_process {"on" "off"} { | |
106 | test_info_inferiors $multi_process | |
107 | } | |
108 | } | |
109 | ||
110 | multi_target_cleanup |