OSDN Git Service

* remote.c (remote_pid_to_str): If printing a process id and we
authorpalves <palves>
Thu, 13 Aug 2009 18:27:56 +0000 (18:27 +0000)
committerpalves <palves>
Thu, 13 Aug 2009 18:27:56 +0000 (18:27 +0000)
don't know what the remote pid could be, output "Remote target";
otherwise, use normal_pid_to_str.

gdb/ChangeLog
gdb/remote.c

index 7f960f9..0dd69cb 100644 (file)
@@ -1,3 +1,9 @@
+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.
+
 2009-08-13  Tom Tromey  <tromey@redhat.com>
 
        * language.h (longest_raw_hex_string): Remove unused declaration.
index 797f3a6..69d1c5f 100644 (file)
@@ -7835,26 +7835,39 @@ remote_pid_to_str (struct target_ops *ops, ptid_t ptid)
   static char buf[64];
   struct remote_state *rs = get_remote_state ();
 
-  if (ptid_equal (magic_null_ptid, 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;
+  if (ptid_is_pid (ptid))
+    {
+      /* 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