summaryrefslogtreecommitdiff
path: root/linuxthreads_db/td_ta_thr_iter.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-11-05 02:26:16 +0000
committerUlrich Drepper <drepper@redhat.com>1999-11-05 02:26:16 +0000
commit9532eb67a4a92baab960d8d37bfa28048285dabb (patch)
tree179887a0e1239d9aebb41cffb1134f019712b56b /linuxthreads_db/td_ta_thr_iter.c
parentab86fbb1d2866df567219904982dac61751808e5 (diff)
Update.
1999-11-03 Ulrich Drepper <drepper@cygnus.com> * Versions.def: Add version for libthread_db.
Diffstat (limited to 'linuxthreads_db/td_ta_thr_iter.c')
-rw-r--r--linuxthreads_db/td_ta_thr_iter.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/linuxthreads_db/td_ta_thr_iter.c b/linuxthreads_db/td_ta_thr_iter.c
index 1fe871f4c7..ecc86c7871 100644
--- a/linuxthreads_db/td_ta_thr_iter.c
+++ b/linuxthreads_db/td_ta_thr_iter.c
@@ -26,24 +26,38 @@ td_ta_thr_iter (const td_thragent_t *ta, td_thr_iter_f *callback,
void *cbdata_p, td_thr_state_e state, int ti_pri,
sigset_t *ti_sigmask_p, unsigned int ti_user_flags)
{
- int pthread_threads_max = ta->pthread_threads_max;
- size_t sizeof_descr = ta->sizeof_descr;
- struct pthread_handle_struct phc[pthread_threads_max];
- int num;
+ int pthread_threads_max;
+ size_t sizeof_descr;
+ struct pthread_handle_struct *phc;
int cnt;
+#ifdef ALL_THREADS_STOPPED
+ int num;
+#else
+# define num 1
+#endif
LOG (__FUNCTION__);
+ /* Test whether the TA parameter is ok. */
+ if (! ta_ok (ta))
+ return TD_BADTA;
+
+ pthread_threads_max = ta->pthread_threads_max;
+ sizeof_descr = ta->sizeof_descr;
+ phc = (struct pthread_handle_struct *) alloca (sizeof (phc[0])
+ * pthread_threads_max);
+
/* Read all the descriptors. */
if (ps_pdread (ta->ph, ta->handles, phc,
sizeof (struct pthread_handle_struct) * pthread_threads_max)
!= PS_OK)
return TD_ERR; /* XXX Other error value? */
+#ifdef ALL_THREADS_STOPPED
/* Read the number of currently active threads. */
- if (ps_pdread (ta->ph, ta->pthread_handles_num, &num, sizeof (int))
- != PS_OK)
+ if (ps_pdread (ta->ph, ta->pthread_handles_num, &num, sizeof (int)) != PS_OK)
return TD_ERR; /* XXX Other error value? */
+#endif
/* Now get all descriptors, one after the other. */
for (cnt = 0; cnt < pthread_threads_max && num > 0; ++cnt)
@@ -52,8 +66,10 @@ td_ta_thr_iter (const td_thragent_t *ta, td_thr_iter_f *callback,
struct _pthread_descr_struct pds;
td_thrhandle_t th;
+#ifdef ALL_THREADS_STOPPED
/* First count this active thread. */
--num;
+#endif
if (ps_pdread (ta->ph, phc[cnt].h_descr, &pds, sizeof_descr)
!= PS_OK)