about summary refs log tree commit diff
path: root/linuxthreads_db/td_ta_thr_iter.c
diff options
context:
space:
mode:
Diffstat (limited to 'linuxthreads_db/td_ta_thr_iter.c')
-rw-r--r--linuxthreads_db/td_ta_thr_iter.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/linuxthreads_db/td_ta_thr_iter.c b/linuxthreads_db/td_ta_thr_iter.c
index 7d7085870f..977711261e 100644
--- a/linuxthreads_db/td_ta_thr_iter.c
+++ b/linuxthreads_db/td_ta_thr_iter.c
@@ -31,6 +31,37 @@ handle_descr (const td_thragent_t *ta, td_thr_iter_f *callback,
   size_t sizeof_descr = ta->sizeof_descr;
   td_thrhandle_t th;
 
+  if (descr == NULL)
+    {
+      /* No descriptor (yet).  */
+      if (cnt == 0)
+	{
+	  /* This is the main thread.  Create a fake descriptor.  */
+	  memset (&pds, '\0', sizeof (pds));
+
+	  /* Empty thread descriptor the thread library would create.  */
+	  pds.p_header.data.self = &pds;
+	  pds.p_nextlive = pds.p_prevlive = &pds;
+	  pds.p_tid = PTHREAD_THREADS_MAX;
+	  /* The init code also sets up p_lock, p_errnop, p_herrnop, and
+	     p_userstack but this should not be necessary here.  */
+
+	  th.th_ta_p = (td_thragent_t *) ta;
+	  th.th_unique = &pds;
+	  if (callback (&th, cbdata_p) != 0)
+	    return TD_DBERR;
+
+	  /* All done successfully.  */
+	  return TD_OK;
+	}
+      else if (cnt == 1)
+	/* The manager is not yet started.  No big deal.  */
+	return TD_OK;
+      else
+	/* For every other thread this should not happen.  */
+	return TD_ERR;
+    }
+
   if (ps_pdread (ta->ph, descr, &pds, sizeof_descr) != PS_OK)
     return TD_ERR;	/* XXX Other error value?  */