xref: /dflybsd-src/contrib/gdb-7/gdb/common/gdb_thread_db.h (revision de8e141f24382815c10a4012d209bbbf7abf1112)
1a45ae5f8SJohn Marino #ifdef HAVE_THREAD_DB_H
2a45ae5f8SJohn Marino #include <thread_db.h>
3a45ae5f8SJohn Marino 
4a45ae5f8SJohn Marino #ifndef LIBTHREAD_DB_SO
5a45ae5f8SJohn Marino #define LIBTHREAD_DB_SO "libthread_db.so.1"
6a45ae5f8SJohn Marino #endif
7a45ae5f8SJohn Marino 
8a45ae5f8SJohn Marino #ifndef LIBTHREAD_DB_SEARCH_PATH
9a45ae5f8SJohn Marino /* $sdir appears before $pdir for some minimal security protection:
10a45ae5f8SJohn Marino    we trust the system libthread_db.so a bit more than some random
11a45ae5f8SJohn Marino    libthread_db associated with whatever libpthread the app is using.  */
12a45ae5f8SJohn Marino #define LIBTHREAD_DB_SEARCH_PATH "$sdir:$pdir"
13a45ae5f8SJohn Marino #endif
14a45ae5f8SJohn Marino 
15a45ae5f8SJohn Marino #else
16a45ae5f8SJohn Marino 
17*ef5ccd6cSJohn Marino /* Copyright (C) 1999-2013 Free Software Foundation, Inc.
18a45ae5f8SJohn Marino    This file is part of the GNU C Library.
19a45ae5f8SJohn Marino 
20a45ae5f8SJohn Marino    The GNU C Library is free software; you can redistribute it and/or
21a45ae5f8SJohn Marino    modify it under the terms of the GNU Library General Public License as
22a45ae5f8SJohn Marino    published by the Free Software Foundation; either version 3 of the
23a45ae5f8SJohn Marino    License, or (at your option) any later version.
24a45ae5f8SJohn Marino 
25a45ae5f8SJohn Marino    The GNU C Library is distributed in the hope that it will be useful,
26a45ae5f8SJohn Marino    but WITHOUT ANY WARRANTY; without even the implied warranty of
27a45ae5f8SJohn Marino    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
28a45ae5f8SJohn Marino    Library General Public License for more details.
29a45ae5f8SJohn Marino 
30a45ae5f8SJohn Marino    You should have received a copy of the GNU General Public License
31a45ae5f8SJohn Marino    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
32a45ae5f8SJohn Marino 
33a45ae5f8SJohn Marino #ifndef _THREAD_DB_H
34a45ae5f8SJohn Marino #define _THREAD_DB_H	1
35a45ae5f8SJohn Marino 
36a45ae5f8SJohn Marino /* This is the debugger interface for the LinuxThreads library.  It is
37a45ae5f8SJohn Marino    modelled closely after the interface with same names in Solaris with
38a45ae5f8SJohn Marino    the goal to share the same code in the debugger.  */
39a45ae5f8SJohn Marino #include <pthread.h>
40a45ae5f8SJohn Marino #include <sys/types.h>
41a45ae5f8SJohn Marino #include <sys/procfs.h>
42a45ae5f8SJohn Marino 
43a45ae5f8SJohn Marino 
44a45ae5f8SJohn Marino /* Error codes of the library.  */
45a45ae5f8SJohn Marino typedef enum
46a45ae5f8SJohn Marino {
47a45ae5f8SJohn Marino   TD_OK,	  /* No error.  */
48a45ae5f8SJohn Marino   TD_ERR,	  /* No further specified error.  */
49a45ae5f8SJohn Marino   TD_NOTHR,	  /* No matching thread found.  */
50a45ae5f8SJohn Marino   TD_NOSV,	  /* No matching synchronization handle found.  */
51a45ae5f8SJohn Marino   TD_NOLWP,	  /* No matching light-weighted process found.  */
52a45ae5f8SJohn Marino   TD_BADPH,	  /* Invalid process handle.  */
53a45ae5f8SJohn Marino   TD_BADTH,	  /* Invalid thread handle.  */
54a45ae5f8SJohn Marino   TD_BADSH,	  /* Invalid synchronization handle.  */
55a45ae5f8SJohn Marino   TD_BADTA,	  /* Invalid thread agent.  */
56a45ae5f8SJohn Marino   TD_BADKEY,	  /* Invalid key.  */
57a45ae5f8SJohn Marino   TD_NOMSG,	  /* No event available.  */
58a45ae5f8SJohn Marino   TD_NOFPREGS,	  /* No floating-point register content available.  */
59a45ae5f8SJohn Marino   TD_NOLIBTHREAD, /* Application not linked with thread library.  */
60a45ae5f8SJohn Marino   TD_NOEVENT,	  /* Requested event is not supported.  */
61a45ae5f8SJohn Marino   TD_NOCAPAB,	  /* Capability not available.  */
62a45ae5f8SJohn Marino   TD_DBERR,	  /* Internal debug library error.  */
63a45ae5f8SJohn Marino   TD_NOAPLIC,	  /* Operation is not applicable.  */
64a45ae5f8SJohn Marino   TD_NOTSD,	  /* No thread-specific data available.  */
65a45ae5f8SJohn Marino   TD_MALLOC,	  /* Out of memory.  */
66a45ae5f8SJohn Marino   TD_PARTIALREG,  /* Not entire register set was read or written.  */
67a45ae5f8SJohn Marino   TD_NOXREGS,	  /* X register set not available for given thread.  */
68a45ae5f8SJohn Marino   TD_NOTALLOC	  /* TLS memory not yet allocated.  */
69a45ae5f8SJohn Marino } td_err_e;
70a45ae5f8SJohn Marino 
71a45ae5f8SJohn Marino 
72a45ae5f8SJohn Marino /* Possible thread states.  TD_THR_ANY_STATE is a pseudo-state used to
73a45ae5f8SJohn Marino    select threads regardless of state in td_ta_thr_iter().  */
74a45ae5f8SJohn Marino typedef enum
75a45ae5f8SJohn Marino {
76a45ae5f8SJohn Marino   TD_THR_ANY_STATE,
77a45ae5f8SJohn Marino   TD_THR_UNKNOWN,
78a45ae5f8SJohn Marino   TD_THR_STOPPED,
79a45ae5f8SJohn Marino   TD_THR_RUN,
80a45ae5f8SJohn Marino   TD_THR_ACTIVE,
81a45ae5f8SJohn Marino   TD_THR_ZOMBIE,
82a45ae5f8SJohn Marino   TD_THR_SLEEP,
83a45ae5f8SJohn Marino   TD_THR_STOPPED_ASLEEP
84a45ae5f8SJohn Marino } td_thr_state_e;
85a45ae5f8SJohn Marino 
86a45ae5f8SJohn Marino /* Thread type: user or system.  TD_THR_ANY_TYPE is a pseudo-type used
87a45ae5f8SJohn Marino    to select threads regardless of type in td_ta_thr_iter().  */
88a45ae5f8SJohn Marino typedef enum
89a45ae5f8SJohn Marino {
90a45ae5f8SJohn Marino   TD_THR_ANY_TYPE,
91a45ae5f8SJohn Marino   TD_THR_USER,
92a45ae5f8SJohn Marino   TD_THR_SYSTEM
93a45ae5f8SJohn Marino } td_thr_type_e;
94a45ae5f8SJohn Marino 
95a45ae5f8SJohn Marino 
96a45ae5f8SJohn Marino /* Types of the debugging library.  */
97a45ae5f8SJohn Marino 
98a45ae5f8SJohn Marino /* Handle for a process.  This type is opaque.  */
99a45ae5f8SJohn Marino typedef struct td_thragent td_thragent_t;
100a45ae5f8SJohn Marino 
101a45ae5f8SJohn Marino /* The actual thread handle type.  This is also opaque.  */
102a45ae5f8SJohn Marino typedef struct td_thrhandle
103a45ae5f8SJohn Marino {
104a45ae5f8SJohn Marino   td_thragent_t *th_ta_p;
105a45ae5f8SJohn Marino   psaddr_t th_unique;
106a45ae5f8SJohn Marino } td_thrhandle_t;
107a45ae5f8SJohn Marino 
108a45ae5f8SJohn Marino 
109a45ae5f8SJohn Marino /* Flags for `td_ta_thr_iter'.  */
110a45ae5f8SJohn Marino #define TD_THR_ANY_USER_FLAGS	0xffffffff
111a45ae5f8SJohn Marino #define TD_THR_LOWEST_PRIORITY	-20
112a45ae5f8SJohn Marino #define TD_SIGNO_MASK		NULL
113a45ae5f8SJohn Marino 
114a45ae5f8SJohn Marino 
115a45ae5f8SJohn Marino #define TD_EVENTSIZE	2
116a45ae5f8SJohn Marino #define BT_UISHIFT	5 		/* log base 2 of BT_NBIPUI, to
117a45ae5f8SJohn Marino 					   extract word index.  */
118a45ae5f8SJohn Marino #define BT_NBIPUI	(1 << BT_UISHIFT)       /* n bits per uint.  */
119a45ae5f8SJohn Marino #define BT_UIMASK	(BT_NBIPUI - 1)         /* to extract bit index.  */
120a45ae5f8SJohn Marino 
121a45ae5f8SJohn Marino /* Bitmask of enabled events.  */
122a45ae5f8SJohn Marino typedef struct td_thr_events
123a45ae5f8SJohn Marino {
124a45ae5f8SJohn Marino   uint32_t event_bits[TD_EVENTSIZE];
125a45ae5f8SJohn Marino } td_thr_events_t;
126a45ae5f8SJohn Marino 
127a45ae5f8SJohn Marino /* Event set manipulation macros.  */
128a45ae5f8SJohn Marino #define __td_eventmask(n) \
129a45ae5f8SJohn Marino   (UINT32_C (1) << (((n) - 1) & BT_UIMASK))
130a45ae5f8SJohn Marino #define __td_eventword(n) \
131a45ae5f8SJohn Marino   ((UINT32_C ((n) - 1)) >> BT_UISHIFT)
132a45ae5f8SJohn Marino 
133a45ae5f8SJohn Marino #define td_event_emptyset(setp) \
134a45ae5f8SJohn Marino   do {									      \
135a45ae5f8SJohn Marino     int __i;								      \
136a45ae5f8SJohn Marino     for (__i = TD_EVENTSIZE; __i > 0; --__i)				      \
137a45ae5f8SJohn Marino       (setp)->event_bits[__i - 1] = 0;					      \
138a45ae5f8SJohn Marino   } while (0)
139a45ae5f8SJohn Marino 
140a45ae5f8SJohn Marino #define td_event_fillset(setp) \
141a45ae5f8SJohn Marino   do {									      \
142a45ae5f8SJohn Marino     int __i;								      \
143a45ae5f8SJohn Marino     for (__i = TD_EVENTSIZE; __i > 0; --__i)				      \
144a45ae5f8SJohn Marino       (setp)->event_bits[__i - 1] = UINT32_C (0xffffffff);		      \
145a45ae5f8SJohn Marino   } while (0)
146a45ae5f8SJohn Marino 
147a45ae5f8SJohn Marino #define td_event_addset(setp, n) \
148a45ae5f8SJohn Marino   (((setp)->event_bits[__td_eventword (n)]) |= __td_eventmask (n))
149a45ae5f8SJohn Marino #define td_event_delset(setp, n) \
150a45ae5f8SJohn Marino   (((setp)->event_bits[__td_eventword (n)]) &= ~__td_eventmask (n))
151a45ae5f8SJohn Marino #define td_eventismember(setp, n) \
152a45ae5f8SJohn Marino   (__td_eventmask (n) & ((setp)->event_bits[__td_eventword (n)]))
153a45ae5f8SJohn Marino #if TD_EVENTSIZE == 2
154a45ae5f8SJohn Marino # define td_eventisempty(setp) \
155a45ae5f8SJohn Marino   (!((setp)->event_bits[0]) && !((setp)->event_bits[1]))
156a45ae5f8SJohn Marino #else
157a45ae5f8SJohn Marino # error "td_eventisempty must be changed to match TD_EVENTSIZE"
158a45ae5f8SJohn Marino #endif
159a45ae5f8SJohn Marino 
160a45ae5f8SJohn Marino /* Events reportable by the thread implementation.  */
161a45ae5f8SJohn Marino typedef enum
162a45ae5f8SJohn Marino {
163a45ae5f8SJohn Marino   TD_ALL_EVENTS,		 /* Pseudo-event number.  */
164a45ae5f8SJohn Marino   TD_EVENT_NONE = TD_ALL_EVENTS, /* Depends on context.  */
165a45ae5f8SJohn Marino   TD_READY,			 /* Is executable now.  */
166a45ae5f8SJohn Marino   TD_SLEEP,			 /* Blocked in a synchronization obj.  */
167a45ae5f8SJohn Marino   TD_SWITCHTO,			 /* Now assigned to a process.  */
168a45ae5f8SJohn Marino   TD_SWITCHFROM,		 /* Not anymore assigned to a process.  */
169a45ae5f8SJohn Marino   TD_LOCK_TRY,			 /* Trying to get an unavailable lock.  */
170a45ae5f8SJohn Marino   TD_CATCHSIG,			 /* Signal posted to the thread.  */
171a45ae5f8SJohn Marino   TD_IDLE,			 /* Process getting idle.  */
172a45ae5f8SJohn Marino   TD_CREATE,			 /* New thread created.  */
173a45ae5f8SJohn Marino   TD_DEATH,			 /* Thread terminated.  */
174a45ae5f8SJohn Marino   TD_PREEMPT,			 /* Preempted.  */
175a45ae5f8SJohn Marino   TD_PRI_INHERIT,		 /* Inherited elevated priority.  */
176a45ae5f8SJohn Marino   TD_REAP,			 /* Reaped.  */
177a45ae5f8SJohn Marino   TD_CONCURRENCY,		 /* Number of processes changing.  */
178a45ae5f8SJohn Marino   TD_TIMEOUT,			 /* Conditional variable wait timed out.  */
179a45ae5f8SJohn Marino   TD_MIN_EVENT_NUM = TD_READY,
180a45ae5f8SJohn Marino   TD_MAX_EVENT_NUM = TD_TIMEOUT,
181a45ae5f8SJohn Marino   TD_EVENTS_ENABLE = 31		/* Event reporting enabled.  */
182a45ae5f8SJohn Marino } td_event_e;
183a45ae5f8SJohn Marino 
184a45ae5f8SJohn Marino /* Values representing the different ways events are reported.  */
185a45ae5f8SJohn Marino typedef enum
186a45ae5f8SJohn Marino {
187a45ae5f8SJohn Marino   NOTIFY_BPT,			/* User must insert breakpoint at
188a45ae5f8SJohn Marino 				   u.bptaddr.  */
189a45ae5f8SJohn Marino   NOTIFY_AUTOBPT,		/* Breakpoint at u.bptaddr is automatically
190a45ae5f8SJohn Marino 				   inserted.  */
191a45ae5f8SJohn Marino   NOTIFY_SYSCALL		/* System call u.syscallno will be invoked.  */
192a45ae5f8SJohn Marino } td_notify_e;
193a45ae5f8SJohn Marino 
194a45ae5f8SJohn Marino /* Description how event type is reported.  */
195a45ae5f8SJohn Marino typedef struct td_notify
196a45ae5f8SJohn Marino {
197a45ae5f8SJohn Marino   td_notify_e type;		/* Way the event is reported.  */
198a45ae5f8SJohn Marino   union
199a45ae5f8SJohn Marino   {
200a45ae5f8SJohn Marino     psaddr_t bptaddr;		/* Address of breakpoint.  */
201a45ae5f8SJohn Marino     int syscallno;		/* Number of system call used.  */
202a45ae5f8SJohn Marino   } u;
203a45ae5f8SJohn Marino } td_notify_t;
204a45ae5f8SJohn Marino 
205a45ae5f8SJohn Marino /* Structure used to report event.  */
206a45ae5f8SJohn Marino typedef struct td_event_msg
207a45ae5f8SJohn Marino {
208a45ae5f8SJohn Marino   td_event_e event;		/* Event type being reported.  */
209a45ae5f8SJohn Marino   const td_thrhandle_t *th_p;	/* Thread reporting the event.  */
210a45ae5f8SJohn Marino   union
211a45ae5f8SJohn Marino   {
212a45ae5f8SJohn Marino #if 0
213a45ae5f8SJohn Marino     td_synchandle_t *sh;	/* Handle of synchronization object.  */
214a45ae5f8SJohn Marino #endif
215a45ae5f8SJohn Marino     uintptr_t data;		/* Event specific data.  */
216a45ae5f8SJohn Marino   } msg;
217a45ae5f8SJohn Marino } td_event_msg_t;
218a45ae5f8SJohn Marino 
219a45ae5f8SJohn Marino /* Structure containing event data available in each thread structure.  */
220a45ae5f8SJohn Marino typedef struct
221a45ae5f8SJohn Marino {
222a45ae5f8SJohn Marino   td_thr_events_t eventmask;	/* Mask of enabled events.  */
223a45ae5f8SJohn Marino   td_event_e eventnum;		/* Number of last event.  */
224a45ae5f8SJohn Marino   void *eventdata;		/* Data associated with event.  */
225a45ae5f8SJohn Marino } td_eventbuf_t;
226a45ae5f8SJohn Marino 
227a45ae5f8SJohn Marino 
228a45ae5f8SJohn Marino /* Gathered statistics about the process.  */
229a45ae5f8SJohn Marino typedef struct td_ta_stats
230a45ae5f8SJohn Marino {
231a45ae5f8SJohn Marino   int nthreads;       		/* Total number of threads in use.  */
232a45ae5f8SJohn Marino   int r_concurrency;		/* Concurrency level requested by user.  */
233a45ae5f8SJohn Marino   int nrunnable_num;		/* Average runnable threads, numerator.  */
234a45ae5f8SJohn Marino   int nrunnable_den;		/* Average runnable threads, denominator.  */
235a45ae5f8SJohn Marino   int a_concurrency_num;	/* Achieved concurrency level, numerator.  */
236a45ae5f8SJohn Marino   int a_concurrency_den;	/* Achieved concurrency level, denominator.  */
237a45ae5f8SJohn Marino   int nlwps_num;		/* Average number of processes in use,
238a45ae5f8SJohn Marino 				   numerator.  */
239a45ae5f8SJohn Marino   int nlwps_den;		/* Average number of processes in use,
240a45ae5f8SJohn Marino 				   denominator.  */
241a45ae5f8SJohn Marino   int nidle_num;		/* Average number of idling processes,
242a45ae5f8SJohn Marino 				   numerator.  */
243a45ae5f8SJohn Marino   int nidle_den;		/* Average number of idling processes,
244a45ae5f8SJohn Marino 				   denominator.  */
245a45ae5f8SJohn Marino } td_ta_stats_t;
246a45ae5f8SJohn Marino 
247a45ae5f8SJohn Marino 
248a45ae5f8SJohn Marino /* Since Sun's library is based on Solaris threads we have to define a few
249a45ae5f8SJohn Marino    types to map them to POSIX threads.  */
250a45ae5f8SJohn Marino typedef pthread_t thread_t;
251a45ae5f8SJohn Marino typedef pthread_key_t thread_key_t;
252a45ae5f8SJohn Marino 
253a45ae5f8SJohn Marino 
254a45ae5f8SJohn Marino /* Callback for iteration over threads.  */
255a45ae5f8SJohn Marino typedef int td_thr_iter_f (const td_thrhandle_t *, void *);
256a45ae5f8SJohn Marino 
257a45ae5f8SJohn Marino /* Callback for iteration over thread local data.  */
258a45ae5f8SJohn Marino typedef int td_key_iter_f (thread_key_t, void (*) (void *), void *);
259a45ae5f8SJohn Marino 
260a45ae5f8SJohn Marino 
261a45ae5f8SJohn Marino 
262a45ae5f8SJohn Marino /* Forward declaration.  This has to be defined by the user.  */
263a45ae5f8SJohn Marino struct ps_prochandle;
264a45ae5f8SJohn Marino 
265a45ae5f8SJohn Marino 
266a45ae5f8SJohn Marino /* Information about the thread.  */
267a45ae5f8SJohn Marino typedef struct td_thrinfo
268a45ae5f8SJohn Marino {
269a45ae5f8SJohn Marino   td_thragent_t *ti_ta_p;		/* Process handle.  */
270a45ae5f8SJohn Marino   unsigned int ti_user_flags;		/* Unused.  */
271a45ae5f8SJohn Marino   thread_t ti_tid;			/* Thread ID returned by
272a45ae5f8SJohn Marino 					   pthread_create().  */
273a45ae5f8SJohn Marino   char *ti_tls;				/* Pointer to thread-local data.  */
274a45ae5f8SJohn Marino   psaddr_t ti_startfunc;		/* Start function passed to
275a45ae5f8SJohn Marino 					   pthread_create().  */
276a45ae5f8SJohn Marino   psaddr_t ti_stkbase;			/* Base of thread's stack.  */
277a45ae5f8SJohn Marino   long int ti_stksize;			/* Size of thread's stack.  */
278a45ae5f8SJohn Marino   psaddr_t ti_ro_area;			/* Unused.  */
279a45ae5f8SJohn Marino   int ti_ro_size;			/* Unused.  */
280a45ae5f8SJohn Marino   td_thr_state_e ti_state;		/* Thread state.  */
281a45ae5f8SJohn Marino   unsigned char ti_db_suspended;	/* Nonzero if suspended by
282a45ae5f8SJohn Marino 					   debugger.  */
283a45ae5f8SJohn Marino   td_thr_type_e ti_type;		/* Type of the thread (system vs
284a45ae5f8SJohn Marino 					   user thread).  */
285a45ae5f8SJohn Marino   intptr_t ti_pc;			/* Unused.  */
286a45ae5f8SJohn Marino   intptr_t ti_sp;			/* Unused.  */
287a45ae5f8SJohn Marino   short int ti_flags;			/* Unused.  */
288a45ae5f8SJohn Marino   int ti_pri;				/* Thread priority.  */
289a45ae5f8SJohn Marino   lwpid_t ti_lid;			/* Kernel pid for this thread.  */
290a45ae5f8SJohn Marino   sigset_t ti_sigmask;			/* Signal mask.  */
291a45ae5f8SJohn Marino   unsigned char ti_traceme;		/* Nonzero if event reporting
292a45ae5f8SJohn Marino 					   enabled.  */
293a45ae5f8SJohn Marino   unsigned char ti_preemptflag;		/* Unused.  */
294a45ae5f8SJohn Marino   unsigned char ti_pirecflag;		/* Unused.  */
295a45ae5f8SJohn Marino   sigset_t ti_pending;			/* Set of pending signals.  */
296a45ae5f8SJohn Marino   td_thr_events_t ti_events;		/* Set of enabled events.  */
297a45ae5f8SJohn Marino } td_thrinfo_t;
298a45ae5f8SJohn Marino 
299a45ae5f8SJohn Marino 
300a45ae5f8SJohn Marino 
301a45ae5f8SJohn Marino /* Prototypes for exported library functions.  */
302a45ae5f8SJohn Marino 
303a45ae5f8SJohn Marino /* Initialize the thread debug support library.  */
304a45ae5f8SJohn Marino extern td_err_e td_init (void);
305a45ae5f8SJohn Marino 
306a45ae5f8SJohn Marino /* Historical relict.  Should not be used anymore.  */
307a45ae5f8SJohn Marino extern td_err_e td_log (void);
308a45ae5f8SJohn Marino 
309a45ae5f8SJohn Marino /* Generate new thread debug library handle for process PS.  */
310a45ae5f8SJohn Marino extern td_err_e td_ta_new (struct ps_prochandle *__ps, td_thragent_t **__ta);
311a45ae5f8SJohn Marino 
312a45ae5f8SJohn Marino /* Free resources allocated for TA.  */
313a45ae5f8SJohn Marino extern td_err_e td_ta_delete (td_thragent_t *__ta);
314a45ae5f8SJohn Marino 
315a45ae5f8SJohn Marino /* Get number of currently running threads in process associated with TA.  */
316a45ae5f8SJohn Marino extern td_err_e td_ta_get_nthreads (const td_thragent_t *__ta, int *__np);
317a45ae5f8SJohn Marino 
318a45ae5f8SJohn Marino /* Return process handle passed in `td_ta_new' for process associated with
319a45ae5f8SJohn Marino    TA.  */
320a45ae5f8SJohn Marino extern td_err_e td_ta_get_ph (const td_thragent_t *__ta,
321a45ae5f8SJohn Marino 			      struct ps_prochandle **__ph);
322a45ae5f8SJohn Marino 
323a45ae5f8SJohn Marino /* Map thread library handle PT to thread debug library handle for process
324a45ae5f8SJohn Marino    associated with TA and store result in *TH.  */
325a45ae5f8SJohn Marino extern td_err_e td_ta_map_id2thr (const td_thragent_t *__ta, pthread_t __pt,
326a45ae5f8SJohn Marino 				  td_thrhandle_t *__th);
327a45ae5f8SJohn Marino 
328a45ae5f8SJohn Marino /* Map process ID LWPID to thread debug library handle for process
329a45ae5f8SJohn Marino    associated with TA and store result in *TH.  */
330a45ae5f8SJohn Marino extern td_err_e td_ta_map_lwp2thr (const td_thragent_t *__ta, lwpid_t __lwpid,
331a45ae5f8SJohn Marino 				   td_thrhandle_t *__th);
332a45ae5f8SJohn Marino 
333a45ae5f8SJohn Marino 
334a45ae5f8SJohn Marino /* Call for each thread in a process associated with TA the callback function
335a45ae5f8SJohn Marino    CALLBACK.  */
336a45ae5f8SJohn Marino extern td_err_e td_ta_thr_iter (const td_thragent_t *__ta,
337a45ae5f8SJohn Marino 				td_thr_iter_f *__callback, void *__cbdata_p,
338a45ae5f8SJohn Marino 				td_thr_state_e __state, int __ti_pri,
339a45ae5f8SJohn Marino 				sigset_t *__ti_sigmask_p,
340a45ae5f8SJohn Marino 				unsigned int __ti_user_flags);
341a45ae5f8SJohn Marino 
342a45ae5f8SJohn Marino /* Call for each defined thread local data entry the callback function KI.  */
343a45ae5f8SJohn Marino extern td_err_e td_ta_tsd_iter (const td_thragent_t *__ta, td_key_iter_f *__ki,
344a45ae5f8SJohn Marino 				void *__p);
345a45ae5f8SJohn Marino 
346a45ae5f8SJohn Marino 
347a45ae5f8SJohn Marino /* Get event address for EVENT.  */
348a45ae5f8SJohn Marino extern td_err_e td_ta_event_addr (const td_thragent_t *__ta,
349a45ae5f8SJohn Marino 				  td_event_e __event, td_notify_t *__ptr);
350a45ae5f8SJohn Marino 
351a45ae5f8SJohn Marino /* Enable EVENT in global mask.  */
352a45ae5f8SJohn Marino extern td_err_e td_ta_set_event (const td_thragent_t *__ta,
353a45ae5f8SJohn Marino 				 td_thr_events_t *__event);
354a45ae5f8SJohn Marino 
355a45ae5f8SJohn Marino /* Disable EVENT in global mask.  */
356a45ae5f8SJohn Marino extern td_err_e td_ta_clear_event (const td_thragent_t *__ta,
357a45ae5f8SJohn Marino 				   td_thr_events_t *__event);
358a45ae5f8SJohn Marino 
359a45ae5f8SJohn Marino /* Return information about last event.  */
360a45ae5f8SJohn Marino extern td_err_e td_ta_event_getmsg (const td_thragent_t *__ta,
361a45ae5f8SJohn Marino 				    td_event_msg_t *msg);
362a45ae5f8SJohn Marino 
363a45ae5f8SJohn Marino 
364a45ae5f8SJohn Marino /* Set suggested concurrency level for process associated with TA.  */
365a45ae5f8SJohn Marino extern td_err_e td_ta_setconcurrency (const td_thragent_t *__ta, int __level);
366a45ae5f8SJohn Marino 
367a45ae5f8SJohn Marino 
368a45ae5f8SJohn Marino /* Enable collecting statistics for process associated with TA.  */
369a45ae5f8SJohn Marino extern td_err_e td_ta_enable_stats (const td_thragent_t *__ta, int __enable);
370a45ae5f8SJohn Marino 
371a45ae5f8SJohn Marino /* Reset statistics.  */
372a45ae5f8SJohn Marino extern td_err_e td_ta_reset_stats (const td_thragent_t *__ta);
373a45ae5f8SJohn Marino 
374a45ae5f8SJohn Marino /* Retrieve statistics from process associated with TA.  */
375a45ae5f8SJohn Marino extern td_err_e td_ta_get_stats (const td_thragent_t *__ta,
376a45ae5f8SJohn Marino 				 td_ta_stats_t *__statsp);
377a45ae5f8SJohn Marino 
378a45ae5f8SJohn Marino 
379a45ae5f8SJohn Marino /* Validate that TH is a thread handle.  */
380a45ae5f8SJohn Marino extern td_err_e td_thr_validate (const td_thrhandle_t *__th);
381a45ae5f8SJohn Marino 
382a45ae5f8SJohn Marino /* Return information about thread TH.  */
383a45ae5f8SJohn Marino extern td_err_e td_thr_get_info (const td_thrhandle_t *__th,
384a45ae5f8SJohn Marino 				 td_thrinfo_t *__infop);
385a45ae5f8SJohn Marino 
386a45ae5f8SJohn Marino /* Retrieve floating-point register contents of process running thread TH.  */
387a45ae5f8SJohn Marino extern td_err_e td_thr_getfpregs (const td_thrhandle_t *__th,
388a45ae5f8SJohn Marino 				  prfpregset_t *__regset);
389a45ae5f8SJohn Marino 
390a45ae5f8SJohn Marino /* Retrieve general register contents of process running thread TH.  */
391a45ae5f8SJohn Marino extern td_err_e td_thr_getgregs (const td_thrhandle_t *__th,
392a45ae5f8SJohn Marino 				 prgregset_t __gregs);
393a45ae5f8SJohn Marino 
394a45ae5f8SJohn Marino /* Retrieve extended register contents of process running thread TH.  */
395a45ae5f8SJohn Marino extern td_err_e td_thr_getxregs (const td_thrhandle_t *__th, void *__xregs);
396a45ae5f8SJohn Marino 
397a45ae5f8SJohn Marino /* Get size of extended register set of process running thread TH.  */
398a45ae5f8SJohn Marino extern td_err_e td_thr_getxregsize (const td_thrhandle_t *__th, int *__sizep);
399a45ae5f8SJohn Marino 
400a45ae5f8SJohn Marino /* Set floating-point register contents of process running thread TH.  */
401a45ae5f8SJohn Marino extern td_err_e td_thr_setfpregs (const td_thrhandle_t *__th,
402a45ae5f8SJohn Marino 				  const prfpregset_t *__fpregs);
403a45ae5f8SJohn Marino 
404a45ae5f8SJohn Marino /* Set general register contents of process running thread TH.  */
405a45ae5f8SJohn Marino extern td_err_e td_thr_setgregs (const td_thrhandle_t *__th,
406a45ae5f8SJohn Marino 				 prgregset_t __gregs);
407a45ae5f8SJohn Marino 
408a45ae5f8SJohn Marino /* Set extended register contents of process running thread TH.  */
409a45ae5f8SJohn Marino extern td_err_e td_thr_setxregs (const td_thrhandle_t *__th,
410a45ae5f8SJohn Marino 				 const void *__addr);
411a45ae5f8SJohn Marino 
412a45ae5f8SJohn Marino 
413a45ae5f8SJohn Marino /* Enable reporting for EVENT for thread TH.  */
414a45ae5f8SJohn Marino extern td_err_e td_thr_event_enable (const td_thrhandle_t *__th, int __event);
415a45ae5f8SJohn Marino 
416a45ae5f8SJohn Marino /* Enable EVENT for thread TH.  */
417a45ae5f8SJohn Marino extern td_err_e td_thr_set_event (const td_thrhandle_t *__th,
418a45ae5f8SJohn Marino 				  td_thr_events_t *__event);
419a45ae5f8SJohn Marino 
420a45ae5f8SJohn Marino /* Disable EVENT for thread TH.  */
421a45ae5f8SJohn Marino extern td_err_e td_thr_clear_event (const td_thrhandle_t *__th,
422a45ae5f8SJohn Marino 				    td_thr_events_t *__event);
423a45ae5f8SJohn Marino 
424a45ae5f8SJohn Marino /* Get event message for thread TH.  */
425a45ae5f8SJohn Marino extern td_err_e td_thr_event_getmsg (const td_thrhandle_t *__th,
426a45ae5f8SJohn Marino 				     td_event_msg_t *__msg);
427a45ae5f8SJohn Marino 
428a45ae5f8SJohn Marino 
429a45ae5f8SJohn Marino /* Set priority of thread TH.  */
430a45ae5f8SJohn Marino extern td_err_e td_thr_setprio (const td_thrhandle_t *__th, int __prio);
431a45ae5f8SJohn Marino 
432a45ae5f8SJohn Marino 
433a45ae5f8SJohn Marino /* Set pending signals for thread TH.  */
434a45ae5f8SJohn Marino extern td_err_e td_thr_setsigpending (const td_thrhandle_t *__th,
435a45ae5f8SJohn Marino 				      unsigned char __n, const sigset_t *__ss);
436a45ae5f8SJohn Marino 
437a45ae5f8SJohn Marino /* Set signal mask for thread TH.  */
438a45ae5f8SJohn Marino extern td_err_e td_thr_sigsetmask (const td_thrhandle_t *__th,
439a45ae5f8SJohn Marino 				   const sigset_t *__ss);
440a45ae5f8SJohn Marino 
441a45ae5f8SJohn Marino 
442a45ae5f8SJohn Marino /* Return thread local data associated with key TK in thread TH.  */
443a45ae5f8SJohn Marino extern td_err_e td_thr_tsd (const td_thrhandle_t *__th,
444a45ae5f8SJohn Marino 			    const thread_key_t __tk, void **__data);
445a45ae5f8SJohn Marino 
446a45ae5f8SJohn Marino 
447a45ae5f8SJohn Marino /* Suspend execution of thread TH.  */
448a45ae5f8SJohn Marino extern td_err_e td_thr_dbsuspend (const td_thrhandle_t *__th);
449a45ae5f8SJohn Marino 
450a45ae5f8SJohn Marino /* Resume execution of thread TH.  */
451a45ae5f8SJohn Marino extern td_err_e td_thr_dbresume (const td_thrhandle_t *__th);
452a45ae5f8SJohn Marino 
453a45ae5f8SJohn Marino #endif	/* thread_db.h */
454a45ae5f8SJohn Marino 
455a45ae5f8SJohn Marino #endif /* HAVE_THREAD_DB_H */
456