[1/6] Tweak "Using the running image of ..." output

Message ID 20221203211338.2264994-2-pedro@palves.net
State Committed
Commit fb6d30e013edc16cc830447a7115c0a5189f753f
Headers
Series Eliminate infrun_thread_thread_exit observer |

Commit Message

Pedro Alves Dec. 3, 2022, 9:13 p.m. UTC
  Currently, "info files" and "info program" on a few native targets
show:

 (gdb) info files
 Symbols from "/home/pedro/gdb/tests/threads".
 Native process:
	 Using the running image of child Thread 0x7ffff7d89740 (LWP 1097968).
					  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 ...

 (gdb) info program
	 Using the running image of child Thread 0x7ffff7d89740 (LWP 1097968).
					  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 Program stopped at 0x555555555278.
 ...


This patch changes them to:

 (gdb) info files
 Symbols from "/home/pedro/gdb/tests/threads".
 Native process:
	 Using the running image of child process 1097968.
	                                  ^^^^^^^^^^^^^^^
 ...

 (gdb) info program
	 Using the running image of child process 1097968.
	                                  ^^^^^^^^^^^^^^^
 Program stopped at 0x555555555278.
 ...


... which I think makes a lot more sense in this context.  The "info
program" manual entry even says:

  "Display information about the status of your program: whether it is
   running or not, what process it is, and why it stopped."
                        ^^^^^^^^^^^^^

This change affects ptrace targets, procfs targets, and Windows.

Change-Id: I6aab061ff494a84ba3398cf98fd49efd7a6ec1ca
---
 gdb/inf-ptrace.c  | 2 +-
 gdb/nto-procfs.c  | 2 +-
 gdb/procfs.c      | 2 +-
 gdb/windows-nat.c | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
  

Comments

Simon Marchi Dec. 8, 2022, 9:30 p.m. UTC | #1
On 12/3/22 16:13, Pedro Alves wrote:
> Currently, "info files" and "info program" on a few native targets
> show:
> 
>  (gdb) info files
>  Symbols from "/home/pedro/gdb/tests/threads".
>  Native process:
> 	 Using the running image of child Thread 0x7ffff7d89740 (LWP 1097968).
> 					  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>  ...
> 
>  (gdb) info program
> 	 Using the running image of child Thread 0x7ffff7d89740 (LWP 1097968).
> 					  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>  Program stopped at 0x555555555278.
>  ...
> 
> 
> This patch changes them to:
> 
>  (gdb) info files
>  Symbols from "/home/pedro/gdb/tests/threads".
>  Native process:
> 	 Using the running image of child process 1097968.
> 	                                  ^^^^^^^^^^^^^^^
>  ...
> 
>  (gdb) info program
> 	 Using the running image of child process 1097968.
> 	                                  ^^^^^^^^^^^^^^^
>  Program stopped at 0x555555555278.
>  ...
> 
> 
> ... which I think makes a lot more sense in this context.  The "info
> program" manual entry even says:
> 
>   "Display information about the status of your program: whether it is
>    running or not, what process it is, and why it stopped."
>                         ^^^^^^^^^^^^^
> 
> This change affects ptrace targets, procfs targets, and Windows.
> 
> Change-Id: I6aab061ff494a84ba3398cf98fd49efd7a6ec1ca
> ---
>  gdb/inf-ptrace.c  | 2 +-
>  gdb/nto-procfs.c  | 2 +-
>  gdb/procfs.c      | 2 +-
>  gdb/windows-nat.c | 2 +-
>  4 files changed, 4 insertions(+), 4 deletions(-)

Approved-By: Simon Marchi <simon.marchi@efficios.com>

Simon
  

Patch

diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c
index ab669a7acc2..ade07f41ef4 100644
--- a/gdb/inf-ptrace.c
+++ b/gdb/inf-ptrace.c
@@ -522,7 +522,7 @@  inf_ptrace_target::files_info ()
 
   gdb_printf (_("\tUsing the running image of %s %s.\n"),
 	      inf->attach_flag ? "attached" : "child",
-	      target_pid_to_str (inferior_ptid).c_str ());
+	      target_pid_to_str (ptid_t (inf->pid)).c_str ());
 }
 
 std::string
diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c
index 4a2968ea179..fe9aa8dabfa 100644
--- a/gdb/nto-procfs.c
+++ b/gdb/nto-procfs.c
@@ -658,7 +658,7 @@  nto_procfs_target::files_info ()
 
   gdb_printf ("\tUsing the running image of %s %s via %s.\n",
 	      inf->attach_flag ? "attached" : "child",
-	      target_pid_to_str (inferior_ptid).c_str (),
+	      target_pid_to_str (ptid_t (inf->pid)).c_str (),
 	      (nodestr != NULL) ? nodestr : "local node");
 }
 
diff --git a/gdb/procfs.c b/gdb/procfs.c
index ac3d60ebf1c..ffc26c8fb9e 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -2533,7 +2533,7 @@  procfs_target::files_info ()
 
   gdb_printf (_("\tUsing the running image of %s %s via /proc.\n"),
 	      inf->attach_flag? "attached": "child",
-	      target_pid_to_str (inferior_ptid).c_str ());
+	      target_pid_to_str (ptid_t (inf->pid)).c_str ());
 }
 
 /* Make it die.  Wait for it to die.  Clean up after it.  Note: this
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index b3329cd1a0d..ee4e78bdabf 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -2157,7 +2157,7 @@  windows_nat_target::files_info ()
 
   gdb_printf ("\tUsing the running image of %s %s.\n",
 	      inf->attach_flag ? "attached" : "child",
-	      target_pid_to_str (inferior_ptid).c_str ());
+	      target_pid_to_str (ptid_t (inf->pid)).c_str ());
 }
 
 /* Modify CreateProcess parameters for use of a new separate console.