10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 50Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 60Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 70Sstevel@tonic-gate * with the License. 80Sstevel@tonic-gate * 90Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate * See the License for the specific language governing permissions 120Sstevel@tonic-gate * and limitations under the License. 130Sstevel@tonic-gate * 140Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate * 200Sstevel@tonic-gate * CDDL HEADER END 210Sstevel@tonic-gate */ 220Sstevel@tonic-gate /* 23457Sbmc * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #ifndef _DT_PRINTF_H 280Sstevel@tonic-gate #define _DT_PRINTF_H 290Sstevel@tonic-gate 300Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 310Sstevel@tonic-gate 320Sstevel@tonic-gate #include <sys/types.h> 330Sstevel@tonic-gate #include <libctf.h> 340Sstevel@tonic-gate #include <dtrace.h> 350Sstevel@tonic-gate #include <stdio.h> 360Sstevel@tonic-gate 370Sstevel@tonic-gate #ifdef __cplusplus 380Sstevel@tonic-gate extern "C" { 390Sstevel@tonic-gate #endif 400Sstevel@tonic-gate 410Sstevel@tonic-gate struct dt_node; 420Sstevel@tonic-gate struct dt_ident; 430Sstevel@tonic-gate 440Sstevel@tonic-gate struct dt_pfconv; 45457Sbmc struct dt_pfargv; 460Sstevel@tonic-gate struct dt_pfargd; 470Sstevel@tonic-gate 48457Sbmc typedef int dt_pfcheck_f(struct dt_pfargv *, 49457Sbmc struct dt_pfargd *, struct dt_node *); 500Sstevel@tonic-gate typedef int dt_pfprint_f(dtrace_hdl_t *, FILE *, const char *, 510Sstevel@tonic-gate const struct dt_pfargd *, const void *, size_t, uint64_t); 520Sstevel@tonic-gate 530Sstevel@tonic-gate typedef struct dt_pfconv { 540Sstevel@tonic-gate const char *pfc_name; /* string name of input conversion */ 550Sstevel@tonic-gate const char *pfc_ofmt; /* string name of output conversion */ 560Sstevel@tonic-gate const char *pfc_tstr; /* string name for conversion type */ 570Sstevel@tonic-gate dt_pfcheck_f *pfc_check; /* function to use for type checking */ 580Sstevel@tonic-gate dt_pfprint_f *pfc_print; /* function to use for formatting */ 590Sstevel@tonic-gate ctf_file_t *pfc_cctfp; /* CTF container for "C" defn of type */ 600Sstevel@tonic-gate ctf_id_t pfc_ctype; /* CTF type ID for "C" defn of type */ 610Sstevel@tonic-gate ctf_file_t *pfc_dctfp; /* CTF container for "D" defn of type */ 620Sstevel@tonic-gate ctf_id_t pfc_dtype; /* CTF type ID for "D" defn of type */ 630Sstevel@tonic-gate struct dt_pfconv *pfc_next; /* next conversion in hash chain */ 640Sstevel@tonic-gate } dt_pfconv_t; 650Sstevel@tonic-gate 660Sstevel@tonic-gate typedef struct dt_pfdict { 670Sstevel@tonic-gate dt_pfconv_t **pdi_buckets; /* hash bucket array */ 680Sstevel@tonic-gate uint_t pdi_nbuckets; /* size of hash bucket array */ 690Sstevel@tonic-gate } dt_pfdict_t; 700Sstevel@tonic-gate 710Sstevel@tonic-gate typedef struct dt_pfargd { 720Sstevel@tonic-gate const char *pfd_prefix; /* prefix string pointer (or NULL) */ 730Sstevel@tonic-gate size_t pfd_preflen; /* length of prefix in bytes */ 740Sstevel@tonic-gate char pfd_fmt[8]; /* output format name to use */ 750Sstevel@tonic-gate uint_t pfd_flags; /* format flags (see below) */ 760Sstevel@tonic-gate int pfd_width; /* field width (or 0) */ 770Sstevel@tonic-gate int pfd_dynwidth; /* dynamic field width (or 0) */ 780Sstevel@tonic-gate int pfd_prec; /* field precision (or 0) */ 790Sstevel@tonic-gate const dt_pfconv_t *pfd_conv; /* conversion specification */ 800Sstevel@tonic-gate const dtrace_recdesc_t *pfd_rec; /* pointer to current record */ 810Sstevel@tonic-gate struct dt_pfargd *pfd_next; /* pointer to next arg descriptor */ 820Sstevel@tonic-gate } dt_pfargd_t; 830Sstevel@tonic-gate 840Sstevel@tonic-gate #define DT_PFCONV_ALT 0x0001 /* alternate print format (%#) */ 850Sstevel@tonic-gate #define DT_PFCONV_ZPAD 0x0002 /* zero-pad integer field (%0) */ 860Sstevel@tonic-gate #define DT_PFCONV_LEFT 0x0004 /* left-align field (%-) */ 870Sstevel@tonic-gate #define DT_PFCONV_SPOS 0x0008 /* sign positive values (%+) */ 880Sstevel@tonic-gate #define DT_PFCONV_DYNWIDTH 0x0010 /* dynamic width (%*.) */ 890Sstevel@tonic-gate #define DT_PFCONV_DYNPREC 0x0020 /* dynamic precision (%.*) */ 900Sstevel@tonic-gate #define DT_PFCONV_GROUP 0x0040 /* group thousands (%') */ 910Sstevel@tonic-gate #define DT_PFCONV_SPACE 0x0080 /* insert leading space (% ) */ 920Sstevel@tonic-gate #define DT_PFCONV_AGG 0x0100 /* use aggregation result (%@) */ 930Sstevel@tonic-gate #define DT_PFCONV_SIGNED 0x0200 /* arg is a signed integer */ 940Sstevel@tonic-gate 950Sstevel@tonic-gate typedef struct dt_pfargv { 96457Sbmc dtrace_hdl_t *pfv_dtp; /* libdtrace client handle */ 970Sstevel@tonic-gate char *pfv_format; /* format string pointer */ 980Sstevel@tonic-gate dt_pfargd_t *pfv_argv; /* list of argument descriptors */ 990Sstevel@tonic-gate uint_t pfv_argc; /* number of argument descriptors */ 1000Sstevel@tonic-gate uint_t pfv_flags; /* flags used for validation */ 1010Sstevel@tonic-gate } dt_pfargv_t; 1020Sstevel@tonic-gate 1030Sstevel@tonic-gate typedef struct dt_pfwalk { 1040Sstevel@tonic-gate const dt_pfargv_t *pfw_argv; /* argument description list */ 1050Sstevel@tonic-gate uint_t pfw_aid; /* aggregation variable identifier */ 1060Sstevel@tonic-gate FILE *pfw_fp; /* file pointer to use for output */ 1070Sstevel@tonic-gate int pfw_err; /* error status code */ 1080Sstevel@tonic-gate } dt_pfwalk_t; 1090Sstevel@tonic-gate 1100Sstevel@tonic-gate extern int dt_pfdict_create(dtrace_hdl_t *); 1110Sstevel@tonic-gate extern void dt_pfdict_destroy(dtrace_hdl_t *); 1120Sstevel@tonic-gate 1130Sstevel@tonic-gate extern dt_pfargv_t *dt_printf_create(dtrace_hdl_t *, const char *); 1140Sstevel@tonic-gate extern void dt_printf_destroy(dt_pfargv_t *); 1150Sstevel@tonic-gate 1160Sstevel@tonic-gate #define DT_PRINTF_EXACTLEN 0x1 /* do not permit extra arguments */ 1170Sstevel@tonic-gate #define DT_PRINTF_AGGREGATION 0x2 /* enable aggregation conversion */ 1180Sstevel@tonic-gate 1190Sstevel@tonic-gate extern void dt_printf_validate(dt_pfargv_t *, uint_t, 1200Sstevel@tonic-gate struct dt_ident *, int, dtrace_actkind_t, struct dt_node *); 1210Sstevel@tonic-gate 122*1017Sbmc extern void dt_printa_validate(struct dt_node *, struct dt_node *); 123*1017Sbmc 1240Sstevel@tonic-gate extern int dt_print_stack(dtrace_hdl_t *, FILE *, 125457Sbmc const char *, caddr_t, int, int); 1260Sstevel@tonic-gate extern int dt_print_ustack(dtrace_hdl_t *, FILE *, 1270Sstevel@tonic-gate const char *, caddr_t, uint64_t); 128457Sbmc extern int dt_print_mod(dtrace_hdl_t *, FILE *, const char *, caddr_t); 129457Sbmc extern int dt_print_umod(dtrace_hdl_t *, FILE *, const char *, caddr_t); 1300Sstevel@tonic-gate 1310Sstevel@tonic-gate #ifdef __cplusplus 1320Sstevel@tonic-gate } 1330Sstevel@tonic-gate #endif 1340Sstevel@tonic-gate 1350Sstevel@tonic-gate #endif /* _DT_PRINTF_H */ 136