17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* 237c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef _DT_IMPL_H 287c478bd9Sstevel@tonic-gate #define _DT_IMPL_H 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #include <sys/param.h> 337c478bd9Sstevel@tonic-gate #include <sys/objfs.h> 347c478bd9Sstevel@tonic-gate #include <setjmp.h> 357c478bd9Sstevel@tonic-gate #include <libctf.h> 367c478bd9Sstevel@tonic-gate #include <dtrace.h> 377c478bd9Sstevel@tonic-gate #include <gelf.h> 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #ifdef __cplusplus 407c478bd9Sstevel@tonic-gate extern "C" { 417c478bd9Sstevel@tonic-gate #endif 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate #include <dt_parser.h> 447c478bd9Sstevel@tonic-gate #include <dt_regset.h> 457c478bd9Sstevel@tonic-gate #include <dt_inttab.h> 467c478bd9Sstevel@tonic-gate #include <dt_strtab.h> 477c478bd9Sstevel@tonic-gate #include <dt_ident.h> 487c478bd9Sstevel@tonic-gate #include <dt_list.h> 497c478bd9Sstevel@tonic-gate #include <dt_decl.h> 507c478bd9Sstevel@tonic-gate #include <dt_as.h> 517c478bd9Sstevel@tonic-gate #include <dt_proc.h> 527c478bd9Sstevel@tonic-gate #include <dt_dof.h> 537c478bd9Sstevel@tonic-gate #include <dt_pcb.h> 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate struct dt_module; /* see below */ 567c478bd9Sstevel@tonic-gate struct dt_pfdict; /* see <dt_printf.h> */ 577c478bd9Sstevel@tonic-gate struct dt_arg; /* see below */ 587c478bd9Sstevel@tonic-gate struct dt_provider; /* see <dt_provider.h> */ 59*1a7c1b72Smws struct dt_xlator; /* see <dt_xlator.h> */ 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate typedef struct dt_intrinsic { 627c478bd9Sstevel@tonic-gate const char *din_name; /* string name of the intrinsic type */ 637c478bd9Sstevel@tonic-gate ctf_encoding_t din_data; /* integer or floating-point CTF encoding */ 647c478bd9Sstevel@tonic-gate uint_t din_kind; /* CTF type kind to instantiate */ 657c478bd9Sstevel@tonic-gate } dt_intrinsic_t; 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate typedef struct dt_typedef { 687c478bd9Sstevel@tonic-gate const char *dty_src; /* string name of typedef source type */ 697c478bd9Sstevel@tonic-gate const char *dty_dst; /* string name of typedef destination type */ 707c478bd9Sstevel@tonic-gate } dt_typedef_t; 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate typedef struct dt_intdesc { 737c478bd9Sstevel@tonic-gate const char *did_name; /* string name of the integer type */ 747c478bd9Sstevel@tonic-gate ctf_file_t *did_ctfp; /* CTF container for this type reference */ 757c478bd9Sstevel@tonic-gate ctf_id_t did_type; /* CTF type reference for this type */ 767c478bd9Sstevel@tonic-gate uintmax_t did_limit; /* maximum positive value held by type */ 777c478bd9Sstevel@tonic-gate } dt_intdesc_t; 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate typedef struct dt_modops { 807c478bd9Sstevel@tonic-gate uint_t (*do_syminit)(struct dt_module *); 817c478bd9Sstevel@tonic-gate void (*do_symsort)(struct dt_module *); 827c478bd9Sstevel@tonic-gate GElf_Sym *(*do_symname)(struct dt_module *, 837c478bd9Sstevel@tonic-gate const char *, GElf_Sym *, uint_t *); 847c478bd9Sstevel@tonic-gate GElf_Sym *(*do_symaddr)(struct dt_module *, 857c478bd9Sstevel@tonic-gate GElf_Addr, GElf_Sym *, uint_t *); 867c478bd9Sstevel@tonic-gate } dt_modops_t; 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate typedef struct dt_arg { 897c478bd9Sstevel@tonic-gate int da_ndx; /* index of this argument */ 907c478bd9Sstevel@tonic-gate int da_mapping; /* mapping of argument indices to arguments */ 917c478bd9Sstevel@tonic-gate ctf_id_t da_type; /* type of argument */ 927c478bd9Sstevel@tonic-gate ctf_file_t *da_ctfp; /* CTF container for type */ 937c478bd9Sstevel@tonic-gate dt_ident_t *da_xlator; /* translator, if any */ 947c478bd9Sstevel@tonic-gate struct dt_arg *da_next; /* next argument */ 957c478bd9Sstevel@tonic-gate } dt_arg_t; 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate typedef struct dt_sym { 987c478bd9Sstevel@tonic-gate uint_t ds_symid; /* id of corresponding symbol */ 997c478bd9Sstevel@tonic-gate uint_t ds_next; /* index of next element in hash chain */ 1007c478bd9Sstevel@tonic-gate } dt_sym_t; 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate typedef struct dt_module { 1037c478bd9Sstevel@tonic-gate dt_list_t dm_list; /* list forward/back pointers */ 1047c478bd9Sstevel@tonic-gate char dm_name[DTRACE_MODNAMELEN]; /* string name of module */ 1057c478bd9Sstevel@tonic-gate char dm_file[MAXPATHLEN]; /* file path of module (if any) */ 1067c478bd9Sstevel@tonic-gate struct dt_module *dm_next; /* pointer to next module in hash chain */ 1077c478bd9Sstevel@tonic-gate const dt_modops_t *dm_ops; /* pointer to data model's ops vector */ 1087c478bd9Sstevel@tonic-gate Elf *dm_elf; /* libelf handle for module object */ 1097c478bd9Sstevel@tonic-gate objfs_info_t dm_info; /* object filesystem private info */ 1107c478bd9Sstevel@tonic-gate ctf_sect_t dm_symtab; /* symbol table for module */ 1117c478bd9Sstevel@tonic-gate ctf_sect_t dm_strtab; /* string table for module */ 1127c478bd9Sstevel@tonic-gate ctf_sect_t dm_ctdata; /* CTF data for module */ 1137c478bd9Sstevel@tonic-gate ctf_file_t *dm_ctfp; /* CTF container handle */ 1147c478bd9Sstevel@tonic-gate uint_t *dm_symbuckets; /* symbol table hash buckets (chain indices) */ 1157c478bd9Sstevel@tonic-gate dt_sym_t *dm_symchains; /* symbol table hash chains buffer */ 1167c478bd9Sstevel@tonic-gate void *dm_asmap; /* symbol pointers sorted by value */ 1177c478bd9Sstevel@tonic-gate uint_t dm_symfree; /* index of next free hash element */ 1187c478bd9Sstevel@tonic-gate uint_t dm_nsymbuckets; /* number of elements in bucket array */ 1197c478bd9Sstevel@tonic-gate uint_t dm_nsymelems; /* number of elements in hash table */ 1207c478bd9Sstevel@tonic-gate uint_t dm_asrsv; /* actual reserved size of dm_asmap */ 1217c478bd9Sstevel@tonic-gate uint_t dm_aslen; /* number of entries in dm_asmap */ 1227c478bd9Sstevel@tonic-gate uint_t dm_flags; /* module flags (see below) */ 1237c478bd9Sstevel@tonic-gate int dm_modid; /* modinfo(1M) module identifier */ 1247c478bd9Sstevel@tonic-gate GElf_Addr dm_text_va; /* virtual address of text section */ 1257c478bd9Sstevel@tonic-gate GElf_Xword dm_text_size; /* size in bytes of text section */ 1267c478bd9Sstevel@tonic-gate GElf_Addr dm_data_va; /* virtual address of data section */ 1277c478bd9Sstevel@tonic-gate GElf_Xword dm_data_size; /* size in bytes of data section */ 1287c478bd9Sstevel@tonic-gate GElf_Addr dm_bss_va; /* virtual address of BSS */ 1297c478bd9Sstevel@tonic-gate GElf_Xword dm_bss_size; /* size in bytes of BSS */ 1307c478bd9Sstevel@tonic-gate dt_idhash_t *dm_extern; /* external symbol definitions */ 1317c478bd9Sstevel@tonic-gate } dt_module_t; 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate #define DT_DM_LOADED 0x1 /* module symbol and type data is loaded */ 1347c478bd9Sstevel@tonic-gate #define DT_DM_KERNEL 0x2 /* module is associated with a kernel object */ 1357c478bd9Sstevel@tonic-gate #define DT_DM_PRIMARY 0x4 /* module is a krtld primary kernel object */ 1367c478bd9Sstevel@tonic-gate 1377c478bd9Sstevel@tonic-gate typedef struct dt_provmod { 1387c478bd9Sstevel@tonic-gate char *dp_name; /* name of provider module */ 1397c478bd9Sstevel@tonic-gate struct dt_provmod *dp_next; /* next module */ 1407c478bd9Sstevel@tonic-gate } dt_provmod_t; 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate typedef struct dt_ahashent { 1437c478bd9Sstevel@tonic-gate struct dt_ahashent *dtahe_prev; /* prev on hash chain */ 1447c478bd9Sstevel@tonic-gate struct dt_ahashent *dtahe_next; /* next on hash chain */ 1457c478bd9Sstevel@tonic-gate struct dt_ahashent *dtahe_prevall; /* prev on list of all */ 1467c478bd9Sstevel@tonic-gate struct dt_ahashent *dtahe_nextall; /* next on list of all */ 1477c478bd9Sstevel@tonic-gate uint64_t dtahe_hashval; /* hash value */ 1487c478bd9Sstevel@tonic-gate size_t dtahe_size; /* size of data */ 1497c478bd9Sstevel@tonic-gate dtrace_aggdata_t dtahe_data; /* data */ 1507c478bd9Sstevel@tonic-gate void (*dtahe_aggregate)(uint64_t *, uint64_t *, size_t); /* function */ 1517c478bd9Sstevel@tonic-gate } dt_ahashent_t; 1527c478bd9Sstevel@tonic-gate 1537c478bd9Sstevel@tonic-gate typedef struct dt_ahash { 1547c478bd9Sstevel@tonic-gate dt_ahashent_t **dtah_hash; /* hash table */ 1557c478bd9Sstevel@tonic-gate dt_ahashent_t *dtah_all; /* list of all elements */ 1567c478bd9Sstevel@tonic-gate size_t dtah_size; /* size of hash table */ 1577c478bd9Sstevel@tonic-gate } dt_ahash_t; 1587c478bd9Sstevel@tonic-gate 1597c478bd9Sstevel@tonic-gate typedef struct dt_aggregate { 1607c478bd9Sstevel@tonic-gate dtrace_bufdesc_t dtat_buf; /* buf aggregation snapshot */ 1617c478bd9Sstevel@tonic-gate int dtat_flags; /* aggregate flags */ 1627c478bd9Sstevel@tonic-gate processorid_t dtat_ncpus; /* number of CPUs in aggregate */ 1637c478bd9Sstevel@tonic-gate processorid_t *dtat_cpus; /* CPUs in aggregate */ 1647c478bd9Sstevel@tonic-gate processorid_t dtat_ncpu; /* size of dtat_cpus array */ 1657c478bd9Sstevel@tonic-gate processorid_t dtat_maxcpu; /* maximum number of CPUs */ 1667c478bd9Sstevel@tonic-gate dt_ahash_t dtat_hash; /* aggregate hash table */ 1677c478bd9Sstevel@tonic-gate } dt_aggregate_t; 1687c478bd9Sstevel@tonic-gate 1697c478bd9Sstevel@tonic-gate typedef struct dt_print_aggdata { 1707c478bd9Sstevel@tonic-gate dtrace_hdl_t *dtpa_dtp; /* pointer to libdtrace handle */ 1717c478bd9Sstevel@tonic-gate dtrace_aggvarid_t dtpa_id; /* aggregation variable of interest */ 1727c478bd9Sstevel@tonic-gate FILE *dtpa_fp; /* file pointer */ 1737c478bd9Sstevel@tonic-gate int dtpa_allunprint; /* print only unprinted aggregations */ 1747c478bd9Sstevel@tonic-gate } dt_print_aggdata_t; 1757c478bd9Sstevel@tonic-gate 1767c478bd9Sstevel@tonic-gate typedef struct dt_dirpath { 1777c478bd9Sstevel@tonic-gate dt_list_t dir_list; /* linked-list forward/back pointers */ 1787c478bd9Sstevel@tonic-gate char *dir_path; /* directory pathname */ 1797c478bd9Sstevel@tonic-gate } dt_dirpath_t; 1807c478bd9Sstevel@tonic-gate 1817c478bd9Sstevel@tonic-gate typedef uint32_t dt_version_t; /* encoded version (see below) */ 1827c478bd9Sstevel@tonic-gate 1837c478bd9Sstevel@tonic-gate struct dtrace_hdl { 1847c478bd9Sstevel@tonic-gate const dtrace_vector_t *dt_vector; /* library vector, if vectored open */ 1857c478bd9Sstevel@tonic-gate void *dt_varg; /* vector argument, if vectored open */ 1867c478bd9Sstevel@tonic-gate dtrace_conf_t dt_conf; /* DTrace driver configuration profile */ 1877c478bd9Sstevel@tonic-gate char dt_errmsg[BUFSIZ]; /* buffer for formatted syntax error msgs */ 1887c478bd9Sstevel@tonic-gate const char *dt_errtag; /* tag used with last call to dt_set_errmsg() */ 1897c478bd9Sstevel@tonic-gate dt_pcb_t *dt_pcb; /* pointer to current parsing control block */ 1907c478bd9Sstevel@tonic-gate ulong_t dt_gen; /* compiler generation number */ 1917c478bd9Sstevel@tonic-gate dt_list_t dt_programs; /* linked list of dtrace_prog_t's */ 1927c478bd9Sstevel@tonic-gate dt_list_t dt_xlators; /* linked list of dt_xlator_t's */ 193*1a7c1b72Smws struct dt_xlator **dt_xlatormap; /* dt_xlator_t's indexed by dx_id */ 194*1a7c1b72Smws id_t dt_xlatorid; /* next dt_xlator_t id to assign */ 1957c478bd9Sstevel@tonic-gate dt_ident_t *dt_externs; /* linked list of external symbol identifiers */ 1967c478bd9Sstevel@tonic-gate dt_idhash_t *dt_macros; /* hash table of macro variable identifiers */ 1977c478bd9Sstevel@tonic-gate dt_idhash_t *dt_aggs; /* hash table of aggregation identifiers */ 1987c478bd9Sstevel@tonic-gate dt_idhash_t *dt_globals; /* hash table of global identifiers */ 1997c478bd9Sstevel@tonic-gate dt_idhash_t *dt_tls; /* hash table of thread-local identifiers */ 2007c478bd9Sstevel@tonic-gate dt_list_t dt_modlist; /* linked list of dt_module_t's */ 2017c478bd9Sstevel@tonic-gate dt_module_t **dt_mods; /* hash table of dt_module_t's */ 2027c478bd9Sstevel@tonic-gate uint_t dt_modbuckets; /* number of module hash buckets */ 2037c478bd9Sstevel@tonic-gate uint_t dt_nmods; /* number of modules in hash and list */ 2047c478bd9Sstevel@tonic-gate dt_provmod_t *dt_provmod; /* linked list of provider modules */ 2057c478bd9Sstevel@tonic-gate dt_module_t *dt_exec; /* pointer to executable module */ 2067c478bd9Sstevel@tonic-gate dt_module_t *dt_rtld; /* pointer to run-time linker module */ 2077c478bd9Sstevel@tonic-gate dt_module_t *dt_cdefs; /* pointer to C dynamic type module */ 2087c478bd9Sstevel@tonic-gate dt_module_t *dt_ddefs; /* pointer to D dynamic type module */ 2097c478bd9Sstevel@tonic-gate dt_list_t dt_provlist; /* linked list of dt_provider_t's */ 2107c478bd9Sstevel@tonic-gate struct dt_provider **dt_provs; /* hash table of dt_provider_t's */ 2117c478bd9Sstevel@tonic-gate uint_t dt_provbuckets; /* number of provider hash buckets */ 2127c478bd9Sstevel@tonic-gate uint_t dt_nprovs; /* number of providers in hash and list */ 2137c478bd9Sstevel@tonic-gate dt_proc_hash_t *dt_procs; /* hash table of grabbed process handles */ 2147c478bd9Sstevel@tonic-gate dt_intdesc_t dt_ints[6]; /* cached integer type descriptions */ 2157c478bd9Sstevel@tonic-gate ctf_id_t dt_type_func; /* cached CTF identifier for function type */ 2167c478bd9Sstevel@tonic-gate ctf_id_t dt_type_fptr; /* cached CTF identifier for function pointer */ 2177c478bd9Sstevel@tonic-gate ctf_id_t dt_type_str; /* cached CTF identifier for string type */ 2187c478bd9Sstevel@tonic-gate ctf_id_t dt_type_dyn; /* cached CTF identifier for <DYN> type */ 2197c478bd9Sstevel@tonic-gate ctf_id_t dt_type_stack; /* cached CTF identifier for stack type */ 2207c478bd9Sstevel@tonic-gate size_t dt_maxprobe; /* max enabled probe ID */ 2217c478bd9Sstevel@tonic-gate dtrace_eprobedesc_t **dt_edesc; /* enabled probe descriptions */ 2227c478bd9Sstevel@tonic-gate dtrace_probedesc_t **dt_pdesc; /* probe descriptions for enabled prbs */ 2237c478bd9Sstevel@tonic-gate size_t dt_maxagg; /* max aggregation ID */ 2247c478bd9Sstevel@tonic-gate dtrace_aggdesc_t **dt_aggdesc; /* aggregation descriptions */ 2257c478bd9Sstevel@tonic-gate int dt_maxformat; /* max format ID */ 2267c478bd9Sstevel@tonic-gate void **dt_formats; /* pointer to format array */ 2277c478bd9Sstevel@tonic-gate dt_aggregate_t dt_aggregate; /* aggregate */ 2287c478bd9Sstevel@tonic-gate dtrace_bufdesc_t dt_buf; /* staging buffer */ 2297c478bd9Sstevel@tonic-gate struct dt_pfdict *dt_pfdict; /* dictionary of printf conversions */ 2307c478bd9Sstevel@tonic-gate dt_version_t dt_vmax; /* optional ceiling on program API binding */ 2317c478bd9Sstevel@tonic-gate dtrace_attribute_t dt_amin; /* optional floor on program attributes */ 2327c478bd9Sstevel@tonic-gate char *dt_cpp_path; /* pathname of cpp(1) to invoke if needed */ 2337c478bd9Sstevel@tonic-gate char **dt_cpp_argv; /* argument vector for exec'ing cpp(1) */ 2347c478bd9Sstevel@tonic-gate int dt_cpp_argc; /* count of initialized cpp(1) arguments */ 2357c478bd9Sstevel@tonic-gate int dt_cpp_args; /* size of dt_cpp_argv[] array */ 2367c478bd9Sstevel@tonic-gate char *dt_ld_path; /* pathname of ld(1) to invoke if needed */ 2377c478bd9Sstevel@tonic-gate dt_list_t dt_lib_path; /* linked-list forming library search path */ 2387c478bd9Sstevel@tonic-gate uint_t dt_lazyload; /* boolean: set via -xlazyload */ 2397c478bd9Sstevel@tonic-gate uint_t dt_active; /* boolean: set once tracing is active */ 2407c478bd9Sstevel@tonic-gate uint_t dt_stopped; /* boolean: set once tracing is stopped */ 2417c478bd9Sstevel@tonic-gate processorid_t dt_beganon; /* CPU that executed BEGIN probe (if any) */ 2427c478bd9Sstevel@tonic-gate processorid_t dt_endedon; /* CPU that executed END probe (if any) */ 2437c478bd9Sstevel@tonic-gate uint_t dt_oflags; /* dtrace open-time options (see dtrace.h) */ 2447c478bd9Sstevel@tonic-gate uint_t dt_cflags; /* dtrace compile-time options (see dtrace.h) */ 2457c478bd9Sstevel@tonic-gate uint_t dt_dflags; /* dtrace link-time options (see dtrace.h) */ 2467c478bd9Sstevel@tonic-gate uint_t dt_prcmode; /* dtrace process create mode (see dt_proc.h) */ 2477c478bd9Sstevel@tonic-gate uint_t dt_linkmode; /* dtrace symbol linking mode (see below) */ 2487c478bd9Sstevel@tonic-gate uint_t dt_linktype; /* dtrace link output file type (see below) */ 249*1a7c1b72Smws uint_t dt_xlatemode; /* dtrace translator linking mode (see below) */ 2507c478bd9Sstevel@tonic-gate uint_t dt_stdcmode; /* dtrace stdc compatibility mode (see below) */ 2517c478bd9Sstevel@tonic-gate uint_t dt_treedump; /* dtrace tree debug bitmap (see below) */ 2527c478bd9Sstevel@tonic-gate uint64_t dt_options[DTRACEOPT_MAX]; /* dtrace run-time options */ 2537c478bd9Sstevel@tonic-gate int dt_version; /* library version requested by client */ 2547c478bd9Sstevel@tonic-gate int dt_ctferr; /* error resulting from last CTF failure */ 2557c478bd9Sstevel@tonic-gate int dt_errno; /* error resulting from last failed operation */ 2567c478bd9Sstevel@tonic-gate int dt_fd; /* file descriptor for dtrace pseudo-device */ 2577c478bd9Sstevel@tonic-gate int dt_ftfd; /* file descriptor for fasttrap pseudo-device */ 2587c478bd9Sstevel@tonic-gate int dt_fterr; /* saved errno from failed open of dt_ftfd */ 2597c478bd9Sstevel@tonic-gate int dt_cdefs_fd; /* file descriptor for C CTF debugging cache */ 2607c478bd9Sstevel@tonic-gate int dt_ddefs_fd; /* file descriptor for D CTF debugging cache */ 2617c478bd9Sstevel@tonic-gate int dt_stdout_fd; /* file descriptor for saved stdout */ 2627c478bd9Sstevel@tonic-gate dtrace_handle_err_f *dt_errhdlr; /* error handler, if any */ 2637c478bd9Sstevel@tonic-gate void *dt_errarg; /* error handler argument */ 2647c478bd9Sstevel@tonic-gate dtrace_prog_t *dt_errprog; /* error handler program, if any */ 2657c478bd9Sstevel@tonic-gate dtrace_handle_drop_f *dt_drophdlr; /* drop handler, if any */ 2667c478bd9Sstevel@tonic-gate void *dt_droparg; /* drop handler argument */ 2677c478bd9Sstevel@tonic-gate dtrace_handle_proc_f *dt_prochdlr; /* proc handler, if any */ 2687c478bd9Sstevel@tonic-gate void *dt_procarg; /* proc handler argument */ 2697c478bd9Sstevel@tonic-gate dtrace_status_t dt_status[2]; /* status cache */ 2707c478bd9Sstevel@tonic-gate int dt_statusgen; /* current status generation */ 2717c478bd9Sstevel@tonic-gate hrtime_t dt_laststatus; /* last status */ 2727c478bd9Sstevel@tonic-gate hrtime_t dt_lastswitch; /* last switch of buffer data */ 2737c478bd9Sstevel@tonic-gate hrtime_t dt_lastagg; /* last snapshot of aggregation data */ 2747c478bd9Sstevel@tonic-gate char *dt_sprintf_buf; /* buffer for dtrace_sprintf() */ 2757c478bd9Sstevel@tonic-gate int dt_sprintf_buflen; /* length of dtrace_sprintf() buffer */ 2767c478bd9Sstevel@tonic-gate const char *dt_filetag; /* default filetag for dt_set_errmsg() */ 2777c478bd9Sstevel@tonic-gate char *dt_buffered_buf; /* buffer for buffered output */ 2787c478bd9Sstevel@tonic-gate size_t dt_buffered_offs; /* current offset into buffered buffer */ 2797c478bd9Sstevel@tonic-gate size_t dt_buffered_size; /* size of buffered buffer */ 2807c478bd9Sstevel@tonic-gate dtrace_handle_buffered_f *dt_bufhdlr; /* buffered handler, if any */ 2817c478bd9Sstevel@tonic-gate void *dt_bufarg; /* buffered handler argument */ 2827c478bd9Sstevel@tonic-gate dt_dof_t dt_dof; /* DOF generation buffers (see dt_dof.c) */ 2837c478bd9Sstevel@tonic-gate struct utsname dt_uts; /* uname(2) information for system */ 2847c478bd9Sstevel@tonic-gate }; 2857c478bd9Sstevel@tonic-gate 2867c478bd9Sstevel@tonic-gate /* 2877c478bd9Sstevel@tonic-gate * Values for the user arg of the ECB. 2887c478bd9Sstevel@tonic-gate */ 2897c478bd9Sstevel@tonic-gate #define DT_ECB_DEFAULT 0 2907c478bd9Sstevel@tonic-gate #define DT_ECB_ERROR 1 2917c478bd9Sstevel@tonic-gate 2927c478bd9Sstevel@tonic-gate /* 2937c478bd9Sstevel@tonic-gate * Values for the dt_linkmode property, which is used by the assembler when 2947c478bd9Sstevel@tonic-gate * processing external symbol references. User can set using -xlink=<mode>. 2957c478bd9Sstevel@tonic-gate */ 2967c478bd9Sstevel@tonic-gate #define DT_LINK_KERNEL 0 /* kernel syms static, user syms dynamic */ 2977c478bd9Sstevel@tonic-gate #define DT_LINK_PRIMARY 1 /* primary kernel syms static, others dynamic */ 2987c478bd9Sstevel@tonic-gate #define DT_LINK_DYNAMIC 2 /* all symbols dynamic */ 2997c478bd9Sstevel@tonic-gate #define DT_LINK_STATIC 3 /* all symbols static */ 3007c478bd9Sstevel@tonic-gate 3017c478bd9Sstevel@tonic-gate /* 3027c478bd9Sstevel@tonic-gate * Values for the dt_linktype property, which is used by dtrace_program_link() 3037c478bd9Sstevel@tonic-gate * to determine the type of output file that is desired by the client. 3047c478bd9Sstevel@tonic-gate */ 3057c478bd9Sstevel@tonic-gate #define DT_LTYP_ELF 0 /* produce ELF containing DOF */ 3067c478bd9Sstevel@tonic-gate #define DT_LTYP_DOF 1 /* produce stand-alone DOF */ 3077c478bd9Sstevel@tonic-gate 3087c478bd9Sstevel@tonic-gate /* 309*1a7c1b72Smws * Values for the dt_xlatemode property, which is used to determine whether 310*1a7c1b72Smws * references to dynamic translators are permitted. Set using -xlate=<mode>. 311*1a7c1b72Smws */ 312*1a7c1b72Smws #define DT_XL_STATIC 0 /* require xlators to be statically defined */ 313*1a7c1b72Smws #define DT_XL_DYNAMIC 1 /* produce references to dynamic translators */ 314*1a7c1b72Smws 315*1a7c1b72Smws /* 3167c478bd9Sstevel@tonic-gate * Values for the dt_stdcmode property, which is used by the compiler when 3177c478bd9Sstevel@tonic-gate * running cpp to determine the presence and setting of the __STDC__ macro. 3187c478bd9Sstevel@tonic-gate */ 3197c478bd9Sstevel@tonic-gate #define DT_STDC_XA 0 /* ISO C + K&R C compat w/o ISO: __STDC__=0 */ 3207c478bd9Sstevel@tonic-gate #define DT_STDC_XC 1 /* Strict ISO C: __STDC__=1 */ 3217c478bd9Sstevel@tonic-gate #define DT_STDC_XS 2 /* K&R C: __STDC__ not defined */ 3227c478bd9Sstevel@tonic-gate #define DT_STDC_XT 3 /* ISO C + K&R C compat with ISO: __STDC__=0 */ 3237c478bd9Sstevel@tonic-gate 3247c478bd9Sstevel@tonic-gate /* 3257c478bd9Sstevel@tonic-gate * Macro to test whether a given pass bit is set in the dt_treedump bit-vector. 3267c478bd9Sstevel@tonic-gate * If the bit for pass 'p' is set, the D compiler displays the parse tree for 3277c478bd9Sstevel@tonic-gate * the program by printing it to stderr at the end of compiler pass 'p'. 3287c478bd9Sstevel@tonic-gate */ 3297c478bd9Sstevel@tonic-gate #define DT_TREEDUMP_PASS(dtp, p) ((dtp)->dt_treedump & (1 << ((p) - 1))) 3307c478bd9Sstevel@tonic-gate 3317c478bd9Sstevel@tonic-gate /* 3327c478bd9Sstevel@tonic-gate * Macros for accessing the cached CTF container and type ID for the common 3337c478bd9Sstevel@tonic-gate * types "int", "string", and <DYN>, which we need to use frequently in the D 3347c478bd9Sstevel@tonic-gate * compiler. The DT_INT_* macro relies upon "int" being at index 0 in the 3357c478bd9Sstevel@tonic-gate * _dtrace_ints_* tables in dt_open.c; the others are also set up there. 3367c478bd9Sstevel@tonic-gate */ 3377c478bd9Sstevel@tonic-gate #define DT_INT_CTFP(dtp) ((dtp)->dt_ints[0].did_ctfp) 3387c478bd9Sstevel@tonic-gate #define DT_INT_TYPE(dtp) ((dtp)->dt_ints[0].did_type) 3397c478bd9Sstevel@tonic-gate 3407c478bd9Sstevel@tonic-gate #define DT_FUNC_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp) 3417c478bd9Sstevel@tonic-gate #define DT_FUNC_TYPE(dtp) ((dtp)->dt_type_func) 3427c478bd9Sstevel@tonic-gate 3437c478bd9Sstevel@tonic-gate #define DT_FPTR_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp) 3447c478bd9Sstevel@tonic-gate #define DT_FPTR_TYPE(dtp) ((dtp)->dt_type_fptr) 3457c478bd9Sstevel@tonic-gate 3467c478bd9Sstevel@tonic-gate #define DT_STR_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp) 3477c478bd9Sstevel@tonic-gate #define DT_STR_TYPE(dtp) ((dtp)->dt_type_str) 3487c478bd9Sstevel@tonic-gate 3497c478bd9Sstevel@tonic-gate #define DT_DYN_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp) 3507c478bd9Sstevel@tonic-gate #define DT_DYN_TYPE(dtp) ((dtp)->dt_type_dyn) 3517c478bd9Sstevel@tonic-gate 3527c478bd9Sstevel@tonic-gate #define DT_STACK_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp) 3537c478bd9Sstevel@tonic-gate #define DT_STACK_TYPE(dtp) ((dtp)->dt_type_stack) 3547c478bd9Sstevel@tonic-gate 3557c478bd9Sstevel@tonic-gate #define DT_ACT_PRINTF 0 /* printf() action */ 3567c478bd9Sstevel@tonic-gate #define DT_ACT_TRACE 1 /* trace() action */ 3577c478bd9Sstevel@tonic-gate #define DT_ACT_TRACEMEM 2 /* tracemem() action */ 3587c478bd9Sstevel@tonic-gate #define DT_ACT_STACK 3 /* stack() action */ 3597c478bd9Sstevel@tonic-gate #define DT_ACT_STOP 4 /* stop() action */ 3607c478bd9Sstevel@tonic-gate #define DT_ACT_BREAKPOINT 5 /* breakpoint() action */ 3617c478bd9Sstevel@tonic-gate #define DT_ACT_PANIC 6 /* panic() action */ 3627c478bd9Sstevel@tonic-gate #define DT_ACT_SPECULATE 7 /* speculate() action */ 3637c478bd9Sstevel@tonic-gate #define DT_ACT_COMMIT 8 /* commit() action */ 3647c478bd9Sstevel@tonic-gate #define DT_ACT_DISCARD 9 /* discard() action */ 3657c478bd9Sstevel@tonic-gate #define DT_ACT_CHILL 10 /* chill() action */ 3667c478bd9Sstevel@tonic-gate #define DT_ACT_EXIT 11 /* exit() action */ 3677c478bd9Sstevel@tonic-gate #define DT_ACT_USTACK 12 /* ustack() action */ 3687c478bd9Sstevel@tonic-gate #define DT_ACT_PRINTA 13 /* printa() action */ 3697c478bd9Sstevel@tonic-gate #define DT_ACT_RAISE 14 /* raise() action */ 3707c478bd9Sstevel@tonic-gate #define DT_ACT_CLEAR 15 /* clear() action */ 3717c478bd9Sstevel@tonic-gate #define DT_ACT_NORMALIZE 16 /* normalize() action */ 3727c478bd9Sstevel@tonic-gate #define DT_ACT_DENORMALIZE 17 /* denormalize() action */ 3737c478bd9Sstevel@tonic-gate #define DT_ACT_TRUNC 18 /* trunc() action */ 3747c478bd9Sstevel@tonic-gate #define DT_ACT_SYSTEM 19 /* system() action */ 3757c478bd9Sstevel@tonic-gate #define DT_ACT_JSTACK 20 /* jstack() action */ 3767c478bd9Sstevel@tonic-gate #define DT_ACT_FTRUNCATE 21 /* ftruncate() action */ 3777c478bd9Sstevel@tonic-gate #define DT_ACT_FREOPEN 22 /* freopen() action */ 3787c478bd9Sstevel@tonic-gate 3797c478bd9Sstevel@tonic-gate /* 3807c478bd9Sstevel@tonic-gate * Sentinel to tell freopen() to restore the saved stdout. This must not 3817c478bd9Sstevel@tonic-gate * be ever valid for opening for write access via freopen(3C), which of 3827c478bd9Sstevel@tonic-gate * course, "." never is. 3837c478bd9Sstevel@tonic-gate */ 3847c478bd9Sstevel@tonic-gate #define DT_FREOPEN_RESTORE "." 3857c478bd9Sstevel@tonic-gate 3867c478bd9Sstevel@tonic-gate #define EDT_BASE 1000 /* base value for libdtrace errnos */ 3877c478bd9Sstevel@tonic-gate 3887c478bd9Sstevel@tonic-gate enum { 3897c478bd9Sstevel@tonic-gate EDT_VERSION = EDT_BASE, /* client is requesting unsupported version */ 3907c478bd9Sstevel@tonic-gate EDT_VERSINVAL, /* version string is invalid or overflows */ 3917c478bd9Sstevel@tonic-gate EDT_VERSUNDEF, /* requested API version is not defined */ 3927c478bd9Sstevel@tonic-gate EDT_VERSREDUCED, /* requested API version has been reduced */ 3937c478bd9Sstevel@tonic-gate EDT_CTF, /* libctf called failed (dt_ctferr has more) */ 3947c478bd9Sstevel@tonic-gate EDT_COMPILER, /* error in D program compilation */ 3957c478bd9Sstevel@tonic-gate EDT_NOREG, /* register allocation failure */ 3967c478bd9Sstevel@tonic-gate EDT_NOTUPREG, /* tuple register allocation failure */ 3977c478bd9Sstevel@tonic-gate EDT_NOMEM, /* memory allocation failure */ 3987c478bd9Sstevel@tonic-gate EDT_INT2BIG, /* integer limit exceeded */ 3997c478bd9Sstevel@tonic-gate EDT_STR2BIG, /* string limit exceeded */ 4007c478bd9Sstevel@tonic-gate EDT_NOMOD, /* unknown module name */ 4017c478bd9Sstevel@tonic-gate EDT_NOPROV, /* unknown provider name */ 4027c478bd9Sstevel@tonic-gate EDT_NOPROBE, /* unknown probe name */ 4037c478bd9Sstevel@tonic-gate EDT_NOSYM, /* unknown symbol name */ 4047c478bd9Sstevel@tonic-gate EDT_NOSYMADDR, /* no symbol corresponds to address */ 4057c478bd9Sstevel@tonic-gate EDT_NOTYPE, /* unknown type name */ 4067c478bd9Sstevel@tonic-gate EDT_NOVAR, /* unknown variable name */ 4077c478bd9Sstevel@tonic-gate EDT_NOAGG, /* unknown aggregation name */ 4087c478bd9Sstevel@tonic-gate EDT_BADSCOPE, /* improper use of type name scoping operator */ 4097c478bd9Sstevel@tonic-gate EDT_BADSPEC, /* overspecified probe description */ 4107c478bd9Sstevel@tonic-gate EDT_BADSPCV, /* bad macro variable in probe description */ 4117c478bd9Sstevel@tonic-gate EDT_BADID, /* invalid probe identifier */ 4127c478bd9Sstevel@tonic-gate EDT_NOTLOADED, /* module is not currently loaded */ 4137c478bd9Sstevel@tonic-gate EDT_NOCTF, /* module does not contain any CTF data */ 4147c478bd9Sstevel@tonic-gate EDT_DATAMODEL, /* module and program data models don't match */ 4157c478bd9Sstevel@tonic-gate EDT_DIFVERS, /* library has newer DIF version than driver */ 4167c478bd9Sstevel@tonic-gate EDT_BADAGG, /* unrecognized aggregating action */ 4177c478bd9Sstevel@tonic-gate EDT_FIO, /* file i/o error */ 4187c478bd9Sstevel@tonic-gate EDT_DIFINVAL, /* invalid DIF program */ 4197c478bd9Sstevel@tonic-gate EDT_DIFSIZE, /* invalid DIF size */ 4207c478bd9Sstevel@tonic-gate EDT_DIFFAULT, /* failed to copyin DIF program */ 4217c478bd9Sstevel@tonic-gate EDT_BADPROBE, /* bad probe description */ 4227c478bd9Sstevel@tonic-gate EDT_BADPGLOB, /* bad probe description globbing pattern */ 4237c478bd9Sstevel@tonic-gate EDT_NOSCOPE, /* declaration scope stack underflow */ 4247c478bd9Sstevel@tonic-gate EDT_NODECL, /* declaration stack underflow */ 4257c478bd9Sstevel@tonic-gate EDT_DMISMATCH, /* record list does not match statement */ 4267c478bd9Sstevel@tonic-gate EDT_DOFFSET, /* record data offset error */ 4277c478bd9Sstevel@tonic-gate EDT_DALIGN, /* record data alignment error */ 4287c478bd9Sstevel@tonic-gate EDT_BADOPTNAME, /* invalid dtrace_setopt option name */ 4297c478bd9Sstevel@tonic-gate EDT_BADOPTVAL, /* invalid dtrace_setopt option value */ 4307c478bd9Sstevel@tonic-gate EDT_BADOPTCTX, /* invalid dtrace_setopt option context */ 4317c478bd9Sstevel@tonic-gate EDT_CPPFORK, /* failed to fork preprocessor */ 4327c478bd9Sstevel@tonic-gate EDT_CPPEXEC, /* failed to exec preprocessor */ 4337c478bd9Sstevel@tonic-gate EDT_CPPENT, /* preprocessor not found */ 4347c478bd9Sstevel@tonic-gate EDT_CPPERR, /* unknown preprocessor error */ 4357c478bd9Sstevel@tonic-gate EDT_SYMOFLOW, /* external symbol table overflow */ 4367c478bd9Sstevel@tonic-gate EDT_ACTIVE, /* operation illegal when tracing is active */ 4377c478bd9Sstevel@tonic-gate EDT_DESTRUCTIVE, /* destructive actions not allowed */ 4387c478bd9Sstevel@tonic-gate EDT_NOANON, /* no anonymous tracing state */ 4397c478bd9Sstevel@tonic-gate EDT_ISANON, /* can't claim anon state and enable probes */ 4407c478bd9Sstevel@tonic-gate EDT_ENDTOOBIG, /* END enablings exceed size of prncpl buffer */ 4417c478bd9Sstevel@tonic-gate EDT_NOCONV, /* failed to load type for printf conversion */ 4427c478bd9Sstevel@tonic-gate EDT_BADCONV, /* incomplete printf conversion */ 4437c478bd9Sstevel@tonic-gate EDT_BADERROR, /* invalid library ERROR action */ 4447c478bd9Sstevel@tonic-gate EDT_ERRABORT, /* abort due to error */ 4457c478bd9Sstevel@tonic-gate EDT_DROPABORT, /* abort due to drop */ 4467c478bd9Sstevel@tonic-gate EDT_DIRABORT, /* abort explicitly directed */ 4477c478bd9Sstevel@tonic-gate EDT_BADRVAL, /* invalid return value from callback */ 4487c478bd9Sstevel@tonic-gate EDT_BADNORMAL, /* invalid normalization */ 4497c478bd9Sstevel@tonic-gate EDT_BUFTOOSMALL, /* enabling exceeds size of buffer */ 4507c478bd9Sstevel@tonic-gate EDT_BADTRUNC, /* invalid truncation */ 4517c478bd9Sstevel@tonic-gate EDT_BUSY, /* device busy (active kernel debugger) */ 4527c478bd9Sstevel@tonic-gate EDT_ACCESS, /* insufficient privileges to use DTrace */ 4537c478bd9Sstevel@tonic-gate EDT_GNOENT, /* dtrace device not available in global zone */ 4547c478bd9Sstevel@tonic-gate EDT_ZNOENT, /* dtrace device not available in local zone */ 4557c478bd9Sstevel@tonic-gate EDT_BRICKED, /* abort due to systemic unresponsiveness */ 4567c478bd9Sstevel@tonic-gate EDT_HARDWIRE, /* failed to load hard-wired definitions */ 4577c478bd9Sstevel@tonic-gate EDT_ELFVERSION, /* libelf is out-of-date w.r.t libdtrace */ 4587c478bd9Sstevel@tonic-gate EDT_NOBUFFERED, /* attempt to buffer output without handler */ 4597c478bd9Sstevel@tonic-gate EDT_UNSTABLE /* description matched unstable set of probes */ 4607c478bd9Sstevel@tonic-gate }; 4617c478bd9Sstevel@tonic-gate 4627c478bd9Sstevel@tonic-gate /* 4637c478bd9Sstevel@tonic-gate * Interfaces for parsing and comparing DTrace attribute tuples, which describe 4647c478bd9Sstevel@tonic-gate * stability and architectural binding information. The dtrace_attribute_t 4657c478bd9Sstevel@tonic-gate * structure and associated constant definitions are found in <sys/dtrace.h>. 4667c478bd9Sstevel@tonic-gate */ 4677c478bd9Sstevel@tonic-gate extern dtrace_attribute_t dt_attr_min(dtrace_attribute_t, dtrace_attribute_t); 4687c478bd9Sstevel@tonic-gate extern dtrace_attribute_t dt_attr_max(dtrace_attribute_t, dtrace_attribute_t); 4697c478bd9Sstevel@tonic-gate extern char *dt_attr_str(dtrace_attribute_t, char *, size_t); 4707c478bd9Sstevel@tonic-gate extern int dt_attr_cmp(dtrace_attribute_t, dtrace_attribute_t); 4717c478bd9Sstevel@tonic-gate 4727c478bd9Sstevel@tonic-gate /* 4737c478bd9Sstevel@tonic-gate * Interfaces for parsing and handling DTrace version strings. Version binding 4747c478bd9Sstevel@tonic-gate * is a feature of the D compiler that is handled completely independently of 4757c478bd9Sstevel@tonic-gate * the DTrace kernel infrastructure, so the definitions are here in libdtrace. 4767c478bd9Sstevel@tonic-gate * Version strings are compiled into an encoded uint32_t which can be compared 4777c478bd9Sstevel@tonic-gate * using C comparison operators. Version definitions are found in dt_open.c. 4787c478bd9Sstevel@tonic-gate */ 4797c478bd9Sstevel@tonic-gate #define DT_VERSION_STRMAX 16 /* enough for "255.4095.4095\0" */ 4807c478bd9Sstevel@tonic-gate #define DT_VERSION_MAJMAX 0xFF /* maximum major version number */ 4817c478bd9Sstevel@tonic-gate #define DT_VERSION_MINMAX 0xFFF /* maximum minor version number */ 4827c478bd9Sstevel@tonic-gate #define DT_VERSION_MICMAX 0xFFF /* maximum micro version number */ 4837c478bd9Sstevel@tonic-gate 4847c478bd9Sstevel@tonic-gate #define DT_VERSION_NUMBER(M, m, u) \ 4857c478bd9Sstevel@tonic-gate ((((M) & 0xFF) << 24) | (((m) & 0xFFF) << 12) | ((u) & 0xFFF)) 4867c478bd9Sstevel@tonic-gate 4877c478bd9Sstevel@tonic-gate #define DT_VERSION_MAJOR(v) (((v) & 0xFF000000) >> 24) 4887c478bd9Sstevel@tonic-gate #define DT_VERSION_MINOR(v) (((v) & 0x00FFF000) >> 12) 4897c478bd9Sstevel@tonic-gate #define DT_VERSION_MICRO(v) ((v) & 0x00000FFF) 4907c478bd9Sstevel@tonic-gate 4917c478bd9Sstevel@tonic-gate extern char *dt_version_num2str(dt_version_t, char *, size_t); 4927c478bd9Sstevel@tonic-gate extern int dt_version_str2num(const char *, dt_version_t *); 4937c478bd9Sstevel@tonic-gate extern int dt_version_defined(dt_version_t); 4947c478bd9Sstevel@tonic-gate 4957c478bd9Sstevel@tonic-gate /* 4967c478bd9Sstevel@tonic-gate * Miscellaneous internal libdtrace interfaces. The definitions below are for 4977c478bd9Sstevel@tonic-gate * libdtrace routines that do not yet merit their own separate header file. 4987c478bd9Sstevel@tonic-gate */ 4997c478bd9Sstevel@tonic-gate extern char *dt_cpp_add_arg(dtrace_hdl_t *, const char *); 5007c478bd9Sstevel@tonic-gate extern char *dt_cpp_pop_arg(dtrace_hdl_t *); 5017c478bd9Sstevel@tonic-gate 5027c478bd9Sstevel@tonic-gate extern int dt_set_errno(dtrace_hdl_t *, int); 5037c478bd9Sstevel@tonic-gate extern void dt_set_errmsg(dtrace_hdl_t *, const char *, const char *, 5047c478bd9Sstevel@tonic-gate const char *, int, const char *, va_list); 5057c478bd9Sstevel@tonic-gate 5067c478bd9Sstevel@tonic-gate extern int dt_ioctl(dtrace_hdl_t *, int, void *); 5077c478bd9Sstevel@tonic-gate extern int dt_status(dtrace_hdl_t *, processorid_t); 5087c478bd9Sstevel@tonic-gate extern long dt_sysconf(dtrace_hdl_t *, int); 5097c478bd9Sstevel@tonic-gate extern ssize_t dt_write(dtrace_hdl_t *, int, const void *, size_t); 5107c478bd9Sstevel@tonic-gate extern int dt_printf(dtrace_hdl_t *, FILE *, const char *, ...); 5117c478bd9Sstevel@tonic-gate 5127c478bd9Sstevel@tonic-gate extern void *dt_zalloc(dtrace_hdl_t *, size_t); 5137c478bd9Sstevel@tonic-gate extern void *dt_alloc(dtrace_hdl_t *, size_t); 5147c478bd9Sstevel@tonic-gate extern void dt_free(dtrace_hdl_t *, void *); 515*1a7c1b72Smws extern void dt_difo_free(dtrace_hdl_t *, dtrace_difo_t *); 5167c478bd9Sstevel@tonic-gate 5177c478bd9Sstevel@tonic-gate extern int dt_gmatch(const char *, const char *); 5187c478bd9Sstevel@tonic-gate extern char *dt_basename(char *); 5197c478bd9Sstevel@tonic-gate 520*1a7c1b72Smws extern ulong_t dt_popc(ulong_t); 521*1a7c1b72Smws extern ulong_t dt_popcb(const ulong_t *, ulong_t); 522*1a7c1b72Smws 5237c478bd9Sstevel@tonic-gate extern int dt_buffered_enable(dtrace_hdl_t *); 5247c478bd9Sstevel@tonic-gate extern int dt_buffered_flush(dtrace_hdl_t *, dtrace_probedata_t *, 5257c478bd9Sstevel@tonic-gate dtrace_recdesc_t *, dtrace_aggdata_t *); 5267c478bd9Sstevel@tonic-gate extern void dt_buffered_disable(dtrace_hdl_t *); 5277c478bd9Sstevel@tonic-gate extern void dt_buffered_destroy(dtrace_hdl_t *); 5287c478bd9Sstevel@tonic-gate 5297c478bd9Sstevel@tonic-gate extern int dt_rw_read_held(pthread_rwlock_t *); 5307c478bd9Sstevel@tonic-gate extern int dt_rw_write_held(pthread_rwlock_t *); 5317c478bd9Sstevel@tonic-gate extern int dt_mutex_held(pthread_mutex_t *); 5327c478bd9Sstevel@tonic-gate 5337c478bd9Sstevel@tonic-gate #define DT_RW_READ_HELD(x) dt_rw_read_held(x) 5347c478bd9Sstevel@tonic-gate #define DT_RW_WRITE_HELD(x) dt_rw_write_held(x) 5357c478bd9Sstevel@tonic-gate #define DT_RW_LOCK_HELD(x) (DT_RW_READ_HELD(x) || DT_RW_WRITE_HELD(x)) 5367c478bd9Sstevel@tonic-gate #define DT_MUTEX_HELD(x) dt_mutex_held(x) 5377c478bd9Sstevel@tonic-gate 5387c478bd9Sstevel@tonic-gate extern int dt_options_load(dtrace_hdl_t *); 5397c478bd9Sstevel@tonic-gate 5407c478bd9Sstevel@tonic-gate extern void dt_dprintf(const char *, ...); 5417c478bd9Sstevel@tonic-gate 5427c478bd9Sstevel@tonic-gate extern void dt_setcontext(dtrace_hdl_t *, dtrace_probedesc_t *); 5437c478bd9Sstevel@tonic-gate extern void dt_endcontext(dtrace_hdl_t *); 5447c478bd9Sstevel@tonic-gate 5457c478bd9Sstevel@tonic-gate extern void dt_pragma(dt_node_t *); 5467c478bd9Sstevel@tonic-gate extern int dt_reduce(dtrace_hdl_t *, dt_version_t); 5477c478bd9Sstevel@tonic-gate extern void dt_cg(dt_pcb_t *, dt_node_t *); 5487c478bd9Sstevel@tonic-gate extern dtrace_difo_t *dt_as(dt_pcb_t *); 549*1a7c1b72Smws extern void dt_dis(const dtrace_difo_t *, FILE *); 5507c478bd9Sstevel@tonic-gate 5517c478bd9Sstevel@tonic-gate extern int dt_aggregate_go(dtrace_hdl_t *); 5527c478bd9Sstevel@tonic-gate extern int dt_aggregate_init(dtrace_hdl_t *); 5537c478bd9Sstevel@tonic-gate extern void dt_aggregate_destroy(dtrace_hdl_t *); 5547c478bd9Sstevel@tonic-gate 5557c478bd9Sstevel@tonic-gate extern int dt_epid_lookup(dtrace_hdl_t *, dtrace_epid_t, 5567c478bd9Sstevel@tonic-gate dtrace_eprobedesc_t **, dtrace_probedesc_t **); 5577c478bd9Sstevel@tonic-gate extern void dt_epid_destroy(dtrace_hdl_t *); 5587c478bd9Sstevel@tonic-gate extern int dt_aggid_lookup(dtrace_hdl_t *, dtrace_aggid_t, dtrace_aggdesc_t **); 5597c478bd9Sstevel@tonic-gate extern void dt_aggid_destroy(dtrace_hdl_t *); 5607c478bd9Sstevel@tonic-gate 5617c478bd9Sstevel@tonic-gate extern void *dt_format_lookup(dtrace_hdl_t *, int); 5627c478bd9Sstevel@tonic-gate extern void dt_format_destroy(dtrace_hdl_t *); 5637c478bd9Sstevel@tonic-gate 5647c478bd9Sstevel@tonic-gate extern int dt_print_quantize(dtrace_hdl_t *, FILE *, 5657c478bd9Sstevel@tonic-gate const void *, size_t, uint64_t); 5667c478bd9Sstevel@tonic-gate extern int dt_print_lquantize(dtrace_hdl_t *, FILE *, 5677c478bd9Sstevel@tonic-gate const void *, size_t, uint64_t); 5687c478bd9Sstevel@tonic-gate extern int dt_print_agg(dtrace_aggdata_t *, void *); 5697c478bd9Sstevel@tonic-gate 5707c478bd9Sstevel@tonic-gate extern int dt_handle(dtrace_hdl_t *, dtrace_probedata_t *); 5717c478bd9Sstevel@tonic-gate extern int dt_handle_liberr(dtrace_hdl_t *, 5727c478bd9Sstevel@tonic-gate const dtrace_probedata_t *, const char *); 5737c478bd9Sstevel@tonic-gate extern int dt_handle_cpudrop(dtrace_hdl_t *, processorid_t, 5747c478bd9Sstevel@tonic-gate dtrace_dropkind_t, uint64_t); 5757c478bd9Sstevel@tonic-gate extern int dt_handle_status(dtrace_hdl_t *, 5767c478bd9Sstevel@tonic-gate dtrace_status_t *, dtrace_status_t *); 5777c478bd9Sstevel@tonic-gate 5787c478bd9Sstevel@tonic-gate extern dt_pcb_t *yypcb; /* pointer to current parser control block */ 5797c478bd9Sstevel@tonic-gate extern char yyintprefix; /* int token prefix for macros (+/-) */ 5807c478bd9Sstevel@tonic-gate extern char yyintsuffix[4]; /* int token suffix ([uUlL]*) */ 5817c478bd9Sstevel@tonic-gate extern int yyintdecimal; /* int token is decimal (1) or octal/hex (0) */ 5827c478bd9Sstevel@tonic-gate extern char yytext[]; /* lex input buffer */ 5837c478bd9Sstevel@tonic-gate extern int yylineno; /* lex line number */ 5847c478bd9Sstevel@tonic-gate extern int yydebug; /* lex debugging */ 5857c478bd9Sstevel@tonic-gate extern dt_node_t *yypragma; /* lex token list for control lines */ 5867c478bd9Sstevel@tonic-gate 5877c478bd9Sstevel@tonic-gate extern const dtrace_attribute_t _dtrace_maxattr; /* maximum attributes */ 5887c478bd9Sstevel@tonic-gate extern const dtrace_attribute_t _dtrace_defattr; /* default attributes */ 5897c478bd9Sstevel@tonic-gate extern const dtrace_attribute_t _dtrace_symattr; /* symbol ref attributes */ 5907c478bd9Sstevel@tonic-gate extern const dtrace_attribute_t _dtrace_typattr; /* type ref attributes */ 5917c478bd9Sstevel@tonic-gate extern const dtrace_attribute_t _dtrace_prvattr; /* provider attributes */ 5927c478bd9Sstevel@tonic-gate extern const dtrace_pattr_t _dtrace_prvdesc; /* provider attribute bundle */ 5937c478bd9Sstevel@tonic-gate 5947c478bd9Sstevel@tonic-gate extern const dt_version_t _dtrace_versions[]; /* array of valid versions */ 5957c478bd9Sstevel@tonic-gate extern const char *const _dtrace_version; /* current version string */ 5967c478bd9Sstevel@tonic-gate 5977c478bd9Sstevel@tonic-gate extern int _dtrace_strbuckets; /* number of hash buckets for strings */ 5987c478bd9Sstevel@tonic-gate extern int _dtrace_intbuckets; /* number of hash buckets for ints */ 5997c478bd9Sstevel@tonic-gate extern uint_t _dtrace_stkindent; /* default indent for stack/ustack */ 6007c478bd9Sstevel@tonic-gate extern uint_t _dtrace_pidbuckets; /* number of hash buckets for pids */ 6017c478bd9Sstevel@tonic-gate extern uint_t _dtrace_pidlrulim; /* number of proc handles to cache */ 6027c478bd9Sstevel@tonic-gate extern int _dtrace_debug; /* debugging messages enabled */ 6037c478bd9Sstevel@tonic-gate extern size_t _dtrace_bufsize; /* default dt_buf_create() size */ 6047c478bd9Sstevel@tonic-gate extern int _dtrace_argmax; /* default maximum probe arguments */ 6057c478bd9Sstevel@tonic-gate 6067c478bd9Sstevel@tonic-gate extern const char *_dtrace_libdir; /* default library directory */ 6077c478bd9Sstevel@tonic-gate extern const char *_dtrace_moddir; /* default kernel module directory */ 6087c478bd9Sstevel@tonic-gate 6097c478bd9Sstevel@tonic-gate #ifdef __cplusplus 6107c478bd9Sstevel@tonic-gate } 6117c478bd9Sstevel@tonic-gate #endif 6127c478bd9Sstevel@tonic-gate 6137c478bd9Sstevel@tonic-gate #endif /* _DT_IMPL_H */ 614