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