thread_db.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _THREAD_DB_H
#define _THREAD_DB_H
#pragma ident "%Z%%M% %I% %E% SMI"
/*
*
* Description:
* Types, global variables, and function definitions for users
* of libc_db (formerly libthread_db).
*
*/
#include <sys/procfs_isa.h>
#include <thread.h>
#include <proc_service.h>
#ifdef __cplusplus
extern "C" {
#endif
#define TD_THR_ANY_USER_FLAGS 0xffffffff
#define TD_THR_LOWEST_PRIORITY 0
#define TD_SIGNO_MASK 0
#define TD_EVENTSIZE 2
/*
* Opaque handle types.
*/
/* Client's handle for a process */
struct ps_prochandle;
/* libthread's handle for a process */
typedef struct td_thragent td_thragent_t;
/* The thread handle. */
typedef struct td_thrhandle {
/* The handle for a synchronization object. */
typedef struct td_synchandle {
/* ------------------------------------------------------------------ */
/*
* The libc_db event facility.
*/
/* Bitmask of enabled events. */
typedef struct td_thr_events {
/* Event set manipulation macros. */
& (BT_NBIPUI - 1)))
#define td_event_emptyset(setp) \
{ \
int _i_; \
_i_ = TD_EVENTSIZE; \
}
#define td_event_fillset(setp) \
{ \
int _i_; \
_i_ = TD_EVENTSIZE; \
0xffffffff; \
}
#define td_event_addset(setp, n) \
#define td_event_delset(setp, n) \
#define td_eventismember(setp, n) \
#define td_eventisempty(setp) \
typedef enum {
TD_ALL_EVENTS, /* pseudo-event number */
} td_event_e;
/*
* Ways that an event type can be reported.
*/
typedef enum {
/*
* bpt to be inserted at u.bptaddr by
* debugger
*/
NOTIFY_AUTOBPT, /* bpt inserted at u.bptaddr by application */
NOTIFY_SYSCALL /* syscall u.syscallno will be invoked */
} td_notify_e;
/*
* How an event type is reported.
*/
typedef struct td_notify {
union {
int syscallno;
} u;
} td_notify_t;
/*
* An event message.
*/
typedef struct td_event_msg {
union { /* Type-dependent event data */
} msg;
/* --------------------------------------------------------------------- */
/*
* Thread information structure as returned by td_thr_get_info(), and
* related types.
*/
/*
* Possible thread states. TD_THR_ANY_STATE is a pseudo-state used
* to select threads regardless of state in td_ta_thr_iter().
*/
typedef enum {
/*
* Thread type: user or system.
* As of Solaris 9, all threads are type TD_THR_USER.
*/
typedef enum {
TD_THR_ANY_TYPE, /* not used */
typedef struct td_thrinfo {
unsigned ti_user_flags; /* flags passed to thr_create() */
void *ti_exitval; /* thread exit value (TD_THR_ZOMBIE) */
long ti_stksize; /* size of thread's stack */
int ti_ro_size; /* size of uthread_t struct */
short ti_flags; /* flags used by libthread */
int ti_pri; /* thread priority */
} td_thrinfo_t;
typedef struct td_ta_stats {
int nthreads; /* total number of threads in use */
int r_concurrency; /* requested concurrency level */
int nrunnable_num; /* numerator, avg. runnable threads */
int nrunnable_den; /* denominator, avg. runnable threads */
int a_concurrency_num; /* numerator, achieved concurrency level */
int a_concurrency_den; /* denominator, concurrency level */
int nlwps_num; /* numerator, average number of LWP's in use */
int nlwps_den; /* denom., average number of LWP's in use */
int nidle_num; /* numerator, avg. number of idling LWP's */
int nidle_den; /* denom., avg. number of idling LWP's */
/*
* Iterator callback function declarations.
*/
/* Callback function for td_ta_tsd_iter(). */
/* Callback function for td_ta_thr_iter(). */
typedef int td_thr_iter_f(const td_thrhandle_t *, void *);
/* Callback function for td_ta_sync_iter(). */
typedef int td_sync_iter_f(const td_synchandle_t *, void *);
/* -------------------------------------------------------------------- */
/*
* Synchronization Objects
*/
/* Enumeration of synchronization object types. */
typedef enum td_sync_type_e {
TD_SYNC_UNKNOWN, /* Sync. variable of unknown type */
TD_SYNC_COND, /* Condition variable */
TD_SYNC_MUTEX, /* Mutex lock */
TD_SYNC_SEMA, /* Semaphore */
TD_SYNC_RWLOCK /* Reader/Writer lock */
#define TD_SV_MAX_FLAGS 4
typedef uint8_t td_sync_flags_t;
/*
* Synchronization object information structure filled in by td_sync_get_info()
*/
typedef struct td_syncinfo {
union _si_un_state {
int sem_count; /* semaphore count */
int nreaders; /* number of readers, -1 if writer */
int mutex_locked; /* non-zero iff locked */
} si_state;
int si_size; /* size in bytes of synch variable */
/*
* Statistics structures for the various synchronization objects, contained
* within the td_syncstats structure returned by td_sync_get_stats().
*/
typedef struct {
typedef struct {
typedef struct {
typedef struct {
/*
* Synchronization object statistics structure filled in by td_sync_get_stats()
*/
typedef struct td_syncstats {
union {
} ss_un;
/* The set of error codes. */
typedef enum {
TD_OK, /* generic "call succeeded" */
TD_ERR, /* generic error. */
TD_NOTHR, /* no thread can be found to satisfy query */
TD_NOSV, /* no synch. handle can be found to satisfy query */
TD_NOLWP, /* no lwp can be found to satisfy query */
TD_BADPH, /* invalid process handle */
TD_BADTH, /* invalid thread handle */
TD_BADSH, /* invalid synchronization handle */
TD_BADTA, /* invalid thread agent */
TD_BADKEY, /* invalid key */
TD_NOMSG, /* no event message for td_thr_event_getmsg() */
TD_NOFPREGS, /* FPU register set not available */
TD_NOLIBTHREAD, /* application not linked with libthread */
TD_NOEVENT, /* requested event is not supported */
TD_NOCAPAB, /* capability not available */
TD_DBERR, /* Debugger service failed */
TD_NOAPLIC, /* Operation not applicable to */
TD_NOTSD, /* No thread-specific data for this thread */
TD_MALLOC, /* Malloc failed */
TD_PARTIALREG, /* Only part of register set was writen/read */
TD_NOXREGS, /* X register set not available for given thread */
TD_NOTLS, /* There is no TLS in the specified module */
TD_TLSDEFER /* module's TLS not yet allocated by the thread */
} td_err_e;
/* ----------------------------------------------------------------------- */
/*
* Exported functions.
*/
/*
* Initialize the threads debug interface.
*/
td_init(void);
/*
* A no-op, left for historical reasons.
*/
void
td_log(void);
/*
* Allocate a new process handle ("thread agent").
*/
/*
* De-allocate a process handle, releasing all related resources.
*/
/*
* Map a process handle to a client process handle.
*/
/*
* Set the process's suggested concurrency level.
*/
td_ta_setconcurrency(const td_thragent_t *, int);
/*
* Get the number of threads in the process, including zombie threads.
*/
td_ta_get_nthreads(const td_thragent_t *, int *);
/*
* Map a tid, as returned by thr_create(), to a thread handle.
*/
/*
* Map the address of a synchronization object to a sync. object handle.
*/
/*
* Iterate over a process's thread-specific data (TSD) keys.
*/
/*
* Iterate over a process's threads, including zombie threads.
*/
td_thr_state_e, int, sigset_t *, unsigned);
/*
* Iterate over a process's known synchronization objects.
*/
/*
*/
td_ta_enable_stats(const td_thragent_t *, int);
/*
* Reset process statistics.
*/
td_ta_reset_stats(const td_thragent_t *);
/*
* Read process statistics.
*/
/*
* Get thread information.
*/
/*
* Get the "event address" for an event type.
*/
/*
*/
td_thr_event_enable(const td_thrhandle_t *, int);
/*
* Enable a set of events for a thread.
*/
/*
* Disable a set of events for a thread.
*/
/*
* Retrieve (and consume) an event message for a thread.
*/
/*
* Enable a set of events in the process.
*/
/*
* Disable a set of events in the process.
*/
/*
* Retrieve (and consume) an event message for some thread in the process.
*/
/*
* Suspend a thread.
*/
td_thr_dbsuspend(const td_thrhandle_t *);
/*
* Resume a suspended thread.
*/
td_thr_dbresume(const td_thrhandle_t *);
/*
* Set a thread's signal mask.
*/
/*
* Set a thread's "signals-pending" set.
*/
/*
* Get a thread's general register set.
*/
/*
* Set a thread's general register set.
*/
/*
* Get a thread's floating-point register set.
*/
/*
* Set a thread's floating-point register set.
*/
/*
* Get the size of the extra state register set for this architecture.
*/
/*
* Get a thread's extra state register set.
*/
/*
* Set a thread's extra state register set.
*/
/*
* Validate a thread handle.
*/
td_thr_validate(const td_thrhandle_t *);
/*
* Get a thread-specific data pointer for a thread.
*/
/*
* Get the base address of a thread's thread local storage (TLS) block
* for the module (executable or shared object) identified by 'moduleid'.
*/
/*
* Set a thread's priority.
*/
td_thr_setprio(const td_thrhandle_t *, int);
/*
* Iterate over the set of locks owned by a thread.
*/
/*
* Return the sync. handle of the object this thread is sleeping on.
*/
/*
* Map an lwpid, as returned by _lwp_create(), to a thread handle.
*/
/*
*/
td_ta_sync_tracking_enable(const td_thragent_t *, int);
/*
* Get information about a synchronization object.
*/
/*
* Get statistics for a synchronization object.
*/
/*
* Set the state of a synchronization object.
*/
/*
* Iterate over all threads blocked on a synchronization object.
*/
#ifdef __cplusplus
}
#endif
#endif /* _THREAD_DB_H */