1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22/* 23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27/* 28 * Copyright (c) 2013, Joyent, Inc. All rights reserved. 29 * Copyright (c) 2012 by Delphix. All rights reserved. 30 */ 31 32#ifndef _DT_IMPL_H 33#define _DT_IMPL_H 34 35#include <sys/param.h> 36#include <sys/objfs.h> 37#if !defined(sun) 38#include <sys/bitmap.h> 39#include <sys/utsname.h> 40#include <sys/ioccom.h> 41#include <sys/time.h> 42#include <string.h> 43#endif 44#include <setjmp.h> 45#include <libctf.h> 46#include <dtrace.h> 47#include <gelf.h> 48#if defined(sun) 49#include <synch.h> 50#endif 51 52#ifdef __cplusplus 53extern "C" { 54#endif 55 56#include <dt_parser.h> 57#include <dt_regset.h> 58#include <dt_inttab.h> 59#include <dt_strtab.h> 60#include <dt_ident.h> 61#include <dt_list.h> 62#include <dt_decl.h> 63#include <dt_as.h> 64#include <dt_proc.h> 65#include <dt_dof.h> 66#include <dt_pcb.h> 67#include <dt_pq.h> 68 69struct dt_module; /* see below */ 70struct dt_pfdict; /* see <dt_printf.h> */ 71struct dt_arg; /* see below */ 72struct dt_provider; /* see <dt_provider.h> */ 73struct dt_xlator; /* see <dt_xlator.h> */ 74 75typedef struct dt_intrinsic { 76 const char *din_name; /* string name of the intrinsic type */ 77 ctf_encoding_t din_data; /* integer or floating-point CTF encoding */ 78 uint_t din_kind; /* CTF type kind to instantiate */ 79} dt_intrinsic_t; 80 81typedef struct dt_typedef { 82 const char *dty_src; /* string name of typedef source type */ 83 const char *dty_dst; /* string name of typedef destination type */ 84} dt_typedef_t; 85 86typedef struct dt_intdesc { 87 const char *did_name; /* string name of the integer type */ 88 ctf_file_t *did_ctfp; /* CTF container for this type reference */ 89 ctf_id_t did_type; /* CTF type reference for this type */ 90 uintmax_t did_limit; /* maximum positive value held by type */ 91} dt_intdesc_t; 92 93typedef struct dt_modops { 94 uint_t (*do_syminit)(struct dt_module *); 95 void (*do_symsort)(struct dt_module *); 96 GElf_Sym *(*do_symname)(struct dt_module *, 97 const char *, GElf_Sym *, uint_t *); 98 GElf_Sym *(*do_symaddr)(struct dt_module *, 99 GElf_Addr, GElf_Sym *, uint_t *); 100} dt_modops_t; 101 102typedef struct dt_arg { 103 int da_ndx; /* index of this argument */ 104 int da_mapping; /* mapping of argument indices to arguments */ 105 ctf_id_t da_type; /* type of argument */ 106 ctf_file_t *da_ctfp; /* CTF container for type */ 107 dt_ident_t *da_xlator; /* translator, if any */ 108 struct dt_arg *da_next; /* next argument */ 109} dt_arg_t; 110 111typedef struct dt_sym { 112 uint_t ds_symid; /* id of corresponding symbol */ 113 uint_t ds_next; /* index of next element in hash chain */ 114} dt_sym_t; 115 116typedef struct dt_module { 117 dt_list_t dm_list; /* list forward/back pointers */ 118 char dm_name[DTRACE_MODNAMELEN]; /* string name of module */ 119 char dm_file[MAXPATHLEN]; /* file path of module (if any) */ 120 struct dt_module *dm_next; /* pointer to next module in hash chain */ 121 const dt_modops_t *dm_ops; /* pointer to data model's ops vector */ 122 Elf *dm_elf; /* libelf handle for module object */ 123 objfs_info_t dm_info; /* object filesystem private info */ 124 ctf_sect_t dm_symtab; /* symbol table for module */ 125 ctf_sect_t dm_strtab; /* string table for module */ 126 ctf_sect_t dm_ctdata; /* CTF data for module */ 127 ctf_file_t *dm_ctfp; /* CTF container handle */ 128 uint_t *dm_symbuckets; /* symbol table hash buckets (chain indices) */ 129 dt_sym_t *dm_symchains; /* symbol table hash chains buffer */ 130 void *dm_asmap; /* symbol pointers sorted by value */ 131 uint_t dm_symfree; /* index of next free hash element */ 132 uint_t dm_nsymbuckets; /* number of elements in bucket array */ 133 uint_t dm_nsymelems; /* number of elements in hash table */ 134 uint_t dm_asrsv; /* actual reserved size of dm_asmap */ 135 uint_t dm_aslen; /* number of entries in dm_asmap */ 136 uint_t dm_flags; /* module flags (see below) */ 137 int dm_modid; /* modinfo(1M) module identifier */ 138 GElf_Addr dm_text_va; /* virtual address of text section */ 139 GElf_Xword dm_text_size; /* size in bytes of text section */ 140 GElf_Addr dm_data_va; /* virtual address of data section */ 141 GElf_Xword dm_data_size; /* size in bytes of data section */ 142 GElf_Addr dm_bss_va; /* virtual address of BSS */ 143 GElf_Xword dm_bss_size; /* size in bytes of BSS */ 144 dt_idhash_t *dm_extern; /* external symbol definitions */ 145#if !defined(sun) 146 caddr_t dm_reloc_offset; /* Symbol relocation offset. */ 147 uintptr_t *dm_sec_offsets; 148#endif
| 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22/* 23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27/* 28 * Copyright (c) 2013, Joyent, Inc. All rights reserved. 29 * Copyright (c) 2012 by Delphix. All rights reserved. 30 */ 31 32#ifndef _DT_IMPL_H 33#define _DT_IMPL_H 34 35#include <sys/param.h> 36#include <sys/objfs.h> 37#if !defined(sun) 38#include <sys/bitmap.h> 39#include <sys/utsname.h> 40#include <sys/ioccom.h> 41#include <sys/time.h> 42#include <string.h> 43#endif 44#include <setjmp.h> 45#include <libctf.h> 46#include <dtrace.h> 47#include <gelf.h> 48#if defined(sun) 49#include <synch.h> 50#endif 51 52#ifdef __cplusplus 53extern "C" { 54#endif 55 56#include <dt_parser.h> 57#include <dt_regset.h> 58#include <dt_inttab.h> 59#include <dt_strtab.h> 60#include <dt_ident.h> 61#include <dt_list.h> 62#include <dt_decl.h> 63#include <dt_as.h> 64#include <dt_proc.h> 65#include <dt_dof.h> 66#include <dt_pcb.h> 67#include <dt_pq.h> 68 69struct dt_module; /* see below */ 70struct dt_pfdict; /* see <dt_printf.h> */ 71struct dt_arg; /* see below */ 72struct dt_provider; /* see <dt_provider.h> */ 73struct dt_xlator; /* see <dt_xlator.h> */ 74 75typedef struct dt_intrinsic { 76 const char *din_name; /* string name of the intrinsic type */ 77 ctf_encoding_t din_data; /* integer or floating-point CTF encoding */ 78 uint_t din_kind; /* CTF type kind to instantiate */ 79} dt_intrinsic_t; 80 81typedef struct dt_typedef { 82 const char *dty_src; /* string name of typedef source type */ 83 const char *dty_dst; /* string name of typedef destination type */ 84} dt_typedef_t; 85 86typedef struct dt_intdesc { 87 const char *did_name; /* string name of the integer type */ 88 ctf_file_t *did_ctfp; /* CTF container for this type reference */ 89 ctf_id_t did_type; /* CTF type reference for this type */ 90 uintmax_t did_limit; /* maximum positive value held by type */ 91} dt_intdesc_t; 92 93typedef struct dt_modops { 94 uint_t (*do_syminit)(struct dt_module *); 95 void (*do_symsort)(struct dt_module *); 96 GElf_Sym *(*do_symname)(struct dt_module *, 97 const char *, GElf_Sym *, uint_t *); 98 GElf_Sym *(*do_symaddr)(struct dt_module *, 99 GElf_Addr, GElf_Sym *, uint_t *); 100} dt_modops_t; 101 102typedef struct dt_arg { 103 int da_ndx; /* index of this argument */ 104 int da_mapping; /* mapping of argument indices to arguments */ 105 ctf_id_t da_type; /* type of argument */ 106 ctf_file_t *da_ctfp; /* CTF container for type */ 107 dt_ident_t *da_xlator; /* translator, if any */ 108 struct dt_arg *da_next; /* next argument */ 109} dt_arg_t; 110 111typedef struct dt_sym { 112 uint_t ds_symid; /* id of corresponding symbol */ 113 uint_t ds_next; /* index of next element in hash chain */ 114} dt_sym_t; 115 116typedef struct dt_module { 117 dt_list_t dm_list; /* list forward/back pointers */ 118 char dm_name[DTRACE_MODNAMELEN]; /* string name of module */ 119 char dm_file[MAXPATHLEN]; /* file path of module (if any) */ 120 struct dt_module *dm_next; /* pointer to next module in hash chain */ 121 const dt_modops_t *dm_ops; /* pointer to data model's ops vector */ 122 Elf *dm_elf; /* libelf handle for module object */ 123 objfs_info_t dm_info; /* object filesystem private info */ 124 ctf_sect_t dm_symtab; /* symbol table for module */ 125 ctf_sect_t dm_strtab; /* string table for module */ 126 ctf_sect_t dm_ctdata; /* CTF data for module */ 127 ctf_file_t *dm_ctfp; /* CTF container handle */ 128 uint_t *dm_symbuckets; /* symbol table hash buckets (chain indices) */ 129 dt_sym_t *dm_symchains; /* symbol table hash chains buffer */ 130 void *dm_asmap; /* symbol pointers sorted by value */ 131 uint_t dm_symfree; /* index of next free hash element */ 132 uint_t dm_nsymbuckets; /* number of elements in bucket array */ 133 uint_t dm_nsymelems; /* number of elements in hash table */ 134 uint_t dm_asrsv; /* actual reserved size of dm_asmap */ 135 uint_t dm_aslen; /* number of entries in dm_asmap */ 136 uint_t dm_flags; /* module flags (see below) */ 137 int dm_modid; /* modinfo(1M) module identifier */ 138 GElf_Addr dm_text_va; /* virtual address of text section */ 139 GElf_Xword dm_text_size; /* size in bytes of text section */ 140 GElf_Addr dm_data_va; /* virtual address of data section */ 141 GElf_Xword dm_data_size; /* size in bytes of data section */ 142 GElf_Addr dm_bss_va; /* virtual address of BSS */ 143 GElf_Xword dm_bss_size; /* size in bytes of BSS */ 144 dt_idhash_t *dm_extern; /* external symbol definitions */ 145#if !defined(sun) 146 caddr_t dm_reloc_offset; /* Symbol relocation offset. */ 147 uintptr_t *dm_sec_offsets; 148#endif
|
| 149 pid_t dm_pid; /* pid for this module */ 150 uint_t dm_nctflibs; /* number of ctf children libraries */ 151 ctf_file_t **dm_libctfp; /* process library ctf pointers */ 152 char **dm_libctfn; /* names of process ctf containers */
|
149} dt_module_t; 150 151#define DT_DM_LOADED 0x1 /* module symbol and type data is loaded */ 152#define DT_DM_KERNEL 0x2 /* module is associated with a kernel object */ 153#define DT_DM_PRIMARY 0x4 /* module is a krtld primary kernel object */ 154 155typedef struct dt_provmod { 156 char *dp_name; /* name of provider module */ 157 struct dt_provmod *dp_next; /* next module */ 158} dt_provmod_t; 159 160typedef struct dt_ahashent { 161 struct dt_ahashent *dtahe_prev; /* prev on hash chain */ 162 struct dt_ahashent *dtahe_next; /* next on hash chain */ 163 struct dt_ahashent *dtahe_prevall; /* prev on list of all */ 164 struct dt_ahashent *dtahe_nextall; /* next on list of all */ 165 uint64_t dtahe_hashval; /* hash value */ 166 size_t dtahe_size; /* size of data */ 167 dtrace_aggdata_t dtahe_data; /* data */ 168 void (*dtahe_aggregate)(int64_t *, int64_t *, size_t); /* function */ 169} dt_ahashent_t; 170 171typedef struct dt_ahash { 172 dt_ahashent_t **dtah_hash; /* hash table */ 173 dt_ahashent_t *dtah_all; /* list of all elements */ 174 size_t dtah_size; /* size of hash table */ 175} dt_ahash_t; 176 177typedef struct dt_aggregate { 178 dtrace_bufdesc_t dtat_buf; /* buf aggregation snapshot */ 179 int dtat_flags; /* aggregate flags */ 180 processorid_t dtat_ncpus; /* number of CPUs in aggregate */ 181 processorid_t *dtat_cpus; /* CPUs in aggregate */ 182 processorid_t dtat_ncpu; /* size of dtat_cpus array */ 183 processorid_t dtat_maxcpu; /* maximum number of CPUs */ 184 dt_ahash_t dtat_hash; /* aggregate hash table */ 185} dt_aggregate_t; 186 187typedef struct dt_print_aggdata { 188 dtrace_hdl_t *dtpa_dtp; /* pointer to libdtrace handle */ 189 dtrace_aggvarid_t dtpa_id; /* aggregation variable of interest */ 190 FILE *dtpa_fp; /* file pointer */ 191 int dtpa_allunprint; /* print only unprinted aggregations */
| 153} dt_module_t; 154 155#define DT_DM_LOADED 0x1 /* module symbol and type data is loaded */ 156#define DT_DM_KERNEL 0x2 /* module is associated with a kernel object */ 157#define DT_DM_PRIMARY 0x4 /* module is a krtld primary kernel object */ 158 159typedef struct dt_provmod { 160 char *dp_name; /* name of provider module */ 161 struct dt_provmod *dp_next; /* next module */ 162} dt_provmod_t; 163 164typedef struct dt_ahashent { 165 struct dt_ahashent *dtahe_prev; /* prev on hash chain */ 166 struct dt_ahashent *dtahe_next; /* next on hash chain */ 167 struct dt_ahashent *dtahe_prevall; /* prev on list of all */ 168 struct dt_ahashent *dtahe_nextall; /* next on list of all */ 169 uint64_t dtahe_hashval; /* hash value */ 170 size_t dtahe_size; /* size of data */ 171 dtrace_aggdata_t dtahe_data; /* data */ 172 void (*dtahe_aggregate)(int64_t *, int64_t *, size_t); /* function */ 173} dt_ahashent_t; 174 175typedef struct dt_ahash { 176 dt_ahashent_t **dtah_hash; /* hash table */ 177 dt_ahashent_t *dtah_all; /* list of all elements */ 178 size_t dtah_size; /* size of hash table */ 179} dt_ahash_t; 180 181typedef struct dt_aggregate { 182 dtrace_bufdesc_t dtat_buf; /* buf aggregation snapshot */ 183 int dtat_flags; /* aggregate flags */ 184 processorid_t dtat_ncpus; /* number of CPUs in aggregate */ 185 processorid_t *dtat_cpus; /* CPUs in aggregate */ 186 processorid_t dtat_ncpu; /* size of dtat_cpus array */ 187 processorid_t dtat_maxcpu; /* maximum number of CPUs */ 188 dt_ahash_t dtat_hash; /* aggregate hash table */ 189} dt_aggregate_t; 190 191typedef struct dt_print_aggdata { 192 dtrace_hdl_t *dtpa_dtp; /* pointer to libdtrace handle */ 193 dtrace_aggvarid_t dtpa_id; /* aggregation variable of interest */ 194 FILE *dtpa_fp; /* file pointer */ 195 int dtpa_allunprint; /* print only unprinted aggregations */
|
| 196 int dtpa_agghist; /* print aggregation as histogram */ 197 int dtpa_agghisthdr; /* aggregation histogram hdr printed */ 198 int dtpa_aggpack; /* pack quantized aggregations */
|
192} dt_print_aggdata_t; 193 194typedef struct dt_dirpath { 195 dt_list_t dir_list; /* linked-list forward/back pointers */ 196 char *dir_path; /* directory pathname */ 197} dt_dirpath_t; 198 199typedef struct dt_lib_depend { 200 dt_list_t dtld_deplist; /* linked-list forward/back pointers */ 201 char *dtld_library; /* library name */ 202 char *dtld_libpath; /* library pathname */ 203 uint_t dtld_finish; /* completion time in tsort for lib */ 204 uint_t dtld_start; /* starting time in tsort for lib */ 205 uint_t dtld_loaded; /* boolean: is this library loaded */ 206 dt_list_t dtld_dependencies; /* linked-list of lib dependencies */ 207 dt_list_t dtld_dependents; /* linked-list of lib dependents */ 208} dt_lib_depend_t; 209 210typedef uint32_t dt_version_t; /* encoded version (see below) */ 211 212struct dtrace_hdl { 213 const dtrace_vector_t *dt_vector; /* library vector, if vectored open */ 214 void *dt_varg; /* vector argument, if vectored open */ 215 dtrace_conf_t dt_conf; /* DTrace driver configuration profile */ 216 char dt_errmsg[BUFSIZ]; /* buffer for formatted syntax error msgs */ 217 const char *dt_errtag; /* tag used with last call to dt_set_errmsg() */ 218 dt_pcb_t *dt_pcb; /* pointer to current parsing control block */ 219 ulong_t dt_gen; /* compiler generation number */ 220 dt_list_t dt_programs; /* linked list of dtrace_prog_t's */ 221 dt_list_t dt_xlators; /* linked list of dt_xlator_t's */ 222 struct dt_xlator **dt_xlatormap; /* dt_xlator_t's indexed by dx_id */ 223 id_t dt_xlatorid; /* next dt_xlator_t id to assign */ 224 dt_ident_t *dt_externs; /* linked list of external symbol identifiers */ 225 dt_idhash_t *dt_macros; /* hash table of macro variable identifiers */ 226 dt_idhash_t *dt_aggs; /* hash table of aggregation identifiers */ 227 dt_idhash_t *dt_globals; /* hash table of global identifiers */ 228 dt_idhash_t *dt_tls; /* hash table of thread-local identifiers */ 229 dt_list_t dt_modlist; /* linked list of dt_module_t's */ 230 dt_module_t **dt_mods; /* hash table of dt_module_t's */ 231 uint_t dt_modbuckets; /* number of module hash buckets */ 232 uint_t dt_nmods; /* number of modules in hash and list */ 233 dt_provmod_t *dt_provmod; /* linked list of provider modules */ 234 dt_module_t *dt_exec; /* pointer to executable module */ 235 dt_module_t *dt_rtld; /* pointer to run-time linker module */ 236 dt_module_t *dt_cdefs; /* pointer to C dynamic type module */ 237 dt_module_t *dt_ddefs; /* pointer to D dynamic type module */ 238 dt_list_t dt_provlist; /* linked list of dt_provider_t's */ 239 struct dt_provider **dt_provs; /* hash table of dt_provider_t's */ 240 uint_t dt_provbuckets; /* number of provider hash buckets */ 241 uint_t dt_nprovs; /* number of providers in hash and list */ 242 dt_proc_hash_t *dt_procs; /* hash table of grabbed process handles */ 243 char **dt_proc_env; /* additional environment variables */ 244 dt_intdesc_t dt_ints[6]; /* cached integer type descriptions */ 245 ctf_id_t dt_type_func; /* cached CTF identifier for function type */ 246 ctf_id_t dt_type_fptr; /* cached CTF identifier for function pointer */ 247 ctf_id_t dt_type_str; /* cached CTF identifier for string type */ 248 ctf_id_t dt_type_dyn; /* cached CTF identifier for <DYN> type */ 249 ctf_id_t dt_type_stack; /* cached CTF identifier for stack type */ 250 ctf_id_t dt_type_symaddr; /* cached CTF identifier for _symaddr type */ 251 ctf_id_t dt_type_usymaddr; /* cached CTF ident. for _usymaddr type */ 252 size_t dt_maxprobe; /* max enabled probe ID */ 253 dtrace_eprobedesc_t **dt_edesc; /* enabled probe descriptions */ 254 dtrace_probedesc_t **dt_pdesc; /* probe descriptions for enabled prbs */ 255 size_t dt_maxagg; /* max aggregation ID */ 256 dtrace_aggdesc_t **dt_aggdesc; /* aggregation descriptions */ 257 int dt_maxformat; /* max format ID */ 258 void **dt_formats; /* pointer to format array */ 259 int dt_maxstrdata; /* max strdata ID */ 260 char **dt_strdata; /* pointer to strdata array */ 261 dt_aggregate_t dt_aggregate; /* aggregate */ 262 dt_pq_t *dt_bufq; /* CPU-specific data queue */ 263 struct dt_pfdict *dt_pfdict; /* dictionary of printf conversions */ 264 dt_version_t dt_vmax; /* optional ceiling on program API binding */ 265 dtrace_attribute_t dt_amin; /* optional floor on program attributes */ 266 char *dt_cpp_path; /* pathname of cpp(1) to invoke if needed */ 267 char **dt_cpp_argv; /* argument vector for exec'ing cpp(1) */ 268 int dt_cpp_argc; /* count of initialized cpp(1) arguments */ 269 int dt_cpp_args; /* size of dt_cpp_argv[] array */ 270 char *dt_ld_path; /* pathname of ld(1) to invoke if needed */ 271 dt_list_t dt_lib_path; /* linked-list forming library search path */ 272 uint_t dt_lazyload; /* boolean: set via -xlazyload */ 273 uint_t dt_droptags; /* boolean: set via -xdroptags */ 274 uint_t dt_active; /* boolean: set once tracing is active */ 275 uint_t dt_stopped; /* boolean: set once tracing is stopped */ 276 processorid_t dt_beganon; /* CPU that executed BEGIN probe (if any) */ 277 processorid_t dt_endedon; /* CPU that executed END probe (if any) */ 278 uint_t dt_oflags; /* dtrace open-time options (see dtrace.h) */ 279 uint_t dt_cflags; /* dtrace compile-time options (see dtrace.h) */ 280 uint_t dt_dflags; /* dtrace link-time options (see dtrace.h) */ 281 uint_t dt_prcmode; /* dtrace process create mode (see dt_proc.h) */ 282 uint_t dt_linkmode; /* dtrace symbol linking mode (see below) */ 283 uint_t dt_linktype; /* dtrace link output file type (see below) */ 284 uint_t dt_xlatemode; /* dtrace translator linking mode (see below) */ 285 uint_t dt_stdcmode; /* dtrace stdc compatibility mode (see below) */
| 199} dt_print_aggdata_t; 200 201typedef struct dt_dirpath { 202 dt_list_t dir_list; /* linked-list forward/back pointers */ 203 char *dir_path; /* directory pathname */ 204} dt_dirpath_t; 205 206typedef struct dt_lib_depend { 207 dt_list_t dtld_deplist; /* linked-list forward/back pointers */ 208 char *dtld_library; /* library name */ 209 char *dtld_libpath; /* library pathname */ 210 uint_t dtld_finish; /* completion time in tsort for lib */ 211 uint_t dtld_start; /* starting time in tsort for lib */ 212 uint_t dtld_loaded; /* boolean: is this library loaded */ 213 dt_list_t dtld_dependencies; /* linked-list of lib dependencies */ 214 dt_list_t dtld_dependents; /* linked-list of lib dependents */ 215} dt_lib_depend_t; 216 217typedef uint32_t dt_version_t; /* encoded version (see below) */ 218 219struct dtrace_hdl { 220 const dtrace_vector_t *dt_vector; /* library vector, if vectored open */ 221 void *dt_varg; /* vector argument, if vectored open */ 222 dtrace_conf_t dt_conf; /* DTrace driver configuration profile */ 223 char dt_errmsg[BUFSIZ]; /* buffer for formatted syntax error msgs */ 224 const char *dt_errtag; /* tag used with last call to dt_set_errmsg() */ 225 dt_pcb_t *dt_pcb; /* pointer to current parsing control block */ 226 ulong_t dt_gen; /* compiler generation number */ 227 dt_list_t dt_programs; /* linked list of dtrace_prog_t's */ 228 dt_list_t dt_xlators; /* linked list of dt_xlator_t's */ 229 struct dt_xlator **dt_xlatormap; /* dt_xlator_t's indexed by dx_id */ 230 id_t dt_xlatorid; /* next dt_xlator_t id to assign */ 231 dt_ident_t *dt_externs; /* linked list of external symbol identifiers */ 232 dt_idhash_t *dt_macros; /* hash table of macro variable identifiers */ 233 dt_idhash_t *dt_aggs; /* hash table of aggregation identifiers */ 234 dt_idhash_t *dt_globals; /* hash table of global identifiers */ 235 dt_idhash_t *dt_tls; /* hash table of thread-local identifiers */ 236 dt_list_t dt_modlist; /* linked list of dt_module_t's */ 237 dt_module_t **dt_mods; /* hash table of dt_module_t's */ 238 uint_t dt_modbuckets; /* number of module hash buckets */ 239 uint_t dt_nmods; /* number of modules in hash and list */ 240 dt_provmod_t *dt_provmod; /* linked list of provider modules */ 241 dt_module_t *dt_exec; /* pointer to executable module */ 242 dt_module_t *dt_rtld; /* pointer to run-time linker module */ 243 dt_module_t *dt_cdefs; /* pointer to C dynamic type module */ 244 dt_module_t *dt_ddefs; /* pointer to D dynamic type module */ 245 dt_list_t dt_provlist; /* linked list of dt_provider_t's */ 246 struct dt_provider **dt_provs; /* hash table of dt_provider_t's */ 247 uint_t dt_provbuckets; /* number of provider hash buckets */ 248 uint_t dt_nprovs; /* number of providers in hash and list */ 249 dt_proc_hash_t *dt_procs; /* hash table of grabbed process handles */ 250 char **dt_proc_env; /* additional environment variables */ 251 dt_intdesc_t dt_ints[6]; /* cached integer type descriptions */ 252 ctf_id_t dt_type_func; /* cached CTF identifier for function type */ 253 ctf_id_t dt_type_fptr; /* cached CTF identifier for function pointer */ 254 ctf_id_t dt_type_str; /* cached CTF identifier for string type */ 255 ctf_id_t dt_type_dyn; /* cached CTF identifier for <DYN> type */ 256 ctf_id_t dt_type_stack; /* cached CTF identifier for stack type */ 257 ctf_id_t dt_type_symaddr; /* cached CTF identifier for _symaddr type */ 258 ctf_id_t dt_type_usymaddr; /* cached CTF ident. for _usymaddr type */ 259 size_t dt_maxprobe; /* max enabled probe ID */ 260 dtrace_eprobedesc_t **dt_edesc; /* enabled probe descriptions */ 261 dtrace_probedesc_t **dt_pdesc; /* probe descriptions for enabled prbs */ 262 size_t dt_maxagg; /* max aggregation ID */ 263 dtrace_aggdesc_t **dt_aggdesc; /* aggregation descriptions */ 264 int dt_maxformat; /* max format ID */ 265 void **dt_formats; /* pointer to format array */ 266 int dt_maxstrdata; /* max strdata ID */ 267 char **dt_strdata; /* pointer to strdata array */ 268 dt_aggregate_t dt_aggregate; /* aggregate */ 269 dt_pq_t *dt_bufq; /* CPU-specific data queue */ 270 struct dt_pfdict *dt_pfdict; /* dictionary of printf conversions */ 271 dt_version_t dt_vmax; /* optional ceiling on program API binding */ 272 dtrace_attribute_t dt_amin; /* optional floor on program attributes */ 273 char *dt_cpp_path; /* pathname of cpp(1) to invoke if needed */ 274 char **dt_cpp_argv; /* argument vector for exec'ing cpp(1) */ 275 int dt_cpp_argc; /* count of initialized cpp(1) arguments */ 276 int dt_cpp_args; /* size of dt_cpp_argv[] array */ 277 char *dt_ld_path; /* pathname of ld(1) to invoke if needed */ 278 dt_list_t dt_lib_path; /* linked-list forming library search path */ 279 uint_t dt_lazyload; /* boolean: set via -xlazyload */ 280 uint_t dt_droptags; /* boolean: set via -xdroptags */ 281 uint_t dt_active; /* boolean: set once tracing is active */ 282 uint_t dt_stopped; /* boolean: set once tracing is stopped */ 283 processorid_t dt_beganon; /* CPU that executed BEGIN probe (if any) */ 284 processorid_t dt_endedon; /* CPU that executed END probe (if any) */ 285 uint_t dt_oflags; /* dtrace open-time options (see dtrace.h) */ 286 uint_t dt_cflags; /* dtrace compile-time options (see dtrace.h) */ 287 uint_t dt_dflags; /* dtrace link-time options (see dtrace.h) */ 288 uint_t dt_prcmode; /* dtrace process create mode (see dt_proc.h) */ 289 uint_t dt_linkmode; /* dtrace symbol linking mode (see below) */ 290 uint_t dt_linktype; /* dtrace link output file type (see below) */ 291 uint_t dt_xlatemode; /* dtrace translator linking mode (see below) */ 292 uint_t dt_stdcmode; /* dtrace stdc compatibility mode (see below) */
|
| 293 uint_t dt_encoding; /* dtrace output encoding (see below) */
|
286 uint_t dt_treedump; /* dtrace tree debug bitmap (see below) */ 287 uint64_t dt_options[DTRACEOPT_MAX]; /* dtrace run-time options */ 288 int dt_version; /* library version requested by client */ 289 int dt_ctferr; /* error resulting from last CTF failure */ 290 int dt_errno; /* error resulting from last failed operation */ 291#if !defined(sun) 292 const char *dt_errfile; 293 int dt_errline; 294#endif 295 int dt_fd; /* file descriptor for dtrace pseudo-device */ 296 int dt_ftfd; /* file descriptor for fasttrap pseudo-device */ 297 int dt_fterr; /* saved errno from failed open of dt_ftfd */ 298 int dt_cdefs_fd; /* file descriptor for C CTF debugging cache */ 299 int dt_ddefs_fd; /* file descriptor for D CTF debugging cache */ 300#if defined(sun) 301 int dt_stdout_fd; /* file descriptor for saved stdout */ 302#else 303 FILE *dt_freopen_fp; /* file pointer for freopened stdout */ 304#endif 305 dtrace_handle_err_f *dt_errhdlr; /* error handler, if any */ 306 void *dt_errarg; /* error handler argument */ 307 dtrace_prog_t *dt_errprog; /* error handler program, if any */ 308 dtrace_handle_drop_f *dt_drophdlr; /* drop handler, if any */ 309 void *dt_droparg; /* drop handler argument */ 310 dtrace_handle_proc_f *dt_prochdlr; /* proc handler, if any */ 311 void *dt_procarg; /* proc handler argument */ 312 dtrace_handle_setopt_f *dt_setopthdlr; /* setopt handler, if any */ 313 void *dt_setoptarg; /* setopt handler argument */ 314 dtrace_status_t dt_status[2]; /* status cache */ 315 int dt_statusgen; /* current status generation */ 316 hrtime_t dt_laststatus; /* last status */ 317 hrtime_t dt_lastswitch; /* last switch of buffer data */ 318 hrtime_t dt_lastagg; /* last snapshot of aggregation data */ 319 char *dt_sprintf_buf; /* buffer for dtrace_sprintf() */ 320 int dt_sprintf_buflen; /* length of dtrace_sprintf() buffer */ 321 const char *dt_filetag; /* default filetag for dt_set_errmsg() */ 322 char *dt_buffered_buf; /* buffer for buffered output */ 323 size_t dt_buffered_offs; /* current offset into buffered buffer */ 324 size_t dt_buffered_size; /* size of buffered buffer */ 325 dtrace_handle_buffered_f *dt_bufhdlr; /* buffered handler, if any */ 326 void *dt_bufarg; /* buffered handler argument */ 327 dt_dof_t dt_dof; /* DOF generation buffers (see dt_dof.c) */ 328 struct utsname dt_uts; /* uname(2) information for system */ 329 dt_list_t dt_lib_dep; /* scratch linked-list of lib dependencies */ 330 dt_list_t dt_lib_dep_sorted; /* dependency sorted library list */ 331 dtrace_flowkind_t dt_flow; /* flow kind */ 332 const char *dt_prefix; /* recommended flow prefix */ 333 int dt_indent; /* recommended flow indent */ 334 dtrace_epid_t dt_last_epid; /* most recently consumed EPID */ 335 uint64_t dt_last_timestamp; /* most recently consumed timestamp */ 336}; 337 338/* 339 * Values for the user arg of the ECB. 340 */ 341#define DT_ECB_DEFAULT 0 342#define DT_ECB_ERROR 1 343 344/* 345 * Values for the dt_linkmode property, which is used by the assembler when 346 * processing external symbol references. User can set using -xlink=<mode>. 347 */ 348#define DT_LINK_KERNEL 0 /* kernel syms static, user syms dynamic */ 349#define DT_LINK_PRIMARY 1 /* primary kernel syms static, others dynamic */ 350#define DT_LINK_DYNAMIC 2 /* all symbols dynamic */ 351#define DT_LINK_STATIC 3 /* all symbols static */ 352 353/* 354 * Values for the dt_linktype property, which is used by dtrace_program_link() 355 * to determine the type of output file that is desired by the client. 356 */ 357#define DT_LTYP_ELF 0 /* produce ELF containing DOF */ 358#define DT_LTYP_DOF 1 /* produce stand-alone DOF */ 359 360/* 361 * Values for the dt_xlatemode property, which is used to determine whether 362 * references to dynamic translators are permitted. Set using -xlate=<mode>. 363 */ 364#define DT_XL_STATIC 0 /* require xlators to be statically defined */ 365#define DT_XL_DYNAMIC 1 /* produce references to dynamic translators */ 366 367/* 368 * Values for the dt_stdcmode property, which is used by the compiler when 369 * running cpp to determine the presence and setting of the __STDC__ macro. 370 */ 371#define DT_STDC_XA 0 /* ISO C + K&R C compat w/o ISO: __STDC__=0 */ 372#define DT_STDC_XC 1 /* Strict ISO C: __STDC__=1 */ 373#define DT_STDC_XS 2 /* K&R C: __STDC__ not defined */ 374#define DT_STDC_XT 3 /* ISO C + K&R C compat with ISO: __STDC__=0 */ 375 376/*
| 294 uint_t dt_treedump; /* dtrace tree debug bitmap (see below) */ 295 uint64_t dt_options[DTRACEOPT_MAX]; /* dtrace run-time options */ 296 int dt_version; /* library version requested by client */ 297 int dt_ctferr; /* error resulting from last CTF failure */ 298 int dt_errno; /* error resulting from last failed operation */ 299#if !defined(sun) 300 const char *dt_errfile; 301 int dt_errline; 302#endif 303 int dt_fd; /* file descriptor for dtrace pseudo-device */ 304 int dt_ftfd; /* file descriptor for fasttrap pseudo-device */ 305 int dt_fterr; /* saved errno from failed open of dt_ftfd */ 306 int dt_cdefs_fd; /* file descriptor for C CTF debugging cache */ 307 int dt_ddefs_fd; /* file descriptor for D CTF debugging cache */ 308#if defined(sun) 309 int dt_stdout_fd; /* file descriptor for saved stdout */ 310#else 311 FILE *dt_freopen_fp; /* file pointer for freopened stdout */ 312#endif 313 dtrace_handle_err_f *dt_errhdlr; /* error handler, if any */ 314 void *dt_errarg; /* error handler argument */ 315 dtrace_prog_t *dt_errprog; /* error handler program, if any */ 316 dtrace_handle_drop_f *dt_drophdlr; /* drop handler, if any */ 317 void *dt_droparg; /* drop handler argument */ 318 dtrace_handle_proc_f *dt_prochdlr; /* proc handler, if any */ 319 void *dt_procarg; /* proc handler argument */ 320 dtrace_handle_setopt_f *dt_setopthdlr; /* setopt handler, if any */ 321 void *dt_setoptarg; /* setopt handler argument */ 322 dtrace_status_t dt_status[2]; /* status cache */ 323 int dt_statusgen; /* current status generation */ 324 hrtime_t dt_laststatus; /* last status */ 325 hrtime_t dt_lastswitch; /* last switch of buffer data */ 326 hrtime_t dt_lastagg; /* last snapshot of aggregation data */ 327 char *dt_sprintf_buf; /* buffer for dtrace_sprintf() */ 328 int dt_sprintf_buflen; /* length of dtrace_sprintf() buffer */ 329 const char *dt_filetag; /* default filetag for dt_set_errmsg() */ 330 char *dt_buffered_buf; /* buffer for buffered output */ 331 size_t dt_buffered_offs; /* current offset into buffered buffer */ 332 size_t dt_buffered_size; /* size of buffered buffer */ 333 dtrace_handle_buffered_f *dt_bufhdlr; /* buffered handler, if any */ 334 void *dt_bufarg; /* buffered handler argument */ 335 dt_dof_t dt_dof; /* DOF generation buffers (see dt_dof.c) */ 336 struct utsname dt_uts; /* uname(2) information for system */ 337 dt_list_t dt_lib_dep; /* scratch linked-list of lib dependencies */ 338 dt_list_t dt_lib_dep_sorted; /* dependency sorted library list */ 339 dtrace_flowkind_t dt_flow; /* flow kind */ 340 const char *dt_prefix; /* recommended flow prefix */ 341 int dt_indent; /* recommended flow indent */ 342 dtrace_epid_t dt_last_epid; /* most recently consumed EPID */ 343 uint64_t dt_last_timestamp; /* most recently consumed timestamp */ 344}; 345 346/* 347 * Values for the user arg of the ECB. 348 */ 349#define DT_ECB_DEFAULT 0 350#define DT_ECB_ERROR 1 351 352/* 353 * Values for the dt_linkmode property, which is used by the assembler when 354 * processing external symbol references. User can set using -xlink=<mode>. 355 */ 356#define DT_LINK_KERNEL 0 /* kernel syms static, user syms dynamic */ 357#define DT_LINK_PRIMARY 1 /* primary kernel syms static, others dynamic */ 358#define DT_LINK_DYNAMIC 2 /* all symbols dynamic */ 359#define DT_LINK_STATIC 3 /* all symbols static */ 360 361/* 362 * Values for the dt_linktype property, which is used by dtrace_program_link() 363 * to determine the type of output file that is desired by the client. 364 */ 365#define DT_LTYP_ELF 0 /* produce ELF containing DOF */ 366#define DT_LTYP_DOF 1 /* produce stand-alone DOF */ 367 368/* 369 * Values for the dt_xlatemode property, which is used to determine whether 370 * references to dynamic translators are permitted. Set using -xlate=<mode>. 371 */ 372#define DT_XL_STATIC 0 /* require xlators to be statically defined */ 373#define DT_XL_DYNAMIC 1 /* produce references to dynamic translators */ 374 375/* 376 * Values for the dt_stdcmode property, which is used by the compiler when 377 * running cpp to determine the presence and setting of the __STDC__ macro. 378 */ 379#define DT_STDC_XA 0 /* ISO C + K&R C compat w/o ISO: __STDC__=0 */ 380#define DT_STDC_XC 1 /* Strict ISO C: __STDC__=1 */ 381#define DT_STDC_XS 2 /* K&R C: __STDC__ not defined */ 382#define DT_STDC_XT 3 /* ISO C + K&R C compat with ISO: __STDC__=0 */ 383 384/*
|
| 385 * Values for the dt_encoding property, which is used to force a particular 386 * character encoding (overriding default behavior and/or automatic detection). 387 */ 388#define DT_ENCODING_UNSET 0 389#define DT_ENCODING_ASCII 1 390#define DT_ENCODING_UTF8 2 391 392/*
|
377 * Macro to test whether a given pass bit is set in the dt_treedump bit-vector. 378 * If the bit for pass 'p' is set, the D compiler displays the parse tree for 379 * the program by printing it to stderr at the end of compiler pass 'p'. 380 */ 381#define DT_TREEDUMP_PASS(dtp, p) ((dtp)->dt_treedump & (1 << ((p) - 1))) 382 383/* 384 * Macros for accessing the cached CTF container and type ID for the common 385 * types "int", "string", and <DYN>, which we need to use frequently in the D 386 * compiler. The DT_INT_* macro relies upon "int" being at index 0 in the 387 * _dtrace_ints_* tables in dt_open.c; the others are also set up there. 388 */ 389#define DT_INT_CTFP(dtp) ((dtp)->dt_ints[0].did_ctfp) 390#define DT_INT_TYPE(dtp) ((dtp)->dt_ints[0].did_type) 391 392#define DT_FUNC_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp) 393#define DT_FUNC_TYPE(dtp) ((dtp)->dt_type_func) 394 395#define DT_FPTR_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp) 396#define DT_FPTR_TYPE(dtp) ((dtp)->dt_type_fptr) 397 398#define DT_STR_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp) 399#define DT_STR_TYPE(dtp) ((dtp)->dt_type_str) 400 401#define DT_DYN_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp) 402#define DT_DYN_TYPE(dtp) ((dtp)->dt_type_dyn) 403 404#define DT_STACK_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp) 405#define DT_STACK_TYPE(dtp) ((dtp)->dt_type_stack) 406 407#define DT_SYMADDR_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp) 408#define DT_SYMADDR_TYPE(dtp) ((dtp)->dt_type_symaddr) 409 410#define DT_USYMADDR_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp) 411#define DT_USYMADDR_TYPE(dtp) ((dtp)->dt_type_usymaddr) 412 413/* 414 * Actions and subroutines are both DT_NODE_FUNC nodes; to avoid confusing 415 * an action for a subroutine (or vice versa), we assure that the DT_ACT_* 416 * constants and the DIF_SUBR_* constants occupy non-overlapping ranges by 417 * starting the DT_ACT_* constants at DIF_SUBR_MAX + 1. 418 */ 419#define DT_ACT_BASE DIF_SUBR_MAX + 1 420#define DT_ACT(n) (DT_ACT_BASE + (n)) 421 422#define DT_ACT_PRINTF DT_ACT(0) /* printf() action */ 423#define DT_ACT_TRACE DT_ACT(1) /* trace() action */ 424#define DT_ACT_TRACEMEM DT_ACT(2) /* tracemem() action */ 425#define DT_ACT_STACK DT_ACT(3) /* stack() action */ 426#define DT_ACT_STOP DT_ACT(4) /* stop() action */ 427#define DT_ACT_BREAKPOINT DT_ACT(5) /* breakpoint() action */ 428#define DT_ACT_PANIC DT_ACT(6) /* panic() action */ 429#define DT_ACT_SPECULATE DT_ACT(7) /* speculate() action */ 430#define DT_ACT_COMMIT DT_ACT(8) /* commit() action */ 431#define DT_ACT_DISCARD DT_ACT(9) /* discard() action */ 432#define DT_ACT_CHILL DT_ACT(10) /* chill() action */ 433#define DT_ACT_EXIT DT_ACT(11) /* exit() action */ 434#define DT_ACT_USTACK DT_ACT(12) /* ustack() action */ 435#define DT_ACT_PRINTA DT_ACT(13) /* printa() action */ 436#define DT_ACT_RAISE DT_ACT(14) /* raise() action */ 437#define DT_ACT_CLEAR DT_ACT(15) /* clear() action */ 438#define DT_ACT_NORMALIZE DT_ACT(16) /* normalize() action */ 439#define DT_ACT_DENORMALIZE DT_ACT(17) /* denormalize() action */ 440#define DT_ACT_TRUNC DT_ACT(18) /* trunc() action */ 441#define DT_ACT_SYSTEM DT_ACT(19) /* system() action */ 442#define DT_ACT_JSTACK DT_ACT(20) /* jstack() action */ 443#define DT_ACT_FTRUNCATE DT_ACT(21) /* ftruncate() action */ 444#define DT_ACT_FREOPEN DT_ACT(22) /* freopen() action */ 445#define DT_ACT_SYM DT_ACT(23) /* sym()/func() actions */ 446#define DT_ACT_MOD DT_ACT(24) /* mod() action */ 447#define DT_ACT_USYM DT_ACT(25) /* usym()/ufunc() actions */ 448#define DT_ACT_UMOD DT_ACT(26) /* umod() action */ 449#define DT_ACT_UADDR DT_ACT(27) /* uaddr() action */ 450#define DT_ACT_SETOPT DT_ACT(28) /* setopt() action */ 451#define DT_ACT_PRINT DT_ACT(29) /* print() action */ 452#define DT_ACT_PRINTM DT_ACT(30) /* printm() action */ 453#define DT_ACT_PRINTT DT_ACT(31) /* printt() action */ 454 455/* 456 * Sentinel to tell freopen() to restore the saved stdout. This must not 457 * be ever valid for opening for write access via freopen(3C), which of 458 * course, "." never is. 459 */ 460#define DT_FREOPEN_RESTORE "." 461 462#define EDT_BASE 1000 /* base value for libdtrace errnos */ 463 464enum { 465 EDT_VERSION = EDT_BASE, /* client is requesting unsupported version */ 466 EDT_VERSINVAL, /* version string is invalid or overflows */ 467 EDT_VERSUNDEF, /* requested API version is not defined */ 468 EDT_VERSREDUCED, /* requested API version has been reduced */ 469 EDT_CTF, /* libctf called failed (dt_ctferr has more) */ 470 EDT_COMPILER, /* error in D program compilation */ 471 EDT_NOTUPREG, /* tuple register allocation failure */ 472 EDT_NOMEM, /* memory allocation failure */ 473 EDT_INT2BIG, /* integer limit exceeded */ 474 EDT_STR2BIG, /* string limit exceeded */ 475 EDT_NOMOD, /* unknown module name */ 476 EDT_NOPROV, /* unknown provider name */ 477 EDT_NOPROBE, /* unknown probe name */ 478 EDT_NOSYM, /* unknown symbol name */ 479 EDT_NOSYMADDR, /* no symbol corresponds to address */ 480 EDT_NOTYPE, /* unknown type name */ 481 EDT_NOVAR, /* unknown variable name */ 482 EDT_NOAGG, /* unknown aggregation name */ 483 EDT_BADSCOPE, /* improper use of type name scoping operator */ 484 EDT_BADSPEC, /* overspecified probe description */ 485 EDT_BADSPCV, /* bad macro variable in probe description */ 486 EDT_BADID, /* invalid probe identifier */ 487 EDT_NOTLOADED, /* module is not currently loaded */ 488 EDT_NOCTF, /* module does not contain any CTF data */ 489 EDT_DATAMODEL, /* module and program data models don't match */ 490 EDT_DIFVERS, /* library has newer DIF version than driver */ 491 EDT_BADAGG, /* unrecognized aggregating action */ 492 EDT_FIO, /* file i/o error */ 493 EDT_DIFINVAL, /* invalid DIF program */ 494 EDT_DIFSIZE, /* invalid DIF size */ 495 EDT_DIFFAULT, /* failed to copyin DIF program */ 496 EDT_BADPROBE, /* bad probe description */ 497 EDT_BADPGLOB, /* bad probe description globbing pattern */ 498 EDT_NOSCOPE, /* declaration scope stack underflow */ 499 EDT_NODECL, /* declaration stack underflow */ 500 EDT_DMISMATCH, /* record list does not match statement */ 501 EDT_DOFFSET, /* record data offset error */ 502 EDT_DALIGN, /* record data alignment error */ 503 EDT_BADOPTNAME, /* invalid dtrace_setopt option name */ 504 EDT_BADOPTVAL, /* invalid dtrace_setopt option value */ 505 EDT_BADOPTCTX, /* invalid dtrace_setopt option context */ 506 EDT_CPPFORK, /* failed to fork preprocessor */ 507 EDT_CPPEXEC, /* failed to exec preprocessor */ 508 EDT_CPPENT, /* preprocessor not found */ 509 EDT_CPPERR, /* unknown preprocessor error */ 510 EDT_SYMOFLOW, /* external symbol table overflow */ 511 EDT_ACTIVE, /* operation illegal when tracing is active */ 512 EDT_DESTRUCTIVE, /* destructive actions not allowed */ 513 EDT_NOANON, /* no anonymous tracing state */ 514 EDT_ISANON, /* can't claim anon state and enable probes */ 515 EDT_ENDTOOBIG, /* END enablings exceed size of prncpl buffer */ 516 EDT_NOCONV, /* failed to load type for printf conversion */ 517 EDT_BADCONV, /* incomplete printf conversion */ 518 EDT_BADERROR, /* invalid library ERROR action */ 519 EDT_ERRABORT, /* abort due to error */ 520 EDT_DROPABORT, /* abort due to drop */ 521 EDT_DIRABORT, /* abort explicitly directed */ 522 EDT_BADRVAL, /* invalid return value from callback */ 523 EDT_BADNORMAL, /* invalid normalization */ 524 EDT_BUFTOOSMALL, /* enabling exceeds size of buffer */ 525 EDT_BADTRUNC, /* invalid truncation */ 526 EDT_BUSY, /* device busy (active kernel debugger) */ 527 EDT_ACCESS, /* insufficient privileges to use DTrace */ 528 EDT_NOENT, /* dtrace device not available */ 529 EDT_BRICKED, /* abort due to systemic unresponsiveness */ 530 EDT_HARDWIRE, /* failed to load hard-wired definitions */ 531 EDT_ELFVERSION, /* libelf is out-of-date w.r.t libdtrace */ 532 EDT_NOBUFFERED, /* attempt to buffer output without handler */ 533 EDT_UNSTABLE, /* description matched unstable set of probes */ 534 EDT_BADSETOPT, /* invalid setopt library action */ 535 EDT_BADSTACKPC, /* invalid stack program counter size */ 536 EDT_BADAGGVAR, /* invalid aggregation variable identifier */ 537 EDT_OVERSION, /* client is requesting deprecated version */ 538 EDT_ENABLING_ERR, /* failed to enable probe */
| 393 * Macro to test whether a given pass bit is set in the dt_treedump bit-vector. 394 * If the bit for pass 'p' is set, the D compiler displays the parse tree for 395 * the program by printing it to stderr at the end of compiler pass 'p'. 396 */ 397#define DT_TREEDUMP_PASS(dtp, p) ((dtp)->dt_treedump & (1 << ((p) - 1))) 398 399/* 400 * Macros for accessing the cached CTF container and type ID for the common 401 * types "int", "string", and <DYN>, which we need to use frequently in the D 402 * compiler. The DT_INT_* macro relies upon "int" being at index 0 in the 403 * _dtrace_ints_* tables in dt_open.c; the others are also set up there. 404 */ 405#define DT_INT_CTFP(dtp) ((dtp)->dt_ints[0].did_ctfp) 406#define DT_INT_TYPE(dtp) ((dtp)->dt_ints[0].did_type) 407 408#define DT_FUNC_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp) 409#define DT_FUNC_TYPE(dtp) ((dtp)->dt_type_func) 410 411#define DT_FPTR_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp) 412#define DT_FPTR_TYPE(dtp) ((dtp)->dt_type_fptr) 413 414#define DT_STR_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp) 415#define DT_STR_TYPE(dtp) ((dtp)->dt_type_str) 416 417#define DT_DYN_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp) 418#define DT_DYN_TYPE(dtp) ((dtp)->dt_type_dyn) 419 420#define DT_STACK_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp) 421#define DT_STACK_TYPE(dtp) ((dtp)->dt_type_stack) 422 423#define DT_SYMADDR_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp) 424#define DT_SYMADDR_TYPE(dtp) ((dtp)->dt_type_symaddr) 425 426#define DT_USYMADDR_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp) 427#define DT_USYMADDR_TYPE(dtp) ((dtp)->dt_type_usymaddr) 428 429/* 430 * Actions and subroutines are both DT_NODE_FUNC nodes; to avoid confusing 431 * an action for a subroutine (or vice versa), we assure that the DT_ACT_* 432 * constants and the DIF_SUBR_* constants occupy non-overlapping ranges by 433 * starting the DT_ACT_* constants at DIF_SUBR_MAX + 1. 434 */ 435#define DT_ACT_BASE DIF_SUBR_MAX + 1 436#define DT_ACT(n) (DT_ACT_BASE + (n)) 437 438#define DT_ACT_PRINTF DT_ACT(0) /* printf() action */ 439#define DT_ACT_TRACE DT_ACT(1) /* trace() action */ 440#define DT_ACT_TRACEMEM DT_ACT(2) /* tracemem() action */ 441#define DT_ACT_STACK DT_ACT(3) /* stack() action */ 442#define DT_ACT_STOP DT_ACT(4) /* stop() action */ 443#define DT_ACT_BREAKPOINT DT_ACT(5) /* breakpoint() action */ 444#define DT_ACT_PANIC DT_ACT(6) /* panic() action */ 445#define DT_ACT_SPECULATE DT_ACT(7) /* speculate() action */ 446#define DT_ACT_COMMIT DT_ACT(8) /* commit() action */ 447#define DT_ACT_DISCARD DT_ACT(9) /* discard() action */ 448#define DT_ACT_CHILL DT_ACT(10) /* chill() action */ 449#define DT_ACT_EXIT DT_ACT(11) /* exit() action */ 450#define DT_ACT_USTACK DT_ACT(12) /* ustack() action */ 451#define DT_ACT_PRINTA DT_ACT(13) /* printa() action */ 452#define DT_ACT_RAISE DT_ACT(14) /* raise() action */ 453#define DT_ACT_CLEAR DT_ACT(15) /* clear() action */ 454#define DT_ACT_NORMALIZE DT_ACT(16) /* normalize() action */ 455#define DT_ACT_DENORMALIZE DT_ACT(17) /* denormalize() action */ 456#define DT_ACT_TRUNC DT_ACT(18) /* trunc() action */ 457#define DT_ACT_SYSTEM DT_ACT(19) /* system() action */ 458#define DT_ACT_JSTACK DT_ACT(20) /* jstack() action */ 459#define DT_ACT_FTRUNCATE DT_ACT(21) /* ftruncate() action */ 460#define DT_ACT_FREOPEN DT_ACT(22) /* freopen() action */ 461#define DT_ACT_SYM DT_ACT(23) /* sym()/func() actions */ 462#define DT_ACT_MOD DT_ACT(24) /* mod() action */ 463#define DT_ACT_USYM DT_ACT(25) /* usym()/ufunc() actions */ 464#define DT_ACT_UMOD DT_ACT(26) /* umod() action */ 465#define DT_ACT_UADDR DT_ACT(27) /* uaddr() action */ 466#define DT_ACT_SETOPT DT_ACT(28) /* setopt() action */ 467#define DT_ACT_PRINT DT_ACT(29) /* print() action */ 468#define DT_ACT_PRINTM DT_ACT(30) /* printm() action */ 469#define DT_ACT_PRINTT DT_ACT(31) /* printt() action */ 470 471/* 472 * Sentinel to tell freopen() to restore the saved stdout. This must not 473 * be ever valid for opening for write access via freopen(3C), which of 474 * course, "." never is. 475 */ 476#define DT_FREOPEN_RESTORE "." 477 478#define EDT_BASE 1000 /* base value for libdtrace errnos */ 479 480enum { 481 EDT_VERSION = EDT_BASE, /* client is requesting unsupported version */ 482 EDT_VERSINVAL, /* version string is invalid or overflows */ 483 EDT_VERSUNDEF, /* requested API version is not defined */ 484 EDT_VERSREDUCED, /* requested API version has been reduced */ 485 EDT_CTF, /* libctf called failed (dt_ctferr has more) */ 486 EDT_COMPILER, /* error in D program compilation */ 487 EDT_NOTUPREG, /* tuple register allocation failure */ 488 EDT_NOMEM, /* memory allocation failure */ 489 EDT_INT2BIG, /* integer limit exceeded */ 490 EDT_STR2BIG, /* string limit exceeded */ 491 EDT_NOMOD, /* unknown module name */ 492 EDT_NOPROV, /* unknown provider name */ 493 EDT_NOPROBE, /* unknown probe name */ 494 EDT_NOSYM, /* unknown symbol name */ 495 EDT_NOSYMADDR, /* no symbol corresponds to address */ 496 EDT_NOTYPE, /* unknown type name */ 497 EDT_NOVAR, /* unknown variable name */ 498 EDT_NOAGG, /* unknown aggregation name */ 499 EDT_BADSCOPE, /* improper use of type name scoping operator */ 500 EDT_BADSPEC, /* overspecified probe description */ 501 EDT_BADSPCV, /* bad macro variable in probe description */ 502 EDT_BADID, /* invalid probe identifier */ 503 EDT_NOTLOADED, /* module is not currently loaded */ 504 EDT_NOCTF, /* module does not contain any CTF data */ 505 EDT_DATAMODEL, /* module and program data models don't match */ 506 EDT_DIFVERS, /* library has newer DIF version than driver */ 507 EDT_BADAGG, /* unrecognized aggregating action */ 508 EDT_FIO, /* file i/o error */ 509 EDT_DIFINVAL, /* invalid DIF program */ 510 EDT_DIFSIZE, /* invalid DIF size */ 511 EDT_DIFFAULT, /* failed to copyin DIF program */ 512 EDT_BADPROBE, /* bad probe description */ 513 EDT_BADPGLOB, /* bad probe description globbing pattern */ 514 EDT_NOSCOPE, /* declaration scope stack underflow */ 515 EDT_NODECL, /* declaration stack underflow */ 516 EDT_DMISMATCH, /* record list does not match statement */ 517 EDT_DOFFSET, /* record data offset error */ 518 EDT_DALIGN, /* record data alignment error */ 519 EDT_BADOPTNAME, /* invalid dtrace_setopt option name */ 520 EDT_BADOPTVAL, /* invalid dtrace_setopt option value */ 521 EDT_BADOPTCTX, /* invalid dtrace_setopt option context */ 522 EDT_CPPFORK, /* failed to fork preprocessor */ 523 EDT_CPPEXEC, /* failed to exec preprocessor */ 524 EDT_CPPENT, /* preprocessor not found */ 525 EDT_CPPERR, /* unknown preprocessor error */ 526 EDT_SYMOFLOW, /* external symbol table overflow */ 527 EDT_ACTIVE, /* operation illegal when tracing is active */ 528 EDT_DESTRUCTIVE, /* destructive actions not allowed */ 529 EDT_NOANON, /* no anonymous tracing state */ 530 EDT_ISANON, /* can't claim anon state and enable probes */ 531 EDT_ENDTOOBIG, /* END enablings exceed size of prncpl buffer */ 532 EDT_NOCONV, /* failed to load type for printf conversion */ 533 EDT_BADCONV, /* incomplete printf conversion */ 534 EDT_BADERROR, /* invalid library ERROR action */ 535 EDT_ERRABORT, /* abort due to error */ 536 EDT_DROPABORT, /* abort due to drop */ 537 EDT_DIRABORT, /* abort explicitly directed */ 538 EDT_BADRVAL, /* invalid return value from callback */ 539 EDT_BADNORMAL, /* invalid normalization */ 540 EDT_BUFTOOSMALL, /* enabling exceeds size of buffer */ 541 EDT_BADTRUNC, /* invalid truncation */ 542 EDT_BUSY, /* device busy (active kernel debugger) */ 543 EDT_ACCESS, /* insufficient privileges to use DTrace */ 544 EDT_NOENT, /* dtrace device not available */ 545 EDT_BRICKED, /* abort due to systemic unresponsiveness */ 546 EDT_HARDWIRE, /* failed to load hard-wired definitions */ 547 EDT_ELFVERSION, /* libelf is out-of-date w.r.t libdtrace */ 548 EDT_NOBUFFERED, /* attempt to buffer output without handler */ 549 EDT_UNSTABLE, /* description matched unstable set of probes */ 550 EDT_BADSETOPT, /* invalid setopt library action */ 551 EDT_BADSTACKPC, /* invalid stack program counter size */ 552 EDT_BADAGGVAR, /* invalid aggregation variable identifier */ 553 EDT_OVERSION, /* client is requesting deprecated version */ 554 EDT_ENABLING_ERR, /* failed to enable probe */
|
539 EDT_NOPROBES /* no probes sites for declared provider */
| 555 EDT_NOPROBES, /* no probes sites for declared provider */ 556 EDT_CANTLOAD /* failed to load a module */
|
540}; 541 542/* 543 * Interfaces for parsing and comparing DTrace attribute tuples, which describe 544 * stability and architectural binding information. The dtrace_attribute_t 545 * structure and associated constant definitions are found in <sys/dtrace.h>. 546 */ 547extern dtrace_attribute_t dt_attr_min(dtrace_attribute_t, dtrace_attribute_t); 548extern dtrace_attribute_t dt_attr_max(dtrace_attribute_t, dtrace_attribute_t); 549extern char *dt_attr_str(dtrace_attribute_t, char *, size_t); 550extern int dt_attr_cmp(dtrace_attribute_t, dtrace_attribute_t); 551 552/* 553 * Interfaces for parsing and handling DTrace version strings. Version binding 554 * is a feature of the D compiler that is handled completely independently of 555 * the DTrace kernel infrastructure, so the definitions are here in libdtrace. 556 * Version strings are compiled into an encoded uint32_t which can be compared 557 * using C comparison operators. Version definitions are found in dt_open.c. 558 */ 559#define DT_VERSION_STRMAX 16 /* enough for "255.4095.4095\0" */ 560#define DT_VERSION_MAJMAX 0xFF /* maximum major version number */ 561#define DT_VERSION_MINMAX 0xFFF /* maximum minor version number */ 562#define DT_VERSION_MICMAX 0xFFF /* maximum micro version number */ 563 564#define DT_VERSION_NUMBER(M, m, u) \ 565 ((((M) & 0xFF) << 24) | (((m) & 0xFFF) << 12) | ((u) & 0xFFF)) 566 567#define DT_VERSION_MAJOR(v) (((v) & 0xFF000000) >> 24) 568#define DT_VERSION_MINOR(v) (((v) & 0x00FFF000) >> 12) 569#define DT_VERSION_MICRO(v) ((v) & 0x00000FFF) 570 571extern char *dt_version_num2str(dt_version_t, char *, size_t); 572extern int dt_version_str2num(const char *, dt_version_t *); 573extern int dt_version_defined(dt_version_t); 574 575/* 576 * Miscellaneous internal libdtrace interfaces. The definitions below are for 577 * libdtrace routines that do not yet merit their own separate header file. 578 */ 579extern char *dt_cpp_add_arg(dtrace_hdl_t *, const char *); 580extern char *dt_cpp_pop_arg(dtrace_hdl_t *); 581 582#if defined(sun) 583extern int dt_set_errno(dtrace_hdl_t *, int); 584#else 585int _dt_set_errno(dtrace_hdl_t *, int, const char *, int); 586void dt_get_errloc(dtrace_hdl_t *, const char **, int *); 587#define dt_set_errno(_a,_b) _dt_set_errno(_a,_b,__FILE__,__LINE__) 588#endif 589extern void dt_set_errmsg(dtrace_hdl_t *, const char *, const char *, 590 const char *, int, const char *, va_list); 591 592#if defined(sun) 593extern int dt_ioctl(dtrace_hdl_t *, int, void *); 594#else 595extern int dt_ioctl(dtrace_hdl_t *, u_long, void *); 596#endif 597extern int dt_status(dtrace_hdl_t *, processorid_t); 598extern long dt_sysconf(dtrace_hdl_t *, int); 599extern ssize_t dt_write(dtrace_hdl_t *, int, const void *, size_t); 600extern int dt_printf(dtrace_hdl_t *, FILE *, const char *, ...); 601 602extern void *dt_zalloc(dtrace_hdl_t *, size_t); 603extern void *dt_alloc(dtrace_hdl_t *, size_t); 604extern void dt_free(dtrace_hdl_t *, void *); 605extern void dt_difo_free(dtrace_hdl_t *, dtrace_difo_t *); 606 607extern int dt_gmatch(const char *, const char *); 608extern char *dt_basename(char *); 609 610extern ulong_t dt_popc(ulong_t); 611extern ulong_t dt_popcb(const ulong_t *, ulong_t); 612 613extern int dt_buffered_enable(dtrace_hdl_t *); 614extern int dt_buffered_flush(dtrace_hdl_t *, dtrace_probedata_t *, 615 const dtrace_recdesc_t *, const dtrace_aggdata_t *, uint32_t flags); 616extern void dt_buffered_disable(dtrace_hdl_t *); 617extern void dt_buffered_destroy(dtrace_hdl_t *); 618 619extern uint64_t dt_stddev(uint64_t *, uint64_t); 620 621extern int dt_rw_read_held(pthread_rwlock_t *); 622extern int dt_rw_write_held(pthread_rwlock_t *); 623extern int dt_mutex_held(pthread_mutex_t *); 624extern int dt_options_load(dtrace_hdl_t *); 625 626#define DT_RW_READ_HELD(x) dt_rw_read_held(x) 627#define DT_RW_WRITE_HELD(x) dt_rw_write_held(x) 628#define DT_RW_LOCK_HELD(x) (DT_RW_READ_HELD(x) || DT_RW_WRITE_HELD(x)) 629#define DT_MUTEX_HELD(x) dt_mutex_held(x) 630 631extern void dt_dprintf(const char *, ...); 632 633extern void dt_setcontext(dtrace_hdl_t *, dtrace_probedesc_t *); 634extern void dt_endcontext(dtrace_hdl_t *); 635 636extern void dt_pragma(dt_node_t *); 637extern int dt_reduce(dtrace_hdl_t *, dt_version_t); 638extern void dt_cg(dt_pcb_t *, dt_node_t *); 639extern dtrace_difo_t *dt_as(dt_pcb_t *); 640extern void dt_dis(const dtrace_difo_t *, FILE *); 641 642extern int dt_aggregate_go(dtrace_hdl_t *); 643extern int dt_aggregate_init(dtrace_hdl_t *); 644extern void dt_aggregate_destroy(dtrace_hdl_t *); 645 646extern int dt_epid_lookup(dtrace_hdl_t *, dtrace_epid_t, 647 dtrace_eprobedesc_t **, dtrace_probedesc_t **); 648extern void dt_epid_destroy(dtrace_hdl_t *); 649extern int dt_aggid_lookup(dtrace_hdl_t *, dtrace_aggid_t, dtrace_aggdesc_t **); 650extern void dt_aggid_destroy(dtrace_hdl_t *); 651 652extern void *dt_format_lookup(dtrace_hdl_t *, int); 653extern void dt_format_destroy(dtrace_hdl_t *); 654 655extern const char *dt_strdata_lookup(dtrace_hdl_t *, int); 656extern void dt_strdata_destroy(dtrace_hdl_t *); 657 658extern int dt_print_quantize(dtrace_hdl_t *, FILE *, 659 const void *, size_t, uint64_t); 660extern int dt_print_lquantize(dtrace_hdl_t *, FILE *, 661 const void *, size_t, uint64_t); 662extern int dt_print_llquantize(dtrace_hdl_t *, FILE *, 663 const void *, size_t, uint64_t); 664extern int dt_print_agg(const dtrace_aggdata_t *, void *); 665 666extern int dt_handle(dtrace_hdl_t *, dtrace_probedata_t *); 667extern int dt_handle_liberr(dtrace_hdl_t *, 668 const dtrace_probedata_t *, const char *); 669extern int dt_handle_cpudrop(dtrace_hdl_t *, processorid_t, 670 dtrace_dropkind_t, uint64_t); 671extern int dt_handle_status(dtrace_hdl_t *, 672 dtrace_status_t *, dtrace_status_t *); 673extern int dt_handle_setopt(dtrace_hdl_t *, dtrace_setoptdata_t *); 674 675extern int dt_lib_depend_add(dtrace_hdl_t *, dt_list_t *, const char *); 676extern dt_lib_depend_t *dt_lib_depend_lookup(dt_list_t *, const char *); 677 678extern dt_pcb_t *yypcb; /* pointer to current parser control block */ 679extern char yyintprefix; /* int token prefix for macros (+/-) */ 680extern char yyintsuffix[4]; /* int token suffix ([uUlL]*) */ 681extern int yyintdecimal; /* int token is decimal (1) or octal/hex (0) */ 682extern char yytext[]; /* lex input buffer */ 683extern int yylineno; /* lex line number */ 684extern int yydebug; /* lex debugging */ 685extern dt_node_t *yypragma; /* lex token list for control lines */ 686 687extern const dtrace_attribute_t _dtrace_maxattr; /* maximum attributes */ 688extern const dtrace_attribute_t _dtrace_defattr; /* default attributes */ 689extern const dtrace_attribute_t _dtrace_symattr; /* symbol ref attributes */ 690extern const dtrace_attribute_t _dtrace_typattr; /* type ref attributes */ 691extern const dtrace_attribute_t _dtrace_prvattr; /* provider attributes */ 692extern const dtrace_pattr_t _dtrace_prvdesc; /* provider attribute bundle */ 693 694extern const dt_version_t _dtrace_versions[]; /* array of valid versions */ 695extern const char *const _dtrace_version; /* current version string */ 696 697extern int _dtrace_strbuckets; /* number of hash buckets for strings */ 698extern int _dtrace_intbuckets; /* number of hash buckets for ints */ 699extern uint_t _dtrace_stkindent; /* default indent for stack/ustack */ 700extern uint_t _dtrace_pidbuckets; /* number of hash buckets for pids */ 701extern uint_t _dtrace_pidlrulim; /* number of proc handles to cache */ 702extern int _dtrace_debug; /* debugging messages enabled */ 703extern size_t _dtrace_bufsize; /* default dt_buf_create() size */ 704extern int _dtrace_argmax; /* default maximum probe arguments */ 705 706extern const char *_dtrace_libdir; /* default library directory */ 707extern const char *_dtrace_moddir; /* default kernel module directory */ 708 709#ifdef __cplusplus 710} 711#endif 712 713#endif /* _DT_IMPL_H */
| 557}; 558 559/* 560 * Interfaces for parsing and comparing DTrace attribute tuples, which describe 561 * stability and architectural binding information. The dtrace_attribute_t 562 * structure and associated constant definitions are found in <sys/dtrace.h>. 563 */ 564extern dtrace_attribute_t dt_attr_min(dtrace_attribute_t, dtrace_attribute_t); 565extern dtrace_attribute_t dt_attr_max(dtrace_attribute_t, dtrace_attribute_t); 566extern char *dt_attr_str(dtrace_attribute_t, char *, size_t); 567extern int dt_attr_cmp(dtrace_attribute_t, dtrace_attribute_t); 568 569/* 570 * Interfaces for parsing and handling DTrace version strings. Version binding 571 * is a feature of the D compiler that is handled completely independently of 572 * the DTrace kernel infrastructure, so the definitions are here in libdtrace. 573 * Version strings are compiled into an encoded uint32_t which can be compared 574 * using C comparison operators. Version definitions are found in dt_open.c. 575 */ 576#define DT_VERSION_STRMAX 16 /* enough for "255.4095.4095\0" */ 577#define DT_VERSION_MAJMAX 0xFF /* maximum major version number */ 578#define DT_VERSION_MINMAX 0xFFF /* maximum minor version number */ 579#define DT_VERSION_MICMAX 0xFFF /* maximum micro version number */ 580 581#define DT_VERSION_NUMBER(M, m, u) \ 582 ((((M) & 0xFF) << 24) | (((m) & 0xFFF) << 12) | ((u) & 0xFFF)) 583 584#define DT_VERSION_MAJOR(v) (((v) & 0xFF000000) >> 24) 585#define DT_VERSION_MINOR(v) (((v) & 0x00FFF000) >> 12) 586#define DT_VERSION_MICRO(v) ((v) & 0x00000FFF) 587 588extern char *dt_version_num2str(dt_version_t, char *, size_t); 589extern int dt_version_str2num(const char *, dt_version_t *); 590extern int dt_version_defined(dt_version_t); 591 592/* 593 * Miscellaneous internal libdtrace interfaces. The definitions below are for 594 * libdtrace routines that do not yet merit their own separate header file. 595 */ 596extern char *dt_cpp_add_arg(dtrace_hdl_t *, const char *); 597extern char *dt_cpp_pop_arg(dtrace_hdl_t *); 598 599#if defined(sun) 600extern int dt_set_errno(dtrace_hdl_t *, int); 601#else 602int _dt_set_errno(dtrace_hdl_t *, int, const char *, int); 603void dt_get_errloc(dtrace_hdl_t *, const char **, int *); 604#define dt_set_errno(_a,_b) _dt_set_errno(_a,_b,__FILE__,__LINE__) 605#endif 606extern void dt_set_errmsg(dtrace_hdl_t *, const char *, const char *, 607 const char *, int, const char *, va_list); 608 609#if defined(sun) 610extern int dt_ioctl(dtrace_hdl_t *, int, void *); 611#else 612extern int dt_ioctl(dtrace_hdl_t *, u_long, void *); 613#endif 614extern int dt_status(dtrace_hdl_t *, processorid_t); 615extern long dt_sysconf(dtrace_hdl_t *, int); 616extern ssize_t dt_write(dtrace_hdl_t *, int, const void *, size_t); 617extern int dt_printf(dtrace_hdl_t *, FILE *, const char *, ...); 618 619extern void *dt_zalloc(dtrace_hdl_t *, size_t); 620extern void *dt_alloc(dtrace_hdl_t *, size_t); 621extern void dt_free(dtrace_hdl_t *, void *); 622extern void dt_difo_free(dtrace_hdl_t *, dtrace_difo_t *); 623 624extern int dt_gmatch(const char *, const char *); 625extern char *dt_basename(char *); 626 627extern ulong_t dt_popc(ulong_t); 628extern ulong_t dt_popcb(const ulong_t *, ulong_t); 629 630extern int dt_buffered_enable(dtrace_hdl_t *); 631extern int dt_buffered_flush(dtrace_hdl_t *, dtrace_probedata_t *, 632 const dtrace_recdesc_t *, const dtrace_aggdata_t *, uint32_t flags); 633extern void dt_buffered_disable(dtrace_hdl_t *); 634extern void dt_buffered_destroy(dtrace_hdl_t *); 635 636extern uint64_t dt_stddev(uint64_t *, uint64_t); 637 638extern int dt_rw_read_held(pthread_rwlock_t *); 639extern int dt_rw_write_held(pthread_rwlock_t *); 640extern int dt_mutex_held(pthread_mutex_t *); 641extern int dt_options_load(dtrace_hdl_t *); 642 643#define DT_RW_READ_HELD(x) dt_rw_read_held(x) 644#define DT_RW_WRITE_HELD(x) dt_rw_write_held(x) 645#define DT_RW_LOCK_HELD(x) (DT_RW_READ_HELD(x) || DT_RW_WRITE_HELD(x)) 646#define DT_MUTEX_HELD(x) dt_mutex_held(x) 647 648extern void dt_dprintf(const char *, ...); 649 650extern void dt_setcontext(dtrace_hdl_t *, dtrace_probedesc_t *); 651extern void dt_endcontext(dtrace_hdl_t *); 652 653extern void dt_pragma(dt_node_t *); 654extern int dt_reduce(dtrace_hdl_t *, dt_version_t); 655extern void dt_cg(dt_pcb_t *, dt_node_t *); 656extern dtrace_difo_t *dt_as(dt_pcb_t *); 657extern void dt_dis(const dtrace_difo_t *, FILE *); 658 659extern int dt_aggregate_go(dtrace_hdl_t *); 660extern int dt_aggregate_init(dtrace_hdl_t *); 661extern void dt_aggregate_destroy(dtrace_hdl_t *); 662 663extern int dt_epid_lookup(dtrace_hdl_t *, dtrace_epid_t, 664 dtrace_eprobedesc_t **, dtrace_probedesc_t **); 665extern void dt_epid_destroy(dtrace_hdl_t *); 666extern int dt_aggid_lookup(dtrace_hdl_t *, dtrace_aggid_t, dtrace_aggdesc_t **); 667extern void dt_aggid_destroy(dtrace_hdl_t *); 668 669extern void *dt_format_lookup(dtrace_hdl_t *, int); 670extern void dt_format_destroy(dtrace_hdl_t *); 671 672extern const char *dt_strdata_lookup(dtrace_hdl_t *, int); 673extern void dt_strdata_destroy(dtrace_hdl_t *); 674 675extern int dt_print_quantize(dtrace_hdl_t *, FILE *, 676 const void *, size_t, uint64_t); 677extern int dt_print_lquantize(dtrace_hdl_t *, FILE *, 678 const void *, size_t, uint64_t); 679extern int dt_print_llquantize(dtrace_hdl_t *, FILE *, 680 const void *, size_t, uint64_t); 681extern int dt_print_agg(const dtrace_aggdata_t *, void *); 682 683extern int dt_handle(dtrace_hdl_t *, dtrace_probedata_t *); 684extern int dt_handle_liberr(dtrace_hdl_t *, 685 const dtrace_probedata_t *, const char *); 686extern int dt_handle_cpudrop(dtrace_hdl_t *, processorid_t, 687 dtrace_dropkind_t, uint64_t); 688extern int dt_handle_status(dtrace_hdl_t *, 689 dtrace_status_t *, dtrace_status_t *); 690extern int dt_handle_setopt(dtrace_hdl_t *, dtrace_setoptdata_t *); 691 692extern int dt_lib_depend_add(dtrace_hdl_t *, dt_list_t *, const char *); 693extern dt_lib_depend_t *dt_lib_depend_lookup(dt_list_t *, const char *); 694 695extern dt_pcb_t *yypcb; /* pointer to current parser control block */ 696extern char yyintprefix; /* int token prefix for macros (+/-) */ 697extern char yyintsuffix[4]; /* int token suffix ([uUlL]*) */ 698extern int yyintdecimal; /* int token is decimal (1) or octal/hex (0) */ 699extern char yytext[]; /* lex input buffer */ 700extern int yylineno; /* lex line number */ 701extern int yydebug; /* lex debugging */ 702extern dt_node_t *yypragma; /* lex token list for control lines */ 703 704extern const dtrace_attribute_t _dtrace_maxattr; /* maximum attributes */ 705extern const dtrace_attribute_t _dtrace_defattr; /* default attributes */ 706extern const dtrace_attribute_t _dtrace_symattr; /* symbol ref attributes */ 707extern const dtrace_attribute_t _dtrace_typattr; /* type ref attributes */ 708extern const dtrace_attribute_t _dtrace_prvattr; /* provider attributes */ 709extern const dtrace_pattr_t _dtrace_prvdesc; /* provider attribute bundle */ 710 711extern const dt_version_t _dtrace_versions[]; /* array of valid versions */ 712extern const char *const _dtrace_version; /* current version string */ 713 714extern int _dtrace_strbuckets; /* number of hash buckets for strings */ 715extern int _dtrace_intbuckets; /* number of hash buckets for ints */ 716extern uint_t _dtrace_stkindent; /* default indent for stack/ustack */ 717extern uint_t _dtrace_pidbuckets; /* number of hash buckets for pids */ 718extern uint_t _dtrace_pidlrulim; /* number of proc handles to cache */ 719extern int _dtrace_debug; /* debugging messages enabled */ 720extern size_t _dtrace_bufsize; /* default dt_buf_create() size */ 721extern int _dtrace_argmax; /* default maximum probe arguments */ 722 723extern const char *_dtrace_libdir; /* default library directory */ 724extern const char *_dtrace_moddir; /* default kernel module directory */ 725 726#ifdef __cplusplus 727} 728#endif 729 730#endif /* _DT_IMPL_H */
|