16ff6d951SJohn Birrell /* 26ff6d951SJohn Birrell * CDDL HEADER START 36ff6d951SJohn Birrell * 46ff6d951SJohn Birrell * The contents of this file are subject to the terms of the 56ff6d951SJohn Birrell * Common Development and Distribution License, Version 1.0 only 66ff6d951SJohn Birrell * (the "License"). You may not use this file except in compliance 76ff6d951SJohn Birrell * with the License. 86ff6d951SJohn Birrell * 96ff6d951SJohn Birrell * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 106ff6d951SJohn Birrell * or http://www.opensolaris.org/os/licensing. 116ff6d951SJohn Birrell * See the License for the specific language governing permissions 126ff6d951SJohn Birrell * and limitations under the License. 136ff6d951SJohn Birrell * 146ff6d951SJohn Birrell * When distributing Covered Code, include this CDDL HEADER in each 156ff6d951SJohn Birrell * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 166ff6d951SJohn Birrell * If applicable, add the following below this CDDL HEADER, with the 176ff6d951SJohn Birrell * fields enclosed by brackets "[]" replaced with your own identifying 186ff6d951SJohn Birrell * information: Portions Copyright [yyyy] [name of copyright owner] 196ff6d951SJohn Birrell * 206ff6d951SJohn Birrell * CDDL HEADER END 216ff6d951SJohn Birrell */ 226ff6d951SJohn Birrell /* 236ff6d951SJohn Birrell * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*93f27766SDomagoj Stolfa * Copyright 2023 Domagoj Stolfa. All rights reserved. 256ff6d951SJohn Birrell * Use is subject to license terms. 266ff6d951SJohn Birrell */ 276ff6d951SJohn Birrell 286ff6d951SJohn Birrell #ifndef _DT_PRINTF_H 296ff6d951SJohn Birrell #define _DT_PRINTF_H 306ff6d951SJohn Birrell 316ff6d951SJohn Birrell #pragma ident "%Z%%M% %I% %E% SMI" 326ff6d951SJohn Birrell 336ff6d951SJohn Birrell #include <sys/types.h> 346ff6d951SJohn Birrell #include <libctf.h> 356ff6d951SJohn Birrell #include <dtrace.h> 366ff6d951SJohn Birrell #include <stdio.h> 376ff6d951SJohn Birrell 386ff6d951SJohn Birrell #ifdef __cplusplus 396ff6d951SJohn Birrell extern "C" { 406ff6d951SJohn Birrell #endif 416ff6d951SJohn Birrell 426ff6d951SJohn Birrell struct dt_node; 436ff6d951SJohn Birrell struct dt_ident; 446ff6d951SJohn Birrell 456ff6d951SJohn Birrell struct dt_pfconv; 466ff6d951SJohn Birrell struct dt_pfargv; 476ff6d951SJohn Birrell struct dt_pfargd; 486ff6d951SJohn Birrell 496ff6d951SJohn Birrell typedef int dt_pfcheck_f(struct dt_pfargv *, 506ff6d951SJohn Birrell struct dt_pfargd *, struct dt_node *); 516ff6d951SJohn Birrell typedef int dt_pfprint_f(dtrace_hdl_t *, FILE *, const char *, 526ff6d951SJohn Birrell const struct dt_pfargd *, const void *, size_t, uint64_t); 536ff6d951SJohn Birrell 546ff6d951SJohn Birrell typedef struct dt_pfconv { 556ff6d951SJohn Birrell const char *pfc_name; /* string name of input conversion */ 566ff6d951SJohn Birrell const char *pfc_ofmt; /* string name of output conversion */ 576ff6d951SJohn Birrell const char *pfc_tstr; /* string name for conversion type */ 586ff6d951SJohn Birrell dt_pfcheck_f *pfc_check; /* function to use for type checking */ 596ff6d951SJohn Birrell dt_pfprint_f *pfc_print; /* function to use for formatting */ 606ff6d951SJohn Birrell ctf_file_t *pfc_cctfp; /* CTF container for "C" defn of type */ 616ff6d951SJohn Birrell ctf_id_t pfc_ctype; /* CTF type ID for "C" defn of type */ 626ff6d951SJohn Birrell ctf_file_t *pfc_dctfp; /* CTF container for "D" defn of type */ 636ff6d951SJohn Birrell ctf_id_t pfc_dtype; /* CTF type ID for "D" defn of type */ 646ff6d951SJohn Birrell struct dt_pfconv *pfc_next; /* next conversion in hash chain */ 656ff6d951SJohn Birrell } dt_pfconv_t; 666ff6d951SJohn Birrell 676ff6d951SJohn Birrell typedef struct dt_pfdict { 686ff6d951SJohn Birrell dt_pfconv_t **pdi_buckets; /* hash bucket array */ 696ff6d951SJohn Birrell uint_t pdi_nbuckets; /* size of hash bucket array */ 706ff6d951SJohn Birrell } dt_pfdict_t; 716ff6d951SJohn Birrell 726ff6d951SJohn Birrell typedef struct dt_pfargd { 736ff6d951SJohn Birrell const char *pfd_prefix; /* prefix string pointer (or NULL) */ 746ff6d951SJohn Birrell size_t pfd_preflen; /* length of prefix in bytes */ 756ff6d951SJohn Birrell char pfd_fmt[8]; /* output format name to use */ 766ff6d951SJohn Birrell uint_t pfd_flags; /* format flags (see below) */ 776ff6d951SJohn Birrell int pfd_width; /* field width (or 0) */ 786ff6d951SJohn Birrell int pfd_dynwidth; /* dynamic field width (or 0) */ 796ff6d951SJohn Birrell int pfd_prec; /* field precision (or 0) */ 806ff6d951SJohn Birrell const dt_pfconv_t *pfd_conv; /* conversion specification */ 816ff6d951SJohn Birrell const dtrace_recdesc_t *pfd_rec; /* pointer to current record */ 826ff6d951SJohn Birrell struct dt_pfargd *pfd_next; /* pointer to next arg descriptor */ 836ff6d951SJohn Birrell } dt_pfargd_t; 846ff6d951SJohn Birrell 856ff6d951SJohn Birrell #define DT_PFCONV_ALT 0x0001 /* alternate print format (%#) */ 866ff6d951SJohn Birrell #define DT_PFCONV_ZPAD 0x0002 /* zero-pad integer field (%0) */ 876ff6d951SJohn Birrell #define DT_PFCONV_LEFT 0x0004 /* left-align field (%-) */ 886ff6d951SJohn Birrell #define DT_PFCONV_SPOS 0x0008 /* sign positive values (%+) */ 896ff6d951SJohn Birrell #define DT_PFCONV_DYNWIDTH 0x0010 /* dynamic width (%*.) */ 906ff6d951SJohn Birrell #define DT_PFCONV_DYNPREC 0x0020 /* dynamic precision (%.*) */ 916ff6d951SJohn Birrell #define DT_PFCONV_GROUP 0x0040 /* group thousands (%') */ 926ff6d951SJohn Birrell #define DT_PFCONV_SPACE 0x0080 /* insert leading space (% ) */ 936ff6d951SJohn Birrell #define DT_PFCONV_AGG 0x0100 /* use aggregation result (%@) */ 946ff6d951SJohn Birrell #define DT_PFCONV_SIGNED 0x0200 /* arg is a signed integer */ 956ff6d951SJohn Birrell 966ff6d951SJohn Birrell typedef struct dt_pfargv { 976ff6d951SJohn Birrell dtrace_hdl_t *pfv_dtp; /* libdtrace client handle */ 986ff6d951SJohn Birrell char *pfv_format; /* format string pointer */ 996ff6d951SJohn Birrell dt_pfargd_t *pfv_argv; /* list of argument descriptors */ 1006ff6d951SJohn Birrell uint_t pfv_argc; /* number of argument descriptors */ 1016ff6d951SJohn Birrell uint_t pfv_flags; /* flags used for validation */ 1026ff6d951SJohn Birrell } dt_pfargv_t; 1036ff6d951SJohn Birrell 1046ff6d951SJohn Birrell typedef struct dt_pfwalk { 1056ff6d951SJohn Birrell const dt_pfargv_t *pfw_argv; /* argument description list */ 1066ff6d951SJohn Birrell uint_t pfw_aid; /* aggregation variable identifier */ 1076ff6d951SJohn Birrell FILE *pfw_fp; /* file pointer to use for output */ 1086ff6d951SJohn Birrell int pfw_err; /* error status code */ 1096ff6d951SJohn Birrell } dt_pfwalk_t; 1106ff6d951SJohn Birrell 1116ff6d951SJohn Birrell extern int dt_pfdict_create(dtrace_hdl_t *); 1126ff6d951SJohn Birrell extern void dt_pfdict_destroy(dtrace_hdl_t *); 1136ff6d951SJohn Birrell 1146ff6d951SJohn Birrell extern dt_pfargv_t *dt_printf_create(dtrace_hdl_t *, const char *); 1156ff6d951SJohn Birrell extern void dt_printf_destroy(dt_pfargv_t *); 1166ff6d951SJohn Birrell 1176ff6d951SJohn Birrell #define DT_PRINTF_EXACTLEN 0x1 /* do not permit extra arguments */ 1186ff6d951SJohn Birrell #define DT_PRINTF_AGGREGATION 0x2 /* enable aggregation conversion */ 1196ff6d951SJohn Birrell 1206ff6d951SJohn Birrell extern void dt_printf_validate(dt_pfargv_t *, uint_t, 1216ff6d951SJohn Birrell struct dt_ident *, int, dtrace_actkind_t, struct dt_node *); 1226ff6d951SJohn Birrell 1236ff6d951SJohn Birrell extern void dt_printa_validate(struct dt_node *, struct dt_node *); 1246ff6d951SJohn Birrell 1256ff6d951SJohn Birrell extern int dt_print_stack(dtrace_hdl_t *, FILE *, 1266ff6d951SJohn Birrell const char *, caddr_t, int, int); 1276ff6d951SJohn Birrell extern int dt_print_ustack(dtrace_hdl_t *, FILE *, 1286ff6d951SJohn Birrell const char *, caddr_t, uint64_t); 1296ff6d951SJohn Birrell extern int dt_print_mod(dtrace_hdl_t *, FILE *, const char *, caddr_t); 1306ff6d951SJohn Birrell extern int dt_print_umod(dtrace_hdl_t *, FILE *, const char *, caddr_t); 1316ff6d951SJohn Birrell 132*93f27766SDomagoj Stolfa extern int dt_format_stack(dtrace_hdl_t *, caddr_t, int, int); 133*93f27766SDomagoj Stolfa extern int dt_format_ustack(dtrace_hdl_t *, caddr_t, uint64_t); 134*93f27766SDomagoj Stolfa extern int dt_format_mod(dtrace_hdl_t *, caddr_t); 135*93f27766SDomagoj Stolfa extern int dt_format_umod(dtrace_hdl_t *, caddr_t); 136*93f27766SDomagoj Stolfa 1376ff6d951SJohn Birrell #ifdef __cplusplus 1386ff6d951SJohn Birrell } 1396ff6d951SJohn Birrell #endif 1406ff6d951SJohn Birrell 1416ff6d951SJohn Birrell #endif /* _DT_PRINTF_H */ 142