xref: /illumos-gate/usr/src/head/thread_db.h (revision 6e270ca8)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
595c76875Sraf  * Common Development and Distribution License (the "License").
695c76875Sraf  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
2195c76875Sraf 
227c478bd9Sstevel@tonic-gate /*
2395c76875Sraf  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #ifndef _THREAD_DB_H
287c478bd9Sstevel@tonic-gate #define	_THREAD_DB_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate /*
317c478bd9Sstevel@tonic-gate  *
327c478bd9Sstevel@tonic-gate  *  Description:
337c478bd9Sstevel@tonic-gate  *	Types, global variables, and function definitions for users
347c478bd9Sstevel@tonic-gate  *	of libc_db (formerly libthread_db).
357c478bd9Sstevel@tonic-gate  *
367c478bd9Sstevel@tonic-gate  */
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #include <sys/lwp.h>
407c478bd9Sstevel@tonic-gate #include <sys/procfs_isa.h>
417c478bd9Sstevel@tonic-gate #include <thread.h>
427c478bd9Sstevel@tonic-gate #include <proc_service.h>
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate #ifdef __cplusplus
457c478bd9Sstevel@tonic-gate extern "C" {
467c478bd9Sstevel@tonic-gate #endif
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate #define		TD_THR_ANY_USER_FLAGS	0xffffffff
4995c76875Sraf #define		TD_THR_LOWEST_PRIORITY	-128
507c478bd9Sstevel@tonic-gate #define		TD_SIGNO_MASK 0
517c478bd9Sstevel@tonic-gate #define		TD_EVENTSIZE 2
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate /*
547c478bd9Sstevel@tonic-gate  * Opaque handle types.
557c478bd9Sstevel@tonic-gate  */
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate /* Client's handle for a process */
587c478bd9Sstevel@tonic-gate struct ps_prochandle;
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate /* libthread's handle for a process */
617c478bd9Sstevel@tonic-gate typedef struct td_thragent td_thragent_t;
627c478bd9Sstevel@tonic-gate 
637c478bd9Sstevel@tonic-gate /* The thread handle. */
647c478bd9Sstevel@tonic-gate typedef struct td_thrhandle {
657c478bd9Sstevel@tonic-gate 	td_thragent_t	*th_ta_p;
667c478bd9Sstevel@tonic-gate 	psaddr_t	th_unique;
677c478bd9Sstevel@tonic-gate } td_thrhandle_t;
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate /* The handle for a synchronization object. */
707c478bd9Sstevel@tonic-gate typedef struct td_synchandle {
717c478bd9Sstevel@tonic-gate 	td_thragent_t	*sh_ta_p;
727c478bd9Sstevel@tonic-gate 	psaddr_t	sh_unique;
737c478bd9Sstevel@tonic-gate } td_synchandle_t;
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate /* ------------------------------------------------------------------ */
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate /*
787c478bd9Sstevel@tonic-gate  * The libc_db event facility.
797c478bd9Sstevel@tonic-gate  */
807c478bd9Sstevel@tonic-gate #define	BT_UISHIFT	5 /* log base 2 of BT_NBIPUI, to extract word index */
817c478bd9Sstevel@tonic-gate #define	BT_NBIPUI	(1 << BT_UISHIFT)	/* n bits per uint */
827c478bd9Sstevel@tonic-gate #define	BT_UIMASK	(BT_NBIPUI - 1)		/* to extract bit index */
837c478bd9Sstevel@tonic-gate 
847c478bd9Sstevel@tonic-gate /* Bitmask of enabled events. */
857c478bd9Sstevel@tonic-gate typedef struct td_thr_events {
867c478bd9Sstevel@tonic-gate 	uint_t	event_bits[TD_EVENTSIZE];
877c478bd9Sstevel@tonic-gate } td_thr_events_t;
887c478bd9Sstevel@tonic-gate 
897c478bd9Sstevel@tonic-gate /* Event set manipulation macros. */
907c478bd9Sstevel@tonic-gate #define	__td_eventmask(n)	((unsigned int)1 << (((n) - 1)	\
917c478bd9Sstevel@tonic-gate 				    & (BT_NBIPUI - 1)))
927c478bd9Sstevel@tonic-gate #define	__td_eventword(n)	(((unsigned int)((n) - 1))>>5)
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate #define	td_event_emptyset(setp)				\
957c478bd9Sstevel@tonic-gate 	{								\
96*6e270ca8SMarcel Telka 		int _i_;						\
977c478bd9Sstevel@tonic-gate 		_i_ = TD_EVENTSIZE;					\
987c478bd9Sstevel@tonic-gate 		while (_i_) (setp)->event_bits[--_i_] = 0;	\
997c478bd9Sstevel@tonic-gate 	}
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate #define	td_event_fillset(setp)				\
1027c478bd9Sstevel@tonic-gate 	{								\
1037c478bd9Sstevel@tonic-gate 		int _i_;						\
1047c478bd9Sstevel@tonic-gate 		_i_ = TD_EVENTSIZE;					\
1057c478bd9Sstevel@tonic-gate 		while (_i_) (setp)->event_bits[--_i_] =	\
1067c478bd9Sstevel@tonic-gate 			0xffffffff;				\
1077c478bd9Sstevel@tonic-gate 	}
1087c478bd9Sstevel@tonic-gate 
1097c478bd9Sstevel@tonic-gate #define	td_event_addset(setp, n)			\
1107c478bd9Sstevel@tonic-gate 	(((setp)->event_bits[__td_eventword(n)]) |= __td_eventmask(n))
1117c478bd9Sstevel@tonic-gate #define	td_event_delset(setp, n)			\
1127c478bd9Sstevel@tonic-gate 	(((setp)->event_bits[__td_eventword(n)]) &= ~__td_eventmask(n))
1137c478bd9Sstevel@tonic-gate #define	td_eventismember(setp, n)		\
1147c478bd9Sstevel@tonic-gate 	(__td_eventmask(n) & ((setp)->event_bits[__td_eventword(n)]))
1157c478bd9Sstevel@tonic-gate #define	td_eventisempty(setp)			\
1167c478bd9Sstevel@tonic-gate 	(!((setp)->event_bits[0]) && !((setp)->event_bits[1]))
1177c478bd9Sstevel@tonic-gate 
1187c478bd9Sstevel@tonic-gate typedef enum {
1197c478bd9Sstevel@tonic-gate 	TD_ALL_EVENTS,	/* pseudo-event number */
1207c478bd9Sstevel@tonic-gate 	TD_EVENT_NONE = TD_ALL_EVENTS,	/* depends on context */
1217c478bd9Sstevel@tonic-gate 	TD_READY,
1227c478bd9Sstevel@tonic-gate 	TD_SLEEP,
1237c478bd9Sstevel@tonic-gate 	TD_SWITCHTO,
1247c478bd9Sstevel@tonic-gate 	TD_SWITCHFROM,
1257c478bd9Sstevel@tonic-gate 	TD_LOCK_TRY,
1267c478bd9Sstevel@tonic-gate 	TD_CATCHSIG,
1277c478bd9Sstevel@tonic-gate 	TD_IDLE,
1287c478bd9Sstevel@tonic-gate 	TD_CREATE,
1297c478bd9Sstevel@tonic-gate 	TD_DEATH,
1307c478bd9Sstevel@tonic-gate 	TD_PREEMPT,
1317c478bd9Sstevel@tonic-gate 	TD_PRI_INHERIT,
1327c478bd9Sstevel@tonic-gate 	TD_REAP,
1337c478bd9Sstevel@tonic-gate 	TD_CONCURRENCY,
1347c478bd9Sstevel@tonic-gate 	TD_TIMEOUT,
1357c478bd9Sstevel@tonic-gate 	TD_MIN_EVENT_NUM = TD_READY,
1367c478bd9Sstevel@tonic-gate 	TD_MAX_EVENT_NUM = TD_TIMEOUT,
1377c478bd9Sstevel@tonic-gate 	TD_EVENTS_ENABLE = 31		/* Event reporting enabled */
1387c478bd9Sstevel@tonic-gate } td_event_e;
1397c478bd9Sstevel@tonic-gate 
1407c478bd9Sstevel@tonic-gate /*
1417c478bd9Sstevel@tonic-gate  *   Ways that an event type can be reported.
1427c478bd9Sstevel@tonic-gate  */
1437c478bd9Sstevel@tonic-gate typedef enum {
1447c478bd9Sstevel@tonic-gate 	NOTIFY_BPT,
1457c478bd9Sstevel@tonic-gate 				/*
1467c478bd9Sstevel@tonic-gate 				 * bpt to be inserted at u.bptaddr by
1477c478bd9Sstevel@tonic-gate 				 * debugger
1487c478bd9Sstevel@tonic-gate 				 */
1497c478bd9Sstevel@tonic-gate 	NOTIFY_AUTOBPT,		/* bpt inserted at u.bptaddr by application */
1507c478bd9Sstevel@tonic-gate 	NOTIFY_SYSCALL		/* syscall u.syscallno will be invoked */
1517c478bd9Sstevel@tonic-gate } td_notify_e;
1527c478bd9Sstevel@tonic-gate 
1537c478bd9Sstevel@tonic-gate /*
1547c478bd9Sstevel@tonic-gate  * How an event type is reported.
1557c478bd9Sstevel@tonic-gate  */
1567c478bd9Sstevel@tonic-gate typedef struct td_notify {
1577c478bd9Sstevel@tonic-gate 	td_notify_e	type;
1587c478bd9Sstevel@tonic-gate 	union {
1597c478bd9Sstevel@tonic-gate 		psaddr_t	bptaddr;
1607c478bd9Sstevel@tonic-gate 		int		syscallno;
1617c478bd9Sstevel@tonic-gate 	} u;
1627c478bd9Sstevel@tonic-gate } td_notify_t;
1637c478bd9Sstevel@tonic-gate 
1647c478bd9Sstevel@tonic-gate /*
1657c478bd9Sstevel@tonic-gate  * An event message.
1667c478bd9Sstevel@tonic-gate  */
1677c478bd9Sstevel@tonic-gate typedef struct td_event_msg {
1687c478bd9Sstevel@tonic-gate 	td_event_e event;		/* Event type being reported */
1697c478bd9Sstevel@tonic-gate 	const td_thrhandle_t *th_p;	/* Thread reporting the event */
1707c478bd9Sstevel@tonic-gate 	union {				/* Type-dependent event data */
1717c478bd9Sstevel@tonic-gate 		td_synchandle_t *sh;	/* historical rubbish; ignore */
1727c478bd9Sstevel@tonic-gate 		uintptr_t	data;	/* valid, depending on event type */
1737c478bd9Sstevel@tonic-gate 	} msg;
1747c478bd9Sstevel@tonic-gate } td_event_msg_t;
1757c478bd9Sstevel@tonic-gate 
1767c478bd9Sstevel@tonic-gate /* --------------------------------------------------------------------- */
1777c478bd9Sstevel@tonic-gate 
1787c478bd9Sstevel@tonic-gate /*
1797c478bd9Sstevel@tonic-gate  * Thread information structure as returned by td_thr_get_info(), and
1807c478bd9Sstevel@tonic-gate  * related types.
1817c478bd9Sstevel@tonic-gate  */
1827c478bd9Sstevel@tonic-gate 
1837c478bd9Sstevel@tonic-gate /*
1847c478bd9Sstevel@tonic-gate  * Possible thread states.  TD_THR_ANY_STATE is a pseudo-state used
1857c478bd9Sstevel@tonic-gate  * to select threads regardless of state in td_ta_thr_iter().
1867c478bd9Sstevel@tonic-gate  */
1877c478bd9Sstevel@tonic-gate typedef enum {
1887c478bd9Sstevel@tonic-gate 	TD_THR_ANY_STATE,
1897c478bd9Sstevel@tonic-gate 	TD_THR_UNKNOWN,
1907c478bd9Sstevel@tonic-gate 	TD_THR_STOPPED,
1917c478bd9Sstevel@tonic-gate 	TD_THR_RUN,
1927c478bd9Sstevel@tonic-gate 	TD_THR_ACTIVE,
1937c478bd9Sstevel@tonic-gate 	TD_THR_ZOMBIE,
1947c478bd9Sstevel@tonic-gate 	TD_THR_SLEEP,
1957c478bd9Sstevel@tonic-gate 	TD_THR_STOPPED_ASLEEP
1967c478bd9Sstevel@tonic-gate } td_thr_state_e;
1977c478bd9Sstevel@tonic-gate 
1987c478bd9Sstevel@tonic-gate /*
1997c478bd9Sstevel@tonic-gate  * Thread type: user or system.
2007c478bd9Sstevel@tonic-gate  * As of Solaris 9, all threads are type TD_THR_USER.
2017c478bd9Sstevel@tonic-gate  */
2027c478bd9Sstevel@tonic-gate typedef enum {
2037c478bd9Sstevel@tonic-gate 	TD_THR_ANY_TYPE,	/* not used */
2047c478bd9Sstevel@tonic-gate 	TD_THR_USER,
2057c478bd9Sstevel@tonic-gate 	TD_THR_SYSTEM
2067c478bd9Sstevel@tonic-gate } td_thr_type_e;
2077c478bd9Sstevel@tonic-gate 
2087c478bd9Sstevel@tonic-gate typedef struct td_thrinfo {
2097c478bd9Sstevel@tonic-gate 	td_thragent_t	*ti_ta_p;	/* process handle */
2107c478bd9Sstevel@tonic-gate 	unsigned	ti_user_flags;	/* flags passed to thr_create() */
2117c478bd9Sstevel@tonic-gate 	thread_t	ti_tid;		/* tid returned by thr_create() */
2127c478bd9Sstevel@tonic-gate 	void		*ti_exitval;	/* thread exit value (TD_THR_ZOMBIE) */
2137c478bd9Sstevel@tonic-gate 	psaddr_t	ti_startfunc;	/* startfunc passed to thr_create() */
2147c478bd9Sstevel@tonic-gate 	psaddr_t	ti_stkbase;	/* base of thread's stack */
2157c478bd9Sstevel@tonic-gate 	long		ti_stksize;	/* size of thread's stack */
2167c478bd9Sstevel@tonic-gate 	psaddr_t	ti_ro_area;	/* address of uthread_t struct */
2177c478bd9Sstevel@tonic-gate 	int		ti_ro_size;	/* size of uthread_t struct */
2187c478bd9Sstevel@tonic-gate 	td_thr_state_e	ti_state;	/* thread state */
2197c478bd9Sstevel@tonic-gate 	uchar_t		ti_db_suspended; /* boolean:  suspended by debugger? */
2207c478bd9Sstevel@tonic-gate 	td_thr_type_e	ti_type;	/* thread type */
2217c478bd9Sstevel@tonic-gate 	intptr_t	ti_pc;		/* resume PC when sleeping */
2227c478bd9Sstevel@tonic-gate 	intptr_t	ti_sp;		/* resume SP when sleeping */
2237c478bd9Sstevel@tonic-gate 	short		ti_flags;	/* flags used by libthread */
2247c478bd9Sstevel@tonic-gate 	int		ti_pri;		/* thread priority */
2257c478bd9Sstevel@tonic-gate 	lwpid_t		ti_lid;		/* last LWP assigned to this thread */
2267c478bd9Sstevel@tonic-gate 	sigset_t	ti_sigmask;	/* signal mask */
2277c478bd9Sstevel@tonic-gate 	uchar_t		ti_traceme;	/* event reporting enabled? */
2287c478bd9Sstevel@tonic-gate 	uchar_t		ti_preemptflag;	/* was thread preemppted? */
2297c478bd9Sstevel@tonic-gate 	uchar_t		ti_pirecflag;	/* priority inheritance happened */
2307c478bd9Sstevel@tonic-gate 	sigset_t	ti_pending;	/* set of pending signals */
2317c478bd9Sstevel@tonic-gate 	td_thr_events_t ti_events;	/* set of enabled events */
2327c478bd9Sstevel@tonic-gate } td_thrinfo_t;
2337c478bd9Sstevel@tonic-gate 
2347c478bd9Sstevel@tonic-gate #define	ti_tls	ti_exitval	/* for source compatibility */
2357c478bd9Sstevel@tonic-gate 
2367c478bd9Sstevel@tonic-gate typedef struct td_ta_stats {
2377c478bd9Sstevel@tonic-gate 	int	nthreads;	/* total number of threads in use */
2387c478bd9Sstevel@tonic-gate 	int	r_concurrency;	/* requested concurrency level */
2397c478bd9Sstevel@tonic-gate 	int	nrunnable_num;	/* numerator, avg. runnable threads */
2407c478bd9Sstevel@tonic-gate 	int	nrunnable_den;	/* denominator, avg. runnable threads */
2417c478bd9Sstevel@tonic-gate 	int	a_concurrency_num; /* numerator, achieved concurrency level */
2427c478bd9Sstevel@tonic-gate 	int	a_concurrency_den; /* denominator,  concurrency level */
2437c478bd9Sstevel@tonic-gate 	int	nlwps_num;	/* numerator, average number of LWP's in use */
2447c478bd9Sstevel@tonic-gate 	int	nlwps_den;	/* denom., average number of LWP's in use */
2457c478bd9Sstevel@tonic-gate 	int	nidle_num;	/* numerator, avg. number of idling LWP's */
2467c478bd9Sstevel@tonic-gate 	int	nidle_den;	/* denom., avg. number of idling LWP's */
2477c478bd9Sstevel@tonic-gate } td_ta_stats_t;
2487c478bd9Sstevel@tonic-gate 
2497c478bd9Sstevel@tonic-gate /*
2507c478bd9Sstevel@tonic-gate  * Iterator callback function declarations.
2517c478bd9Sstevel@tonic-gate  */
2527c478bd9Sstevel@tonic-gate 
2537c478bd9Sstevel@tonic-gate /* Callback function for td_ta_tsd_iter(). */
2547c478bd9Sstevel@tonic-gate typedef int	td_key_iter_f(thread_key_t, void (*destructor)(), void *);
2557c478bd9Sstevel@tonic-gate 
2567c478bd9Sstevel@tonic-gate /* Callback function for td_ta_thr_iter(). */
2577c478bd9Sstevel@tonic-gate typedef int	td_thr_iter_f(const td_thrhandle_t *, void *);
2587c478bd9Sstevel@tonic-gate 
2597c478bd9Sstevel@tonic-gate /* Callback function for td_ta_sync_iter(). */
2607c478bd9Sstevel@tonic-gate typedef int	td_sync_iter_f(const td_synchandle_t *, void *);
2617c478bd9Sstevel@tonic-gate 
2627c478bd9Sstevel@tonic-gate /* -------------------------------------------------------------------- */
2637c478bd9Sstevel@tonic-gate 
2647c478bd9Sstevel@tonic-gate /*
2657c478bd9Sstevel@tonic-gate  * Synchronization Objects
2667c478bd9Sstevel@tonic-gate  */
2677c478bd9Sstevel@tonic-gate 
2687c478bd9Sstevel@tonic-gate /* Enumeration of synchronization object types. */
2697c478bd9Sstevel@tonic-gate typedef enum td_sync_type_e {
2707c478bd9Sstevel@tonic-gate 	TD_SYNC_UNKNOWN,	/* Sync. variable of unknown type  */
2717c478bd9Sstevel@tonic-gate 	TD_SYNC_COND,		/* Condition variable  */
2727c478bd9Sstevel@tonic-gate 	TD_SYNC_MUTEX,		/* Mutex lock  */
2737c478bd9Sstevel@tonic-gate 	TD_SYNC_SEMA,		/* Semaphore  */
2747c478bd9Sstevel@tonic-gate 	TD_SYNC_RWLOCK		/* Reader/Writer lock  */
2757c478bd9Sstevel@tonic-gate } td_sync_type_e;
2767c478bd9Sstevel@tonic-gate 
2777c478bd9Sstevel@tonic-gate #define	TD_SV_MAX_FLAGS 4
2787c478bd9Sstevel@tonic-gate typedef uint8_t td_sync_flags_t;
2797c478bd9Sstevel@tonic-gate 
2807c478bd9Sstevel@tonic-gate /*
2817c478bd9Sstevel@tonic-gate  * Synchronization object information structure filled in by td_sync_get_info()
2827c478bd9Sstevel@tonic-gate  */
2837c478bd9Sstevel@tonic-gate typedef struct td_syncinfo {
2847c478bd9Sstevel@tonic-gate 	td_thragent_t	*si_ta_p;	/* process handle */
2857c478bd9Sstevel@tonic-gate 	psaddr_t	si_sv_addr;	/* address of sync. object */
2867c478bd9Sstevel@tonic-gate 	td_sync_type_e	si_type;	/* object type */
2877c478bd9Sstevel@tonic-gate 	uint32_t	si_shared_type;	/* process-shared or process-private */
2887c478bd9Sstevel@tonic-gate 	td_sync_flags_t	si_flags[TD_SV_MAX_FLAGS];	/* flags (?) */
2897c478bd9Sstevel@tonic-gate 	pid_t		si_ownerpid;	/* owner's process-id (USYNC_PROCESS) */
2907c478bd9Sstevel@tonic-gate 	union _si_un_state {
2917c478bd9Sstevel@tonic-gate 		int	sem_count;	/* semaphore count */
2927c478bd9Sstevel@tonic-gate 		int	nreaders;	/* number of readers, -1 if writer */
2937c478bd9Sstevel@tonic-gate 		int	mutex_locked;	/* non-zero iff locked */
2947c478bd9Sstevel@tonic-gate 	} si_state;
2957c478bd9Sstevel@tonic-gate 	int		si_size;	/* size in bytes of synch variable */
2967c478bd9Sstevel@tonic-gate 	uint8_t		si_has_waiters;	/* non-zero iff at least one waiter */
2977c478bd9Sstevel@tonic-gate 	uint8_t		si_is_wlock;	/* non-zero iff rwlock write-locked */
2987c478bd9Sstevel@tonic-gate 	uint8_t		si_rcount;	/* count for locked recursive mutex */
2997c478bd9Sstevel@tonic-gate 	uint8_t		si_prioceiling;	/* ceiling pri (PTHREAD_PRIO_PROTECT) */
3007c478bd9Sstevel@tonic-gate 	td_thrhandle_t	si_owner;	/* mutex holder or write-lock holder */
3017c478bd9Sstevel@tonic-gate 	psaddr_t	si_data;	/* optional data */
3027c478bd9Sstevel@tonic-gate } td_syncinfo_t;
3037c478bd9Sstevel@tonic-gate 
3047c478bd9Sstevel@tonic-gate /*
3057c478bd9Sstevel@tonic-gate  * Statistics structures for the various synchronization objects, contained
3067c478bd9Sstevel@tonic-gate  * within the td_syncstats structure returned by td_sync_get_stats().
3077c478bd9Sstevel@tonic-gate  */
3087c478bd9Sstevel@tonic-gate typedef struct {
3097c478bd9Sstevel@tonic-gate 	uint_t		mutex_lock;
3107c478bd9Sstevel@tonic-gate 	uint_t		mutex_sleep;
3117c478bd9Sstevel@tonic-gate 	hrtime_t	mutex_sleep_time;
3127c478bd9Sstevel@tonic-gate 	hrtime_t	mutex_hold_time;
3137c478bd9Sstevel@tonic-gate 	uint_t		mutex_try;
3147c478bd9Sstevel@tonic-gate 	uint_t		mutex_try_fail;
3157c478bd9Sstevel@tonic-gate 	uint_t		mutex_internal;		/* internal to libthread */
3167c478bd9Sstevel@tonic-gate } td_mutex_stats_t;
3177c478bd9Sstevel@tonic-gate 
3187c478bd9Sstevel@tonic-gate typedef struct {
3197c478bd9Sstevel@tonic-gate 	uint_t		cond_wait;
3207c478bd9Sstevel@tonic-gate 	uint_t		cond_timedwait;
3217c478bd9Sstevel@tonic-gate 	hrtime_t	cond_wait_sleep_time;
3227c478bd9Sstevel@tonic-gate 	hrtime_t	cond_timedwait_sleep_time;
3237c478bd9Sstevel@tonic-gate 	uint_t		cond_timedwait_timeout;
3247c478bd9Sstevel@tonic-gate 	uint_t		cond_signal;
3257c478bd9Sstevel@tonic-gate 	uint_t		cond_broadcast;
3267c478bd9Sstevel@tonic-gate 	uint_t		cond_internal;		/* internal to libthread */
3277c478bd9Sstevel@tonic-gate } td_cond_stats_t;
3287c478bd9Sstevel@tonic-gate 
3297c478bd9Sstevel@tonic-gate typedef struct {
3307c478bd9Sstevel@tonic-gate 	uint_t		rw_rdlock;
3317c478bd9Sstevel@tonic-gate 	uint_t		rw_rdlock_sleep;
3327c478bd9Sstevel@tonic-gate 	hrtime_t	rw_rdlock_sleep_time;
3337c478bd9Sstevel@tonic-gate 	uint_t		rw_rdlock_try;
3347c478bd9Sstevel@tonic-gate 	uint_t		rw_rdlock_try_fail;
3357c478bd9Sstevel@tonic-gate 	uint_t		rw_wrlock;
3367c478bd9Sstevel@tonic-gate 	uint_t		rw_wrlock_sleep;
3377c478bd9Sstevel@tonic-gate 	hrtime_t	rw_wrlock_sleep_time;
3387c478bd9Sstevel@tonic-gate 	hrtime_t	rw_wrlock_hold_time;
3397c478bd9Sstevel@tonic-gate 	uint_t		rw_wrlock_try;
3407c478bd9Sstevel@tonic-gate 	uint_t		rw_wrlock_try_fail;
3417c478bd9Sstevel@tonic-gate } td_rwlock_stats_t;
3427c478bd9Sstevel@tonic-gate 
3437c478bd9Sstevel@tonic-gate typedef struct {
3447c478bd9Sstevel@tonic-gate 	uint_t		sema_wait;
3457c478bd9Sstevel@tonic-gate 	uint_t		sema_wait_sleep;
3467c478bd9Sstevel@tonic-gate 	hrtime_t	sema_wait_sleep_time;
3477c478bd9Sstevel@tonic-gate 	uint_t		sema_trywait;
3487c478bd9Sstevel@tonic-gate 	uint_t		sema_trywait_fail;
3497c478bd9Sstevel@tonic-gate 	uint_t		sema_post;
3507c478bd9Sstevel@tonic-gate 	uint_t		sema_max_count;
3517c478bd9Sstevel@tonic-gate 	uint_t		sema_min_count;
3527c478bd9Sstevel@tonic-gate } td_sema_stats_t;
3537c478bd9Sstevel@tonic-gate 
3547c478bd9Sstevel@tonic-gate /*
3557c478bd9Sstevel@tonic-gate  * Synchronization object statistics structure filled in by td_sync_get_stats()
3567c478bd9Sstevel@tonic-gate  */
3577c478bd9Sstevel@tonic-gate typedef struct td_syncstats {
3587c478bd9Sstevel@tonic-gate 	td_syncinfo_t	ss_info;	/* as returned by td_sync_get_info() */
3597c478bd9Sstevel@tonic-gate 	union {
3607c478bd9Sstevel@tonic-gate 		td_mutex_stats_t	mutex;
3617c478bd9Sstevel@tonic-gate 		td_cond_stats_t		cond;
3627c478bd9Sstevel@tonic-gate 		td_rwlock_stats_t	rwlock;
3637c478bd9Sstevel@tonic-gate 		td_sema_stats_t		sema;
3647c478bd9Sstevel@tonic-gate 		uint_t			pad[32];	/* for future growth */
3657c478bd9Sstevel@tonic-gate 	} ss_un;
3667c478bd9Sstevel@tonic-gate } td_syncstats_t;
3677c478bd9Sstevel@tonic-gate 
3687c478bd9Sstevel@tonic-gate /* The set of error codes. */
3697c478bd9Sstevel@tonic-gate typedef enum {
3707c478bd9Sstevel@tonic-gate 	TD_OK,		/* generic "call succeeded" */
3717c478bd9Sstevel@tonic-gate 	TD_ERR,		/* generic error. */
3727c478bd9Sstevel@tonic-gate 	TD_NOTHR,	/* no thread can be found to satisfy query */
3737c478bd9Sstevel@tonic-gate 	TD_NOSV,	/* no synch. handle can be found to satisfy query */
3747c478bd9Sstevel@tonic-gate 	TD_NOLWP,	/* no lwp can be found to satisfy query */
3757c478bd9Sstevel@tonic-gate 	TD_BADPH,	/* invalid process handle */
3767c478bd9Sstevel@tonic-gate 	TD_BADTH,	/* invalid thread handle */
3777c478bd9Sstevel@tonic-gate 	TD_BADSH,	/* invalid synchronization handle */
3787c478bd9Sstevel@tonic-gate 	TD_BADTA,	/* invalid thread agent */
3797c478bd9Sstevel@tonic-gate 	TD_BADKEY,	/* invalid key */
3807c478bd9Sstevel@tonic-gate 	TD_NOMSG,	/* no event message for td_thr_event_getmsg() */
3817c478bd9Sstevel@tonic-gate 	TD_NOFPREGS,	/* FPU register set not available */
3827c478bd9Sstevel@tonic-gate 	TD_NOLIBTHREAD,	/* application not linked with libthread */
3837c478bd9Sstevel@tonic-gate 	TD_NOEVENT,	/* requested event is not supported */
3847c478bd9Sstevel@tonic-gate 	TD_NOCAPAB,	/* capability not available */
3857c478bd9Sstevel@tonic-gate 	TD_DBERR,	/* Debugger service failed */
3867c478bd9Sstevel@tonic-gate 	TD_NOAPLIC,	/* Operation not applicable to */
3877c478bd9Sstevel@tonic-gate 	TD_NOTSD,	/* No thread-specific data for this thread */
3887c478bd9Sstevel@tonic-gate 	TD_MALLOC,	/* Malloc failed */
3897c478bd9Sstevel@tonic-gate 	TD_PARTIALREG,	/* Only part of register set was writen/read */
3907c478bd9Sstevel@tonic-gate 	TD_NOXREGS,	/* X register set not available for given thread */
3917c478bd9Sstevel@tonic-gate 	TD_NOTLS,	/* There is no TLS in the specified module */
3927c478bd9Sstevel@tonic-gate 	TD_TLSDEFER	/* module's TLS not yet allocated by the thread */
3937c478bd9Sstevel@tonic-gate }	td_err_e;
3947c478bd9Sstevel@tonic-gate 
3957c478bd9Sstevel@tonic-gate 
3967c478bd9Sstevel@tonic-gate /* ----------------------------------------------------------------------- */
3977c478bd9Sstevel@tonic-gate 
3987c478bd9Sstevel@tonic-gate /*
3997c478bd9Sstevel@tonic-gate  * Exported functions.
4007c478bd9Sstevel@tonic-gate  */
4017c478bd9Sstevel@tonic-gate 
4027c478bd9Sstevel@tonic-gate /*
4037c478bd9Sstevel@tonic-gate  * Initialize the threads debug interface.
4047c478bd9Sstevel@tonic-gate  */
4057c478bd9Sstevel@tonic-gate td_err_e
4067c478bd9Sstevel@tonic-gate td_init(void);
4077c478bd9Sstevel@tonic-gate 
4087c478bd9Sstevel@tonic-gate /*
4097c478bd9Sstevel@tonic-gate  * A no-op, left for historical reasons.
4107c478bd9Sstevel@tonic-gate  */
4117c478bd9Sstevel@tonic-gate void
4127c478bd9Sstevel@tonic-gate td_log(void);
4137c478bd9Sstevel@tonic-gate 
4147c478bd9Sstevel@tonic-gate /*
4157c478bd9Sstevel@tonic-gate  * Allocate a new process handle ("thread agent").
4167c478bd9Sstevel@tonic-gate  */
4177c478bd9Sstevel@tonic-gate td_err_e
4187c478bd9Sstevel@tonic-gate td_ta_new(struct ps_prochandle *, td_thragent_t **);
4197c478bd9Sstevel@tonic-gate 
4207c478bd9Sstevel@tonic-gate /*
4217c478bd9Sstevel@tonic-gate  * De-allocate a process handle, releasing all related resources.
4227c478bd9Sstevel@tonic-gate  */
4237c478bd9Sstevel@tonic-gate td_err_e
4247c478bd9Sstevel@tonic-gate td_ta_delete(td_thragent_t *);
4257c478bd9Sstevel@tonic-gate 
4267c478bd9Sstevel@tonic-gate /*
4277c478bd9Sstevel@tonic-gate  * Map a process handle to a client process handle.
4287c478bd9Sstevel@tonic-gate  */
4297c478bd9Sstevel@tonic-gate td_err_e
4307c478bd9Sstevel@tonic-gate td_ta_get_ph(const td_thragent_t *, struct ps_prochandle **);
4317c478bd9Sstevel@tonic-gate 
4327c478bd9Sstevel@tonic-gate /*
4337c478bd9Sstevel@tonic-gate  * Set the process's suggested concurrency level.
4347c478bd9Sstevel@tonic-gate  */
4357c478bd9Sstevel@tonic-gate td_err_e
4367c478bd9Sstevel@tonic-gate td_ta_setconcurrency(const td_thragent_t *, int);
4377c478bd9Sstevel@tonic-gate 
4387c478bd9Sstevel@tonic-gate /*
4397c478bd9Sstevel@tonic-gate  * Get the number of threads in the process, including zombie threads.
4407c478bd9Sstevel@tonic-gate  */
4417c478bd9Sstevel@tonic-gate td_err_e
4427c478bd9Sstevel@tonic-gate td_ta_get_nthreads(const td_thragent_t *, int *);
4437c478bd9Sstevel@tonic-gate 
4447c478bd9Sstevel@tonic-gate /*
4457c478bd9Sstevel@tonic-gate  * Map a tid, as returned by thr_create(), to a thread handle.
4467c478bd9Sstevel@tonic-gate  */
4477c478bd9Sstevel@tonic-gate td_err_e
4487c478bd9Sstevel@tonic-gate td_ta_map_id2thr(const td_thragent_t *, thread_t,  td_thrhandle_t *);
4497c478bd9Sstevel@tonic-gate 
4507c478bd9Sstevel@tonic-gate /*
4517c478bd9Sstevel@tonic-gate  * Map the address of a synchronization object to a sync. object handle.
4527c478bd9Sstevel@tonic-gate  */
4537c478bd9Sstevel@tonic-gate td_err_e
4547c478bd9Sstevel@tonic-gate td_ta_map_addr2sync(const td_thragent_t *, psaddr_t, td_synchandle_t *);
4557c478bd9Sstevel@tonic-gate 
4567c478bd9Sstevel@tonic-gate /*
4577c478bd9Sstevel@tonic-gate  * Iterate over a process's thread-specific data (TSD) keys.
4587c478bd9Sstevel@tonic-gate  */
4597c478bd9Sstevel@tonic-gate td_err_e
4607c478bd9Sstevel@tonic-gate td_ta_tsd_iter(const td_thragent_t *, td_key_iter_f *, void *);
4617c478bd9Sstevel@tonic-gate 
4627c478bd9Sstevel@tonic-gate /*
4637c478bd9Sstevel@tonic-gate  * Iterate over a process's threads, including zombie threads.
4647c478bd9Sstevel@tonic-gate  */
4657c478bd9Sstevel@tonic-gate td_err_e
4667c478bd9Sstevel@tonic-gate td_ta_thr_iter(const td_thragent_t *, td_thr_iter_f *, void *,
467*6e270ca8SMarcel Telka     td_thr_state_e, int, sigset_t *, unsigned);
4687c478bd9Sstevel@tonic-gate 
4697c478bd9Sstevel@tonic-gate /*
4707c478bd9Sstevel@tonic-gate  * Iterate over a process's known synchronization objects.
4717c478bd9Sstevel@tonic-gate  */
4727c478bd9Sstevel@tonic-gate td_err_e
4737c478bd9Sstevel@tonic-gate td_ta_sync_iter(const td_thragent_t *, td_sync_iter_f *, void *);
4747c478bd9Sstevel@tonic-gate 
4757c478bd9Sstevel@tonic-gate /*
4767c478bd9Sstevel@tonic-gate  * Enable/disable process statistics collection.
4777c478bd9Sstevel@tonic-gate  */
4787c478bd9Sstevel@tonic-gate td_err_e
4797c478bd9Sstevel@tonic-gate td_ta_enable_stats(const td_thragent_t *, int);
4807c478bd9Sstevel@tonic-gate 
4817c478bd9Sstevel@tonic-gate /*
4827c478bd9Sstevel@tonic-gate  * Reset process statistics.
4837c478bd9Sstevel@tonic-gate  */
4847c478bd9Sstevel@tonic-gate td_err_e
4857c478bd9Sstevel@tonic-gate td_ta_reset_stats(const td_thragent_t *);
4867c478bd9Sstevel@tonic-gate 
4877c478bd9Sstevel@tonic-gate /*
4887c478bd9Sstevel@tonic-gate  * Read process statistics.
4897c478bd9Sstevel@tonic-gate  */
4907c478bd9Sstevel@tonic-gate td_err_e
4917c478bd9Sstevel@tonic-gate td_ta_get_stats(const td_thragent_t *, td_ta_stats_t *);
4927c478bd9Sstevel@tonic-gate 
4937c478bd9Sstevel@tonic-gate /*
4947c478bd9Sstevel@tonic-gate  * Get thread information.
4957c478bd9Sstevel@tonic-gate  */
4967c478bd9Sstevel@tonic-gate td_err_e
4977c478bd9Sstevel@tonic-gate td_thr_get_info(const td_thrhandle_t *, td_thrinfo_t *);
4987c478bd9Sstevel@tonic-gate 
4997c478bd9Sstevel@tonic-gate /*
5007c478bd9Sstevel@tonic-gate  * Get the "event address" for an event type.
5017c478bd9Sstevel@tonic-gate  */
5027c478bd9Sstevel@tonic-gate td_err_e
5037c478bd9Sstevel@tonic-gate td_ta_event_addr(const td_thragent_t *, td_event_e, td_notify_t *);
5047c478bd9Sstevel@tonic-gate 
5057c478bd9Sstevel@tonic-gate /*
5067c478bd9Sstevel@tonic-gate  * Enable/disable event reporting for a thread.
5077c478bd9Sstevel@tonic-gate  */
5087c478bd9Sstevel@tonic-gate td_err_e
5097c478bd9Sstevel@tonic-gate td_thr_event_enable(const td_thrhandle_t *, int);
5107c478bd9Sstevel@tonic-gate 
5117c478bd9Sstevel@tonic-gate /*
5127c478bd9Sstevel@tonic-gate  * Enable a set of events for a thread.
5137c478bd9Sstevel@tonic-gate  */
5147c478bd9Sstevel@tonic-gate td_err_e
5157c478bd9Sstevel@tonic-gate td_thr_set_event(const td_thrhandle_t *, td_thr_events_t *);
5167c478bd9Sstevel@tonic-gate 
5177c478bd9Sstevel@tonic-gate /*
5187c478bd9Sstevel@tonic-gate  * Disable a set of events for a thread.
5197c478bd9Sstevel@tonic-gate  */
5207c478bd9Sstevel@tonic-gate td_err_e
5217c478bd9Sstevel@tonic-gate td_thr_clear_event(const td_thrhandle_t *, td_thr_events_t *);
5227c478bd9Sstevel@tonic-gate 
5237c478bd9Sstevel@tonic-gate /*
5247c478bd9Sstevel@tonic-gate  * Retrieve (and consume) an event message for a thread.
5257c478bd9Sstevel@tonic-gate  */
5267c478bd9Sstevel@tonic-gate td_err_e
5277c478bd9Sstevel@tonic-gate td_thr_event_getmsg(const td_thrhandle_t *, td_event_msg_t *);
5287c478bd9Sstevel@tonic-gate 
5297c478bd9Sstevel@tonic-gate /*
5307c478bd9Sstevel@tonic-gate  * Enable a set of events in the process.
5317c478bd9Sstevel@tonic-gate  */
5327c478bd9Sstevel@tonic-gate td_err_e
5337c478bd9Sstevel@tonic-gate td_ta_set_event(const td_thragent_t *, td_thr_events_t *);
5347c478bd9Sstevel@tonic-gate 
5357c478bd9Sstevel@tonic-gate /*
5367c478bd9Sstevel@tonic-gate  * Disable a set of events in the process.
5377c478bd9Sstevel@tonic-gate  */
5387c478bd9Sstevel@tonic-gate td_err_e
5397c478bd9Sstevel@tonic-gate td_ta_clear_event(const td_thragent_t *, td_thr_events_t *);
5407c478bd9Sstevel@tonic-gate 
5417c478bd9Sstevel@tonic-gate /*
5427c478bd9Sstevel@tonic-gate  * Retrieve (and consume) an event message for some thread in the process.
5437c478bd9Sstevel@tonic-gate  */
5447c478bd9Sstevel@tonic-gate td_err_e
5457c478bd9Sstevel@tonic-gate td_ta_event_getmsg(const td_thragent_t *, td_event_msg_t *);
5467c478bd9Sstevel@tonic-gate 
5477c478bd9Sstevel@tonic-gate /*
5487c478bd9Sstevel@tonic-gate  * Suspend a thread.
5497c478bd9Sstevel@tonic-gate  */
5507c478bd9Sstevel@tonic-gate td_err_e
5517c478bd9Sstevel@tonic-gate td_thr_dbsuspend(const td_thrhandle_t *);
5527c478bd9Sstevel@tonic-gate 
5537c478bd9Sstevel@tonic-gate /*
5547c478bd9Sstevel@tonic-gate  * Resume a suspended thread.
5557c478bd9Sstevel@tonic-gate  */
5567c478bd9Sstevel@tonic-gate td_err_e
5577c478bd9Sstevel@tonic-gate td_thr_dbresume(const td_thrhandle_t *);
5587c478bd9Sstevel@tonic-gate 
5597c478bd9Sstevel@tonic-gate /*
5607c478bd9Sstevel@tonic-gate  * Set a thread's signal mask.
5617c478bd9Sstevel@tonic-gate  */
5627c478bd9Sstevel@tonic-gate td_err_e
5637c478bd9Sstevel@tonic-gate td_thr_sigsetmask(const td_thrhandle_t *, const sigset_t);
5647c478bd9Sstevel@tonic-gate 
5657c478bd9Sstevel@tonic-gate /*
5667c478bd9Sstevel@tonic-gate  * Set a thread's "signals-pending" set.
5677c478bd9Sstevel@tonic-gate  */
5687c478bd9Sstevel@tonic-gate td_err_e
5697c478bd9Sstevel@tonic-gate td_thr_setsigpending(const td_thrhandle_t *, uchar_t, const sigset_t);
5707c478bd9Sstevel@tonic-gate 
5717c478bd9Sstevel@tonic-gate /*
5727c478bd9Sstevel@tonic-gate  * Get a thread's general register set.
5737c478bd9Sstevel@tonic-gate  */
5747c478bd9Sstevel@tonic-gate td_err_e
5757c478bd9Sstevel@tonic-gate td_thr_getgregs(const td_thrhandle_t *, prgregset_t);
5767c478bd9Sstevel@tonic-gate 
5777c478bd9Sstevel@tonic-gate /*
5787c478bd9Sstevel@tonic-gate  * Set a thread's general register set.
5797c478bd9Sstevel@tonic-gate  */
5807c478bd9Sstevel@tonic-gate td_err_e
5817c478bd9Sstevel@tonic-gate td_thr_setgregs(const td_thrhandle_t *, const prgregset_t);
5827c478bd9Sstevel@tonic-gate 
5837c478bd9Sstevel@tonic-gate /*
5847c478bd9Sstevel@tonic-gate  * Get a thread's floating-point register set.
5857c478bd9Sstevel@tonic-gate  */
5867c478bd9Sstevel@tonic-gate td_err_e
5877c478bd9Sstevel@tonic-gate td_thr_getfpregs(const td_thrhandle_t *, prfpregset_t *);
5887c478bd9Sstevel@tonic-gate 
5897c478bd9Sstevel@tonic-gate /*
5907c478bd9Sstevel@tonic-gate  * Set a thread's floating-point register set.
5917c478bd9Sstevel@tonic-gate  */
5927c478bd9Sstevel@tonic-gate td_err_e
5937c478bd9Sstevel@tonic-gate td_thr_setfpregs(const td_thrhandle_t *, const prfpregset_t *);
5947c478bd9Sstevel@tonic-gate 
5957c478bd9Sstevel@tonic-gate /*
5967c478bd9Sstevel@tonic-gate  * Get the size of the extra state register set for this architecture.
5977c478bd9Sstevel@tonic-gate  */
5987c478bd9Sstevel@tonic-gate td_err_e
5997c478bd9Sstevel@tonic-gate td_thr_getxregsize(const td_thrhandle_t *th_p, int *xregsize);
6007c478bd9Sstevel@tonic-gate 
6017c478bd9Sstevel@tonic-gate /*
6027c478bd9Sstevel@tonic-gate  * Get a thread's extra state register set.
6037c478bd9Sstevel@tonic-gate  */
6047c478bd9Sstevel@tonic-gate td_err_e
6057c478bd9Sstevel@tonic-gate td_thr_getxregs(const td_thrhandle_t *th_p, void *xregs);
6067c478bd9Sstevel@tonic-gate 
6077c478bd9Sstevel@tonic-gate /*
6087c478bd9Sstevel@tonic-gate  * Set a thread's extra state register set.
6097c478bd9Sstevel@tonic-gate  */
6107c478bd9Sstevel@tonic-gate td_err_e
6117c478bd9Sstevel@tonic-gate td_thr_setxregs(const td_thrhandle_t *th_p, const void *xregs);
6127c478bd9Sstevel@tonic-gate 
6137c478bd9Sstevel@tonic-gate /*
6147c478bd9Sstevel@tonic-gate  * Validate a thread handle.
6157c478bd9Sstevel@tonic-gate  */
6167c478bd9Sstevel@tonic-gate td_err_e
6177c478bd9Sstevel@tonic-gate td_thr_validate(const td_thrhandle_t *);
6187c478bd9Sstevel@tonic-gate 
6197c478bd9Sstevel@tonic-gate /*
6207c478bd9Sstevel@tonic-gate  * Get a thread-specific data pointer for a thread.
6217c478bd9Sstevel@tonic-gate  */
6227c478bd9Sstevel@tonic-gate td_err_e
6237c478bd9Sstevel@tonic-gate td_thr_tsd(const td_thrhandle_t *, thread_key_t, void **);
6247c478bd9Sstevel@tonic-gate 
6257c478bd9Sstevel@tonic-gate /*
6267c478bd9Sstevel@tonic-gate  * Get the base address of a thread's thread local storage (TLS) block
6277c478bd9Sstevel@tonic-gate  * for the module (executable or shared object) identified by 'moduleid'.
6287c478bd9Sstevel@tonic-gate  */
6297c478bd9Sstevel@tonic-gate td_err_e
6307c478bd9Sstevel@tonic-gate td_thr_tlsbase(const td_thrhandle_t *, ulong_t moduleid, psaddr_t *base);
6317c478bd9Sstevel@tonic-gate 
6327c478bd9Sstevel@tonic-gate /*
6337c478bd9Sstevel@tonic-gate  * Set a thread's priority.
6347c478bd9Sstevel@tonic-gate  */
6357c478bd9Sstevel@tonic-gate td_err_e
6367c478bd9Sstevel@tonic-gate td_thr_setprio(const td_thrhandle_t *, int);
6377c478bd9Sstevel@tonic-gate 
6387c478bd9Sstevel@tonic-gate /*
6397c478bd9Sstevel@tonic-gate  * Iterate over the set of locks owned by a thread.
6407c478bd9Sstevel@tonic-gate  */
6417c478bd9Sstevel@tonic-gate td_err_e
6427c478bd9Sstevel@tonic-gate td_thr_lockowner(const td_thrhandle_t *, td_sync_iter_f *, void *);
6437c478bd9Sstevel@tonic-gate 
6447c478bd9Sstevel@tonic-gate /*
6457c478bd9Sstevel@tonic-gate  * Return the sync. handle of the object this thread is sleeping on.
6467c478bd9Sstevel@tonic-gate  */
6477c478bd9Sstevel@tonic-gate td_err_e
6487c478bd9Sstevel@tonic-gate td_thr_sleepinfo(const td_thrhandle_t *, td_synchandle_t *);
6497c478bd9Sstevel@tonic-gate 
6507c478bd9Sstevel@tonic-gate /*
6517c478bd9Sstevel@tonic-gate  * Map an lwpid, as returned by _lwp_create(), to a thread handle.
6527c478bd9Sstevel@tonic-gate  */
6537c478bd9Sstevel@tonic-gate td_err_e
6547c478bd9Sstevel@tonic-gate td_ta_map_lwp2thr(const td_thragent_t *, lwpid_t, td_thrhandle_t *th_p);
6557c478bd9Sstevel@tonic-gate 
6567c478bd9Sstevel@tonic-gate /*
6577c478bd9Sstevel@tonic-gate  * Enable/disable a process's synchronization object tracking.
6587c478bd9Sstevel@tonic-gate  */
6597c478bd9Sstevel@tonic-gate td_err_e
6607c478bd9Sstevel@tonic-gate td_ta_sync_tracking_enable(const td_thragent_t *, int);
6617c478bd9Sstevel@tonic-gate 
6627c478bd9Sstevel@tonic-gate /*
6637c478bd9Sstevel@tonic-gate  * Get information about a synchronization object.
6647c478bd9Sstevel@tonic-gate  */
6657c478bd9Sstevel@tonic-gate td_err_e
6667c478bd9Sstevel@tonic-gate td_sync_get_info(const td_synchandle_t *, td_syncinfo_t *);
6677c478bd9Sstevel@tonic-gate 
6687c478bd9Sstevel@tonic-gate /*
6697c478bd9Sstevel@tonic-gate  * Get statistics for a synchronization object.
6707c478bd9Sstevel@tonic-gate  */
6717c478bd9Sstevel@tonic-gate td_err_e
6727c478bd9Sstevel@tonic-gate td_sync_get_stats(const td_synchandle_t *, td_syncstats_t *);
6737c478bd9Sstevel@tonic-gate 
6747c478bd9Sstevel@tonic-gate /*
6757c478bd9Sstevel@tonic-gate  * Set the state of a synchronization object.
6767c478bd9Sstevel@tonic-gate  */
6777c478bd9Sstevel@tonic-gate td_err_e
6787c478bd9Sstevel@tonic-gate td_sync_setstate(const td_synchandle_t *, int value);
6797c478bd9Sstevel@tonic-gate 
6807c478bd9Sstevel@tonic-gate /*
6817c478bd9Sstevel@tonic-gate  * Iterate over all threads blocked on a synchronization object.
6827c478bd9Sstevel@tonic-gate  */
6837c478bd9Sstevel@tonic-gate td_err_e
6847c478bd9Sstevel@tonic-gate td_sync_waiters(const td_synchandle_t *, td_thr_iter_f *, void *);
6857c478bd9Sstevel@tonic-gate 
6867c478bd9Sstevel@tonic-gate #ifdef __cplusplus
6877c478bd9Sstevel@tonic-gate }
6887c478bd9Sstevel@tonic-gate #endif
6897c478bd9Sstevel@tonic-gate 
6907c478bd9Sstevel@tonic-gate #endif	/* _THREAD_DB_H */
691