1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _THREAD_DB_H 28*7c478bd9Sstevel@tonic-gate #define _THREAD_DB_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate /* 33*7c478bd9Sstevel@tonic-gate * 34*7c478bd9Sstevel@tonic-gate * Description: 35*7c478bd9Sstevel@tonic-gate * Types, global variables, and function definitions for users 36*7c478bd9Sstevel@tonic-gate * of libc_db (formerly libthread_db). 37*7c478bd9Sstevel@tonic-gate * 38*7c478bd9Sstevel@tonic-gate */ 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate 41*7c478bd9Sstevel@tonic-gate #include <sys/lwp.h> 42*7c478bd9Sstevel@tonic-gate #include <sys/procfs_isa.h> 43*7c478bd9Sstevel@tonic-gate #include <thread.h> 44*7c478bd9Sstevel@tonic-gate #include <proc_service.h> 45*7c478bd9Sstevel@tonic-gate 46*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 47*7c478bd9Sstevel@tonic-gate extern "C" { 48*7c478bd9Sstevel@tonic-gate #endif 49*7c478bd9Sstevel@tonic-gate 50*7c478bd9Sstevel@tonic-gate #define TD_THR_ANY_USER_FLAGS 0xffffffff 51*7c478bd9Sstevel@tonic-gate #define TD_THR_LOWEST_PRIORITY 0 52*7c478bd9Sstevel@tonic-gate #define TD_SIGNO_MASK 0 53*7c478bd9Sstevel@tonic-gate #define TD_EVENTSIZE 2 54*7c478bd9Sstevel@tonic-gate 55*7c478bd9Sstevel@tonic-gate /* 56*7c478bd9Sstevel@tonic-gate * Opaque handle types. 57*7c478bd9Sstevel@tonic-gate */ 58*7c478bd9Sstevel@tonic-gate 59*7c478bd9Sstevel@tonic-gate /* Client's handle for a process */ 60*7c478bd9Sstevel@tonic-gate struct ps_prochandle; 61*7c478bd9Sstevel@tonic-gate 62*7c478bd9Sstevel@tonic-gate /* libthread's handle for a process */ 63*7c478bd9Sstevel@tonic-gate typedef struct td_thragent td_thragent_t; 64*7c478bd9Sstevel@tonic-gate 65*7c478bd9Sstevel@tonic-gate /* The thread handle. */ 66*7c478bd9Sstevel@tonic-gate typedef struct td_thrhandle { 67*7c478bd9Sstevel@tonic-gate td_thragent_t *th_ta_p; 68*7c478bd9Sstevel@tonic-gate psaddr_t th_unique; 69*7c478bd9Sstevel@tonic-gate } td_thrhandle_t; 70*7c478bd9Sstevel@tonic-gate 71*7c478bd9Sstevel@tonic-gate /* The handle for a synchronization object. */ 72*7c478bd9Sstevel@tonic-gate typedef struct td_synchandle { 73*7c478bd9Sstevel@tonic-gate td_thragent_t *sh_ta_p; 74*7c478bd9Sstevel@tonic-gate psaddr_t sh_unique; 75*7c478bd9Sstevel@tonic-gate } td_synchandle_t; 76*7c478bd9Sstevel@tonic-gate 77*7c478bd9Sstevel@tonic-gate /* ------------------------------------------------------------------ */ 78*7c478bd9Sstevel@tonic-gate 79*7c478bd9Sstevel@tonic-gate /* 80*7c478bd9Sstevel@tonic-gate * The libc_db event facility. 81*7c478bd9Sstevel@tonic-gate */ 82*7c478bd9Sstevel@tonic-gate #define BT_UISHIFT 5 /* log base 2 of BT_NBIPUI, to extract word index */ 83*7c478bd9Sstevel@tonic-gate #define BT_NBIPUI (1 << BT_UISHIFT) /* n bits per uint */ 84*7c478bd9Sstevel@tonic-gate #define BT_UIMASK (BT_NBIPUI - 1) /* to extract bit index */ 85*7c478bd9Sstevel@tonic-gate 86*7c478bd9Sstevel@tonic-gate /* Bitmask of enabled events. */ 87*7c478bd9Sstevel@tonic-gate typedef struct td_thr_events { 88*7c478bd9Sstevel@tonic-gate uint_t event_bits[TD_EVENTSIZE]; 89*7c478bd9Sstevel@tonic-gate } td_thr_events_t; 90*7c478bd9Sstevel@tonic-gate 91*7c478bd9Sstevel@tonic-gate /* Event set manipulation macros. */ 92*7c478bd9Sstevel@tonic-gate #define __td_eventmask(n) ((unsigned int)1 << (((n) - 1) \ 93*7c478bd9Sstevel@tonic-gate & (BT_NBIPUI - 1))) 94*7c478bd9Sstevel@tonic-gate #define __td_eventword(n) (((unsigned int)((n) - 1))>>5) 95*7c478bd9Sstevel@tonic-gate 96*7c478bd9Sstevel@tonic-gate #define td_event_emptyset(setp) \ 97*7c478bd9Sstevel@tonic-gate { \ 98*7c478bd9Sstevel@tonic-gate int _i_; \ 99*7c478bd9Sstevel@tonic-gate _i_ = TD_EVENTSIZE; \ 100*7c478bd9Sstevel@tonic-gate while (_i_) (setp)->event_bits[--_i_] = 0; \ 101*7c478bd9Sstevel@tonic-gate } 102*7c478bd9Sstevel@tonic-gate 103*7c478bd9Sstevel@tonic-gate #define td_event_fillset(setp) \ 104*7c478bd9Sstevel@tonic-gate { \ 105*7c478bd9Sstevel@tonic-gate int _i_; \ 106*7c478bd9Sstevel@tonic-gate _i_ = TD_EVENTSIZE; \ 107*7c478bd9Sstevel@tonic-gate while (_i_) (setp)->event_bits[--_i_] = \ 108*7c478bd9Sstevel@tonic-gate 0xffffffff; \ 109*7c478bd9Sstevel@tonic-gate } 110*7c478bd9Sstevel@tonic-gate 111*7c478bd9Sstevel@tonic-gate #define td_event_addset(setp, n) \ 112*7c478bd9Sstevel@tonic-gate (((setp)->event_bits[__td_eventword(n)]) |= __td_eventmask(n)) 113*7c478bd9Sstevel@tonic-gate #define td_event_delset(setp, n) \ 114*7c478bd9Sstevel@tonic-gate (((setp)->event_bits[__td_eventword(n)]) &= ~__td_eventmask(n)) 115*7c478bd9Sstevel@tonic-gate #define td_eventismember(setp, n) \ 116*7c478bd9Sstevel@tonic-gate (__td_eventmask(n) & ((setp)->event_bits[__td_eventword(n)])) 117*7c478bd9Sstevel@tonic-gate #define td_eventisempty(setp) \ 118*7c478bd9Sstevel@tonic-gate (!((setp)->event_bits[0]) && !((setp)->event_bits[1])) 119*7c478bd9Sstevel@tonic-gate 120*7c478bd9Sstevel@tonic-gate typedef enum { 121*7c478bd9Sstevel@tonic-gate TD_ALL_EVENTS, /* pseudo-event number */ 122*7c478bd9Sstevel@tonic-gate TD_EVENT_NONE = TD_ALL_EVENTS, /* depends on context */ 123*7c478bd9Sstevel@tonic-gate TD_READY, 124*7c478bd9Sstevel@tonic-gate TD_SLEEP, 125*7c478bd9Sstevel@tonic-gate TD_SWITCHTO, 126*7c478bd9Sstevel@tonic-gate TD_SWITCHFROM, 127*7c478bd9Sstevel@tonic-gate TD_LOCK_TRY, 128*7c478bd9Sstevel@tonic-gate TD_CATCHSIG, 129*7c478bd9Sstevel@tonic-gate TD_IDLE, 130*7c478bd9Sstevel@tonic-gate TD_CREATE, 131*7c478bd9Sstevel@tonic-gate TD_DEATH, 132*7c478bd9Sstevel@tonic-gate TD_PREEMPT, 133*7c478bd9Sstevel@tonic-gate TD_PRI_INHERIT, 134*7c478bd9Sstevel@tonic-gate TD_REAP, 135*7c478bd9Sstevel@tonic-gate TD_CONCURRENCY, 136*7c478bd9Sstevel@tonic-gate TD_TIMEOUT, 137*7c478bd9Sstevel@tonic-gate TD_MIN_EVENT_NUM = TD_READY, 138*7c478bd9Sstevel@tonic-gate TD_MAX_EVENT_NUM = TD_TIMEOUT, 139*7c478bd9Sstevel@tonic-gate TD_EVENTS_ENABLE = 31 /* Event reporting enabled */ 140*7c478bd9Sstevel@tonic-gate } td_event_e; 141*7c478bd9Sstevel@tonic-gate 142*7c478bd9Sstevel@tonic-gate /* 143*7c478bd9Sstevel@tonic-gate * Ways that an event type can be reported. 144*7c478bd9Sstevel@tonic-gate */ 145*7c478bd9Sstevel@tonic-gate typedef enum { 146*7c478bd9Sstevel@tonic-gate NOTIFY_BPT, 147*7c478bd9Sstevel@tonic-gate /* 148*7c478bd9Sstevel@tonic-gate * bpt to be inserted at u.bptaddr by 149*7c478bd9Sstevel@tonic-gate * debugger 150*7c478bd9Sstevel@tonic-gate */ 151*7c478bd9Sstevel@tonic-gate NOTIFY_AUTOBPT, /* bpt inserted at u.bptaddr by application */ 152*7c478bd9Sstevel@tonic-gate NOTIFY_SYSCALL /* syscall u.syscallno will be invoked */ 153*7c478bd9Sstevel@tonic-gate } td_notify_e; 154*7c478bd9Sstevel@tonic-gate 155*7c478bd9Sstevel@tonic-gate /* 156*7c478bd9Sstevel@tonic-gate * How an event type is reported. 157*7c478bd9Sstevel@tonic-gate */ 158*7c478bd9Sstevel@tonic-gate typedef struct td_notify { 159*7c478bd9Sstevel@tonic-gate td_notify_e type; 160*7c478bd9Sstevel@tonic-gate union { 161*7c478bd9Sstevel@tonic-gate psaddr_t bptaddr; 162*7c478bd9Sstevel@tonic-gate int syscallno; 163*7c478bd9Sstevel@tonic-gate } u; 164*7c478bd9Sstevel@tonic-gate } td_notify_t; 165*7c478bd9Sstevel@tonic-gate 166*7c478bd9Sstevel@tonic-gate /* 167*7c478bd9Sstevel@tonic-gate * An event message. 168*7c478bd9Sstevel@tonic-gate */ 169*7c478bd9Sstevel@tonic-gate typedef struct td_event_msg { 170*7c478bd9Sstevel@tonic-gate td_event_e event; /* Event type being reported */ 171*7c478bd9Sstevel@tonic-gate const td_thrhandle_t *th_p; /* Thread reporting the event */ 172*7c478bd9Sstevel@tonic-gate union { /* Type-dependent event data */ 173*7c478bd9Sstevel@tonic-gate td_synchandle_t *sh; /* historical rubbish; ignore */ 174*7c478bd9Sstevel@tonic-gate uintptr_t data; /* valid, depending on event type */ 175*7c478bd9Sstevel@tonic-gate } msg; 176*7c478bd9Sstevel@tonic-gate } td_event_msg_t; 177*7c478bd9Sstevel@tonic-gate 178*7c478bd9Sstevel@tonic-gate /* --------------------------------------------------------------------- */ 179*7c478bd9Sstevel@tonic-gate 180*7c478bd9Sstevel@tonic-gate /* 181*7c478bd9Sstevel@tonic-gate * Thread information structure as returned by td_thr_get_info(), and 182*7c478bd9Sstevel@tonic-gate * related types. 183*7c478bd9Sstevel@tonic-gate */ 184*7c478bd9Sstevel@tonic-gate 185*7c478bd9Sstevel@tonic-gate /* 186*7c478bd9Sstevel@tonic-gate * Possible thread states. TD_THR_ANY_STATE is a pseudo-state used 187*7c478bd9Sstevel@tonic-gate * to select threads regardless of state in td_ta_thr_iter(). 188*7c478bd9Sstevel@tonic-gate */ 189*7c478bd9Sstevel@tonic-gate typedef enum { 190*7c478bd9Sstevel@tonic-gate TD_THR_ANY_STATE, 191*7c478bd9Sstevel@tonic-gate TD_THR_UNKNOWN, 192*7c478bd9Sstevel@tonic-gate TD_THR_STOPPED, 193*7c478bd9Sstevel@tonic-gate TD_THR_RUN, 194*7c478bd9Sstevel@tonic-gate TD_THR_ACTIVE, 195*7c478bd9Sstevel@tonic-gate TD_THR_ZOMBIE, 196*7c478bd9Sstevel@tonic-gate TD_THR_SLEEP, 197*7c478bd9Sstevel@tonic-gate TD_THR_STOPPED_ASLEEP 198*7c478bd9Sstevel@tonic-gate } td_thr_state_e; 199*7c478bd9Sstevel@tonic-gate 200*7c478bd9Sstevel@tonic-gate /* 201*7c478bd9Sstevel@tonic-gate * Thread type: user or system. 202*7c478bd9Sstevel@tonic-gate * As of Solaris 9, all threads are type TD_THR_USER. 203*7c478bd9Sstevel@tonic-gate */ 204*7c478bd9Sstevel@tonic-gate typedef enum { 205*7c478bd9Sstevel@tonic-gate TD_THR_ANY_TYPE, /* not used */ 206*7c478bd9Sstevel@tonic-gate TD_THR_USER, 207*7c478bd9Sstevel@tonic-gate TD_THR_SYSTEM 208*7c478bd9Sstevel@tonic-gate } td_thr_type_e; 209*7c478bd9Sstevel@tonic-gate 210*7c478bd9Sstevel@tonic-gate typedef struct td_thrinfo { 211*7c478bd9Sstevel@tonic-gate td_thragent_t *ti_ta_p; /* process handle */ 212*7c478bd9Sstevel@tonic-gate unsigned ti_user_flags; /* flags passed to thr_create() */ 213*7c478bd9Sstevel@tonic-gate thread_t ti_tid; /* tid returned by thr_create() */ 214*7c478bd9Sstevel@tonic-gate void *ti_exitval; /* thread exit value (TD_THR_ZOMBIE) */ 215*7c478bd9Sstevel@tonic-gate psaddr_t ti_startfunc; /* startfunc passed to thr_create() */ 216*7c478bd9Sstevel@tonic-gate psaddr_t ti_stkbase; /* base of thread's stack */ 217*7c478bd9Sstevel@tonic-gate long ti_stksize; /* size of thread's stack */ 218*7c478bd9Sstevel@tonic-gate psaddr_t ti_ro_area; /* address of uthread_t struct */ 219*7c478bd9Sstevel@tonic-gate int ti_ro_size; /* size of uthread_t struct */ 220*7c478bd9Sstevel@tonic-gate td_thr_state_e ti_state; /* thread state */ 221*7c478bd9Sstevel@tonic-gate uchar_t ti_db_suspended; /* boolean: suspended by debugger? */ 222*7c478bd9Sstevel@tonic-gate td_thr_type_e ti_type; /* thread type */ 223*7c478bd9Sstevel@tonic-gate intptr_t ti_pc; /* resume PC when sleeping */ 224*7c478bd9Sstevel@tonic-gate intptr_t ti_sp; /* resume SP when sleeping */ 225*7c478bd9Sstevel@tonic-gate short ti_flags; /* flags used by libthread */ 226*7c478bd9Sstevel@tonic-gate int ti_pri; /* thread priority */ 227*7c478bd9Sstevel@tonic-gate lwpid_t ti_lid; /* last LWP assigned to this thread */ 228*7c478bd9Sstevel@tonic-gate sigset_t ti_sigmask; /* signal mask */ 229*7c478bd9Sstevel@tonic-gate uchar_t ti_traceme; /* event reporting enabled? */ 230*7c478bd9Sstevel@tonic-gate uchar_t ti_preemptflag; /* was thread preemppted? */ 231*7c478bd9Sstevel@tonic-gate uchar_t ti_pirecflag; /* priority inheritance happened */ 232*7c478bd9Sstevel@tonic-gate sigset_t ti_pending; /* set of pending signals */ 233*7c478bd9Sstevel@tonic-gate td_thr_events_t ti_events; /* set of enabled events */ 234*7c478bd9Sstevel@tonic-gate } td_thrinfo_t; 235*7c478bd9Sstevel@tonic-gate 236*7c478bd9Sstevel@tonic-gate #define ti_tls ti_exitval /* for source compatibility */ 237*7c478bd9Sstevel@tonic-gate 238*7c478bd9Sstevel@tonic-gate typedef struct td_ta_stats { 239*7c478bd9Sstevel@tonic-gate int nthreads; /* total number of threads in use */ 240*7c478bd9Sstevel@tonic-gate int r_concurrency; /* requested concurrency level */ 241*7c478bd9Sstevel@tonic-gate int nrunnable_num; /* numerator, avg. runnable threads */ 242*7c478bd9Sstevel@tonic-gate int nrunnable_den; /* denominator, avg. runnable threads */ 243*7c478bd9Sstevel@tonic-gate int a_concurrency_num; /* numerator, achieved concurrency level */ 244*7c478bd9Sstevel@tonic-gate int a_concurrency_den; /* denominator, concurrency level */ 245*7c478bd9Sstevel@tonic-gate int nlwps_num; /* numerator, average number of LWP's in use */ 246*7c478bd9Sstevel@tonic-gate int nlwps_den; /* denom., average number of LWP's in use */ 247*7c478bd9Sstevel@tonic-gate int nidle_num; /* numerator, avg. number of idling LWP's */ 248*7c478bd9Sstevel@tonic-gate int nidle_den; /* denom., avg. number of idling LWP's */ 249*7c478bd9Sstevel@tonic-gate } td_ta_stats_t; 250*7c478bd9Sstevel@tonic-gate 251*7c478bd9Sstevel@tonic-gate /* 252*7c478bd9Sstevel@tonic-gate * Iterator callback function declarations. 253*7c478bd9Sstevel@tonic-gate */ 254*7c478bd9Sstevel@tonic-gate 255*7c478bd9Sstevel@tonic-gate /* Callback function for td_ta_tsd_iter(). */ 256*7c478bd9Sstevel@tonic-gate typedef int td_key_iter_f(thread_key_t, void (*destructor)(), void *); 257*7c478bd9Sstevel@tonic-gate 258*7c478bd9Sstevel@tonic-gate /* Callback function for td_ta_thr_iter(). */ 259*7c478bd9Sstevel@tonic-gate typedef int td_thr_iter_f(const td_thrhandle_t *, void *); 260*7c478bd9Sstevel@tonic-gate 261*7c478bd9Sstevel@tonic-gate /* Callback function for td_ta_sync_iter(). */ 262*7c478bd9Sstevel@tonic-gate typedef int td_sync_iter_f(const td_synchandle_t *, void *); 263*7c478bd9Sstevel@tonic-gate 264*7c478bd9Sstevel@tonic-gate /* -------------------------------------------------------------------- */ 265*7c478bd9Sstevel@tonic-gate 266*7c478bd9Sstevel@tonic-gate /* 267*7c478bd9Sstevel@tonic-gate * Synchronization Objects 268*7c478bd9Sstevel@tonic-gate */ 269*7c478bd9Sstevel@tonic-gate 270*7c478bd9Sstevel@tonic-gate /* Enumeration of synchronization object types. */ 271*7c478bd9Sstevel@tonic-gate typedef enum td_sync_type_e { 272*7c478bd9Sstevel@tonic-gate TD_SYNC_UNKNOWN, /* Sync. variable of unknown type */ 273*7c478bd9Sstevel@tonic-gate TD_SYNC_COND, /* Condition variable */ 274*7c478bd9Sstevel@tonic-gate TD_SYNC_MUTEX, /* Mutex lock */ 275*7c478bd9Sstevel@tonic-gate TD_SYNC_SEMA, /* Semaphore */ 276*7c478bd9Sstevel@tonic-gate TD_SYNC_RWLOCK /* Reader/Writer lock */ 277*7c478bd9Sstevel@tonic-gate } td_sync_type_e; 278*7c478bd9Sstevel@tonic-gate 279*7c478bd9Sstevel@tonic-gate #define TD_SV_MAX_FLAGS 4 280*7c478bd9Sstevel@tonic-gate typedef uint8_t td_sync_flags_t; 281*7c478bd9Sstevel@tonic-gate 282*7c478bd9Sstevel@tonic-gate /* 283*7c478bd9Sstevel@tonic-gate * Synchronization object information structure filled in by td_sync_get_info() 284*7c478bd9Sstevel@tonic-gate */ 285*7c478bd9Sstevel@tonic-gate typedef struct td_syncinfo { 286*7c478bd9Sstevel@tonic-gate td_thragent_t *si_ta_p; /* process handle */ 287*7c478bd9Sstevel@tonic-gate psaddr_t si_sv_addr; /* address of sync. object */ 288*7c478bd9Sstevel@tonic-gate td_sync_type_e si_type; /* object type */ 289*7c478bd9Sstevel@tonic-gate uint32_t si_shared_type; /* process-shared or process-private */ 290*7c478bd9Sstevel@tonic-gate td_sync_flags_t si_flags[TD_SV_MAX_FLAGS]; /* flags (?) */ 291*7c478bd9Sstevel@tonic-gate pid_t si_ownerpid; /* owner's process-id (USYNC_PROCESS) */ 292*7c478bd9Sstevel@tonic-gate union _si_un_state { 293*7c478bd9Sstevel@tonic-gate int sem_count; /* semaphore count */ 294*7c478bd9Sstevel@tonic-gate int nreaders; /* number of readers, -1 if writer */ 295*7c478bd9Sstevel@tonic-gate int mutex_locked; /* non-zero iff locked */ 296*7c478bd9Sstevel@tonic-gate } si_state; 297*7c478bd9Sstevel@tonic-gate int si_size; /* size in bytes of synch variable */ 298*7c478bd9Sstevel@tonic-gate uint8_t si_has_waiters; /* non-zero iff at least one waiter */ 299*7c478bd9Sstevel@tonic-gate uint8_t si_is_wlock; /* non-zero iff rwlock write-locked */ 300*7c478bd9Sstevel@tonic-gate uint8_t si_rcount; /* count for locked recursive mutex */ 301*7c478bd9Sstevel@tonic-gate uint8_t si_prioceiling; /* ceiling pri (PTHREAD_PRIO_PROTECT) */ 302*7c478bd9Sstevel@tonic-gate td_thrhandle_t si_owner; /* mutex holder or write-lock holder */ 303*7c478bd9Sstevel@tonic-gate psaddr_t si_data; /* optional data */ 304*7c478bd9Sstevel@tonic-gate } td_syncinfo_t; 305*7c478bd9Sstevel@tonic-gate 306*7c478bd9Sstevel@tonic-gate /* 307*7c478bd9Sstevel@tonic-gate * Statistics structures for the various synchronization objects, contained 308*7c478bd9Sstevel@tonic-gate * within the td_syncstats structure returned by td_sync_get_stats(). 309*7c478bd9Sstevel@tonic-gate */ 310*7c478bd9Sstevel@tonic-gate typedef struct { 311*7c478bd9Sstevel@tonic-gate uint_t mutex_lock; 312*7c478bd9Sstevel@tonic-gate uint_t mutex_sleep; 313*7c478bd9Sstevel@tonic-gate hrtime_t mutex_sleep_time; 314*7c478bd9Sstevel@tonic-gate hrtime_t mutex_hold_time; 315*7c478bd9Sstevel@tonic-gate uint_t mutex_try; 316*7c478bd9Sstevel@tonic-gate uint_t mutex_try_fail; 317*7c478bd9Sstevel@tonic-gate uint_t mutex_internal; /* internal to libthread */ 318*7c478bd9Sstevel@tonic-gate } td_mutex_stats_t; 319*7c478bd9Sstevel@tonic-gate 320*7c478bd9Sstevel@tonic-gate typedef struct { 321*7c478bd9Sstevel@tonic-gate uint_t cond_wait; 322*7c478bd9Sstevel@tonic-gate uint_t cond_timedwait; 323*7c478bd9Sstevel@tonic-gate hrtime_t cond_wait_sleep_time; 324*7c478bd9Sstevel@tonic-gate hrtime_t cond_timedwait_sleep_time; 325*7c478bd9Sstevel@tonic-gate uint_t cond_timedwait_timeout; 326*7c478bd9Sstevel@tonic-gate uint_t cond_signal; 327*7c478bd9Sstevel@tonic-gate uint_t cond_broadcast; 328*7c478bd9Sstevel@tonic-gate uint_t cond_internal; /* internal to libthread */ 329*7c478bd9Sstevel@tonic-gate } td_cond_stats_t; 330*7c478bd9Sstevel@tonic-gate 331*7c478bd9Sstevel@tonic-gate typedef struct { 332*7c478bd9Sstevel@tonic-gate uint_t rw_rdlock; 333*7c478bd9Sstevel@tonic-gate uint_t rw_rdlock_sleep; 334*7c478bd9Sstevel@tonic-gate hrtime_t rw_rdlock_sleep_time; 335*7c478bd9Sstevel@tonic-gate uint_t rw_rdlock_try; 336*7c478bd9Sstevel@tonic-gate uint_t rw_rdlock_try_fail; 337*7c478bd9Sstevel@tonic-gate uint_t rw_wrlock; 338*7c478bd9Sstevel@tonic-gate uint_t rw_wrlock_sleep; 339*7c478bd9Sstevel@tonic-gate hrtime_t rw_wrlock_sleep_time; 340*7c478bd9Sstevel@tonic-gate hrtime_t rw_wrlock_hold_time; 341*7c478bd9Sstevel@tonic-gate uint_t rw_wrlock_try; 342*7c478bd9Sstevel@tonic-gate uint_t rw_wrlock_try_fail; 343*7c478bd9Sstevel@tonic-gate } td_rwlock_stats_t; 344*7c478bd9Sstevel@tonic-gate 345*7c478bd9Sstevel@tonic-gate typedef struct { 346*7c478bd9Sstevel@tonic-gate uint_t sema_wait; 347*7c478bd9Sstevel@tonic-gate uint_t sema_wait_sleep; 348*7c478bd9Sstevel@tonic-gate hrtime_t sema_wait_sleep_time; 349*7c478bd9Sstevel@tonic-gate uint_t sema_trywait; 350*7c478bd9Sstevel@tonic-gate uint_t sema_trywait_fail; 351*7c478bd9Sstevel@tonic-gate uint_t sema_post; 352*7c478bd9Sstevel@tonic-gate uint_t sema_max_count; 353*7c478bd9Sstevel@tonic-gate uint_t sema_min_count; 354*7c478bd9Sstevel@tonic-gate } td_sema_stats_t; 355*7c478bd9Sstevel@tonic-gate 356*7c478bd9Sstevel@tonic-gate /* 357*7c478bd9Sstevel@tonic-gate * Synchronization object statistics structure filled in by td_sync_get_stats() 358*7c478bd9Sstevel@tonic-gate */ 359*7c478bd9Sstevel@tonic-gate typedef struct td_syncstats { 360*7c478bd9Sstevel@tonic-gate td_syncinfo_t ss_info; /* as returned by td_sync_get_info() */ 361*7c478bd9Sstevel@tonic-gate union { 362*7c478bd9Sstevel@tonic-gate td_mutex_stats_t mutex; 363*7c478bd9Sstevel@tonic-gate td_cond_stats_t cond; 364*7c478bd9Sstevel@tonic-gate td_rwlock_stats_t rwlock; 365*7c478bd9Sstevel@tonic-gate td_sema_stats_t sema; 366*7c478bd9Sstevel@tonic-gate uint_t pad[32]; /* for future growth */ 367*7c478bd9Sstevel@tonic-gate } ss_un; 368*7c478bd9Sstevel@tonic-gate } td_syncstats_t; 369*7c478bd9Sstevel@tonic-gate 370*7c478bd9Sstevel@tonic-gate /* The set of error codes. */ 371*7c478bd9Sstevel@tonic-gate typedef enum { 372*7c478bd9Sstevel@tonic-gate TD_OK, /* generic "call succeeded" */ 373*7c478bd9Sstevel@tonic-gate TD_ERR, /* generic error. */ 374*7c478bd9Sstevel@tonic-gate TD_NOTHR, /* no thread can be found to satisfy query */ 375*7c478bd9Sstevel@tonic-gate TD_NOSV, /* no synch. handle can be found to satisfy query */ 376*7c478bd9Sstevel@tonic-gate TD_NOLWP, /* no lwp can be found to satisfy query */ 377*7c478bd9Sstevel@tonic-gate TD_BADPH, /* invalid process handle */ 378*7c478bd9Sstevel@tonic-gate TD_BADTH, /* invalid thread handle */ 379*7c478bd9Sstevel@tonic-gate TD_BADSH, /* invalid synchronization handle */ 380*7c478bd9Sstevel@tonic-gate TD_BADTA, /* invalid thread agent */ 381*7c478bd9Sstevel@tonic-gate TD_BADKEY, /* invalid key */ 382*7c478bd9Sstevel@tonic-gate TD_NOMSG, /* no event message for td_thr_event_getmsg() */ 383*7c478bd9Sstevel@tonic-gate TD_NOFPREGS, /* FPU register set not available */ 384*7c478bd9Sstevel@tonic-gate TD_NOLIBTHREAD, /* application not linked with libthread */ 385*7c478bd9Sstevel@tonic-gate TD_NOEVENT, /* requested event is not supported */ 386*7c478bd9Sstevel@tonic-gate TD_NOCAPAB, /* capability not available */ 387*7c478bd9Sstevel@tonic-gate TD_DBERR, /* Debugger service failed */ 388*7c478bd9Sstevel@tonic-gate TD_NOAPLIC, /* Operation not applicable to */ 389*7c478bd9Sstevel@tonic-gate TD_NOTSD, /* No thread-specific data for this thread */ 390*7c478bd9Sstevel@tonic-gate TD_MALLOC, /* Malloc failed */ 391*7c478bd9Sstevel@tonic-gate TD_PARTIALREG, /* Only part of register set was writen/read */ 392*7c478bd9Sstevel@tonic-gate TD_NOXREGS, /* X register set not available for given thread */ 393*7c478bd9Sstevel@tonic-gate TD_NOTLS, /* There is no TLS in the specified module */ 394*7c478bd9Sstevel@tonic-gate TD_TLSDEFER /* module's TLS not yet allocated by the thread */ 395*7c478bd9Sstevel@tonic-gate } td_err_e; 396*7c478bd9Sstevel@tonic-gate 397*7c478bd9Sstevel@tonic-gate 398*7c478bd9Sstevel@tonic-gate /* ----------------------------------------------------------------------- */ 399*7c478bd9Sstevel@tonic-gate 400*7c478bd9Sstevel@tonic-gate /* 401*7c478bd9Sstevel@tonic-gate * Exported functions. 402*7c478bd9Sstevel@tonic-gate */ 403*7c478bd9Sstevel@tonic-gate 404*7c478bd9Sstevel@tonic-gate /* 405*7c478bd9Sstevel@tonic-gate * Initialize the threads debug interface. 406*7c478bd9Sstevel@tonic-gate */ 407*7c478bd9Sstevel@tonic-gate td_err_e 408*7c478bd9Sstevel@tonic-gate td_init(void); 409*7c478bd9Sstevel@tonic-gate 410*7c478bd9Sstevel@tonic-gate /* 411*7c478bd9Sstevel@tonic-gate * A no-op, left for historical reasons. 412*7c478bd9Sstevel@tonic-gate */ 413*7c478bd9Sstevel@tonic-gate void 414*7c478bd9Sstevel@tonic-gate td_log(void); 415*7c478bd9Sstevel@tonic-gate 416*7c478bd9Sstevel@tonic-gate /* 417*7c478bd9Sstevel@tonic-gate * Allocate a new process handle ("thread agent"). 418*7c478bd9Sstevel@tonic-gate */ 419*7c478bd9Sstevel@tonic-gate td_err_e 420*7c478bd9Sstevel@tonic-gate td_ta_new(struct ps_prochandle *, td_thragent_t **); 421*7c478bd9Sstevel@tonic-gate 422*7c478bd9Sstevel@tonic-gate /* 423*7c478bd9Sstevel@tonic-gate * De-allocate a process handle, releasing all related resources. 424*7c478bd9Sstevel@tonic-gate */ 425*7c478bd9Sstevel@tonic-gate td_err_e 426*7c478bd9Sstevel@tonic-gate td_ta_delete(td_thragent_t *); 427*7c478bd9Sstevel@tonic-gate 428*7c478bd9Sstevel@tonic-gate /* 429*7c478bd9Sstevel@tonic-gate * Map a process handle to a client process handle. 430*7c478bd9Sstevel@tonic-gate */ 431*7c478bd9Sstevel@tonic-gate td_err_e 432*7c478bd9Sstevel@tonic-gate td_ta_get_ph(const td_thragent_t *, struct ps_prochandle **); 433*7c478bd9Sstevel@tonic-gate 434*7c478bd9Sstevel@tonic-gate /* 435*7c478bd9Sstevel@tonic-gate * Set the process's suggested concurrency level. 436*7c478bd9Sstevel@tonic-gate */ 437*7c478bd9Sstevel@tonic-gate td_err_e 438*7c478bd9Sstevel@tonic-gate td_ta_setconcurrency(const td_thragent_t *, int); 439*7c478bd9Sstevel@tonic-gate 440*7c478bd9Sstevel@tonic-gate /* 441*7c478bd9Sstevel@tonic-gate * Get the number of threads in the process, including zombie threads. 442*7c478bd9Sstevel@tonic-gate */ 443*7c478bd9Sstevel@tonic-gate td_err_e 444*7c478bd9Sstevel@tonic-gate td_ta_get_nthreads(const td_thragent_t *, int *); 445*7c478bd9Sstevel@tonic-gate 446*7c478bd9Sstevel@tonic-gate /* 447*7c478bd9Sstevel@tonic-gate * Map a tid, as returned by thr_create(), to a thread handle. 448*7c478bd9Sstevel@tonic-gate */ 449*7c478bd9Sstevel@tonic-gate td_err_e 450*7c478bd9Sstevel@tonic-gate td_ta_map_id2thr(const td_thragent_t *, thread_t, td_thrhandle_t *); 451*7c478bd9Sstevel@tonic-gate 452*7c478bd9Sstevel@tonic-gate /* 453*7c478bd9Sstevel@tonic-gate * Map the address of a synchronization object to a sync. object handle. 454*7c478bd9Sstevel@tonic-gate */ 455*7c478bd9Sstevel@tonic-gate td_err_e 456*7c478bd9Sstevel@tonic-gate td_ta_map_addr2sync(const td_thragent_t *, psaddr_t, td_synchandle_t *); 457*7c478bd9Sstevel@tonic-gate 458*7c478bd9Sstevel@tonic-gate /* 459*7c478bd9Sstevel@tonic-gate * Iterate over a process's thread-specific data (TSD) keys. 460*7c478bd9Sstevel@tonic-gate */ 461*7c478bd9Sstevel@tonic-gate td_err_e 462*7c478bd9Sstevel@tonic-gate td_ta_tsd_iter(const td_thragent_t *, td_key_iter_f *, void *); 463*7c478bd9Sstevel@tonic-gate 464*7c478bd9Sstevel@tonic-gate /* 465*7c478bd9Sstevel@tonic-gate * Iterate over a process's threads, including zombie threads. 466*7c478bd9Sstevel@tonic-gate */ 467*7c478bd9Sstevel@tonic-gate td_err_e 468*7c478bd9Sstevel@tonic-gate td_ta_thr_iter(const td_thragent_t *, td_thr_iter_f *, void *, 469*7c478bd9Sstevel@tonic-gate td_thr_state_e, int, sigset_t *, unsigned); 470*7c478bd9Sstevel@tonic-gate 471*7c478bd9Sstevel@tonic-gate /* 472*7c478bd9Sstevel@tonic-gate * Iterate over a process's known synchronization objects. 473*7c478bd9Sstevel@tonic-gate */ 474*7c478bd9Sstevel@tonic-gate td_err_e 475*7c478bd9Sstevel@tonic-gate td_ta_sync_iter(const td_thragent_t *, td_sync_iter_f *, void *); 476*7c478bd9Sstevel@tonic-gate 477*7c478bd9Sstevel@tonic-gate /* 478*7c478bd9Sstevel@tonic-gate * Enable/disable process statistics collection. 479*7c478bd9Sstevel@tonic-gate */ 480*7c478bd9Sstevel@tonic-gate td_err_e 481*7c478bd9Sstevel@tonic-gate td_ta_enable_stats(const td_thragent_t *, int); 482*7c478bd9Sstevel@tonic-gate 483*7c478bd9Sstevel@tonic-gate /* 484*7c478bd9Sstevel@tonic-gate * Reset process statistics. 485*7c478bd9Sstevel@tonic-gate */ 486*7c478bd9Sstevel@tonic-gate td_err_e 487*7c478bd9Sstevel@tonic-gate td_ta_reset_stats(const td_thragent_t *); 488*7c478bd9Sstevel@tonic-gate 489*7c478bd9Sstevel@tonic-gate /* 490*7c478bd9Sstevel@tonic-gate * Read process statistics. 491*7c478bd9Sstevel@tonic-gate */ 492*7c478bd9Sstevel@tonic-gate td_err_e 493*7c478bd9Sstevel@tonic-gate td_ta_get_stats(const td_thragent_t *, td_ta_stats_t *); 494*7c478bd9Sstevel@tonic-gate 495*7c478bd9Sstevel@tonic-gate /* 496*7c478bd9Sstevel@tonic-gate * Get thread information. 497*7c478bd9Sstevel@tonic-gate */ 498*7c478bd9Sstevel@tonic-gate td_err_e 499*7c478bd9Sstevel@tonic-gate td_thr_get_info(const td_thrhandle_t *, td_thrinfo_t *); 500*7c478bd9Sstevel@tonic-gate 501*7c478bd9Sstevel@tonic-gate /* 502*7c478bd9Sstevel@tonic-gate * Get the "event address" for an event type. 503*7c478bd9Sstevel@tonic-gate */ 504*7c478bd9Sstevel@tonic-gate td_err_e 505*7c478bd9Sstevel@tonic-gate td_ta_event_addr(const td_thragent_t *, td_event_e, td_notify_t *); 506*7c478bd9Sstevel@tonic-gate 507*7c478bd9Sstevel@tonic-gate /* 508*7c478bd9Sstevel@tonic-gate * Enable/disable event reporting for a thread. 509*7c478bd9Sstevel@tonic-gate */ 510*7c478bd9Sstevel@tonic-gate td_err_e 511*7c478bd9Sstevel@tonic-gate td_thr_event_enable(const td_thrhandle_t *, int); 512*7c478bd9Sstevel@tonic-gate 513*7c478bd9Sstevel@tonic-gate /* 514*7c478bd9Sstevel@tonic-gate * Enable a set of events for a thread. 515*7c478bd9Sstevel@tonic-gate */ 516*7c478bd9Sstevel@tonic-gate td_err_e 517*7c478bd9Sstevel@tonic-gate td_thr_set_event(const td_thrhandle_t *, td_thr_events_t *); 518*7c478bd9Sstevel@tonic-gate 519*7c478bd9Sstevel@tonic-gate /* 520*7c478bd9Sstevel@tonic-gate * Disable a set of events for a thread. 521*7c478bd9Sstevel@tonic-gate */ 522*7c478bd9Sstevel@tonic-gate td_err_e 523*7c478bd9Sstevel@tonic-gate td_thr_clear_event(const td_thrhandle_t *, td_thr_events_t *); 524*7c478bd9Sstevel@tonic-gate 525*7c478bd9Sstevel@tonic-gate /* 526*7c478bd9Sstevel@tonic-gate * Retrieve (and consume) an event message for a thread. 527*7c478bd9Sstevel@tonic-gate */ 528*7c478bd9Sstevel@tonic-gate td_err_e 529*7c478bd9Sstevel@tonic-gate td_thr_event_getmsg(const td_thrhandle_t *, td_event_msg_t *); 530*7c478bd9Sstevel@tonic-gate 531*7c478bd9Sstevel@tonic-gate /* 532*7c478bd9Sstevel@tonic-gate * Enable a set of events in the process. 533*7c478bd9Sstevel@tonic-gate */ 534*7c478bd9Sstevel@tonic-gate td_err_e 535*7c478bd9Sstevel@tonic-gate td_ta_set_event(const td_thragent_t *, td_thr_events_t *); 536*7c478bd9Sstevel@tonic-gate 537*7c478bd9Sstevel@tonic-gate /* 538*7c478bd9Sstevel@tonic-gate * Disable a set of events in the process. 539*7c478bd9Sstevel@tonic-gate */ 540*7c478bd9Sstevel@tonic-gate td_err_e 541*7c478bd9Sstevel@tonic-gate td_ta_clear_event(const td_thragent_t *, td_thr_events_t *); 542*7c478bd9Sstevel@tonic-gate 543*7c478bd9Sstevel@tonic-gate /* 544*7c478bd9Sstevel@tonic-gate * Retrieve (and consume) an event message for some thread in the process. 545*7c478bd9Sstevel@tonic-gate */ 546*7c478bd9Sstevel@tonic-gate td_err_e 547*7c478bd9Sstevel@tonic-gate td_ta_event_getmsg(const td_thragent_t *, td_event_msg_t *); 548*7c478bd9Sstevel@tonic-gate 549*7c478bd9Sstevel@tonic-gate /* 550*7c478bd9Sstevel@tonic-gate * Suspend a thread. 551*7c478bd9Sstevel@tonic-gate */ 552*7c478bd9Sstevel@tonic-gate td_err_e 553*7c478bd9Sstevel@tonic-gate td_thr_dbsuspend(const td_thrhandle_t *); 554*7c478bd9Sstevel@tonic-gate 555*7c478bd9Sstevel@tonic-gate /* 556*7c478bd9Sstevel@tonic-gate * Resume a suspended thread. 557*7c478bd9Sstevel@tonic-gate */ 558*7c478bd9Sstevel@tonic-gate td_err_e 559*7c478bd9Sstevel@tonic-gate td_thr_dbresume(const td_thrhandle_t *); 560*7c478bd9Sstevel@tonic-gate 561*7c478bd9Sstevel@tonic-gate /* 562*7c478bd9Sstevel@tonic-gate * Set a thread's signal mask. 563*7c478bd9Sstevel@tonic-gate */ 564*7c478bd9Sstevel@tonic-gate td_err_e 565*7c478bd9Sstevel@tonic-gate td_thr_sigsetmask(const td_thrhandle_t *, const sigset_t); 566*7c478bd9Sstevel@tonic-gate 567*7c478bd9Sstevel@tonic-gate /* 568*7c478bd9Sstevel@tonic-gate * Set a thread's "signals-pending" set. 569*7c478bd9Sstevel@tonic-gate */ 570*7c478bd9Sstevel@tonic-gate td_err_e 571*7c478bd9Sstevel@tonic-gate td_thr_setsigpending(const td_thrhandle_t *, uchar_t, const sigset_t); 572*7c478bd9Sstevel@tonic-gate 573*7c478bd9Sstevel@tonic-gate /* 574*7c478bd9Sstevel@tonic-gate * Get a thread's general register set. 575*7c478bd9Sstevel@tonic-gate */ 576*7c478bd9Sstevel@tonic-gate td_err_e 577*7c478bd9Sstevel@tonic-gate td_thr_getgregs(const td_thrhandle_t *, prgregset_t); 578*7c478bd9Sstevel@tonic-gate 579*7c478bd9Sstevel@tonic-gate /* 580*7c478bd9Sstevel@tonic-gate * Set a thread's general register set. 581*7c478bd9Sstevel@tonic-gate */ 582*7c478bd9Sstevel@tonic-gate td_err_e 583*7c478bd9Sstevel@tonic-gate td_thr_setgregs(const td_thrhandle_t *, const prgregset_t); 584*7c478bd9Sstevel@tonic-gate 585*7c478bd9Sstevel@tonic-gate /* 586*7c478bd9Sstevel@tonic-gate * Get a thread's floating-point register set. 587*7c478bd9Sstevel@tonic-gate */ 588*7c478bd9Sstevel@tonic-gate td_err_e 589*7c478bd9Sstevel@tonic-gate td_thr_getfpregs(const td_thrhandle_t *, prfpregset_t *); 590*7c478bd9Sstevel@tonic-gate 591*7c478bd9Sstevel@tonic-gate /* 592*7c478bd9Sstevel@tonic-gate * Set a thread's floating-point register set. 593*7c478bd9Sstevel@tonic-gate */ 594*7c478bd9Sstevel@tonic-gate td_err_e 595*7c478bd9Sstevel@tonic-gate td_thr_setfpregs(const td_thrhandle_t *, const prfpregset_t *); 596*7c478bd9Sstevel@tonic-gate 597*7c478bd9Sstevel@tonic-gate /* 598*7c478bd9Sstevel@tonic-gate * Get the size of the extra state register set for this architecture. 599*7c478bd9Sstevel@tonic-gate */ 600*7c478bd9Sstevel@tonic-gate td_err_e 601*7c478bd9Sstevel@tonic-gate td_thr_getxregsize(const td_thrhandle_t *th_p, int *xregsize); 602*7c478bd9Sstevel@tonic-gate 603*7c478bd9Sstevel@tonic-gate /* 604*7c478bd9Sstevel@tonic-gate * Get a thread's extra state register set. 605*7c478bd9Sstevel@tonic-gate */ 606*7c478bd9Sstevel@tonic-gate td_err_e 607*7c478bd9Sstevel@tonic-gate td_thr_getxregs(const td_thrhandle_t *th_p, void *xregs); 608*7c478bd9Sstevel@tonic-gate 609*7c478bd9Sstevel@tonic-gate /* 610*7c478bd9Sstevel@tonic-gate * Set a thread's extra state register set. 611*7c478bd9Sstevel@tonic-gate */ 612*7c478bd9Sstevel@tonic-gate td_err_e 613*7c478bd9Sstevel@tonic-gate td_thr_setxregs(const td_thrhandle_t *th_p, const void *xregs); 614*7c478bd9Sstevel@tonic-gate 615*7c478bd9Sstevel@tonic-gate /* 616*7c478bd9Sstevel@tonic-gate * Validate a thread handle. 617*7c478bd9Sstevel@tonic-gate */ 618*7c478bd9Sstevel@tonic-gate td_err_e 619*7c478bd9Sstevel@tonic-gate td_thr_validate(const td_thrhandle_t *); 620*7c478bd9Sstevel@tonic-gate 621*7c478bd9Sstevel@tonic-gate /* 622*7c478bd9Sstevel@tonic-gate * Get a thread-specific data pointer for a thread. 623*7c478bd9Sstevel@tonic-gate */ 624*7c478bd9Sstevel@tonic-gate td_err_e 625*7c478bd9Sstevel@tonic-gate td_thr_tsd(const td_thrhandle_t *, thread_key_t, void **); 626*7c478bd9Sstevel@tonic-gate 627*7c478bd9Sstevel@tonic-gate /* 628*7c478bd9Sstevel@tonic-gate * Get the base address of a thread's thread local storage (TLS) block 629*7c478bd9Sstevel@tonic-gate * for the module (executable or shared object) identified by 'moduleid'. 630*7c478bd9Sstevel@tonic-gate */ 631*7c478bd9Sstevel@tonic-gate td_err_e 632*7c478bd9Sstevel@tonic-gate td_thr_tlsbase(const td_thrhandle_t *, ulong_t moduleid, psaddr_t *base); 633*7c478bd9Sstevel@tonic-gate 634*7c478bd9Sstevel@tonic-gate /* 635*7c478bd9Sstevel@tonic-gate * Set a thread's priority. 636*7c478bd9Sstevel@tonic-gate */ 637*7c478bd9Sstevel@tonic-gate td_err_e 638*7c478bd9Sstevel@tonic-gate td_thr_setprio(const td_thrhandle_t *, int); 639*7c478bd9Sstevel@tonic-gate 640*7c478bd9Sstevel@tonic-gate /* 641*7c478bd9Sstevel@tonic-gate * Iterate over the set of locks owned by a thread. 642*7c478bd9Sstevel@tonic-gate */ 643*7c478bd9Sstevel@tonic-gate td_err_e 644*7c478bd9Sstevel@tonic-gate td_thr_lockowner(const td_thrhandle_t *, td_sync_iter_f *, void *); 645*7c478bd9Sstevel@tonic-gate 646*7c478bd9Sstevel@tonic-gate /* 647*7c478bd9Sstevel@tonic-gate * Return the sync. handle of the object this thread is sleeping on. 648*7c478bd9Sstevel@tonic-gate */ 649*7c478bd9Sstevel@tonic-gate td_err_e 650*7c478bd9Sstevel@tonic-gate td_thr_sleepinfo(const td_thrhandle_t *, td_synchandle_t *); 651*7c478bd9Sstevel@tonic-gate 652*7c478bd9Sstevel@tonic-gate /* 653*7c478bd9Sstevel@tonic-gate * Map an lwpid, as returned by _lwp_create(), to a thread handle. 654*7c478bd9Sstevel@tonic-gate */ 655*7c478bd9Sstevel@tonic-gate td_err_e 656*7c478bd9Sstevel@tonic-gate td_ta_map_lwp2thr(const td_thragent_t *, lwpid_t, td_thrhandle_t *th_p); 657*7c478bd9Sstevel@tonic-gate 658*7c478bd9Sstevel@tonic-gate /* 659*7c478bd9Sstevel@tonic-gate * Enable/disable a process's synchronization object tracking. 660*7c478bd9Sstevel@tonic-gate */ 661*7c478bd9Sstevel@tonic-gate td_err_e 662*7c478bd9Sstevel@tonic-gate td_ta_sync_tracking_enable(const td_thragent_t *, int); 663*7c478bd9Sstevel@tonic-gate 664*7c478bd9Sstevel@tonic-gate /* 665*7c478bd9Sstevel@tonic-gate * Get information about a synchronization object. 666*7c478bd9Sstevel@tonic-gate */ 667*7c478bd9Sstevel@tonic-gate td_err_e 668*7c478bd9Sstevel@tonic-gate td_sync_get_info(const td_synchandle_t *, td_syncinfo_t *); 669*7c478bd9Sstevel@tonic-gate 670*7c478bd9Sstevel@tonic-gate /* 671*7c478bd9Sstevel@tonic-gate * Get statistics for a synchronization object. 672*7c478bd9Sstevel@tonic-gate */ 673*7c478bd9Sstevel@tonic-gate td_err_e 674*7c478bd9Sstevel@tonic-gate td_sync_get_stats(const td_synchandle_t *, td_syncstats_t *); 675*7c478bd9Sstevel@tonic-gate 676*7c478bd9Sstevel@tonic-gate /* 677*7c478bd9Sstevel@tonic-gate * Set the state of a synchronization object. 678*7c478bd9Sstevel@tonic-gate */ 679*7c478bd9Sstevel@tonic-gate td_err_e 680*7c478bd9Sstevel@tonic-gate td_sync_setstate(const td_synchandle_t *, int value); 681*7c478bd9Sstevel@tonic-gate 682*7c478bd9Sstevel@tonic-gate /* 683*7c478bd9Sstevel@tonic-gate * Iterate over all threads blocked on a synchronization object. 684*7c478bd9Sstevel@tonic-gate */ 685*7c478bd9Sstevel@tonic-gate td_err_e 686*7c478bd9Sstevel@tonic-gate td_sync_waiters(const td_synchandle_t *, td_thr_iter_f *, void *); 687*7c478bd9Sstevel@tonic-gate 688*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 689*7c478bd9Sstevel@tonic-gate } 690*7c478bd9Sstevel@tonic-gate #endif 691*7c478bd9Sstevel@tonic-gate 692*7c478bd9Sstevel@tonic-gate #endif /* _THREAD_DB_H */ 693