aboutsummaryrefslogtreecommitdiff
path: root/gdb/inferior.c
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2022-12-14 14:17:44 +0000
committerAndrew Burgess <aburgess@redhat.com>2022-12-15 12:12:08 +0000
commit53cf95c3389a3ecd97276d322e4a60fe3396a201 (patch)
tree3cb108e13d3035ddfcecc985b1d37eed263bc286 /gdb/inferior.c
parentc91a13e4e6790324e2177fa4b98e4637e3b03f97 (diff)
downloadgdb-53cf95c3389a3ecd97276d322e4a60fe3396a201.zip
gdb-53cf95c3389a3ecd97276d322e4a60fe3396a201.tar.gz
gdb-53cf95c3389a3ecd97276d322e4a60fe3396a201.tar.bz2
gdb: make more use of make_target_connection_string
I noticed that we have a function make_target_connection_string which wraps all the logic for creating a string that describes a target connection - but in some places we are not calling this function, instead we duplicate the function's logic. This commit cleans this up, and calls make_target_connection_string where possible. There should be no user visible changes after this commit.
Diffstat (limited to 'gdb/inferior.c')
-rw-r--r--gdb/inferior.c34
1 files changed, 10 insertions, 24 deletions
diff --git a/gdb/inferior.c b/gdb/inferior.c
index ec63e04..3d2bce9 100644
--- a/gdb/inferior.c
+++ b/gdb/inferior.c
@@ -33,6 +33,7 @@
#include "cli/cli-utils.h"
#include "arch-utils.h"
#include "target-descriptions.h"
+#include "target-connection.h"
#include "readline/tilde.h"
#include "progspace-and-thread.h"
#include "gdbsupport/buildargv.h"
@@ -482,21 +483,13 @@ static std::string
uiout_field_connection (process_stratum_target *proc_target)
{
if (proc_target == NULL)
- {
- return {};
- }
- else if (proc_target->connection_string () != NULL)
- {
- return string_printf ("%d (%s %s)",
- proc_target->connection_number,
- proc_target->shortname (),
- proc_target->connection_string ());
- }
+ return {};
else
{
- return string_printf ("%d (%s)",
- proc_target->connection_number,
- proc_target->shortname ());
+ std::string conn_str
+ = make_target_connection_string (proc_target).c_str ();
+ return string_printf ("%d (%s)", proc_target->connection_number,
+ conn_str.c_str ());
}
}
@@ -823,17 +816,10 @@ switch_to_inferior_and_push_target (inferior *new_inf,
if (!no_connection && proc_target != NULL)
{
new_inf->push_target (proc_target);
- if (proc_target->connection_string () != NULL)
- gdb_printf (_("Added inferior %d on connection %d (%s %s)\n"),
- new_inf->num,
- proc_target->connection_number,
- proc_target->shortname (),
- proc_target->connection_string ());
- else
- gdb_printf (_("Added inferior %d on connection %d (%s)\n"),
- new_inf->num,
- proc_target->connection_number,
- proc_target->shortname ());
+ gdb_printf (_("Added inferior %d on connection %d (%s)\n"),
+ new_inf->num,
+ proc_target->connection_number,
+ make_target_connection_string (proc_target).c_str ());
}
else
gdb_printf (_("Added inferior %d\n"), new_inf->num);