From db2b9fdd4f883c597bb5707b8a5d6e55d2406323 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Fri, 10 Feb 2012 14:23:52 +0000 Subject: [PATCH] 2012-02-10 Pedro Alves * inferior.c (inferior_pid_to_str): New. (print_inferior, inferior_command): Use it. --- gdb/ChangeLog | 5 +++++ gdb/inferior.c | 21 +++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9cf37d566a2..41c32b9671a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2012-02-10 Pedro Alves + + * inferior.c (inferior_pid_to_str): New. + (print_inferior, inferior_command): Use it. + 2012-02-10 Pedro Alves * configure.ac (HAVE_ELF test): Put the old CFLAGS at the end of diff --git a/gdb/inferior.c b/gdb/inferior.c index 4df8c774627..51748a9ee56 100644 --- a/gdb/inferior.c +++ b/gdb/inferior.c @@ -526,6 +526,18 @@ number_of_inferiors (void) return count; } +/* Converts an inferior process id to a string. Like + target_pid_to_str, but special cases the null process. */ + +static char * +inferior_pid_to_str (int pid) +{ + if (pid != 0) + return target_pid_to_str (pid_to_ptid (pid)); + else + return _(""); +} + /* Prints the list of inferiors and their details on UIOUT. This is a version of 'info_inferior_command' suitable for use from MI. @@ -579,11 +591,8 @@ print_inferior (struct ui_out *uiout, char *requested_inferiors) ui_out_field_int (uiout, "number", inf->num); - if (inf->pid) - ui_out_field_string (uiout, "target-id", - target_pid_to_str (pid_to_ptid (inf->pid))); - else - ui_out_field_string (uiout, "target-id", ""); + ui_out_field_string (uiout, "target-id", + inferior_pid_to_str (inf->pid)); if (inf->pspace->ebfd) ui_out_field_string (uiout, "exec", @@ -700,7 +709,7 @@ inferior_command (char *args, int from_tty) printf_filtered (_("[Switching to inferior %d [%s] (%s)]\n"), inf->num, - target_pid_to_str (pid_to_ptid (inf->pid)), + inferior_pid_to_str (inf->pid), (inf->pspace->ebfd ? bfd_get_filename (inf->pspace->ebfd) : _(""))); -- 2.30.2