Path: blob/main/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.h
39562 views
/*1* CDDL HEADER START2*3* The contents of this file are subject to the terms of the4* Common Development and Distribution License, Version 1.0 only5* (the "License"). You may not use this file except in compliance6* with the License.7*8* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE9* or http://www.opensolaris.org/os/licensing.10* See the License for the specific language governing permissions11* and limitations under the License.12*13* When distributing Covered Code, include this CDDL HEADER in each14* file and include the License file at usr/src/OPENSOLARIS.LICENSE.15* If applicable, add the following below this CDDL HEADER, with the16* fields enclosed by brackets "[]" replaced with your own identifying17* information: Portions Copyright [yyyy] [name of copyright owner]18*19* CDDL HEADER END20*/21/*22* Copyright 2005 Sun Microsystems, Inc. All rights reserved.23* Copyright 2023 Domagoj Stolfa. All rights reserved.24* Use is subject to license terms.25*/2627#ifndef _DT_PRINTF_H28#define _DT_PRINTF_H2930#pragma ident "%Z%%M% %I% %E% SMI"3132#include <sys/types.h>33#include <libctf.h>34#include <dtrace.h>35#include <stdio.h>3637#ifdef __cplusplus38extern "C" {39#endif4041struct dt_node;42struct dt_ident;4344struct dt_pfconv;45struct dt_pfargv;46struct dt_pfargd;4748typedef int dt_pfcheck_f(struct dt_pfargv *,49struct dt_pfargd *, struct dt_node *);50typedef int dt_pfprint_f(dtrace_hdl_t *, FILE *, const char *,51const struct dt_pfargd *, const void *, size_t, uint64_t);5253typedef struct dt_pfconv {54const char *pfc_name; /* string name of input conversion */55const char *pfc_ofmt; /* string name of output conversion */56const char *pfc_tstr; /* string name for conversion type */57dt_pfcheck_f *pfc_check; /* function to use for type checking */58dt_pfprint_f *pfc_print; /* function to use for formatting */59ctf_file_t *pfc_cctfp; /* CTF container for "C" defn of type */60ctf_id_t pfc_ctype; /* CTF type ID for "C" defn of type */61ctf_file_t *pfc_dctfp; /* CTF container for "D" defn of type */62ctf_id_t pfc_dtype; /* CTF type ID for "D" defn of type */63struct dt_pfconv *pfc_next; /* next conversion in hash chain */64} dt_pfconv_t;6566typedef struct dt_pfdict {67dt_pfconv_t **pdi_buckets; /* hash bucket array */68uint_t pdi_nbuckets; /* size of hash bucket array */69} dt_pfdict_t;7071typedef struct dt_pfargd {72const char *pfd_prefix; /* prefix string pointer (or NULL) */73size_t pfd_preflen; /* length of prefix in bytes */74char pfd_fmt[8]; /* output format name to use */75uint_t pfd_flags; /* format flags (see below) */76int pfd_width; /* field width (or 0) */77int pfd_dynwidth; /* dynamic field width (or 0) */78int pfd_prec; /* field precision (or 0) */79const dt_pfconv_t *pfd_conv; /* conversion specification */80const dtrace_recdesc_t *pfd_rec; /* pointer to current record */81struct dt_pfargd *pfd_next; /* pointer to next arg descriptor */82} dt_pfargd_t;8384#define DT_PFCONV_ALT 0x0001 /* alternate print format (%#) */85#define DT_PFCONV_ZPAD 0x0002 /* zero-pad integer field (%0) */86#define DT_PFCONV_LEFT 0x0004 /* left-align field (%-) */87#define DT_PFCONV_SPOS 0x0008 /* sign positive values (%+) */88#define DT_PFCONV_DYNWIDTH 0x0010 /* dynamic width (%*.) */89#define DT_PFCONV_DYNPREC 0x0020 /* dynamic precision (%.*) */90#define DT_PFCONV_GROUP 0x0040 /* group thousands (%') */91#define DT_PFCONV_SPACE 0x0080 /* insert leading space (% ) */92#define DT_PFCONV_AGG 0x0100 /* use aggregation result (%@) */93#define DT_PFCONV_SIGNED 0x0200 /* arg is a signed integer */9495typedef struct dt_pfargv {96dtrace_hdl_t *pfv_dtp; /* libdtrace client handle */97char *pfv_format; /* format string pointer */98dt_pfargd_t *pfv_argv; /* list of argument descriptors */99uint_t pfv_argc; /* number of argument descriptors */100uint_t pfv_flags; /* flags used for validation */101} dt_pfargv_t;102103typedef struct dt_pfwalk {104const dt_pfargv_t *pfw_argv; /* argument description list */105uint_t pfw_aid; /* aggregation variable identifier */106FILE *pfw_fp; /* file pointer to use for output */107int pfw_err; /* error status code */108} dt_pfwalk_t;109110extern int dt_pfdict_create(dtrace_hdl_t *);111extern void dt_pfdict_destroy(dtrace_hdl_t *);112113extern dt_pfargv_t *dt_printf_create(dtrace_hdl_t *, const char *);114extern void dt_printf_destroy(dt_pfargv_t *);115116#define DT_PRINTF_EXACTLEN 0x1 /* do not permit extra arguments */117#define DT_PRINTF_AGGREGATION 0x2 /* enable aggregation conversion */118119extern void dt_printf_validate(dt_pfargv_t *, uint_t,120struct dt_ident *, int, dtrace_actkind_t, struct dt_node *);121122extern void dt_printa_validate(struct dt_node *, struct dt_node *);123124extern int dt_print_stack(dtrace_hdl_t *, FILE *,125const char *, caddr_t, int, int);126extern int dt_print_ustack(dtrace_hdl_t *, FILE *,127const char *, caddr_t, uint64_t);128extern int dt_print_mod(dtrace_hdl_t *, FILE *, const char *, caddr_t);129extern int dt_print_umod(dtrace_hdl_t *, FILE *, const char *, caddr_t);130131extern int dt_format_stack(dtrace_hdl_t *, caddr_t, int, int);132extern int dt_format_ustack(dtrace_hdl_t *, caddr_t, uint64_t);133extern int dt_format_mod(dtrace_hdl_t *, caddr_t);134extern int dt_format_umod(dtrace_hdl_t *, caddr_t);135136#ifdef __cplusplus137}138#endif139140#endif /* _DT_PRINTF_H */141142143