2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A
2N/A/*
2N/A * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A#ifndef _DT_PROC_H
2N/A#define _DT_PROC_H
2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A#include <libproc.h>
2N/A#include <dtrace.h>
2N/A#include <pthread.h>
2N/A#include <dt_list.h>
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/Atypedef struct dt_proc {
2N/A dt_list_t dpr_list; /* prev/next pointers for lru chain */
2N/A struct dt_proc *dpr_hash; /* next pointer for pid hash chain */
2N/A dtrace_hdl_t *dpr_hdl; /* back pointer to libdtrace handle */
2N/A struct ps_prochandle *dpr_proc; /* proc handle for libproc calls */
2N/A char dpr_errmsg[BUFSIZ]; /* error message */
2N/A rd_agent_t *dpr_rtld; /* rtld handle for librtld_db calls */
2N/A pthread_mutex_t dpr_lock; /* lock for manipulating dpr_hdl */
2N/A pthread_cond_t dpr_cv; /* cond for dpr_stop/quit/done */
2N/A pid_t dpr_pid; /* pid of process */
2N/A uint_t dpr_refs; /* reference count */
2N/A uint8_t dpr_cacheable; /* cache handle using lru list */
2N/A uint8_t dpr_stop; /* stop mask: see flag bits below */
2N/A uint8_t dpr_quit; /* quit flag: ctl thread should quit */
2N/A uint8_t dpr_done; /* done flag: ctl thread has exited */
2N/A uint8_t dpr_usdt; /* usdt flag: usdt initialized */
2N/A uint8_t dpr_stale; /* proc flag: been deprecated */
2N/A uint8_t dpr_rdonly; /* proc flag: opened read-only */
2N/A pthread_t dpr_tid; /* control thread (or zero if none) */
2N/A dt_list_t dpr_bps; /* list of dt_bkpt_t structures */
2N/A} dt_proc_t;
2N/A
2N/Atypedef struct dt_proc_notify {
2N/A dt_proc_t *dprn_dpr; /* process associated with the event */
2N/A char dprn_errmsg[BUFSIZ]; /* error message */
2N/A struct dt_proc_notify *dprn_next; /* next pointer */
2N/A} dt_proc_notify_t;
2N/A
2N/A#define DT_PROC_STOP_IDLE 0x01 /* idle on owner's stop request */
2N/A#define DT_PROC_STOP_CREATE 0x02 /* wait on dpr_cv at process exec */
2N/A#define DT_PROC_STOP_GRAB 0x04 /* wait on dpr_cv at process grab */
2N/A#define DT_PROC_STOP_PREINIT 0x08 /* wait on dpr_cv at rtld preinit */
2N/A#define DT_PROC_STOP_POSTINIT 0x10 /* wait on dpr_cv at rtld postinit */
2N/A#define DT_PROC_STOP_MAIN 0x20 /* wait on dpr_cv at a.out`main() */
2N/A
2N/Atypedef void dt_bkpt_f(dtrace_hdl_t *, dt_proc_t *, void *);
2N/A
2N/Atypedef struct dt_bkpt {
2N/A dt_list_t dbp_list; /* prev/next pointers for bkpt list */
2N/A dt_bkpt_f *dbp_func; /* callback function to execute */
2N/A void *dbp_data; /* callback function private data */
2N/A uintptr_t dbp_addr; /* virtual address of breakpoint */
2N/A ulong_t dbp_instr; /* saved instruction from breakpoint */
2N/A ulong_t dbp_hits; /* count of breakpoint hits for debug */
2N/A int dbp_active; /* flag indicating breakpoint is on */
2N/A} dt_bkpt_t;
2N/A
2N/Atypedef struct dt_proc_hash {
2N/A pthread_mutex_t dph_lock; /* lock protecting dph_notify list */
2N/A pthread_cond_t dph_cv; /* cond for waiting for dph_notify */
2N/A dt_proc_notify_t *dph_notify; /* list of pending proc notifications */
2N/A dt_list_t dph_lrulist; /* list of dt_proc_t's in lru order */
2N/A uint_t dph_lrulim; /* limit on number of procs to hold */
2N/A uint_t dph_lrucnt; /* count of cached process handles */
2N/A uint_t dph_hashlen; /* size of hash chains array */
2N/A dt_proc_t *dph_hash[1]; /* hash chains array */
2N/A} dt_proc_hash_t;
2N/A
2N/Aextern struct ps_prochandle *dt_proc_create(dtrace_hdl_t *,
2N/A const char *, char *const *);
2N/A
2N/Aextern struct ps_prochandle *dt_proc_grab(dtrace_hdl_t *, pid_t, int, int);
2N/Aextern void dt_proc_release(dtrace_hdl_t *, struct ps_prochandle *);
2N/Aextern void dt_proc_continue(dtrace_hdl_t *, struct ps_prochandle *);
2N/Aextern void dt_proc_lock(dtrace_hdl_t *, struct ps_prochandle *);
2N/Aextern void dt_proc_unlock(dtrace_hdl_t *, struct ps_prochandle *);
2N/Aextern dt_proc_t *dt_proc_lookup(dtrace_hdl_t *, struct ps_prochandle *, int);
2N/A
2N/Aextern void dt_proc_hash_create(dtrace_hdl_t *);
2N/Aextern void dt_proc_hash_destroy(dtrace_hdl_t *);
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _DT_PROC_H */