]>
git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.multi/multi-target-info-inferiors.py
1 # Copyright (C) 2021-2024 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/>.
19 # Take a gdb.TargetConnection and return the connection number.
24 # Takes a gdb.TargetConnection and return a string that is either the
25 # type, or the type and details (if the details are not None).
26 def make_target_connection_string(c
):
30 return "%s %s" % (c
.type, c
.details
)
33 # A Python implementation of 'info connections'. Produce output that
34 # is identical to the output of 'info connections' so we can check
35 # that aspects of gdb.TargetConnection work correctly.
36 def info_connections():
37 all_connections
= sorted(gdb
.connections(), key
=conn_num
)
38 current_conn
= gdb
.selected_inferior().connection
40 for c
in all_connections
:
41 s
= make_target_connection_string(c
)
42 if len(s
) > what_width
:
45 fmt
= " Num %%-%ds Description" % what_width
47 fmt
= "%%s%%-3d %%-%ds %%s" % what_width
48 for c
in all_connections
:
54 print(fmt
% (prefix
, c
.num
, make_target_connection_string(c
), c
.description
))
61 # Print information about each inferior, and the connection it is
64 all_inferiors
= sorted(gdb
.inferiors(), key
=inf_num
)
65 for i
in gdb
.inferiors():
67 "Inferior %d, Connection #%d: %s"
68 % (i
.num
, i
.connection_num
, make_target_connection_string(i
.connection
))