This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[remote/commit] Don't let the magic 42000 pid show through when printing an inferior target id.


This pending multi-process patch that I've been posting for
a while, initialy here: <http://sourceware.org/ml/gdb-patches/2008-11/msg00291.html>
would let the remote target's magic 42000 pid show through:

A debugging session is active.

        Inferior 1 [process 42000] will be killed.

Do you still want to close the debugger? (y or n)  

This patch makes it so that when that other patch is
applied, we get this instead:

A debugging session is active.

        Inferior 1 [Remote target] will be killed.

Do you still want to close the debugger? (y or n)  

42000 is still visible in the "info inferiors" command though.
That will be fixed with the pending multi-exec patch(es), which
make the "info inferiors" command call target_pid_to_str instead of
printing the raw pid.

Tested against a local x86_64-unknown-linux-gnu
gdbserver and checked in.

-- 
Pedro Alves

2009-08-13  Pedro Alves  <pedro@codesourcery.com>

	* remote.c (remote_pid_to_str): If printing a process id and we
	don't know what the remote pid could be, output "Remote target";
	otherwise, use normal_pid_to_str.

---
 gdb/remote.c |   43 ++++++++++++++++++++++++++++---------------
 1 file changed, 28 insertions(+), 15 deletions(-)

Index: src/gdb/remote.c
===================================================================
--- src.orig/gdb/remote.c	2009-08-13 19:19:15.000000000 +0100
+++ src/gdb/remote.c	2009-08-13 19:21:41.000000000 +0100
@@ -7835,26 +7835,39 @@ remote_pid_to_str (struct target_ops *op
   static char buf[64];
   struct remote_state *rs = get_remote_state ();
 
-  if (ptid_equal (magic_null_ptid, ptid))
+  if (ptid_is_pid (ptid))
     {
-      xsnprintf (buf, sizeof buf, "Thread <main>");
-      return buf;
-    }
-  else if (remote_multi_process_p (rs)
-	   && ptid_get_tid (ptid) != 0 && ptid_get_pid (ptid) != 0)
-    {
-      xsnprintf (buf, sizeof buf, "Thread %d.%ld",
-		 ptid_get_pid (ptid), ptid_get_tid (ptid));
-      return buf;
+      /* Printing an inferior target id.  */
+
+      /* When multi-process extensions are off, there's no way in the
+	 remote protocol to know the remote process id, if there's any
+	 at all.  There's one exception --- when we're connected with
+	 target extended-remote, and we manually attached to a process
+	 with "attach PID".  We don't record anywhere a flag that
+	 allows us to distinguish that case from the case of
+	 connecting with extended-remote and the stub already being
+	 attached to a process, and reporting yes to qAttached, hence
+	 no smart special casing here.  */
+      if (!remote_multi_process_p (rs))
+	{
+	  xsnprintf (buf, sizeof buf, "Remote target");
+	  return buf;
+	}
+
+      return normal_pid_to_str (ptid);
     }
-  else if (ptid_get_tid (ptid) != 0)
+  else
     {
-      xsnprintf (buf, sizeof buf, "Thread %ld",
-		 ptid_get_tid (ptid));
+      if (ptid_equal (magic_null_ptid, ptid))
+	xsnprintf (buf, sizeof buf, "Thread <main>");
+      else if (remote_multi_process_p (rs))
+	xsnprintf (buf, sizeof buf, "Thread %d.%ld",
+		   ptid_get_pid (ptid), ptid_get_tid (ptid));
+      else
+	xsnprintf (buf, sizeof buf, "Thread %ld",
+		   ptid_get_tid (ptid));
       return buf;
     }
-
-  return normal_pid_to_str (ptid);
 }
 
 /* Get the address of the thread local variable in OBJFILE which is


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]