1178479Sjb/* 2178479Sjb * CDDL HEADER START 3178479Sjb * 4178479Sjb * The contents of this file are subject to the terms of the 5178479Sjb * Common Development and Distribution License, Version 1.0 only 6178479Sjb * (the "License"). You may not use this file except in compliance 7178479Sjb * with the License. 8178479Sjb * 9178479Sjb * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10178479Sjb * or http://www.opensolaris.org/os/licensing. 11178479Sjb * See the License for the specific language governing permissions 12178479Sjb * and limitations under the License. 13178479Sjb * 14178479Sjb * When distributing Covered Code, include this CDDL HEADER in each 15178479Sjb * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16178479Sjb * If applicable, add the following below this CDDL HEADER, with the 17178479Sjb * fields enclosed by brackets "[]" replaced with your own identifying 18178479Sjb * information: Portions Copyright [yyyy] [name of copyright owner] 19178479Sjb * 20178479Sjb * CDDL HEADER END 21178479Sjb */ 22178479Sjb/* 23178479Sjb * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24178479Sjb * Use is subject to license terms. 25178479Sjb */ 26178479Sjb 27178479Sjb#ifndef _DT_PRINTF_H 28178479Sjb#define _DT_PRINTF_H 29178479Sjb 30178479Sjb#pragma ident "%Z%%M% %I% %E% SMI" 31178479Sjb 32178479Sjb#include <sys/types.h> 33178479Sjb#include <libctf.h> 34178479Sjb#include <dtrace.h> 35178479Sjb#include <stdio.h> 36178479Sjb 37178479Sjb#ifdef __cplusplus 38178479Sjbextern "C" { 39178479Sjb#endif 40178479Sjb 41178479Sjbstruct dt_node; 42178479Sjbstruct dt_ident; 43178479Sjb 44178479Sjbstruct dt_pfconv; 45178479Sjbstruct dt_pfargv; 46178479Sjbstruct dt_pfargd; 47178479Sjb 48178479Sjbtypedef int dt_pfcheck_f(struct dt_pfargv *, 49178479Sjb struct dt_pfargd *, struct dt_node *); 50178479Sjbtypedef int dt_pfprint_f(dtrace_hdl_t *, FILE *, const char *, 51178479Sjb const struct dt_pfargd *, const void *, size_t, uint64_t); 52178479Sjb 53178479Sjbtypedef struct dt_pfconv { 54178479Sjb const char *pfc_name; /* string name of input conversion */ 55178479Sjb const char *pfc_ofmt; /* string name of output conversion */ 56178479Sjb const char *pfc_tstr; /* string name for conversion type */ 57178479Sjb dt_pfcheck_f *pfc_check; /* function to use for type checking */ 58178479Sjb dt_pfprint_f *pfc_print; /* function to use for formatting */ 59178479Sjb ctf_file_t *pfc_cctfp; /* CTF container for "C" defn of type */ 60178479Sjb ctf_id_t pfc_ctype; /* CTF type ID for "C" defn of type */ 61178479Sjb ctf_file_t *pfc_dctfp; /* CTF container for "D" defn of type */ 62178479Sjb ctf_id_t pfc_dtype; /* CTF type ID for "D" defn of type */ 63178479Sjb struct dt_pfconv *pfc_next; /* next conversion in hash chain */ 64178479Sjb} dt_pfconv_t; 65178479Sjb 66178479Sjbtypedef struct dt_pfdict { 67178479Sjb dt_pfconv_t **pdi_buckets; /* hash bucket array */ 68178479Sjb uint_t pdi_nbuckets; /* size of hash bucket array */ 69178479Sjb} dt_pfdict_t; 70178479Sjb 71178479Sjbtypedef struct dt_pfargd { 72178479Sjb const char *pfd_prefix; /* prefix string pointer (or NULL) */ 73178479Sjb size_t pfd_preflen; /* length of prefix in bytes */ 74178479Sjb char pfd_fmt[8]; /* output format name to use */ 75178479Sjb uint_t pfd_flags; /* format flags (see below) */ 76178479Sjb int pfd_width; /* field width (or 0) */ 77178479Sjb int pfd_dynwidth; /* dynamic field width (or 0) */ 78178479Sjb int pfd_prec; /* field precision (or 0) */ 79178479Sjb const dt_pfconv_t *pfd_conv; /* conversion specification */ 80178479Sjb const dtrace_recdesc_t *pfd_rec; /* pointer to current record */ 81178479Sjb struct dt_pfargd *pfd_next; /* pointer to next arg descriptor */ 82178479Sjb} dt_pfargd_t; 83178479Sjb 84178479Sjb#define DT_PFCONV_ALT 0x0001 /* alternate print format (%#) */ 85178479Sjb#define DT_PFCONV_ZPAD 0x0002 /* zero-pad integer field (%0) */ 86178479Sjb#define DT_PFCONV_LEFT 0x0004 /* left-align field (%-) */ 87178479Sjb#define DT_PFCONV_SPOS 0x0008 /* sign positive values (%+) */ 88178479Sjb#define DT_PFCONV_DYNWIDTH 0x0010 /* dynamic width (%*.) */ 89178479Sjb#define DT_PFCONV_DYNPREC 0x0020 /* dynamic precision (%.*) */ 90178479Sjb#define DT_PFCONV_GROUP 0x0040 /* group thousands (%') */ 91178479Sjb#define DT_PFCONV_SPACE 0x0080 /* insert leading space (% ) */ 92178479Sjb#define DT_PFCONV_AGG 0x0100 /* use aggregation result (%@) */ 93178479Sjb#define DT_PFCONV_SIGNED 0x0200 /* arg is a signed integer */ 94178479Sjb 95178479Sjbtypedef struct dt_pfargv { 96178479Sjb dtrace_hdl_t *pfv_dtp; /* libdtrace client handle */ 97178479Sjb char *pfv_format; /* format string pointer */ 98178479Sjb dt_pfargd_t *pfv_argv; /* list of argument descriptors */ 99178479Sjb uint_t pfv_argc; /* number of argument descriptors */ 100178479Sjb uint_t pfv_flags; /* flags used for validation */ 101178479Sjb} dt_pfargv_t; 102178479Sjb 103178479Sjbtypedef struct dt_pfwalk { 104178479Sjb const dt_pfargv_t *pfw_argv; /* argument description list */ 105178479Sjb uint_t pfw_aid; /* aggregation variable identifier */ 106178479Sjb FILE *pfw_fp; /* file pointer to use for output */ 107178479Sjb int pfw_err; /* error status code */ 108178479Sjb} dt_pfwalk_t; 109178479Sjb 110178479Sjbextern int dt_pfdict_create(dtrace_hdl_t *); 111178479Sjbextern void dt_pfdict_destroy(dtrace_hdl_t *); 112178479Sjb 113178479Sjbextern dt_pfargv_t *dt_printf_create(dtrace_hdl_t *, const char *); 114178479Sjbextern void dt_printf_destroy(dt_pfargv_t *); 115178479Sjb 116178479Sjb#define DT_PRINTF_EXACTLEN 0x1 /* do not permit extra arguments */ 117178479Sjb#define DT_PRINTF_AGGREGATION 0x2 /* enable aggregation conversion */ 118178479Sjb 119178479Sjbextern void dt_printf_validate(dt_pfargv_t *, uint_t, 120178479Sjb struct dt_ident *, int, dtrace_actkind_t, struct dt_node *); 121178479Sjb 122178479Sjbextern void dt_printa_validate(struct dt_node *, struct dt_node *); 123178479Sjb 124178479Sjbextern int dt_print_stack(dtrace_hdl_t *, FILE *, 125178479Sjb const char *, caddr_t, int, int); 126178479Sjbextern int dt_print_ustack(dtrace_hdl_t *, FILE *, 127178479Sjb const char *, caddr_t, uint64_t); 128178479Sjbextern int dt_print_mod(dtrace_hdl_t *, FILE *, const char *, caddr_t); 129178479Sjbextern int dt_print_umod(dtrace_hdl_t *, FILE *, const char *, caddr_t); 130178479Sjb 131178479Sjb#ifdef __cplusplus 132178479Sjb} 133178479Sjb#endif 134178479Sjb 135178479Sjb#endif /* _DT_PRINTF_H */ 136