1 /* Get thread information.
2 Copyright (C) 1999 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public
17 License along with the GNU C Library; see the file COPYING.LIB. If not,
18 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
23 #include "thread_dbP.h"
27 td_thr_get_info (const td_thrhandle_t
*th
, td_thrinfo_t
*infop
)
29 struct _pthread_descr_struct pds
;
33 /* Get the thread descriptor. */
34 if (ps_pdread (th
->th_ta_p
->ph
, th
->th_unique
, &pds
,
35 th
->th_ta_p
->sizeof_descr
) != PS_OK
)
36 return TD_ERR
; /* XXX Other error value? */
38 /* Fill in information. Clear first to provide reproducable
39 results for the fields we do not fill in. */
40 memset (infop
, '\0', sizeof (td_thrinfo_t
));
42 infop
->ti_ta_p
= th
->th_ta_p
;
43 infop
->ti_tid
= pds
.p_tid
;
44 infop
->ti_tls
= (char *) pds
.p_specific
;
45 infop
->ti_pri
= pds
.p_priority
;
46 /* The first thread (0 being the initial one) is the manager thread
47 Mark it appropriately. */
48 infop
->ti_type
= ((pds
.p_tid
% th
->th_ta_p
->pthread_threads_max
) == 1
49 ? TD_THR_SYSTEM
: TD_THR_USER
);
51 /* We can get the following information only if the thread descriptor
52 in the target processor is large enough, i.e., comes from a recent
54 if (offsetof (struct _pthread_descr_struct
, p_startfct
)
55 < th
->th_ta_p
->sizeof_descr
)
56 infop
->ti_startfunc
= pds
.p_startfct
;