2008-10-23 Michael Snyder Pedro Alves * remote.c (remote_thread_alive): Emit leading zeros in the single-process case to preserve remote protocol behavior. --- gdb/remote.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) Index: src/gdb/remote.c =================================================================== --- src.orig/gdb/remote.c 2008-10-23 15:57:07.000000000 +0100 +++ src/gdb/remote.c 2008-10-23 16:30:19.000000000 +0100 @@ -1279,8 +1279,6 @@ static int remote_thread_alive (ptid_t ptid) { struct remote_state *rs = get_remote_state (); - int tid = ptid_get_tid (ptid); - char *p, *endp; if (ptid_equal (ptid, magic_null_ptid)) /* The main thread is always alive. */ @@ -1292,11 +1290,29 @@ remote_thread_alive (ptid_t ptid) multi-threading. */ return 1; - p = rs->buf; - endp = rs->buf + get_remote_packet_size (); + /* Note: We don't use write_ptid unconditionally here, since it + doesn't output leading zeros (%08x below). Although nothing in + the docs suggests that the leading zeros are required, there's no + reason to break backwards compatibility, in case stubs are + relying on them being present. */ + if (!remote_multi_process_p (rs)) + { + int tid = ptid_get_tid (ptid); + + if (tid < 0) + xsnprintf (rs->buf, get_remote_packet_size (), "T-%08x", -tid); + else + xsnprintf (rs->buf, get_remote_packet_size (), "T%08x", tid); + } + else + { + char *p, *endp; - *p++ = 'T'; - write_ptid (p, endp, ptid); + p = rs->buf; + endp = rs->buf + get_remote_packet_size (); + *p++ = 'T'; + write_ptid (p, endp, ptid); + } putpkt (rs->buf); getpkt (&rs->buf, &rs->buf_size, 0);