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, Version 1.0 only
2N/A * (the "License"). You may not use this file except in compliance
2N/A * 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 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A#ifndef _DT_PRINTF_H
2N/A#define _DT_PRINTF_H
2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A#include <sys/types.h>
2N/A#include <libctf.h>
2N/A#include <dtrace.h>
2N/A#include <stdio.h>
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/Astruct dt_node;
2N/Astruct dt_ident;
2N/A
2N/Astruct dt_pfconv;
2N/Astruct dt_pfargv;
2N/Astruct dt_pfargd;
2N/A
2N/Atypedef int dt_pfcheck_f(struct dt_pfargv *,
2N/A struct dt_pfargd *, struct dt_node *);
2N/Atypedef int dt_pfprint_f(dtrace_hdl_t *, FILE *, const char *,
2N/A const struct dt_pfargd *, const void *, size_t, uint64_t);
2N/A
2N/Atypedef struct dt_pfconv {
2N/A const char *pfc_name; /* string name of input conversion */
2N/A const char *pfc_ofmt; /* string name of output conversion */
2N/A const char *pfc_tstr; /* string name for conversion type */
2N/A dt_pfcheck_f *pfc_check; /* function to use for type checking */
2N/A dt_pfprint_f *pfc_print; /* function to use for formatting */
2N/A ctf_file_t *pfc_cctfp; /* CTF container for "C" defn of type */
2N/A ctf_id_t pfc_ctype; /* CTF type ID for "C" defn of type */
2N/A ctf_file_t *pfc_dctfp; /* CTF container for "D" defn of type */
2N/A ctf_id_t pfc_dtype; /* CTF type ID for "D" defn of type */
2N/A struct dt_pfconv *pfc_next; /* next conversion in hash chain */
2N/A} dt_pfconv_t;
2N/A
2N/Atypedef struct dt_pfdict {
2N/A dt_pfconv_t **pdi_buckets; /* hash bucket array */
2N/A uint_t pdi_nbuckets; /* size of hash bucket array */
2N/A} dt_pfdict_t;
2N/A
2N/Atypedef struct dt_pfargd {
2N/A const char *pfd_prefix; /* prefix string pointer (or NULL) */
2N/A size_t pfd_preflen; /* length of prefix in bytes */
2N/A char pfd_fmt[8]; /* output format name to use */
2N/A uint_t pfd_flags; /* format flags (see below) */
2N/A int pfd_width; /* field width (or 0) */
2N/A int pfd_dynwidth; /* dynamic field width (or 0) */
2N/A int pfd_prec; /* field precision (or 0) */
2N/A const dt_pfconv_t *pfd_conv; /* conversion specification */
2N/A const dtrace_recdesc_t *pfd_rec; /* pointer to current record */
2N/A struct dt_pfargd *pfd_next; /* pointer to next arg descriptor */
2N/A} dt_pfargd_t;
2N/A
2N/A#define DT_PFCONV_ALT 0x0001 /* alternate print format (%#) */
2N/A#define DT_PFCONV_ZPAD 0x0002 /* zero-pad integer field (%0) */
2N/A#define DT_PFCONV_LEFT 0x0004 /* left-align field (%-) */
2N/A#define DT_PFCONV_SPOS 0x0008 /* sign positive values (%+) */
2N/A#define DT_PFCONV_DYNWIDTH 0x0010 /* dynamic width (%*.) */
2N/A#define DT_PFCONV_DYNPREC 0x0020 /* dynamic precision (%.*) */
2N/A#define DT_PFCONV_GROUP 0x0040 /* group thousands (%') */
2N/A#define DT_PFCONV_SPACE 0x0080 /* insert leading space (% ) */
2N/A#define DT_PFCONV_AGG 0x0100 /* use aggregation result (%@) */
2N/A#define DT_PFCONV_SIGNED 0x0200 /* arg is a signed integer */
2N/A
2N/Atypedef struct dt_pfargv {
2N/A dtrace_hdl_t *pfv_dtp; /* libdtrace client handle */
2N/A char *pfv_format; /* format string pointer */
2N/A dt_pfargd_t *pfv_argv; /* list of argument descriptors */
2N/A uint_t pfv_argc; /* number of argument descriptors */
2N/A uint_t pfv_flags; /* flags used for validation */
2N/A} dt_pfargv_t;
2N/A
2N/Atypedef struct dt_pfwalk {
2N/A const dt_pfargv_t *pfw_argv; /* argument description list */
2N/A uint_t pfw_aid; /* aggregation variable identifier */
2N/A FILE *pfw_fp; /* file pointer to use for output */
2N/A int pfw_err; /* error status code */
2N/A} dt_pfwalk_t;
2N/A
2N/Aextern int dt_pfdict_create(dtrace_hdl_t *);
2N/Aextern void dt_pfdict_destroy(dtrace_hdl_t *);
2N/A
2N/Aextern dt_pfargv_t *dt_printf_create(dtrace_hdl_t *, const char *);
2N/Aextern void dt_printf_destroy(dt_pfargv_t *);
2N/A
2N/A#define DT_PRINTF_EXACTLEN 0x1 /* do not permit extra arguments */
2N/A#define DT_PRINTF_AGGREGATION 0x2 /* enable aggregation conversion */
2N/A
2N/Aextern void dt_printf_validate(dt_pfargv_t *, uint_t,
2N/A struct dt_ident *, int, dtrace_actkind_t, struct dt_node *);
2N/A
2N/Aextern void dt_printa_validate(struct dt_node *, struct dt_node *);
2N/A
2N/Aextern int dt_print_stack(dtrace_hdl_t *, FILE *,
2N/A const char *, caddr_t, int, int);
2N/Aextern int dt_print_ustack(dtrace_hdl_t *, FILE *,
2N/A const char *, caddr_t, uint64_t);
2N/Aextern int dt_print_mod(dtrace_hdl_t *, FILE *, const char *, caddr_t);
2N/Aextern int dt_print_umod(dtrace_hdl_t *, FILE *, const char *, caddr_t);
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _DT_PRINTF_H */