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 5ad4023c4Sdp * Common Development and Distribution License (the "License"). 6ad4023c4Sdp * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 216009dbc6Sahl 227c478bd9Sstevel@tonic-gate /* 2353f3aea0SRoger A. Faulkner * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 272b6389efSBryan Cantrill /* 2854a20ab4SBryan Cantrill * Copyright (c) 2013, Joyent, Inc. All rights reserved. 29*0af8f00bSMatthew Ahrens * Copyright (c) 2011, 2016 by Delphix. All rights reserved. 302b6389efSBryan Cantrill */ 312b6389efSBryan Cantrill 327c478bd9Sstevel@tonic-gate #ifndef _DT_IMPL_H 337c478bd9Sstevel@tonic-gate #define _DT_IMPL_H 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #include <sys/param.h> 367c478bd9Sstevel@tonic-gate #include <sys/objfs.h> 377c478bd9Sstevel@tonic-gate #include <setjmp.h> 387c478bd9Sstevel@tonic-gate #include <libctf.h> 397c478bd9Sstevel@tonic-gate #include <dtrace.h> 407c478bd9Sstevel@tonic-gate #include <gelf.h> 4153f3aea0SRoger A. Faulkner #include <synch.h> 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate #ifdef __cplusplus 447c478bd9Sstevel@tonic-gate extern "C" { 457c478bd9Sstevel@tonic-gate #endif 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate #include <dt_parser.h> 487c478bd9Sstevel@tonic-gate #include <dt_regset.h> 497c478bd9Sstevel@tonic-gate #include <dt_inttab.h> 507c478bd9Sstevel@tonic-gate #include <dt_strtab.h> 517c478bd9Sstevel@tonic-gate #include <dt_ident.h> 527c478bd9Sstevel@tonic-gate #include <dt_list.h> 537c478bd9Sstevel@tonic-gate #include <dt_decl.h> 547c478bd9Sstevel@tonic-gate #include <dt_as.h> 557c478bd9Sstevel@tonic-gate #include <dt_proc.h> 567c478bd9Sstevel@tonic-gate #include <dt_dof.h> 577c478bd9Sstevel@tonic-gate #include <dt_pcb.h> 58e5803b76SAdam H. Leventhal #include <dt_pq.h> 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate struct dt_module; /* see below */ 617c478bd9Sstevel@tonic-gate struct dt_pfdict; /* see <dt_printf.h> */ 627c478bd9Sstevel@tonic-gate struct dt_arg; /* see below */ 637c478bd9Sstevel@tonic-gate struct dt_provider; /* see <dt_provider.h> */ 641a7c1b72Smws struct dt_xlator; /* see <dt_xlator.h> */ 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate typedef struct dt_intrinsic { 677c478bd9Sstevel@tonic-gate const char *din_name; /* string name of the intrinsic type */ 687c478bd9Sstevel@tonic-gate ctf_encoding_t din_data; /* integer or floating-point CTF encoding */ 697c478bd9Sstevel@tonic-gate uint_t din_kind; /* CTF type kind to instantiate */ 707c478bd9Sstevel@tonic-gate } dt_intrinsic_t; 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate typedef struct dt_typedef { 737c478bd9Sstevel@tonic-gate const char *dty_src; /* string name of typedef source type */ 747c478bd9Sstevel@tonic-gate const char *dty_dst; /* string name of typedef destination type */ 757c478bd9Sstevel@tonic-gate } dt_typedef_t; 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate typedef struct dt_intdesc { 787c478bd9Sstevel@tonic-gate const char *did_name; /* string name of the integer type */ 797c478bd9Sstevel@tonic-gate ctf_file_t *did_ctfp; /* CTF container for this type reference */ 807c478bd9Sstevel@tonic-gate ctf_id_t did_type; /* CTF type reference for this type */ 817c478bd9Sstevel@tonic-gate uintmax_t did_limit; /* maximum positive value held by type */ 827c478bd9Sstevel@tonic-gate } dt_intdesc_t; 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate typedef struct dt_modops { 857c478bd9Sstevel@tonic-gate uint_t (*do_syminit)(struct dt_module *); 867c478bd9Sstevel@tonic-gate void (*do_symsort)(struct dt_module *); 877c478bd9Sstevel@tonic-gate GElf_Sym *(*do_symname)(struct dt_module *, 887c478bd9Sstevel@tonic-gate const char *, GElf_Sym *, uint_t *); 897c478bd9Sstevel@tonic-gate GElf_Sym *(*do_symaddr)(struct dt_module *, 907c478bd9Sstevel@tonic-gate GElf_Addr, GElf_Sym *, uint_t *); 917c478bd9Sstevel@tonic-gate } dt_modops_t; 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate typedef struct dt_arg { 947c478bd9Sstevel@tonic-gate int da_ndx; /* index of this argument */ 957c478bd9Sstevel@tonic-gate int da_mapping; /* mapping of argument indices to arguments */ 967c478bd9Sstevel@tonic-gate ctf_id_t da_type; /* type of argument */ 977c478bd9Sstevel@tonic-gate ctf_file_t *da_ctfp; /* CTF container for type */ 987c478bd9Sstevel@tonic-gate dt_ident_t *da_xlator; /* translator, if any */ 997c478bd9Sstevel@tonic-gate struct dt_arg *da_next; /* next argument */ 1007c478bd9Sstevel@tonic-gate } dt_arg_t; 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate typedef struct dt_sym { 1037c478bd9Sstevel@tonic-gate uint_t ds_symid; /* id of corresponding symbol */ 1047c478bd9Sstevel@tonic-gate uint_t ds_next; /* index of next element in hash chain */ 1057c478bd9Sstevel@tonic-gate } dt_sym_t; 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate typedef struct dt_module { 1087c478bd9Sstevel@tonic-gate dt_list_t dm_list; /* list forward/back pointers */ 1097c478bd9Sstevel@tonic-gate char dm_name[DTRACE_MODNAMELEN]; /* string name of module */ 1107c478bd9Sstevel@tonic-gate char dm_file[MAXPATHLEN]; /* file path of module (if any) */ 1117c478bd9Sstevel@tonic-gate struct dt_module *dm_next; /* pointer to next module in hash chain */ 1127c478bd9Sstevel@tonic-gate const dt_modops_t *dm_ops; /* pointer to data model's ops vector */ 1137c478bd9Sstevel@tonic-gate Elf *dm_elf; /* libelf handle for module object */ 1147c478bd9Sstevel@tonic-gate objfs_info_t dm_info; /* object filesystem private info */ 1157c478bd9Sstevel@tonic-gate ctf_sect_t dm_symtab; /* symbol table for module */ 1167c478bd9Sstevel@tonic-gate ctf_sect_t dm_strtab; /* string table for module */ 1177c478bd9Sstevel@tonic-gate ctf_sect_t dm_ctdata; /* CTF data for module */ 1187c478bd9Sstevel@tonic-gate ctf_file_t *dm_ctfp; /* CTF container handle */ 1197c478bd9Sstevel@tonic-gate uint_t *dm_symbuckets; /* symbol table hash buckets (chain indices) */ 1207c478bd9Sstevel@tonic-gate dt_sym_t *dm_symchains; /* symbol table hash chains buffer */ 1217c478bd9Sstevel@tonic-gate void *dm_asmap; /* symbol pointers sorted by value */ 1227c478bd9Sstevel@tonic-gate uint_t dm_symfree; /* index of next free hash element */ 1237c478bd9Sstevel@tonic-gate uint_t dm_nsymbuckets; /* number of elements in bucket array */ 1247c478bd9Sstevel@tonic-gate uint_t dm_nsymelems; /* number of elements in hash table */ 1257c478bd9Sstevel@tonic-gate uint_t dm_asrsv; /* actual reserved size of dm_asmap */ 1267c478bd9Sstevel@tonic-gate uint_t dm_aslen; /* number of entries in dm_asmap */ 1277c478bd9Sstevel@tonic-gate uint_t dm_flags; /* module flags (see below) */ 1287c478bd9Sstevel@tonic-gate int dm_modid; /* modinfo(1M) module identifier */ 1297c478bd9Sstevel@tonic-gate GElf_Addr dm_text_va; /* virtual address of text section */ 1307c478bd9Sstevel@tonic-gate GElf_Xword dm_text_size; /* size in bytes of text section */ 1317c478bd9Sstevel@tonic-gate GElf_Addr dm_data_va; /* virtual address of data section */ 1327c478bd9Sstevel@tonic-gate GElf_Xword dm_data_size; /* size in bytes of data section */ 1337c478bd9Sstevel@tonic-gate GElf_Addr dm_bss_va; /* virtual address of BSS */ 1347c478bd9Sstevel@tonic-gate GElf_Xword dm_bss_size; /* size in bytes of BSS */ 1357c478bd9Sstevel@tonic-gate dt_idhash_t *dm_extern; /* external symbol definitions */ 136a386cc11SRobert Mustacchi pid_t dm_pid; /* pid for this module */ 137a386cc11SRobert Mustacchi uint_t dm_nctflibs; /* number of ctf children libraries */ 138a386cc11SRobert Mustacchi ctf_file_t **dm_libctfp; /* process library ctf pointers */ 139a386cc11SRobert Mustacchi char **dm_libctfn; /* names of process ctf containers */ 1407c478bd9Sstevel@tonic-gate } dt_module_t; 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate #define DT_DM_LOADED 0x1 /* module symbol and type data is loaded */ 1437c478bd9Sstevel@tonic-gate #define DT_DM_KERNEL 0x2 /* module is associated with a kernel object */ 1447c478bd9Sstevel@tonic-gate #define DT_DM_PRIMARY 0x4 /* module is a krtld primary kernel object */ 1457c478bd9Sstevel@tonic-gate 1467c478bd9Sstevel@tonic-gate typedef struct dt_provmod { 1477c478bd9Sstevel@tonic-gate char *dp_name; /* name of provider module */ 1487c478bd9Sstevel@tonic-gate struct dt_provmod *dp_next; /* next module */ 1497c478bd9Sstevel@tonic-gate } dt_provmod_t; 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gate typedef struct dt_ahashent { 1527c478bd9Sstevel@tonic-gate struct dt_ahashent *dtahe_prev; /* prev on hash chain */ 1537c478bd9Sstevel@tonic-gate struct dt_ahashent *dtahe_next; /* next on hash chain */ 1547c478bd9Sstevel@tonic-gate struct dt_ahashent *dtahe_prevall; /* prev on list of all */ 1557c478bd9Sstevel@tonic-gate struct dt_ahashent *dtahe_nextall; /* next on list of all */ 1567c478bd9Sstevel@tonic-gate uint64_t dtahe_hashval; /* hash value */ 1577c478bd9Sstevel@tonic-gate size_t dtahe_size; /* size of data */ 1587c478bd9Sstevel@tonic-gate dtrace_aggdata_t dtahe_data; /* data */ 159187eccf8Sbmc void (*dtahe_aggregate)(int64_t *, int64_t *, size_t); /* function */ 1607c478bd9Sstevel@tonic-gate } dt_ahashent_t; 1617c478bd9Sstevel@tonic-gate 1627c478bd9Sstevel@tonic-gate typedef struct dt_ahash { 1637c478bd9Sstevel@tonic-gate dt_ahashent_t **dtah_hash; /* hash table */ 1647c478bd9Sstevel@tonic-gate dt_ahashent_t *dtah_all; /* list of all elements */ 1657c478bd9Sstevel@tonic-gate size_t dtah_size; /* size of hash table */ 1667c478bd9Sstevel@tonic-gate } dt_ahash_t; 1677c478bd9Sstevel@tonic-gate 1687c478bd9Sstevel@tonic-gate typedef struct dt_aggregate { 1697c478bd9Sstevel@tonic-gate dtrace_bufdesc_t dtat_buf; /* buf aggregation snapshot */ 1707c478bd9Sstevel@tonic-gate int dtat_flags; /* aggregate flags */ 1717c478bd9Sstevel@tonic-gate processorid_t dtat_ncpus; /* number of CPUs in aggregate */ 1727c478bd9Sstevel@tonic-gate processorid_t *dtat_cpus; /* CPUs in aggregate */ 1737c478bd9Sstevel@tonic-gate processorid_t dtat_ncpu; /* size of dtat_cpus array */ 1747c478bd9Sstevel@tonic-gate processorid_t dtat_maxcpu; /* maximum number of CPUs */ 1757c478bd9Sstevel@tonic-gate dt_ahash_t dtat_hash; /* aggregate hash table */ 1767c478bd9Sstevel@tonic-gate } dt_aggregate_t; 1777c478bd9Sstevel@tonic-gate 1787c478bd9Sstevel@tonic-gate typedef struct dt_print_aggdata { 1797c478bd9Sstevel@tonic-gate dtrace_hdl_t *dtpa_dtp; /* pointer to libdtrace handle */ 1807c478bd9Sstevel@tonic-gate dtrace_aggvarid_t dtpa_id; /* aggregation variable of interest */ 1817c478bd9Sstevel@tonic-gate FILE *dtpa_fp; /* file pointer */ 1827c478bd9Sstevel@tonic-gate int dtpa_allunprint; /* print only unprinted aggregations */ 18333093f5bSBryan Cantrill int dtpa_agghist; /* print aggregation as histogram */ 18433093f5bSBryan Cantrill int dtpa_agghisthdr; /* aggregation histogram hdr printed */ 18533093f5bSBryan Cantrill int dtpa_aggpack; /* pack quantized aggregations */ 1867c478bd9Sstevel@tonic-gate } dt_print_aggdata_t; 1877c478bd9Sstevel@tonic-gate 1887c478bd9Sstevel@tonic-gate typedef struct dt_dirpath { 1897c478bd9Sstevel@tonic-gate dt_list_t dir_list; /* linked-list forward/back pointers */ 1907c478bd9Sstevel@tonic-gate char *dir_path; /* directory pathname */ 1917c478bd9Sstevel@tonic-gate } dt_dirpath_t; 1927c478bd9Sstevel@tonic-gate 193c9d6cd77Sjhaslam typedef struct dt_lib_depend { 194c9d6cd77Sjhaslam dt_list_t dtld_deplist; /* linked-list forward/back pointers */ 195c9d6cd77Sjhaslam char *dtld_library; /* library name */ 196c9d6cd77Sjhaslam char *dtld_libpath; /* library pathname */ 197c9d6cd77Sjhaslam uint_t dtld_finish; /* completion time in tsort for lib */ 198c9d6cd77Sjhaslam uint_t dtld_start; /* starting time in tsort for lib */ 1996009dbc6Sahl uint_t dtld_loaded; /* boolean: is this library loaded */ 200c9d6cd77Sjhaslam dt_list_t dtld_dependencies; /* linked-list of lib dependencies */ 201c9d6cd77Sjhaslam dt_list_t dtld_dependents; /* linked-list of lib dependents */ 202c9d6cd77Sjhaslam } dt_lib_depend_t; 203c9d6cd77Sjhaslam 2047c478bd9Sstevel@tonic-gate typedef uint32_t dt_version_t; /* encoded version (see below) */ 2057c478bd9Sstevel@tonic-gate 2067c478bd9Sstevel@tonic-gate struct dtrace_hdl { 2077c478bd9Sstevel@tonic-gate const dtrace_vector_t *dt_vector; /* library vector, if vectored open */ 2087c478bd9Sstevel@tonic-gate void *dt_varg; /* vector argument, if vectored open */ 2097c478bd9Sstevel@tonic-gate dtrace_conf_t dt_conf; /* DTrace driver configuration profile */ 2107c478bd9Sstevel@tonic-gate char dt_errmsg[BUFSIZ]; /* buffer for formatted syntax error msgs */ 2117c478bd9Sstevel@tonic-gate const char *dt_errtag; /* tag used with last call to dt_set_errmsg() */ 2127c478bd9Sstevel@tonic-gate dt_pcb_t *dt_pcb; /* pointer to current parsing control block */ 2137c478bd9Sstevel@tonic-gate ulong_t dt_gen; /* compiler generation number */ 2147c478bd9Sstevel@tonic-gate dt_list_t dt_programs; /* linked list of dtrace_prog_t's */ 2157c478bd9Sstevel@tonic-gate dt_list_t dt_xlators; /* linked list of dt_xlator_t's */ 2161a7c1b72Smws struct dt_xlator **dt_xlatormap; /* dt_xlator_t's indexed by dx_id */ 2171a7c1b72Smws id_t dt_xlatorid; /* next dt_xlator_t id to assign */ 2187c478bd9Sstevel@tonic-gate dt_ident_t *dt_externs; /* linked list of external symbol identifiers */ 2197c478bd9Sstevel@tonic-gate dt_idhash_t *dt_macros; /* hash table of macro variable identifiers */ 2207c478bd9Sstevel@tonic-gate dt_idhash_t *dt_aggs; /* hash table of aggregation identifiers */ 2217c478bd9Sstevel@tonic-gate dt_idhash_t *dt_globals; /* hash table of global identifiers */ 2227c478bd9Sstevel@tonic-gate dt_idhash_t *dt_tls; /* hash table of thread-local identifiers */ 2237c478bd9Sstevel@tonic-gate dt_list_t dt_modlist; /* linked list of dt_module_t's */ 2247c478bd9Sstevel@tonic-gate dt_module_t **dt_mods; /* hash table of dt_module_t's */ 2257c478bd9Sstevel@tonic-gate uint_t dt_modbuckets; /* number of module hash buckets */ 2267c478bd9Sstevel@tonic-gate uint_t dt_nmods; /* number of modules in hash and list */ 2277c478bd9Sstevel@tonic-gate dt_provmod_t *dt_provmod; /* linked list of provider modules */ 2287c478bd9Sstevel@tonic-gate dt_module_t *dt_exec; /* pointer to executable module */ 2297c478bd9Sstevel@tonic-gate dt_module_t *dt_rtld; /* pointer to run-time linker module */ 2307c478bd9Sstevel@tonic-gate dt_module_t *dt_cdefs; /* pointer to C dynamic type module */ 2317c478bd9Sstevel@tonic-gate dt_module_t *dt_ddefs; /* pointer to D dynamic type module */ 2327c478bd9Sstevel@tonic-gate dt_list_t dt_provlist; /* linked list of dt_provider_t's */ 2337c478bd9Sstevel@tonic-gate struct dt_provider **dt_provs; /* hash table of dt_provider_t's */ 2347c478bd9Sstevel@tonic-gate uint_t dt_provbuckets; /* number of provider hash buckets */ 2357c478bd9Sstevel@tonic-gate uint_t dt_nprovs; /* number of providers in hash and list */ 2367c478bd9Sstevel@tonic-gate dt_proc_hash_t *dt_procs; /* hash table of grabbed process handles */ 237e5803b76SAdam H. Leventhal char **dt_proc_env; /* additional environment variables */ 2387c478bd9Sstevel@tonic-gate dt_intdesc_t dt_ints[6]; /* cached integer type descriptions */ 2397c478bd9Sstevel@tonic-gate ctf_id_t dt_type_func; /* cached CTF identifier for function type */ 2407c478bd9Sstevel@tonic-gate ctf_id_t dt_type_fptr; /* cached CTF identifier for function pointer */ 2417c478bd9Sstevel@tonic-gate ctf_id_t dt_type_str; /* cached CTF identifier for string type */ 2427c478bd9Sstevel@tonic-gate ctf_id_t dt_type_dyn; /* cached CTF identifier for <DYN> type */ 2437c478bd9Sstevel@tonic-gate ctf_id_t dt_type_stack; /* cached CTF identifier for stack type */ 244a1b5e537Sbmc ctf_id_t dt_type_symaddr; /* cached CTF identifier for _symaddr type */ 245a1b5e537Sbmc ctf_id_t dt_type_usymaddr; /* cached CTF ident. for _usymaddr type */ 2467c478bd9Sstevel@tonic-gate size_t dt_maxprobe; /* max enabled probe ID */ 2477c478bd9Sstevel@tonic-gate dtrace_eprobedesc_t **dt_edesc; /* enabled probe descriptions */ 2487c478bd9Sstevel@tonic-gate dtrace_probedesc_t **dt_pdesc; /* probe descriptions for enabled prbs */ 2497c478bd9Sstevel@tonic-gate size_t dt_maxagg; /* max aggregation ID */ 2507c478bd9Sstevel@tonic-gate dtrace_aggdesc_t **dt_aggdesc; /* aggregation descriptions */ 2517c478bd9Sstevel@tonic-gate int dt_maxformat; /* max format ID */ 2527c478bd9Sstevel@tonic-gate void **dt_formats; /* pointer to format array */ 253deef35fdSEric Schrock int dt_maxstrdata; /* max strdata ID */ 254deef35fdSEric Schrock char **dt_strdata; /* pointer to strdata array */ 2557c478bd9Sstevel@tonic-gate dt_aggregate_t dt_aggregate; /* aggregate */ 256e5803b76SAdam H. Leventhal dt_pq_t *dt_bufq; /* CPU-specific data queue */ 2577c478bd9Sstevel@tonic-gate struct dt_pfdict *dt_pfdict; /* dictionary of printf conversions */ 2587c478bd9Sstevel@tonic-gate dt_version_t dt_vmax; /* optional ceiling on program API binding */ 2597c478bd9Sstevel@tonic-gate dtrace_attribute_t dt_amin; /* optional floor on program attributes */ 2607c478bd9Sstevel@tonic-gate char *dt_cpp_path; /* pathname of cpp(1) to invoke if needed */ 2617c478bd9Sstevel@tonic-gate char **dt_cpp_argv; /* argument vector for exec'ing cpp(1) */ 2627c478bd9Sstevel@tonic-gate int dt_cpp_argc; /* count of initialized cpp(1) arguments */ 2637c478bd9Sstevel@tonic-gate int dt_cpp_args; /* size of dt_cpp_argv[] array */ 2647c478bd9Sstevel@tonic-gate char *dt_ld_path; /* pathname of ld(1) to invoke if needed */ 2657c478bd9Sstevel@tonic-gate dt_list_t dt_lib_path; /* linked-list forming library search path */ 2667c478bd9Sstevel@tonic-gate uint_t dt_lazyload; /* boolean: set via -xlazyload */ 267a1b5e537Sbmc uint_t dt_droptags; /* boolean: set via -xdroptags */ 2687c478bd9Sstevel@tonic-gate uint_t dt_active; /* boolean: set once tracing is active */ 2697c478bd9Sstevel@tonic-gate uint_t dt_stopped; /* boolean: set once tracing is stopped */ 2707c478bd9Sstevel@tonic-gate processorid_t dt_beganon; /* CPU that executed BEGIN probe (if any) */ 2717c478bd9Sstevel@tonic-gate processorid_t dt_endedon; /* CPU that executed END probe (if any) */ 2727c478bd9Sstevel@tonic-gate uint_t dt_oflags; /* dtrace open-time options (see dtrace.h) */ 2737c478bd9Sstevel@tonic-gate uint_t dt_cflags; /* dtrace compile-time options (see dtrace.h) */ 2747c478bd9Sstevel@tonic-gate uint_t dt_dflags; /* dtrace link-time options (see dtrace.h) */ 2757c478bd9Sstevel@tonic-gate uint_t dt_prcmode; /* dtrace process create mode (see dt_proc.h) */ 2767c478bd9Sstevel@tonic-gate uint_t dt_linkmode; /* dtrace symbol linking mode (see below) */ 2777c478bd9Sstevel@tonic-gate uint_t dt_linktype; /* dtrace link output file type (see below) */ 2781a7c1b72Smws uint_t dt_xlatemode; /* dtrace translator linking mode (see below) */ 2797c478bd9Sstevel@tonic-gate uint_t dt_stdcmode; /* dtrace stdc compatibility mode (see below) */ 28033093f5bSBryan Cantrill uint_t dt_encoding; /* dtrace output encoding (see below) */ 2817c478bd9Sstevel@tonic-gate uint_t dt_treedump; /* dtrace tree debug bitmap (see below) */ 2827c478bd9Sstevel@tonic-gate uint64_t dt_options[DTRACEOPT_MAX]; /* dtrace run-time options */ 2837c478bd9Sstevel@tonic-gate int dt_version; /* library version requested by client */ 2847c478bd9Sstevel@tonic-gate int dt_ctferr; /* error resulting from last CTF failure */ 2857c478bd9Sstevel@tonic-gate int dt_errno; /* error resulting from last failed operation */ 2867c478bd9Sstevel@tonic-gate int dt_fd; /* file descriptor for dtrace pseudo-device */ 2877c478bd9Sstevel@tonic-gate int dt_ftfd; /* file descriptor for fasttrap pseudo-device */ 2887c478bd9Sstevel@tonic-gate int dt_fterr; /* saved errno from failed open of dt_ftfd */ 2897c478bd9Sstevel@tonic-gate int dt_cdefs_fd; /* file descriptor for C CTF debugging cache */ 2907c478bd9Sstevel@tonic-gate int dt_ddefs_fd; /* file descriptor for D CTF debugging cache */ 2917c478bd9Sstevel@tonic-gate int dt_stdout_fd; /* file descriptor for saved stdout */ 2927c478bd9Sstevel@tonic-gate dtrace_handle_err_f *dt_errhdlr; /* error handler, if any */ 2937c478bd9Sstevel@tonic-gate void *dt_errarg; /* error handler argument */ 2947c478bd9Sstevel@tonic-gate dtrace_prog_t *dt_errprog; /* error handler program, if any */ 2957c478bd9Sstevel@tonic-gate dtrace_handle_drop_f *dt_drophdlr; /* drop handler, if any */ 2967c478bd9Sstevel@tonic-gate void *dt_droparg; /* drop handler argument */ 2977c478bd9Sstevel@tonic-gate dtrace_handle_proc_f *dt_prochdlr; /* proc handler, if any */ 2987c478bd9Sstevel@tonic-gate void *dt_procarg; /* proc handler argument */ 299a1b5e537Sbmc dtrace_handle_setopt_f *dt_setopthdlr; /* setopt handler, if any */ 300a1b5e537Sbmc void *dt_setoptarg; /* setopt handler argument */ 3017c478bd9Sstevel@tonic-gate dtrace_status_t dt_status[2]; /* status cache */ 3027c478bd9Sstevel@tonic-gate int dt_statusgen; /* current status generation */ 3037c478bd9Sstevel@tonic-gate hrtime_t dt_laststatus; /* last status */ 3047c478bd9Sstevel@tonic-gate hrtime_t dt_lastswitch; /* last switch of buffer data */ 3057c478bd9Sstevel@tonic-gate hrtime_t dt_lastagg; /* last snapshot of aggregation data */ 3067c478bd9Sstevel@tonic-gate char *dt_sprintf_buf; /* buffer for dtrace_sprintf() */ 3077c478bd9Sstevel@tonic-gate int dt_sprintf_buflen; /* length of dtrace_sprintf() buffer */ 3087c478bd9Sstevel@tonic-gate const char *dt_filetag; /* default filetag for dt_set_errmsg() */ 3097c478bd9Sstevel@tonic-gate char *dt_buffered_buf; /* buffer for buffered output */ 3107c478bd9Sstevel@tonic-gate size_t dt_buffered_offs; /* current offset into buffered buffer */ 3117c478bd9Sstevel@tonic-gate size_t dt_buffered_size; /* size of buffered buffer */ 3127c478bd9Sstevel@tonic-gate dtrace_handle_buffered_f *dt_bufhdlr; /* buffered handler, if any */ 3137c478bd9Sstevel@tonic-gate void *dt_bufarg; /* buffered handler argument */ 3147c478bd9Sstevel@tonic-gate dt_dof_t dt_dof; /* DOF generation buffers (see dt_dof.c) */ 3157c478bd9Sstevel@tonic-gate struct utsname dt_uts; /* uname(2) information for system */ 316c9d6cd77Sjhaslam dt_list_t dt_lib_dep; /* scratch linked-list of lib dependencies */ 317c9d6cd77Sjhaslam dt_list_t dt_lib_dep_sorted; /* dependency sorted library list */ 318e5803b76SAdam H. Leventhal dtrace_flowkind_t dt_flow; /* flow kind */ 319e5803b76SAdam H. Leventhal const char *dt_prefix; /* recommended flow prefix */ 320e5803b76SAdam H. Leventhal int dt_indent; /* recommended flow indent */ 321e5803b76SAdam H. Leventhal dtrace_epid_t dt_last_epid; /* most recently consumed EPID */ 322e5803b76SAdam H. Leventhal uint64_t dt_last_timestamp; /* most recently consumed timestamp */ 323*0af8f00bSMatthew Ahrens boolean_t dt_has_sugar; /* syntactic sugar used? */ 3247c478bd9Sstevel@tonic-gate }; 3257c478bd9Sstevel@tonic-gate 3267c478bd9Sstevel@tonic-gate /* 3277c478bd9Sstevel@tonic-gate * Values for the user arg of the ECB. 3287c478bd9Sstevel@tonic-gate */ 3297c478bd9Sstevel@tonic-gate #define DT_ECB_DEFAULT 0 3307c478bd9Sstevel@tonic-gate #define DT_ECB_ERROR 1 3317c478bd9Sstevel@tonic-gate 3327c478bd9Sstevel@tonic-gate /* 3337c478bd9Sstevel@tonic-gate * Values for the dt_linkmode property, which is used by the assembler when 3347c478bd9Sstevel@tonic-gate * processing external symbol references. User can set using -xlink=<mode>. 3357c478bd9Sstevel@tonic-gate */ 3367c478bd9Sstevel@tonic-gate #define DT_LINK_KERNEL 0 /* kernel syms static, user syms dynamic */ 3377c478bd9Sstevel@tonic-gate #define DT_LINK_PRIMARY 1 /* primary kernel syms static, others dynamic */ 3387c478bd9Sstevel@tonic-gate #define DT_LINK_DYNAMIC 2 /* all symbols dynamic */ 3397c478bd9Sstevel@tonic-gate #define DT_LINK_STATIC 3 /* all symbols static */ 3407c478bd9Sstevel@tonic-gate 3417c478bd9Sstevel@tonic-gate /* 3427c478bd9Sstevel@tonic-gate * Values for the dt_linktype property, which is used by dtrace_program_link() 3437c478bd9Sstevel@tonic-gate * to determine the type of output file that is desired by the client. 3447c478bd9Sstevel@tonic-gate */ 3457c478bd9Sstevel@tonic-gate #define DT_LTYP_ELF 0 /* produce ELF containing DOF */ 3467c478bd9Sstevel@tonic-gate #define DT_LTYP_DOF 1 /* produce stand-alone DOF */ 3477c478bd9Sstevel@tonic-gate 3487c478bd9Sstevel@tonic-gate /* 3491a7c1b72Smws * Values for the dt_xlatemode property, which is used to determine whether 3501a7c1b72Smws * references to dynamic translators are permitted. Set using -xlate=<mode>. 3511a7c1b72Smws */ 3521a7c1b72Smws #define DT_XL_STATIC 0 /* require xlators to be statically defined */ 3531a7c1b72Smws #define DT_XL_DYNAMIC 1 /* produce references to dynamic translators */ 3541a7c1b72Smws 3551a7c1b72Smws /* 3567c478bd9Sstevel@tonic-gate * Values for the dt_stdcmode property, which is used by the compiler when 3577c478bd9Sstevel@tonic-gate * running cpp to determine the presence and setting of the __STDC__ macro. 3587c478bd9Sstevel@tonic-gate */ 3597c478bd9Sstevel@tonic-gate #define DT_STDC_XA 0 /* ISO C + K&R C compat w/o ISO: __STDC__=0 */ 3607c478bd9Sstevel@tonic-gate #define DT_STDC_XC 1 /* Strict ISO C: __STDC__=1 */ 3617c478bd9Sstevel@tonic-gate #define DT_STDC_XS 2 /* K&R C: __STDC__ not defined */ 3627c478bd9Sstevel@tonic-gate #define DT_STDC_XT 3 /* ISO C + K&R C compat with ISO: __STDC__=0 */ 3637c478bd9Sstevel@tonic-gate 3647c478bd9Sstevel@tonic-gate /* 36533093f5bSBryan Cantrill * Values for the dt_encoding property, which is used to force a particular 36633093f5bSBryan Cantrill * character encoding (overriding default behavior and/or automatic detection). 36733093f5bSBryan Cantrill */ 36833093f5bSBryan Cantrill #define DT_ENCODING_UNSET 0 36933093f5bSBryan Cantrill #define DT_ENCODING_ASCII 1 37033093f5bSBryan Cantrill #define DT_ENCODING_UTF8 2 37133093f5bSBryan Cantrill 37233093f5bSBryan Cantrill /* 3737c478bd9Sstevel@tonic-gate * Macro to test whether a given pass bit is set in the dt_treedump bit-vector. 3747c478bd9Sstevel@tonic-gate * If the bit for pass 'p' is set, the D compiler displays the parse tree for 3757c478bd9Sstevel@tonic-gate * the program by printing it to stderr at the end of compiler pass 'p'. 3767c478bd9Sstevel@tonic-gate */ 3777c478bd9Sstevel@tonic-gate #define DT_TREEDUMP_PASS(dtp, p) ((dtp)->dt_treedump & (1 << ((p) - 1))) 3787c478bd9Sstevel@tonic-gate 3797c478bd9Sstevel@tonic-gate /* 3807c478bd9Sstevel@tonic-gate * Macros for accessing the cached CTF container and type ID for the common 3817c478bd9Sstevel@tonic-gate * types "int", "string", and <DYN>, which we need to use frequently in the D 3827c478bd9Sstevel@tonic-gate * compiler. The DT_INT_* macro relies upon "int" being at index 0 in the 3837c478bd9Sstevel@tonic-gate * _dtrace_ints_* tables in dt_open.c; the others are also set up there. 3847c478bd9Sstevel@tonic-gate */ 3857c478bd9Sstevel@tonic-gate #define DT_INT_CTFP(dtp) ((dtp)->dt_ints[0].did_ctfp) 3867c478bd9Sstevel@tonic-gate #define DT_INT_TYPE(dtp) ((dtp)->dt_ints[0].did_type) 3877c478bd9Sstevel@tonic-gate 3887c478bd9Sstevel@tonic-gate #define DT_FUNC_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp) 3897c478bd9Sstevel@tonic-gate #define DT_FUNC_TYPE(dtp) ((dtp)->dt_type_func) 3907c478bd9Sstevel@tonic-gate 3917c478bd9Sstevel@tonic-gate #define DT_FPTR_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp) 3927c478bd9Sstevel@tonic-gate #define DT_FPTR_TYPE(dtp) ((dtp)->dt_type_fptr) 3937c478bd9Sstevel@tonic-gate 3947c478bd9Sstevel@tonic-gate #define DT_STR_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp) 3957c478bd9Sstevel@tonic-gate #define DT_STR_TYPE(dtp) ((dtp)->dt_type_str) 3967c478bd9Sstevel@tonic-gate 3977c478bd9Sstevel@tonic-gate #define DT_DYN_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp) 3987c478bd9Sstevel@tonic-gate #define DT_DYN_TYPE(dtp) ((dtp)->dt_type_dyn) 3997c478bd9Sstevel@tonic-gate 4007c478bd9Sstevel@tonic-gate #define DT_STACK_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp) 4017c478bd9Sstevel@tonic-gate #define DT_STACK_TYPE(dtp) ((dtp)->dt_type_stack) 4027c478bd9Sstevel@tonic-gate 403a1b5e537Sbmc #define DT_SYMADDR_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp) 404a1b5e537Sbmc #define DT_SYMADDR_TYPE(dtp) ((dtp)->dt_type_symaddr) 405a1b5e537Sbmc 406a1b5e537Sbmc #define DT_USYMADDR_CTFP(dtp) ((dtp)->dt_ddefs->dm_ctfp) 407a1b5e537Sbmc #define DT_USYMADDR_TYPE(dtp) ((dtp)->dt_type_usymaddr) 408a1b5e537Sbmc 409a1b5e537Sbmc /* 410a1b5e537Sbmc * Actions and subroutines are both DT_NODE_FUNC nodes; to avoid confusing 411a1b5e537Sbmc * an action for a subroutine (or vice versa), we assure that the DT_ACT_* 412a1b5e537Sbmc * constants and the DIF_SUBR_* constants occupy non-overlapping ranges by 413a1b5e537Sbmc * starting the DT_ACT_* constants at DIF_SUBR_MAX + 1. 414a1b5e537Sbmc */ 415a1b5e537Sbmc #define DT_ACT_BASE DIF_SUBR_MAX + 1 416a1b5e537Sbmc #define DT_ACT(n) (DT_ACT_BASE + (n)) 417a1b5e537Sbmc 418a1b5e537Sbmc #define DT_ACT_PRINTF DT_ACT(0) /* printf() action */ 419a1b5e537Sbmc #define DT_ACT_TRACE DT_ACT(1) /* trace() action */ 420a1b5e537Sbmc #define DT_ACT_TRACEMEM DT_ACT(2) /* tracemem() action */ 421a1b5e537Sbmc #define DT_ACT_STACK DT_ACT(3) /* stack() action */ 422a1b5e537Sbmc #define DT_ACT_STOP DT_ACT(4) /* stop() action */ 423a1b5e537Sbmc #define DT_ACT_BREAKPOINT DT_ACT(5) /* breakpoint() action */ 424a1b5e537Sbmc #define DT_ACT_PANIC DT_ACT(6) /* panic() action */ 425a1b5e537Sbmc #define DT_ACT_SPECULATE DT_ACT(7) /* speculate() action */ 426a1b5e537Sbmc #define DT_ACT_COMMIT DT_ACT(8) /* commit() action */ 427a1b5e537Sbmc #define DT_ACT_DISCARD DT_ACT(9) /* discard() action */ 428a1b5e537Sbmc #define DT_ACT_CHILL DT_ACT(10) /* chill() action */ 429a1b5e537Sbmc #define DT_ACT_EXIT DT_ACT(11) /* exit() action */ 430a1b5e537Sbmc #define DT_ACT_USTACK DT_ACT(12) /* ustack() action */ 431a1b5e537Sbmc #define DT_ACT_PRINTA DT_ACT(13) /* printa() action */ 432a1b5e537Sbmc #define DT_ACT_RAISE DT_ACT(14) /* raise() action */ 433a1b5e537Sbmc #define DT_ACT_CLEAR DT_ACT(15) /* clear() action */ 434a1b5e537Sbmc #define DT_ACT_NORMALIZE DT_ACT(16) /* normalize() action */ 435a1b5e537Sbmc #define DT_ACT_DENORMALIZE DT_ACT(17) /* denormalize() action */ 436a1b5e537Sbmc #define DT_ACT_TRUNC DT_ACT(18) /* trunc() action */ 437a1b5e537Sbmc #define DT_ACT_SYSTEM DT_ACT(19) /* system() action */ 438a1b5e537Sbmc #define DT_ACT_JSTACK DT_ACT(20) /* jstack() action */ 439a1b5e537Sbmc #define DT_ACT_FTRUNCATE DT_ACT(21) /* ftruncate() action */ 440a1b5e537Sbmc #define DT_ACT_FREOPEN DT_ACT(22) /* freopen() action */ 441a1b5e537Sbmc #define DT_ACT_SYM DT_ACT(23) /* sym()/func() actions */ 442a1b5e537Sbmc #define DT_ACT_MOD DT_ACT(24) /* mod() action */ 443a1b5e537Sbmc #define DT_ACT_USYM DT_ACT(25) /* usym()/ufunc() actions */ 444a1b5e537Sbmc #define DT_ACT_UMOD DT_ACT(26) /* umod() action */ 445a1b5e537Sbmc #define DT_ACT_UADDR DT_ACT(27) /* uaddr() action */ 446a1b5e537Sbmc #define DT_ACT_SETOPT DT_ACT(28) /* setopt() action */ 447deef35fdSEric Schrock #define DT_ACT_PRINT DT_ACT(29) /* print() action */ 4487c478bd9Sstevel@tonic-gate 4497c478bd9Sstevel@tonic-gate /* 4507c478bd9Sstevel@tonic-gate * Sentinel to tell freopen() to restore the saved stdout. This must not 4517c478bd9Sstevel@tonic-gate * be ever valid for opening for write access via freopen(3C), which of 4527c478bd9Sstevel@tonic-gate * course, "." never is. 4537c478bd9Sstevel@tonic-gate */ 4547c478bd9Sstevel@tonic-gate #define DT_FREOPEN_RESTORE "." 4557c478bd9Sstevel@tonic-gate 4567c478bd9Sstevel@tonic-gate #define EDT_BASE 1000 /* base value for libdtrace errnos */ 4577c478bd9Sstevel@tonic-gate 4587c478bd9Sstevel@tonic-gate enum { 4597c478bd9Sstevel@tonic-gate EDT_VERSION = EDT_BASE, /* client is requesting unsupported version */ 4607c478bd9Sstevel@tonic-gate EDT_VERSINVAL, /* version string is invalid or overflows */ 4617c478bd9Sstevel@tonic-gate EDT_VERSUNDEF, /* requested API version is not defined */ 4627c478bd9Sstevel@tonic-gate EDT_VERSREDUCED, /* requested API version has been reduced */ 4637c478bd9Sstevel@tonic-gate EDT_CTF, /* libctf called failed (dt_ctferr has more) */ 4647c478bd9Sstevel@tonic-gate EDT_COMPILER, /* error in D program compilation */ 4657c478bd9Sstevel@tonic-gate EDT_NOTUPREG, /* tuple register allocation failure */ 4667c478bd9Sstevel@tonic-gate EDT_NOMEM, /* memory allocation failure */ 4677c478bd9Sstevel@tonic-gate EDT_INT2BIG, /* integer limit exceeded */ 4687c478bd9Sstevel@tonic-gate EDT_STR2BIG, /* string limit exceeded */ 4697c478bd9Sstevel@tonic-gate EDT_NOMOD, /* unknown module name */ 4707c478bd9Sstevel@tonic-gate EDT_NOPROV, /* unknown provider name */ 4717c478bd9Sstevel@tonic-gate EDT_NOPROBE, /* unknown probe name */ 4727c478bd9Sstevel@tonic-gate EDT_NOSYM, /* unknown symbol name */ 4737c478bd9Sstevel@tonic-gate EDT_NOSYMADDR, /* no symbol corresponds to address */ 4747c478bd9Sstevel@tonic-gate EDT_NOTYPE, /* unknown type name */ 4757c478bd9Sstevel@tonic-gate EDT_NOVAR, /* unknown variable name */ 4767c478bd9Sstevel@tonic-gate EDT_NOAGG, /* unknown aggregation name */ 4777c478bd9Sstevel@tonic-gate EDT_BADSCOPE, /* improper use of type name scoping operator */ 4787c478bd9Sstevel@tonic-gate EDT_BADSPEC, /* overspecified probe description */ 4797c478bd9Sstevel@tonic-gate EDT_BADSPCV, /* bad macro variable in probe description */ 4807c478bd9Sstevel@tonic-gate EDT_BADID, /* invalid probe identifier */ 4817c478bd9Sstevel@tonic-gate EDT_NOTLOADED, /* module is not currently loaded */ 4827c478bd9Sstevel@tonic-gate EDT_NOCTF, /* module does not contain any CTF data */ 4837c478bd9Sstevel@tonic-gate EDT_DATAMODEL, /* module and program data models don't match */ 4847c478bd9Sstevel@tonic-gate EDT_DIFVERS, /* library has newer DIF version than driver */ 4857c478bd9Sstevel@tonic-gate EDT_BADAGG, /* unrecognized aggregating action */ 4867c478bd9Sstevel@tonic-gate EDT_FIO, /* file i/o error */ 4877c478bd9Sstevel@tonic-gate EDT_DIFINVAL, /* invalid DIF program */ 4887c478bd9Sstevel@tonic-gate EDT_DIFSIZE, /* invalid DIF size */ 4897c478bd9Sstevel@tonic-gate EDT_DIFFAULT, /* failed to copyin DIF program */ 4907c478bd9Sstevel@tonic-gate EDT_BADPROBE, /* bad probe description */ 4917c478bd9Sstevel@tonic-gate EDT_BADPGLOB, /* bad probe description globbing pattern */ 4927c478bd9Sstevel@tonic-gate EDT_NOSCOPE, /* declaration scope stack underflow */ 4937c478bd9Sstevel@tonic-gate EDT_NODECL, /* declaration stack underflow */ 4947c478bd9Sstevel@tonic-gate EDT_DMISMATCH, /* record list does not match statement */ 4957c478bd9Sstevel@tonic-gate EDT_DOFFSET, /* record data offset error */ 4967c478bd9Sstevel@tonic-gate EDT_DALIGN, /* record data alignment error */ 4977c478bd9Sstevel@tonic-gate EDT_BADOPTNAME, /* invalid dtrace_setopt option name */ 4987c478bd9Sstevel@tonic-gate EDT_BADOPTVAL, /* invalid dtrace_setopt option value */ 4997c478bd9Sstevel@tonic-gate EDT_BADOPTCTX, /* invalid dtrace_setopt option context */ 5007c478bd9Sstevel@tonic-gate EDT_CPPFORK, /* failed to fork preprocessor */ 5017c478bd9Sstevel@tonic-gate EDT_CPPEXEC, /* failed to exec preprocessor */ 5027c478bd9Sstevel@tonic-gate EDT_CPPENT, /* preprocessor not found */ 5037c478bd9Sstevel@tonic-gate EDT_CPPERR, /* unknown preprocessor error */ 5047c478bd9Sstevel@tonic-gate EDT_SYMOFLOW, /* external symbol table overflow */ 5057c478bd9Sstevel@tonic-gate EDT_ACTIVE, /* operation illegal when tracing is active */ 5067c478bd9Sstevel@tonic-gate EDT_DESTRUCTIVE, /* destructive actions not allowed */ 5077c478bd9Sstevel@tonic-gate EDT_NOANON, /* no anonymous tracing state */ 5087c478bd9Sstevel@tonic-gate EDT_ISANON, /* can't claim anon state and enable probes */ 5097c478bd9Sstevel@tonic-gate EDT_ENDTOOBIG, /* END enablings exceed size of prncpl buffer */ 5107c478bd9Sstevel@tonic-gate EDT_NOCONV, /* failed to load type for printf conversion */ 5117c478bd9Sstevel@tonic-gate EDT_BADCONV, /* incomplete printf conversion */ 5127c478bd9Sstevel@tonic-gate EDT_BADERROR, /* invalid library ERROR action */ 5137c478bd9Sstevel@tonic-gate EDT_ERRABORT, /* abort due to error */ 5147c478bd9Sstevel@tonic-gate EDT_DROPABORT, /* abort due to drop */ 5157c478bd9Sstevel@tonic-gate EDT_DIRABORT, /* abort explicitly directed */ 5167c478bd9Sstevel@tonic-gate EDT_BADRVAL, /* invalid return value from callback */ 5177c478bd9Sstevel@tonic-gate EDT_BADNORMAL, /* invalid normalization */ 5187c478bd9Sstevel@tonic-gate EDT_BUFTOOSMALL, /* enabling exceeds size of buffer */ 5197c478bd9Sstevel@tonic-gate EDT_BADTRUNC, /* invalid truncation */ 5207c478bd9Sstevel@tonic-gate EDT_BUSY, /* device busy (active kernel debugger) */ 5217c478bd9Sstevel@tonic-gate EDT_ACCESS, /* insufficient privileges to use DTrace */ 522ad4023c4Sdp EDT_NOENT, /* dtrace device not available */ 5237c478bd9Sstevel@tonic-gate EDT_BRICKED, /* abort due to systemic unresponsiveness */ 5247c478bd9Sstevel@tonic-gate EDT_HARDWIRE, /* failed to load hard-wired definitions */ 5257c478bd9Sstevel@tonic-gate EDT_ELFVERSION, /* libelf is out-of-date w.r.t libdtrace */ 5267c478bd9Sstevel@tonic-gate EDT_NOBUFFERED, /* attempt to buffer output without handler */ 527a1b5e537Sbmc EDT_UNSTABLE, /* description matched unstable set of probes */ 528a1b5e537Sbmc EDT_BADSETOPT, /* invalid setopt library action */ 52930ef842dSbmc EDT_BADSTACKPC, /* invalid stack program counter size */ 53030ef842dSbmc EDT_BADAGGVAR, /* invalid aggregation variable identifier */ 531b9e93c10SJonathan Haslam EDT_OVERSION, /* client is requesting deprecated version */ 53254a20ab4SBryan Cantrill EDT_ENABLING_ERR, /* failed to enable probe */ 533a386cc11SRobert Mustacchi EDT_NOPROBES, /* no probes sites for declared provider */ 534a386cc11SRobert Mustacchi EDT_CANTLOAD /* failed to load a module */ 5357c478bd9Sstevel@tonic-gate }; 5367c478bd9Sstevel@tonic-gate 5377c478bd9Sstevel@tonic-gate /* 5387c478bd9Sstevel@tonic-gate * Interfaces for parsing and comparing DTrace attribute tuples, which describe 5397c478bd9Sstevel@tonic-gate * stability and architectural binding information. The dtrace_attribute_t 5407c478bd9Sstevel@tonic-gate * structure and associated constant definitions are found in <sys/dtrace.h>. 5417c478bd9Sstevel@tonic-gate */ 5427c478bd9Sstevel@tonic-gate extern dtrace_attribute_t dt_attr_min(dtrace_attribute_t, dtrace_attribute_t); 5437c478bd9Sstevel@tonic-gate extern dtrace_attribute_t dt_attr_max(dtrace_attribute_t, dtrace_attribute_t); 5447c478bd9Sstevel@tonic-gate extern char *dt_attr_str(dtrace_attribute_t, char *, size_t); 5457c478bd9Sstevel@tonic-gate extern int dt_attr_cmp(dtrace_attribute_t, dtrace_attribute_t); 5467c478bd9Sstevel@tonic-gate 5477c478bd9Sstevel@tonic-gate /* 5487c478bd9Sstevel@tonic-gate * Interfaces for parsing and handling DTrace version strings. Version binding 5497c478bd9Sstevel@tonic-gate * is a feature of the D compiler that is handled completely independently of 5507c478bd9Sstevel@tonic-gate * the DTrace kernel infrastructure, so the definitions are here in libdtrace. 5517c478bd9Sstevel@tonic-gate * Version strings are compiled into an encoded uint32_t which can be compared 5527c478bd9Sstevel@tonic-gate * using C comparison operators. Version definitions are found in dt_open.c. 5537c478bd9Sstevel@tonic-gate */ 5547c478bd9Sstevel@tonic-gate #define DT_VERSION_STRMAX 16 /* enough for "255.4095.4095\0" */ 5557c478bd9Sstevel@tonic-gate #define DT_VERSION_MAJMAX 0xFF /* maximum major version number */ 5567c478bd9Sstevel@tonic-gate #define DT_VERSION_MINMAX 0xFFF /* maximum minor version number */ 5577c478bd9Sstevel@tonic-gate #define DT_VERSION_MICMAX 0xFFF /* maximum micro version number */ 5587c478bd9Sstevel@tonic-gate 5597c478bd9Sstevel@tonic-gate #define DT_VERSION_NUMBER(M, m, u) \ 5607c478bd9Sstevel@tonic-gate ((((M) & 0xFF) << 24) | (((m) & 0xFFF) << 12) | ((u) & 0xFFF)) 5617c478bd9Sstevel@tonic-gate 5627c478bd9Sstevel@tonic-gate #define DT_VERSION_MAJOR(v) (((v) & 0xFF000000) >> 24) 5637c478bd9Sstevel@tonic-gate #define DT_VERSION_MINOR(v) (((v) & 0x00FFF000) >> 12) 5647c478bd9Sstevel@tonic-gate #define DT_VERSION_MICRO(v) ((v) & 0x00000FFF) 5657c478bd9Sstevel@tonic-gate 5667c478bd9Sstevel@tonic-gate extern char *dt_version_num2str(dt_version_t, char *, size_t); 5677c478bd9Sstevel@tonic-gate extern int dt_version_str2num(const char *, dt_version_t *); 5687c478bd9Sstevel@tonic-gate extern int dt_version_defined(dt_version_t); 5697c478bd9Sstevel@tonic-gate 5707c478bd9Sstevel@tonic-gate /* 5717c478bd9Sstevel@tonic-gate * Miscellaneous internal libdtrace interfaces. The definitions below are for 5727c478bd9Sstevel@tonic-gate * libdtrace routines that do not yet merit their own separate header file. 5737c478bd9Sstevel@tonic-gate */ 5747c478bd9Sstevel@tonic-gate extern char *dt_cpp_add_arg(dtrace_hdl_t *, const char *); 5757c478bd9Sstevel@tonic-gate extern char *dt_cpp_pop_arg(dtrace_hdl_t *); 5767c478bd9Sstevel@tonic-gate 5777c478bd9Sstevel@tonic-gate extern int dt_set_errno(dtrace_hdl_t *, int); 5787c478bd9Sstevel@tonic-gate extern void dt_set_errmsg(dtrace_hdl_t *, const char *, const char *, 5797c478bd9Sstevel@tonic-gate const char *, int, const char *, va_list); 5807c478bd9Sstevel@tonic-gate 5817c478bd9Sstevel@tonic-gate extern int dt_ioctl(dtrace_hdl_t *, int, void *); 5827c478bd9Sstevel@tonic-gate extern int dt_status(dtrace_hdl_t *, processorid_t); 5837c478bd9Sstevel@tonic-gate extern long dt_sysconf(dtrace_hdl_t *, int); 5847c478bd9Sstevel@tonic-gate extern ssize_t dt_write(dtrace_hdl_t *, int, const void *, size_t); 5857c478bd9Sstevel@tonic-gate extern int dt_printf(dtrace_hdl_t *, FILE *, const char *, ...); 5867c478bd9Sstevel@tonic-gate 5877c478bd9Sstevel@tonic-gate extern void *dt_zalloc(dtrace_hdl_t *, size_t); 5887c478bd9Sstevel@tonic-gate extern void *dt_alloc(dtrace_hdl_t *, size_t); 5897c478bd9Sstevel@tonic-gate extern void dt_free(dtrace_hdl_t *, void *); 5901a7c1b72Smws extern void dt_difo_free(dtrace_hdl_t *, dtrace_difo_t *); 5917c478bd9Sstevel@tonic-gate 5927c478bd9Sstevel@tonic-gate extern int dt_gmatch(const char *, const char *); 5937c478bd9Sstevel@tonic-gate extern char *dt_basename(char *); 5947c478bd9Sstevel@tonic-gate 5951a7c1b72Smws extern ulong_t dt_popc(ulong_t); 5961a7c1b72Smws extern ulong_t dt_popcb(const ulong_t *, ulong_t); 5971a7c1b72Smws 5987c478bd9Sstevel@tonic-gate extern int dt_buffered_enable(dtrace_hdl_t *); 5997c478bd9Sstevel@tonic-gate extern int dt_buffered_flush(dtrace_hdl_t *, dtrace_probedata_t *, 60030ef842dSbmc const dtrace_recdesc_t *, const dtrace_aggdata_t *, uint32_t flags); 6017c478bd9Sstevel@tonic-gate extern void dt_buffered_disable(dtrace_hdl_t *); 6027c478bd9Sstevel@tonic-gate extern void dt_buffered_destroy(dtrace_hdl_t *); 6037c478bd9Sstevel@tonic-gate 6046e0bee74Sjhaslam extern uint64_t dt_stddev(uint64_t *, uint64_t); 6056e0bee74Sjhaslam 6067c478bd9Sstevel@tonic-gate extern int dt_options_load(dtrace_hdl_t *); 6077c478bd9Sstevel@tonic-gate 6087c478bd9Sstevel@tonic-gate extern void dt_dprintf(const char *, ...); 6097c478bd9Sstevel@tonic-gate 6107c478bd9Sstevel@tonic-gate extern void dt_setcontext(dtrace_hdl_t *, dtrace_probedesc_t *); 6117c478bd9Sstevel@tonic-gate extern void dt_endcontext(dtrace_hdl_t *); 6127c478bd9Sstevel@tonic-gate 6137c478bd9Sstevel@tonic-gate extern void dt_pragma(dt_node_t *); 6147c478bd9Sstevel@tonic-gate extern int dt_reduce(dtrace_hdl_t *, dt_version_t); 6157c478bd9Sstevel@tonic-gate extern void dt_cg(dt_pcb_t *, dt_node_t *); 6167c478bd9Sstevel@tonic-gate extern dtrace_difo_t *dt_as(dt_pcb_t *); 6171a7c1b72Smws extern void dt_dis(const dtrace_difo_t *, FILE *); 6187c478bd9Sstevel@tonic-gate 6197c478bd9Sstevel@tonic-gate extern int dt_aggregate_go(dtrace_hdl_t *); 6207c478bd9Sstevel@tonic-gate extern int dt_aggregate_init(dtrace_hdl_t *); 6217c478bd9Sstevel@tonic-gate extern void dt_aggregate_destroy(dtrace_hdl_t *); 6227c478bd9Sstevel@tonic-gate 6237c478bd9Sstevel@tonic-gate extern int dt_epid_lookup(dtrace_hdl_t *, dtrace_epid_t, 6247c478bd9Sstevel@tonic-gate dtrace_eprobedesc_t **, dtrace_probedesc_t **); 6257c478bd9Sstevel@tonic-gate extern void dt_epid_destroy(dtrace_hdl_t *); 6267c478bd9Sstevel@tonic-gate extern int dt_aggid_lookup(dtrace_hdl_t *, dtrace_aggid_t, dtrace_aggdesc_t **); 6277c478bd9Sstevel@tonic-gate extern void dt_aggid_destroy(dtrace_hdl_t *); 6287c478bd9Sstevel@tonic-gate 6297c478bd9Sstevel@tonic-gate extern void *dt_format_lookup(dtrace_hdl_t *, int); 6307c478bd9Sstevel@tonic-gate extern void dt_format_destroy(dtrace_hdl_t *); 6317c478bd9Sstevel@tonic-gate 632deef35fdSEric Schrock extern const char *dt_strdata_lookup(dtrace_hdl_t *, int); 633deef35fdSEric Schrock extern void dt_strdata_destroy(dtrace_hdl_t *); 634deef35fdSEric Schrock 6357c478bd9Sstevel@tonic-gate extern int dt_print_quantize(dtrace_hdl_t *, FILE *, 6367c478bd9Sstevel@tonic-gate const void *, size_t, uint64_t); 6377c478bd9Sstevel@tonic-gate extern int dt_print_lquantize(dtrace_hdl_t *, FILE *, 6387c478bd9Sstevel@tonic-gate const void *, size_t, uint64_t); 6392b6389efSBryan Cantrill extern int dt_print_llquantize(dtrace_hdl_t *, FILE *, 6402b6389efSBryan Cantrill const void *, size_t, uint64_t); 641a1b5e537Sbmc extern int dt_print_agg(const dtrace_aggdata_t *, void *); 6427c478bd9Sstevel@tonic-gate 6437c478bd9Sstevel@tonic-gate extern int dt_handle(dtrace_hdl_t *, dtrace_probedata_t *); 6447c478bd9Sstevel@tonic-gate extern int dt_handle_liberr(dtrace_hdl_t *, 6457c478bd9Sstevel@tonic-gate const dtrace_probedata_t *, const char *); 6467c478bd9Sstevel@tonic-gate extern int dt_handle_cpudrop(dtrace_hdl_t *, processorid_t, 6477c478bd9Sstevel@tonic-gate dtrace_dropkind_t, uint64_t); 6487c478bd9Sstevel@tonic-gate extern int dt_handle_status(dtrace_hdl_t *, 6497c478bd9Sstevel@tonic-gate dtrace_status_t *, dtrace_status_t *); 650a1b5e537Sbmc extern int dt_handle_setopt(dtrace_hdl_t *, dtrace_setoptdata_t *); 6517c478bd9Sstevel@tonic-gate 652c9d6cd77Sjhaslam extern int dt_lib_depend_add(dtrace_hdl_t *, dt_list_t *, const char *); 653c9d6cd77Sjhaslam extern dt_lib_depend_t *dt_lib_depend_lookup(dt_list_t *, const char *); 654c9d6cd77Sjhaslam 6557c478bd9Sstevel@tonic-gate extern dt_pcb_t *yypcb; /* pointer to current parser control block */ 6567c478bd9Sstevel@tonic-gate extern char yyintprefix; /* int token prefix for macros (+/-) */ 6577c478bd9Sstevel@tonic-gate extern char yyintsuffix[4]; /* int token suffix ([uUlL]*) */ 6587c478bd9Sstevel@tonic-gate extern int yyintdecimal; /* int token is decimal (1) or octal/hex (0) */ 6597c478bd9Sstevel@tonic-gate extern char yytext[]; /* lex input buffer */ 6607c478bd9Sstevel@tonic-gate extern int yylineno; /* lex line number */ 6617c478bd9Sstevel@tonic-gate extern int yydebug; /* lex debugging */ 6627c478bd9Sstevel@tonic-gate extern dt_node_t *yypragma; /* lex token list for control lines */ 6637c478bd9Sstevel@tonic-gate 6647c478bd9Sstevel@tonic-gate extern const dtrace_attribute_t _dtrace_maxattr; /* maximum attributes */ 6657c478bd9Sstevel@tonic-gate extern const dtrace_attribute_t _dtrace_defattr; /* default attributes */ 6667c478bd9Sstevel@tonic-gate extern const dtrace_attribute_t _dtrace_symattr; /* symbol ref attributes */ 6677c478bd9Sstevel@tonic-gate extern const dtrace_attribute_t _dtrace_typattr; /* type ref attributes */ 6687c478bd9Sstevel@tonic-gate extern const dtrace_attribute_t _dtrace_prvattr; /* provider attributes */ 6697c478bd9Sstevel@tonic-gate extern const dtrace_pattr_t _dtrace_prvdesc; /* provider attribute bundle */ 6707c478bd9Sstevel@tonic-gate 6717c478bd9Sstevel@tonic-gate extern const dt_version_t _dtrace_versions[]; /* array of valid versions */ 6727c478bd9Sstevel@tonic-gate extern const char *const _dtrace_version; /* current version string */ 6737c478bd9Sstevel@tonic-gate 6747c478bd9Sstevel@tonic-gate extern int _dtrace_strbuckets; /* number of hash buckets for strings */ 6757c478bd9Sstevel@tonic-gate extern int _dtrace_intbuckets; /* number of hash buckets for ints */ 6767c478bd9Sstevel@tonic-gate extern uint_t _dtrace_stkindent; /* default indent for stack/ustack */ 6777c478bd9Sstevel@tonic-gate extern uint_t _dtrace_pidbuckets; /* number of hash buckets for pids */ 6787c478bd9Sstevel@tonic-gate extern uint_t _dtrace_pidlrulim; /* number of proc handles to cache */ 6797c478bd9Sstevel@tonic-gate extern int _dtrace_debug; /* debugging messages enabled */ 6807c478bd9Sstevel@tonic-gate extern size_t _dtrace_bufsize; /* default dt_buf_create() size */ 6817c478bd9Sstevel@tonic-gate extern int _dtrace_argmax; /* default maximum probe arguments */ 6827c478bd9Sstevel@tonic-gate 6837c478bd9Sstevel@tonic-gate extern const char *_dtrace_libdir; /* default library directory */ 6847c478bd9Sstevel@tonic-gate extern const char *_dtrace_moddir; /* default kernel module directory */ 6857c478bd9Sstevel@tonic-gate 6867c478bd9Sstevel@tonic-gate #ifdef __cplusplus 6877c478bd9Sstevel@tonic-gate } 6887c478bd9Sstevel@tonic-gate #endif 6897c478bd9Sstevel@tonic-gate 6907c478bd9Sstevel@tonic-gate #endif /* _DT_IMPL_H */ 691