Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [rfa] Include the LWP in thread-db's PTIDs
@ 2004-10-10 21:36 Daniel Jacobowitz
  2004-10-11 15:29 ` Andrew Cagney
  2004-11-14 19:17 ` Daniel Jacobowitz
  0 siblings, 2 replies; 17+ messages in thread
From: Daniel Jacobowitz @ 2004-10-10 21:36 UTC (permalink / raw)
  To: gdb-patches, msnyder

At one time, I believe that thread-db.c was planned to support the full
range of features supported by the libthread_db interface, presumably as
defined by Sun's implementation.  That never panned out, and while non-1:1
support did work at one point, I don't think it has in a long while.  If it
was wanted, I wouldn't re-implement it the same way.  So this patch begins
the process of removing unneeded generality from thread-db.  In particular,
while thread-db will still compute the TID, the mapping of threads to LWPs
will be considered fixed.

My goal is to have a GNU/Linux target vector, whose entry points call into
thread-db when necessary, instead of having a thread-db wrapper around all
the GNU/Linux methods.  One of the things this will fix is the need for two
separate versions of the GNU/Linux native wait() code - we will always use
the multi-threaded-aware version.  Another thing it will fix is a bug in the
fork-following code which tries to find the LWP from a thread ID.

This patch tested on i686-pc-linux-gnu using NPTL; no regressions. OK?

-- 
Daniel Jacobowitz

2004-10-10  Daniel Jacobowitz  <dan@debian.org>

	* thread-db.c (BUILD_THREAD): Delete.
	(thread_get_info_callback): Include LWP ID in thread ID.
	(thread_from_lwp, check_event, find_new_threads_callback): Likewise.
	(lwp_from_thread): Use the LWP ID from the thread ID.

Index: thread-db.c
===================================================================
RCS file: /cvs/src/src/gdb/thread-db.c,v
retrieving revision 1.46
diff -u -p -r1.46 thread-db.c
--- thread-db.c	8 Oct 2004 20:29:56 -0000	1.46
+++ thread-db.c	10 Oct 2004 21:23:44 -0000
@@ -143,7 +143,6 @@ static void detach_thread (ptid_t ptid, 
 #define is_thread(ptid)		(GET_THREAD (ptid) != 0)
 
 #define BUILD_LWP(lwp, pid)	ptid_build (pid, lwp, 0)
-#define BUILD_THREAD(tid, pid)	ptid_build (pid, 0, tid)
 \f
 
 /* Use "struct private_thread_info" to cache thread state.  This is
@@ -267,7 +266,7 @@ thread_get_info_callback (const td_thrha
 	   thread_db_err_str (err));
 
   /* Fill the cache.  */
-  thread_ptid = BUILD_THREAD (ti.ti_tid, GET_PID (inferior_ptid));
+  thread_ptid = ptid_build (GET_PID (inferior_ptid), ti.ti_lid, ti.ti_tid);
   thread_info = find_thread_pid (thread_ptid);
 
   /* In the case of a zombie thread, don't continue.  We don't want to
@@ -385,22 +384,14 @@ thread_from_lwp (ptid_t ptid)
 
   gdb_assert (thread_info && thread_info->private->ti_valid);
 
-  return BUILD_THREAD (thread_info->private->ti.ti_tid, GET_PID (ptid));
+  return ptid_build (GET_PID (ptid), GET_LWP (ptid),
+		     thread_info->private->ti.ti_tid);
 }
 
 static ptid_t
 lwp_from_thread (ptid_t ptid)
 {
-  struct thread_info *thread_info;
-  ptid_t thread_ptid;
-
-  if (!is_thread (ptid))
-    return ptid;
-
-  thread_info = find_thread_pid (ptid);
-  thread_db_get_info (thread_info);
-
-  return BUILD_LWP (thread_info->private->ti.ti_lid, GET_PID (ptid));
+  return BUILD_LWP (GET_LWP (ptid), GET_PID (ptid));
 }
 \f
 
@@ -903,7 +894,7 @@ check_event (ptid_t ptid)
       if (err != TD_OK)
 	error ("Cannot get thread info: %s", thread_db_err_str (err));
 
-      ptid = BUILD_THREAD (ti.ti_tid, GET_PID (ptid));
+      ptid = ptid_build (GET_PID (ptid), ti.ti_lid, ti.ti_tid);
 
       switch (msg.event)
 	{
@@ -1175,7 +1166,7 @@ find_new_threads_callback (const td_thrh
   if (ti.ti_state == TD_THR_UNKNOWN || ti.ti_state == TD_THR_ZOMBIE)
     return 0;			/* A zombie -- ignore.  */
 
-  ptid = BUILD_THREAD (ti.ti_tid, GET_PID (inferior_ptid));
+  ptid = ptid_build (GET_PID (inferior_ptid), ti.ti_lid, ti.ti_tid);
 
   if (!in_thread_list (ptid))
     attach_thread (ptid, th_p, &ti, 1);


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2004-12-08 16:03 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-10 21:36 [rfa] Include the LWP in thread-db's PTIDs Daniel Jacobowitz
2004-10-11 15:29 ` Andrew Cagney
2004-10-11 15:38   ` Daniel Jacobowitz
2004-10-11 15:55     ` Joel Brobecker
2004-10-11 16:17     ` Andrew Cagney
2004-10-11 17:12       ` Daniel Jacobowitz
2004-10-11 18:29         ` Andrew Cagney
2004-10-12 13:26           ` Daniel Jacobowitz
2004-10-11 19:40   ` Mark Kettenis
2004-10-12 13:31     ` Daniel Jacobowitz
2004-10-13 21:16       ` Mark Kettenis
2004-10-13 21:27         ` Daniel Jacobowitz
2004-10-17 19:19           ` Daniel Jacobowitz
2004-10-13 21:37     ` Paul Gilliam
2004-11-14 19:17 ` Daniel Jacobowitz
2004-12-02 21:16   ` Michael Snyder
2004-12-08 16:14     ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox