dtrace.h revision ed2a9def43e38be9ed1ee10cdc35307de992a165
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _DTRACE_H
#define _DTRACE_H
#ifndef VBOX
#pragma ident "%Z%%M% %I% %E% SMI"
#endif
#include <stdarg.h>
#include <stdio.h>
#ifndef VBOX
#include <gelf.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
* DTrace Dynamic Tracing Software: Library Interfaces
*
* Note: The contents of this file are private to the implementation of the
* Solaris system and DTrace subsystem and are subject to change at any time
* without notice. Applications and drivers using these interfaces will fail
* to run on future releases. These interfaces should not be used for any
* purpose except those expressly outlined in dtrace(7D) and libdtrace(3LIB).
* Please refer to the "Solaris Dynamic Tracing Guide" for more information.
*/
struct ps_prochandle;
typedef struct dtrace_hdl dtrace_hdl_t;
typedef struct dtrace_prog dtrace_prog_t;
typedef struct dtrace_vector dtrace_vector_t;
typedef struct dtrace_aggdata dtrace_aggdata_t;
extern dtrace_hdl_t *dtrace_open(int, int, int *);
extern dtrace_hdl_t *dtrace_vopen(int, int, int *,
const dtrace_vector_t *, void *);
extern int dtrace_go(dtrace_hdl_t *);
extern int dtrace_stop(dtrace_hdl_t *);
extern void dtrace_sleep(dtrace_hdl_t *);
extern void dtrace_close(dtrace_hdl_t *);
extern int dtrace_errno(dtrace_hdl_t *);
extern const char *dtrace_errmsg(dtrace_hdl_t *, int);
extern const char *dtrace_faultstr(dtrace_hdl_t *, int);
extern const char *dtrace_subrstr(dtrace_hdl_t *, int);
extern int dtrace_setopt(dtrace_hdl_t *, const char *, const char *);
extern void dtrace_update(dtrace_hdl_t *);
extern int dtrace_ctlfd(dtrace_hdl_t *);
/*
* DTrace Program Interface
*
* DTrace programs can be created by compiling ASCII text files containing
* D programs or by compiling in-memory C strings that specify a D program.
* Once created, callers can examine the list of program statements and
* enable the probes and actions described by these statements.
*/
typedef struct dtrace_proginfo {
const char *, dtrace_probespec_t, uint_t, int, char *const []);
uint_t, const char *, int, char *const []);
extern void dtrace_dof_destroy(dtrace_hdl_t *, void *);
extern void *dtrace_getopt_dof(dtrace_hdl_t *);
extern void *dtrace_geterr_dof(dtrace_hdl_t *);
typedef struct dtrace_stmtdesc {
void *dtsd_aggdata; /* aggregation data */
void *dtsd_fmtdata; /* type-specific output data */
void (*dtsd_callback)(); /* callback function for EPID */
void *dtsd_data; /* callback data pointer */
dtrace_stmtdesc_t *, void *);
dtrace_ecbdesc_t *);
dtrace_stmt_f *, void *);
/*
* DTrace Data Consumption Interface
*/
typedef enum {
#define DTRACE_CONSUME_THIS 0 /* consume this probe/record */
typedef struct dtrace_probedata {
const char *dtpda_prefix; /* recommended flow prefix */
int dtpda_indent; /* recommended flow indent */
typedef int dtrace_consume_probe_f(const dtrace_probedata_t *, void *);
typedef int dtrace_consume_rec_f(const dtrace_probedata_t *,
const dtrace_recdesc_t *, void *);
dtrace_consume_probe_f *, dtrace_consume_rec_f *, void *);
#define DTRACE_STATUS_NONE 0 /* no status; not yet time */
extern int dtrace_status(dtrace_hdl_t *);
/*
* DTrace Formatted Output Interfaces
*
* To format output associated with a given dtrace_stmtdesc, the caller can
* invoke one of the following functions, passing the opaque dtsd_fmtdata and a
* list of record descriptions. These functions return either -1 to indicate
* an error, or a positive integer indicating the number of records consumed.
* For anonymous enablings, the consumer can use the dtrd_format member of
* the record description to obtain a format description. The dtfd_string
* member of the format description may be passed to dtrace_print{fa}_create()
* to create the opaque format data.
*/
extern void *dtrace_printf_create(dtrace_hdl_t *, const char *);
extern void *dtrace_printa_create(dtrace_hdl_t *, const char *);
const void *, size_t);
const void *, size_t);
const void *, size_t);
const void *, size_t);
/*
* DTrace Work Interface
*/
typedef enum {
DTRACE_WORKSTATUS_ERROR = -1,
dtrace_consume_probe_f *, dtrace_consume_rec_f *, void *);
/*
* DTrace Handler Interface
*/
#define DTRACE_HANDLE_OK 0 /* handled okay; continue */
typedef struct dtrace_errdata {
int dteda_action; /* action inducing error */
int dteda_offset; /* offset in DIFO of error */
int dteda_fault; /* specific fault */
const char *dteda_msg; /* preconstructed message */
typedef int dtrace_handle_err_f(const dtrace_errdata_t *, void *);
typedef enum {
DTRACEDROP_PRINCIPAL, /* drop to principal buffer */
DTRACEDROP_AGGREGATION, /* drop to aggregation buffer */
DTRACEDROP_DYNAMIC, /* dynamic drop */
DTRACEDROP_DYNRINSE, /* dyn drop due to rinsing */
DTRACEDROP_DYNDIRTY, /* dyn drop due to dirty */
DTRACEDROP_SPEC, /* speculative drop */
DTRACEDROP_SPECBUSY, /* spec drop due to busy */
DTRACEDROP_SPECUNAVAIL, /* spec drop due to unavail */
DTRACEDROP_STKSTROVERFLOW, /* stack string tab overflow */
DTRACEDROP_DBLERROR /* error in ERROR probe */
typedef struct dtrace_dropdata {
const char *dtdda_msg; /* preconstructed message */
typedef int dtrace_handle_drop_f(const dtrace_dropdata_t *, void *);
typedef void dtrace_handle_proc_f(struct ps_prochandle *, const char *, void *);
typedef struct dtrace_bufdata {
const char *dtbda_buffered; /* buffered output */
typedef int dtrace_handle_buffered_f(const dtrace_bufdata_t *, void *);
extern int dtrace_handle_buffered(dtrace_hdl_t *,
dtrace_handle_buffered_f *, void *);
typedef struct dtrace_setoptdata {
const char *dtsda_option; /* option that was set */
typedef int dtrace_handle_setopt_f(const dtrace_setoptdata_t *, void *);
extern int dtrace_handle_setopt(dtrace_hdl_t *,
dtrace_handle_setopt_f *, void *);
/*
* DTrace Aggregate Interface
*/
#define DTRACE_A_PERCPU 0x0001
#define DTRACE_A_KEEPDELTA 0x0002
#define DTRACE_A_ANONYMOUS 0x0004
#define DTRACE_AGGWALK_NEXT 0 /* proceed to next element */
struct dtrace_aggdata {
};
typedef int dtrace_aggregate_f(const dtrace_aggdata_t *, void *);
typedef int dtrace_aggregate_walk_f(dtrace_hdl_t *,
dtrace_aggregate_f *, void *);
typedef int dtrace_aggregate_walk_joined_f(const dtrace_aggdata_t **,
const int, void *);
extern void dtrace_aggregate_clear(dtrace_hdl_t *);
extern int dtrace_aggregate_snap(dtrace_hdl_t *);
extern int dtrace_aggregate_walk_joined(dtrace_hdl_t *,
dtrace_aggvarid_t *, int, dtrace_aggregate_walk_joined_f *, void *);
extern int dtrace_aggregate_walk_sorted(dtrace_hdl_t *,
dtrace_aggregate_f *, void *);
extern int dtrace_aggregate_walk_keysorted(dtrace_hdl_t *,
dtrace_aggregate_f *, void *);
extern int dtrace_aggregate_walk_valsorted(dtrace_hdl_t *,
dtrace_aggregate_f *, void *);
extern int dtrace_aggregate_walk_keyvarsorted(dtrace_hdl_t *,
dtrace_aggregate_f *, void *);
extern int dtrace_aggregate_walk_valvarsorted(dtrace_hdl_t *,
dtrace_aggregate_f *, void *);
extern int dtrace_aggregate_walk_keyrevsorted(dtrace_hdl_t *,
dtrace_aggregate_f *, void *);
extern int dtrace_aggregate_walk_valrevsorted(dtrace_hdl_t *,
dtrace_aggregate_f *, void *);
extern int dtrace_aggregate_walk_keyvarrevsorted(dtrace_hdl_t *,
dtrace_aggregate_f *, void *);
extern int dtrace_aggregate_walk_valvarrevsorted(dtrace_hdl_t *,
dtrace_aggregate_f *, void *);
/*
* DTrace Process Control Interface
*
* Library clients who wish to have libdtrace create or grab processes for
* monitoring of their symbol table changes may use these interfaces to
* request that libdtrace obtain control of the process using libproc.
*/
const char *, char *const *);
/*
* DTrace Object, Symbol, and Type Interfaces
*
* Library clients can use libdtrace to perform symbol and C type information
* lookups by symbol name, symbol address, or C type name, or to lookup meta-
* information cached for each of the program objects in use by DTrace. The
* resulting struct contain pointers to arbitrary-length strings, including
* object, symbol, and type names, that are persistent until the next call to
* dtrace_update(). Once dtrace_update() is called, any cached values must
* be flushed and not used subsequently by the client program.
*/
#ifndef VBOX
#define DTRACE_OBJ_EXEC ((const char *)0L) /* primary executable file */
typedef struct dtrace_objinfo {
const char *dto_name; /* object file scope name */
const char *dto_file; /* object file path (if any) */
int dto_id; /* object file id (if any) */
typedef struct dtrace_syminfo {
const char *dts_object; /* object name */
const char *dts_name; /* symbol name */
extern int dtrace_lookup_by_name(dtrace_hdl_t *, const char *, const char *,
GElf_Sym *, dtrace_syminfo_t *);
GElf_Sym *, dtrace_syminfo_t *);
#endif /* !VBOX */
typedef struct dtrace_typeinfo {
const char *dtt_object; /* object containing type */
extern int dtrace_lookup_by_type(dtrace_hdl_t *, const char *, const char *,
#ifndef VBOX
const dtrace_syminfo_t *, dtrace_typeinfo_t *);
#endif
extern int dtrace_type_strcompile(dtrace_hdl_t *,
const char *, dtrace_typeinfo_t *);
extern int dtrace_type_fcompile(dtrace_hdl_t *,
FILE *, dtrace_typeinfo_t *);
/*
* DTrace Probe Interface
*
* Library clients can use these functions to iterate over the set of available
* probe definitions and inquire as to their attributes. The probe iteration
* interfaces report probes that are declared as well as those from dtrace(7D).
*/
typedef struct dtrace_probeinfo {
int dtp_argc; /* arg count */
extern int dtrace_probe_iter(dtrace_hdl_t *,
extern int dtrace_probe_info(dtrace_hdl_t *,
const dtrace_probedesc_t *, dtrace_probeinfo_t *);
#ifndef VBOX
/*
* DTrace Vector Interface
*
* The DTrace library normally speaks directly to dtrace(7D). However,
* this communication may be vectored elsewhere. Consumers who wish to
* perform a vectored open must fill in the vector, and use the dtrace_vopen()
* entry point to obtain a library handle.
*/
struct dtrace_vector {
int (*dtv_ioctl)(void *, int, void *);
dtrace_syminfo_t *);
int (*dtv_status)(void *, processorid_t);
long (*dtv_sysconf)(void *, int);
};
#endif /* !VBOX */
/*
* DTrace Utility Functions
*
* Library clients can use these functions to convert addresses strings, to
* convert between string and integer probe descriptions and the
* dtrace_probedesc_t representation, and to perform similar conversions on
* stability attributes.
*/
const char *, int, char *const [], dtrace_probedesc_t *);
const char *, dtrace_probedesc_t *);
extern int dtrace_str2attr(const char *, dtrace_attribute_t *);
extern const char *dtrace_stability_name(dtrace_stability_t);
extern const char *dtrace_class_name(dtrace_class_t);
extern int dtrace_provider_modules(dtrace_hdl_t *, const char **, int);
extern const char *const _dtrace_version;
extern int _dtrace_debug;
#ifdef __cplusplus
}
#endif
#endif /* _DTRACE_H */