/*
* 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.
*/
/*
* Copyright (c) 2014, 2016 by Delphix. All rights reserved.
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
*/
#ifndef _DTRACE_H
#define _DTRACE_H
#include <stdarg.h>
#include <stdio.h>
#include <gelf.h>
#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;
struct dt_node;
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 {
dtrace_stmtdesc_t *, void *);
dtrace_ecbdesc_t *);
dtrace_stmt_f *, void *);
/*
* DTrace Data Consumption Interface
*/
typedef enum {
typedef struct dtrace_probedata {
const dtrace_recdesc_t *, void *);
dtrace_consume_probe_f *, dtrace_consume_rec_f *, void *);
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);
/*
* Type-specific output printing
*
* The print() action will associate a string data record that is actually the
* fully-qualified type name of the data traced by the DIFEXPR action. This is
* stored in the same 'format' record from the kernel, but we know by virtue of
* the fact that the action is still DIFEXPR that it is actually a reference to
* plain string data.
*/
/*
* DTrace Work Interface
*/
typedef enum {
dtrace_consume_probe_f *, dtrace_consume_rec_f *, void *);
/*
* DTrace Handler Interface
*/
typedef struct dtrace_errdata {
typedef enum {
typedef struct dtrace_dropdata {
typedef struct dtrace_bufdata {
extern int dtrace_handle_buffered(dtrace_hdl_t *,
dtrace_handle_buffered_f *, void *);
typedef struct dtrace_setoptdata {
extern int dtrace_handle_setopt(dtrace_hdl_t *,
dtrace_handle_setopt_f *, void *);
/*
* DTrace Aggregate Interface
*/
struct dtrace_aggdata {
};
dtrace_aggregate_f *, void *);
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.
*/
typedef struct dtrace_objinfo {
typedef struct dtrace_syminfo {
extern int dtrace_lookup_by_name(dtrace_hdl_t *, const char *, const char *,
GElf_Sym *, dtrace_syminfo_t *);
GElf_Sym *, dtrace_syminfo_t *);
typedef struct dtrace_typeinfo {
extern int dtrace_lookup_by_type(dtrace_hdl_t *, const char *, const char *,
const dtrace_syminfo_t *, dtrace_typeinfo_t *);
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 *);
struct dt_node *);
/*
* 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 {
extern int dtrace_probe_iter(dtrace_hdl_t *,
extern int dtrace_probe_info(dtrace_hdl_t *,
const dtrace_probedesc_t *, dtrace_probeinfo_t *);
/*
* 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 *);
long (*dtv_sysconf)(void *, int);
};
/*
* 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 */