From ecd0ada520284724373d81f3580cf1e15855b737 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Thu, 13 Aug 2009 18:27:56 +0000 Subject: [PATCH] * 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/ChangeLog | 6 ++++++ gdb/remote.c | 45 +++++++++++++++++++++++++++++---------------- 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 7f960f90a83..0dd69cbeeb8 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2009-08-13 Pedro Alves + + * 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 * language.h (longest_raw_hex_string): Remove unused declaration. diff --git a/gdb/remote.c b/gdb/remote.c index 797f3a63b93..69d1c5ffec9 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -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
"); - 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
"); + 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 -- 2.30.2