From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21090 invoked by alias); 12 Feb 2014 14:07:06 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 20908 invoked by uid 89); 12 Feb 2014 14:07:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 12 Feb 2014 14:07:04 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s1CE73Nc005553 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 12 Feb 2014 09:07:03 -0500 Received: from brno.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s1CE70rG012701 for ; Wed, 12 Feb 2014 09:07:02 -0500 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 1/2] remote.c: Use the ptid.lwp field to store remote thread ids rather than ptid.tid. Date: Wed, 12 Feb 2014 14:07:00 -0000 Message-Id: <1392214020-21478-2-git-send-email-palves@redhat.com> In-Reply-To: <1392214020-21478-1-git-send-email-palves@redhat.com> References: <1392214020-21478-1-git-send-email-palves@redhat.com> X-SW-Source: 2014-02/txt/msg00412.txt.bz2 >From GDB's perspective, independently of how the target really implements threads, gdb/remote sees all threads as if kernel/system threads. A rationale along theses lines led to gdbserver storing thread ids in ptid.lwp in all ports. I believe that on the GDB side too, it's best that we standardize on process_stratum targets using the ptid.lwp field to store thread ids. The idea being leave the ptid.tid field free for any thread_stratum target that might want to sit on top. Because remote.c is currently using ptid.tid, we can't make gdbserver and gdb share bits of remote-specific code that manipulates ptids. This patch thus makes remote.c use ptid.lwp instead of ptid.tid. Tested on x86_64 Fedora 17, w/ local gdbserver. gdb/ 2014-02-12 Pedro Alves * remote.c (remote_thread_alive, write_ptid, read_ptid) (read_ptid, remote_newthread_step, remote_threads_extra_info) (remote_get_ada_task_ptid, append_resumption, remote_stop_ns) (threadalive_test, remote_pid_to_str, _initialize_remote): Use the ptid.lwp field to store remote thread ids rather than ptid.tid. --- gdb/remote.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/gdb/remote.c b/gdb/remote.c index eff4c44..02f2669 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -1877,7 +1877,7 @@ remote_thread_alive (struct target_ops *ops, ptid_t ptid) /* The main thread is always alive. */ return 1; - if (ptid_get_pid (ptid) != 0 && ptid_get_tid (ptid) == 0) + if (ptid_get_pid (ptid) != 0 && ptid_get_lwp (ptid) == 0) /* The main thread is always alive. This can happen after a vAttach, if the remote side doesn't support multi-threading. */ @@ -2021,7 +2021,7 @@ write_ptid (char *buf, const char *endbuf, ptid_t ptid) else buf += xsnprintf (buf, endbuf - buf, "p%x.", pid); } - tid = ptid_get_tid (ptid); + tid = ptid_get_lwp (ptid); if (tid < 0) buf += xsnprintf (buf, endbuf - buf, "-%x", -tid); else @@ -2051,7 +2051,7 @@ read_ptid (char *buf, char **obuf) pp = unpack_varlen_hex (p + 1, &tid); if (obuf) *obuf = pp; - return ptid_build (pid, 0, tid); + return ptid_build (pid, tid, 0); } /* No multi-process. Just a tid. */ @@ -2068,7 +2068,7 @@ read_ptid (char *buf, char **obuf) if (obuf) *obuf = pp; - return ptid_build (pid, 0, tid); + return ptid_build (pid, tid, 0); } /* Encode 64 bits in 16 chars of hex. */ @@ -2618,7 +2618,7 @@ static int remote_newthread_step (threadref *ref, void *context) { int pid = ptid_get_pid (inferior_ptid); - ptid_t ptid = ptid_build (pid, 0, threadref_to_int (ref)); + ptid_t ptid = ptid_build (pid, threadref_to_int (ref), 0); if (!in_thread_list (ptid)) add_thread (ptid); @@ -2887,7 +2887,7 @@ remote_threads_extra_info (struct thread_info *tp) _("remote_threads_extra_info")); if (ptid_equal (tp->ptid, magic_null_ptid) - || (ptid_get_pid (tp->ptid) != 0 && ptid_get_tid (tp->ptid) == 0)) + || (ptid_get_pid (tp->ptid) != 0 && ptid_get_lwp (tp->ptid) == 0)) /* This is the main thread which was added by GDB. The remote server doesn't know about it. */ return NULL; @@ -2926,7 +2926,7 @@ remote_threads_extra_info (struct thread_info *tp) rs->use_threadextra_query = 0; set = TAG_THREADID | TAG_EXISTS | TAG_THREADNAME | TAG_MOREDISPLAY | TAG_DISPLAY; - int_to_threadref (&id, ptid_get_tid (tp->ptid)); + int_to_threadref (&id, ptid_get_lwp (tp->ptid)); if (remote_get_threadinfo (&id, set, &threadinfo)) if (threadinfo.active) { @@ -3035,7 +3035,7 @@ remote_static_tracepoint_markers_by_strid (const char *strid) static ptid_t remote_get_ada_task_ptid (long lwp, long thread) { - return ptid_build (ptid_get_pid (inferior_ptid), 0, lwp); + return ptid_build (ptid_get_pid (inferior_ptid), lwp, 0); } @@ -4847,7 +4847,7 @@ append_resumption (char *p, char *endp, ptid_t nptid; /* All (-1) threads of process. */ - nptid = ptid_build (ptid_get_pid (ptid), 0, -1); + nptid = ptid_build (ptid_get_pid (ptid), -1, 0); p += xsnprintf (p, endp - p, ":"); p = write_ptid (p, endp, nptid); @@ -5162,7 +5162,7 @@ remote_stop_ns (ptid_t ptid) if (ptid_is_pid (ptid)) /* All (-1) threads of process. */ - nptid = ptid_build (ptid_get_pid (ptid), 0, -1); + nptid = ptid_build (ptid_get_pid (ptid), -1, 0); else { /* Small optimization: if we already have a stop reply for @@ -9314,7 +9314,7 @@ threadalive_test (char *cmd, int tty) { int sample_thread = SAMPLE_THREAD; int pid = ptid_get_pid (inferior_ptid); - ptid_t ptid = ptid_build (pid, 0, sample_thread); + ptid_t ptid = ptid_build (pid, sample_thread, 0); if (remote_thread_alive (ptid)) printf_filtered ("PASS: Thread alive test\n"); @@ -9462,10 +9462,10 @@ remote_pid_to_str (struct target_ops *ops, ptid_t ptid) xsnprintf (buf, sizeof buf, "Thread
"); else if (rs->extended && remote_multi_process_p (rs)) xsnprintf (buf, sizeof buf, "Thread %d.%ld", - ptid_get_pid (ptid), ptid_get_tid (ptid)); + ptid_get_pid (ptid), ptid_get_lwp (ptid)); else xsnprintf (buf, sizeof buf, "Thread %ld", - ptid_get_tid (ptid)); + ptid_get_lwp (ptid)); return buf; } } @@ -12318,11 +12318,11 @@ stepping is supported by the target. The default is on."), /* Eventually initialize fileio. See fileio.c */ initialize_remote_fileio (remote_set_cmdlist, remote_show_cmdlist); - /* Take advantage of the fact that the LWP field is not used, to tag + /* Take advantage of the fact that the TID field is not used, to tag special ptids with it set to != 0. */ - magic_null_ptid = ptid_build (42000, 1, -1); - not_sent_ptid = ptid_build (42000, 1, -2); - any_thread_ptid = ptid_build (42000, 1, 0); + magic_null_ptid = ptid_build (42000, -1, 1); + not_sent_ptid = ptid_build (42000, -2, 1); + any_thread_ptid = ptid_build (42000, 0, 1); target_buf_size = 2048; target_buf = xmalloc (target_buf_size); -- 1.7.11.7