1*a864dc36Sdarran /* 2*a864dc36Sdarran * CDDL HEADER START 3*a864dc36Sdarran * 4*a864dc36Sdarran * The contents of this file are subject to the terms of the 5*a864dc36Sdarran * Common Development and Distribution License, Version 1.0 only 6*a864dc36Sdarran * (the "License"). You may not use this file except in compliance 7*a864dc36Sdarran * with the License. 8*a864dc36Sdarran * 9*a864dc36Sdarran * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*a864dc36Sdarran * or http://www.opensolaris.org/os/licensing. 11*a864dc36Sdarran * See the License for the specific language governing permissions 12*a864dc36Sdarran * and limitations under the License. 13*a864dc36Sdarran * 14*a864dc36Sdarran * When distributing Covered Code, include this CDDL HEADER in each 15*a864dc36Sdarran * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*a864dc36Sdarran * If applicable, add the following below this CDDL HEADER, with the 17*a864dc36Sdarran * fields enclosed by brackets "[]" replaced with your own identifying 18*a864dc36Sdarran * information: Portions Copyright [yyyy] [name of copyright owner] 19*a864dc36Sdarran * 20*a864dc36Sdarran * CDDL HEADER END 21*a864dc36Sdarran */ 22*a864dc36Sdarran /* 23*a864dc36Sdarran * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*a864dc36Sdarran * Use is subject to license terms. 25*a864dc36Sdarran */ 26*a864dc36Sdarran 27*a864dc36Sdarran #ifndef _DT_PRINTF_H 28*a864dc36Sdarran #define _DT_PRINTF_H 29*a864dc36Sdarran 30*a864dc36Sdarran #pragma ident "%Z%%M% %I% %E% SMI" 31*a864dc36Sdarran 32*a864dc36Sdarran #include <sys/types.h> 33*a864dc36Sdarran #include <libctf.h> 34*a864dc36Sdarran #include <dtrace.h> 35*a864dc36Sdarran #include <stdio.h> 36*a864dc36Sdarran 37*a864dc36Sdarran #ifdef __cplusplus 38*a864dc36Sdarran extern "C" { 39*a864dc36Sdarran #endif 40*a864dc36Sdarran 41*a864dc36Sdarran struct dt_node; 42*a864dc36Sdarran struct dt_ident; 43*a864dc36Sdarran 44*a864dc36Sdarran struct dt_pfconv; 45*a864dc36Sdarran struct dt_pfargv; 46*a864dc36Sdarran struct dt_pfargd; 47*a864dc36Sdarran 48*a864dc36Sdarran typedef int dt_pfcheck_f(struct dt_pfargv *, 49*a864dc36Sdarran struct dt_pfargd *, struct dt_node *); 50*a864dc36Sdarran typedef int dt_pfprint_f(dtrace_hdl_t *, FILE *, const char *, 51*a864dc36Sdarran const struct dt_pfargd *, const void *, size_t, uint64_t); 52*a864dc36Sdarran 53*a864dc36Sdarran typedef struct dt_pfconv { 54*a864dc36Sdarran const char *pfc_name; /* string name of input conversion */ 55*a864dc36Sdarran const char *pfc_ofmt; /* string name of output conversion */ 56*a864dc36Sdarran const char *pfc_tstr; /* string name for conversion type */ 57*a864dc36Sdarran dt_pfcheck_f *pfc_check; /* function to use for type checking */ 58*a864dc36Sdarran dt_pfprint_f *pfc_print; /* function to use for formatting */ 59*a864dc36Sdarran ctf_file_t *pfc_cctfp; /* CTF container for "C" defn of type */ 60*a864dc36Sdarran ctf_id_t pfc_ctype; /* CTF type ID for "C" defn of type */ 61*a864dc36Sdarran ctf_file_t *pfc_dctfp; /* CTF container for "D" defn of type */ 62*a864dc36Sdarran ctf_id_t pfc_dtype; /* CTF type ID for "D" defn of type */ 63*a864dc36Sdarran struct dt_pfconv *pfc_next; /* next conversion in hash chain */ 64*a864dc36Sdarran } dt_pfconv_t; 65*a864dc36Sdarran 66*a864dc36Sdarran typedef struct dt_pfdict { 67*a864dc36Sdarran dt_pfconv_t **pdi_buckets; /* hash bucket array */ 68*a864dc36Sdarran uint_t pdi_nbuckets; /* size of hash bucket array */ 69*a864dc36Sdarran } dt_pfdict_t; 70*a864dc36Sdarran 71*a864dc36Sdarran typedef struct dt_pfargd { 72*a864dc36Sdarran const char *pfd_prefix; /* prefix string pointer (or NULL) */ 73*a864dc36Sdarran size_t pfd_preflen; /* length of prefix in bytes */ 74*a864dc36Sdarran char pfd_fmt[8]; /* output format name to use */ 75*a864dc36Sdarran uint_t pfd_flags; /* format flags (see below) */ 76*a864dc36Sdarran int pfd_width; /* field width (or 0) */ 77*a864dc36Sdarran int pfd_dynwidth; /* dynamic field width (or 0) */ 78*a864dc36Sdarran int pfd_prec; /* field precision (or 0) */ 79*a864dc36Sdarran const dt_pfconv_t *pfd_conv; /* conversion specification */ 80*a864dc36Sdarran const dtrace_recdesc_t *pfd_rec; /* pointer to current record */ 81*a864dc36Sdarran struct dt_pfargd *pfd_next; /* pointer to next arg descriptor */ 82*a864dc36Sdarran } dt_pfargd_t; 83*a864dc36Sdarran 84*a864dc36Sdarran #define DT_PFCONV_ALT 0x0001 /* alternate print format (%#) */ 85*a864dc36Sdarran #define DT_PFCONV_ZPAD 0x0002 /* zero-pad integer field (%0) */ 86*a864dc36Sdarran #define DT_PFCONV_LEFT 0x0004 /* left-align field (%-) */ 87*a864dc36Sdarran #define DT_PFCONV_SPOS 0x0008 /* sign positive values (%+) */ 88*a864dc36Sdarran #define DT_PFCONV_DYNWIDTH 0x0010 /* dynamic width (%*.) */ 89*a864dc36Sdarran #define DT_PFCONV_DYNPREC 0x0020 /* dynamic precision (%.*) */ 90*a864dc36Sdarran #define DT_PFCONV_GROUP 0x0040 /* group thousands (%') */ 91*a864dc36Sdarran #define DT_PFCONV_SPACE 0x0080 /* insert leading space (% ) */ 92*a864dc36Sdarran #define DT_PFCONV_AGG 0x0100 /* use aggregation result (%@) */ 93*a864dc36Sdarran #define DT_PFCONV_SIGNED 0x0200 /* arg is a signed integer */ 94*a864dc36Sdarran 95*a864dc36Sdarran typedef struct dt_pfargv { 96*a864dc36Sdarran dtrace_hdl_t *pfv_dtp; /* libdtrace client handle */ 97*a864dc36Sdarran char *pfv_format; /* format string pointer */ 98*a864dc36Sdarran dt_pfargd_t *pfv_argv; /* list of argument descriptors */ 99*a864dc36Sdarran uint_t pfv_argc; /* number of argument descriptors */ 100*a864dc36Sdarran uint_t pfv_flags; /* flags used for validation */ 101*a864dc36Sdarran } dt_pfargv_t; 102*a864dc36Sdarran 103*a864dc36Sdarran typedef struct dt_pfwalk { 104*a864dc36Sdarran const dt_pfargv_t *pfw_argv; /* argument description list */ 105*a864dc36Sdarran uint_t pfw_aid; /* aggregation variable identifier */ 106*a864dc36Sdarran FILE *pfw_fp; /* file pointer to use for output */ 107*a864dc36Sdarran int pfw_err; /* error status code */ 108*a864dc36Sdarran } dt_pfwalk_t; 109*a864dc36Sdarran 110*a864dc36Sdarran extern int dt_pfdict_create(dtrace_hdl_t *); 111*a864dc36Sdarran extern void dt_pfdict_destroy(dtrace_hdl_t *); 112*a864dc36Sdarran 113*a864dc36Sdarran extern dt_pfargv_t *dt_printf_create(dtrace_hdl_t *, const char *); 114*a864dc36Sdarran extern void dt_printf_destroy(dt_pfargv_t *); 115*a864dc36Sdarran 116*a864dc36Sdarran #define DT_PRINTF_EXACTLEN 0x1 /* do not permit extra arguments */ 117*a864dc36Sdarran #define DT_PRINTF_AGGREGATION 0x2 /* enable aggregation conversion */ 118*a864dc36Sdarran 119*a864dc36Sdarran extern void dt_printf_validate(dt_pfargv_t *, uint_t, 120*a864dc36Sdarran struct dt_ident *, int, dtrace_actkind_t, struct dt_node *); 121*a864dc36Sdarran 122*a864dc36Sdarran extern void dt_printa_validate(struct dt_node *, struct dt_node *); 123*a864dc36Sdarran 124*a864dc36Sdarran extern int dt_print_stack(dtrace_hdl_t *, FILE *, 125*a864dc36Sdarran const char *, caddr_t, int, int); 126*a864dc36Sdarran extern int dt_print_ustack(dtrace_hdl_t *, FILE *, 127*a864dc36Sdarran const char *, caddr_t, uint64_t); 128*a864dc36Sdarran extern int dt_print_mod(dtrace_hdl_t *, FILE *, const char *, caddr_t); 129*a864dc36Sdarran extern int dt_print_umod(dtrace_hdl_t *, FILE *, const char *, caddr_t); 130*a864dc36Sdarran 131*a864dc36Sdarran #ifdef __cplusplus 132*a864dc36Sdarran } 133*a864dc36Sdarran #endif 134*a864dc36Sdarran 135*a864dc36Sdarran #endif /* _DT_PRINTF_H */ 136