14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * CDDL HEADER START
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * The contents of this file are subject to the terms of the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Common Development and Distribution License, Version 1.0 only
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * (the "License"). You may not use this file except in compliance
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * with the License.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * or http://www.opensolaris.org/os/licensing.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * See the License for the specific language governing permissions
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * and limitations under the License.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * When distributing Covered Code, include this CDDL HEADER in each
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * If applicable, add the following below this CDDL HEADER, with the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * fields enclosed by brackets "[]" replaced with your own identifying
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * information: Portions Copyright [yyyy] [name of copyright owner]
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * CDDL HEADER END
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Use is subject to license terms.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#ifndef _DT_PRINTF_H
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#define _DT_PRINTF_H
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
dfd08267d2958ae1cd559dd7dc2f36bf5461648dvboxsync#ifndef VBOX
dfd08267d2958ae1cd559dd7dc2f36bf5461648dvboxsync# pragma ident "%Z%%M% %I% %E% SMI"
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <sys/types.h>
dfd08267d2958ae1cd559dd7dc2f36bf5461648dvboxsync#endif
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <libctf.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <dtrace.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <stdio.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#ifdef __cplusplus
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncextern "C" {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#endif
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstruct dt_node;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstruct dt_ident;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstruct dt_pfconv;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstruct dt_pfargv;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstruct dt_pfargd;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynctypedef int dt_pfcheck_f(struct dt_pfargv *,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct dt_pfargd *, struct dt_node *);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynctypedef int dt_pfprint_f(dtrace_hdl_t *, FILE *, const char *,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync const struct dt_pfargd *, const void *, size_t, uint64_t);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynctypedef struct dt_pfconv {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync const char *pfc_name; /* string name of input conversion */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync const char *pfc_ofmt; /* string name of output conversion */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync const char *pfc_tstr; /* string name for conversion type */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_pfcheck_f *pfc_check; /* function to use for type checking */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_pfprint_f *pfc_print; /* function to use for formatting */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ctf_file_t *pfc_cctfp; /* CTF container for "C" defn of type */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ctf_id_t pfc_ctype; /* CTF type ID for "C" defn of type */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ctf_file_t *pfc_dctfp; /* CTF container for "D" defn of type */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync ctf_id_t pfc_dtype; /* CTF type ID for "D" defn of type */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct dt_pfconv *pfc_next; /* next conversion in hash chain */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync} dt_pfconv_t;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynctypedef struct dt_pfdict {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_pfconv_t **pdi_buckets; /* hash bucket array */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync uint_t pdi_nbuckets; /* size of hash bucket array */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync} dt_pfdict_t;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynctypedef struct dt_pfargd {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync const char *pfd_prefix; /* prefix string pointer (or NULL) */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync size_t pfd_preflen; /* length of prefix in bytes */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync char pfd_fmt[8]; /* output format name to use */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync uint_t pfd_flags; /* format flags (see below) */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int pfd_width; /* field width (or 0) */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int pfd_dynwidth; /* dynamic field width (or 0) */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int pfd_prec; /* field precision (or 0) */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync const dt_pfconv_t *pfd_conv; /* conversion specification */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync const dtrace_recdesc_t *pfd_rec; /* pointer to current record */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct dt_pfargd *pfd_next; /* pointer to next arg descriptor */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync} dt_pfargd_t;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#define DT_PFCONV_ALT 0x0001 /* alternate print format (%#) */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#define DT_PFCONV_ZPAD 0x0002 /* zero-pad integer field (%0) */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#define DT_PFCONV_LEFT 0x0004 /* left-align field (%-) */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#define DT_PFCONV_SPOS 0x0008 /* sign positive values (%+) */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#define DT_PFCONV_DYNWIDTH 0x0010 /* dynamic width (%*.) */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#define DT_PFCONV_DYNPREC 0x0020 /* dynamic precision (%.*) */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#define DT_PFCONV_GROUP 0x0040 /* group thousands (%') */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#define DT_PFCONV_SPACE 0x0080 /* insert leading space (% ) */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#define DT_PFCONV_AGG 0x0100 /* use aggregation result (%@) */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#define DT_PFCONV_SIGNED 0x0200 /* arg is a signed integer */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynctypedef struct dt_pfargv {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dtrace_hdl_t *pfv_dtp; /* libdtrace client handle */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync char *pfv_format; /* format string pointer */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync dt_pfargd_t *pfv_argv; /* list of argument descriptors */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync uint_t pfv_argc; /* number of argument descriptors */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync uint_t pfv_flags; /* flags used for validation */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync} dt_pfargv_t;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynctypedef struct dt_pfwalk {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync const dt_pfargv_t *pfw_argv; /* argument description list */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync uint_t pfw_aid; /* aggregation variable identifier */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync FILE *pfw_fp; /* file pointer to use for output */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync int pfw_err; /* error status code */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync} dt_pfwalk_t;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncextern int dt_pfdict_create(dtrace_hdl_t *);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncextern void dt_pfdict_destroy(dtrace_hdl_t *);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncextern dt_pfargv_t *dt_printf_create(dtrace_hdl_t *, const char *);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncextern void dt_printf_destroy(dt_pfargv_t *);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#define DT_PRINTF_EXACTLEN 0x1 /* do not permit extra arguments */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#define DT_PRINTF_AGGREGATION 0x2 /* enable aggregation conversion */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncextern void dt_printf_validate(dt_pfargv_t *, uint_t,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync struct dt_ident *, int, dtrace_actkind_t, struct dt_node *);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncextern void dt_printa_validate(struct dt_node *, struct dt_node *);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncextern int dt_print_stack(dtrace_hdl_t *, FILE *,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync const char *, caddr_t, int, int);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncextern int dt_print_ustack(dtrace_hdl_t *, FILE *,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync const char *, caddr_t, uint64_t);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncextern int dt_print_mod(dtrace_hdl_t *, FILE *, const char *, caddr_t);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncextern int dt_print_umod(dtrace_hdl_t *, FILE *, const char *, caddr_t);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#ifdef __cplusplus
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#endif
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#endif /* _DT_PRINTF_H */