1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _DT_IDENT_H 28*7c478bd9Sstevel@tonic-gate #define _DT_IDENT_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #include <libctf.h> 33*7c478bd9Sstevel@tonic-gate #include <dtrace.h> 34*7c478bd9Sstevel@tonic-gate 35*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 36*7c478bd9Sstevel@tonic-gate extern "C" { 37*7c478bd9Sstevel@tonic-gate #endif 38*7c478bd9Sstevel@tonic-gate 39*7c478bd9Sstevel@tonic-gate #include <dt_list.h> 40*7c478bd9Sstevel@tonic-gate 41*7c478bd9Sstevel@tonic-gate struct dt_node; 42*7c478bd9Sstevel@tonic-gate struct dt_ident; 43*7c478bd9Sstevel@tonic-gate struct dt_idhash; 44*7c478bd9Sstevel@tonic-gate struct dt_irlist; 45*7c478bd9Sstevel@tonic-gate struct dt_regset; 46*7c478bd9Sstevel@tonic-gate 47*7c478bd9Sstevel@tonic-gate typedef struct dt_idsig { 48*7c478bd9Sstevel@tonic-gate int dis_varargs; /* argument index of start of varargs (or -1) */ 49*7c478bd9Sstevel@tonic-gate int dis_optargs; /* argument index of start of optargs (or -1) */ 50*7c478bd9Sstevel@tonic-gate int dis_argc; /* number of types in this signature */ 51*7c478bd9Sstevel@tonic-gate struct dt_node *dis_args; /* array of nodes representing formal types */ 52*7c478bd9Sstevel@tonic-gate } dt_idsig_t; 53*7c478bd9Sstevel@tonic-gate 54*7c478bd9Sstevel@tonic-gate typedef struct dt_idnode { 55*7c478bd9Sstevel@tonic-gate struct dt_node *din_list; /* allocation list for parse tree nodes */ 56*7c478bd9Sstevel@tonic-gate struct dt_node *din_root; /* root of this identifier's parse tree */ 57*7c478bd9Sstevel@tonic-gate struct dt_idhash *din_hash; /* identifiers private to this subtree */ 58*7c478bd9Sstevel@tonic-gate struct dt_ident **din_argv; /* identifiers in din_hash for arguments */ 59*7c478bd9Sstevel@tonic-gate int din_argc; /* length of din_argv[] array */ 60*7c478bd9Sstevel@tonic-gate } dt_idnode_t; 61*7c478bd9Sstevel@tonic-gate 62*7c478bd9Sstevel@tonic-gate typedef struct dt_idops { 63*7c478bd9Sstevel@tonic-gate void (*di_cook)(struct dt_node *, struct dt_ident *, 64*7c478bd9Sstevel@tonic-gate int, struct dt_node *); 65*7c478bd9Sstevel@tonic-gate void (*di_dtor)(struct dt_ident *); 66*7c478bd9Sstevel@tonic-gate size_t (*di_size)(struct dt_ident *); 67*7c478bd9Sstevel@tonic-gate } dt_idops_t; 68*7c478bd9Sstevel@tonic-gate 69*7c478bd9Sstevel@tonic-gate typedef struct dt_ident { 70*7c478bd9Sstevel@tonic-gate char *di_name; /* identifier name */ 71*7c478bd9Sstevel@tonic-gate ushort_t di_kind; /* identifier kind (see below) */ 72*7c478bd9Sstevel@tonic-gate ushort_t di_flags; /* identifier flags (see below) */ 73*7c478bd9Sstevel@tonic-gate uint_t di_id; /* variable or subr id (see <sys/dtrace.h>) */ 74*7c478bd9Sstevel@tonic-gate dtrace_attribute_t di_attr; /* identifier stability attributes */ 75*7c478bd9Sstevel@tonic-gate uint_t di_vers; /* identifier version number (dt_version_t) */ 76*7c478bd9Sstevel@tonic-gate const dt_idops_t *di_ops; /* identifier's class-specific ops vector */ 77*7c478bd9Sstevel@tonic-gate void *di_iarg; /* initial argument pointer for ops vector */ 78*7c478bd9Sstevel@tonic-gate void *di_data; /* private data pointer for ops vector */ 79*7c478bd9Sstevel@tonic-gate ctf_file_t *di_ctfp; /* CTF container for the variable data type */ 80*7c478bd9Sstevel@tonic-gate ctf_id_t di_type; /* CTF identifier for the variable data type */ 81*7c478bd9Sstevel@tonic-gate struct dt_ident *di_next; /* pointer to next ident in hash chain */ 82*7c478bd9Sstevel@tonic-gate ulong_t di_gen; /* generation number (pass that created me) */ 83*7c478bd9Sstevel@tonic-gate int di_lineno; /* line number that defined this identifier */ 84*7c478bd9Sstevel@tonic-gate } dt_ident_t; 85*7c478bd9Sstevel@tonic-gate 86*7c478bd9Sstevel@tonic-gate #define DT_IDENT_ARRAY 0 /* identifier is an array variable */ 87*7c478bd9Sstevel@tonic-gate #define DT_IDENT_SCALAR 1 /* identifier is a scalar variable */ 88*7c478bd9Sstevel@tonic-gate #define DT_IDENT_PTR 2 /* identifier is a magic pointer */ 89*7c478bd9Sstevel@tonic-gate #define DT_IDENT_FUNC 3 /* identifier is a built-in function */ 90*7c478bd9Sstevel@tonic-gate #define DT_IDENT_AGG 4 /* identifier is an aggregation */ 91*7c478bd9Sstevel@tonic-gate #define DT_IDENT_AGGFUNC 5 /* identifier is an aggregating function */ 92*7c478bd9Sstevel@tonic-gate #define DT_IDENT_ACTFUNC 6 /* identifier is an action function */ 93*7c478bd9Sstevel@tonic-gate #define DT_IDENT_XLSOU 7 /* identifier is a translated struct or union */ 94*7c478bd9Sstevel@tonic-gate #define DT_IDENT_XLPTR 8 /* identifier is a translated pointer */ 95*7c478bd9Sstevel@tonic-gate #define DT_IDENT_SYMBOL 9 /* identifier is an external symbol */ 96*7c478bd9Sstevel@tonic-gate #define DT_IDENT_ENUM 10 /* identifier is an enumerator */ 97*7c478bd9Sstevel@tonic-gate #define DT_IDENT_PRAGAT 11 /* identifier is #pragma attributes */ 98*7c478bd9Sstevel@tonic-gate #define DT_IDENT_PRAGBN 12 /* identifier is #pragma binding */ 99*7c478bd9Sstevel@tonic-gate #define DT_IDENT_PROBE 13 /* identifier is a probe definition */ 100*7c478bd9Sstevel@tonic-gate 101*7c478bd9Sstevel@tonic-gate #define DT_IDFLG_TLS 0x0001 /* variable is thread-local storage */ 102*7c478bd9Sstevel@tonic-gate #define DT_IDFLG_LOCAL 0x0002 /* variable is local storage */ 103*7c478bd9Sstevel@tonic-gate #define DT_IDFLG_WRITE 0x0004 /* variable is writable (can be modified) */ 104*7c478bd9Sstevel@tonic-gate #define DT_IDFLG_INLINE 0x0008 /* variable is an inline definition */ 105*7c478bd9Sstevel@tonic-gate #define DT_IDFLG_REF 0x0010 /* variable is referenced by this program */ 106*7c478bd9Sstevel@tonic-gate #define DT_IDFLG_MOD 0x0020 /* variable is modified by this program */ 107*7c478bd9Sstevel@tonic-gate #define DT_IDFLG_DIFR 0x0040 /* variable is referenced by current DIFO */ 108*7c478bd9Sstevel@tonic-gate #define DT_IDFLG_DIFW 0x0080 /* variable is modified by current DIFO */ 109*7c478bd9Sstevel@tonic-gate #define DT_IDFLG_CGREG 0x0100 /* variable is inlined by code generator */ 110*7c478bd9Sstevel@tonic-gate #define DT_IDFLG_USER 0x0200 /* variable is associated with userland */ 111*7c478bd9Sstevel@tonic-gate #define DT_IDFLG_PRIM 0x0400 /* variable is associated with primary object */ 112*7c478bd9Sstevel@tonic-gate #define DT_IDFLG_DECL 0x0800 /* variable is associated with explicit decl */ 113*7c478bd9Sstevel@tonic-gate #define DT_IDFLG_ORPHAN 0x1000 /* variable is in a dt_node and not dt_idhash */ 114*7c478bd9Sstevel@tonic-gate 115*7c478bd9Sstevel@tonic-gate typedef struct dt_idhash { 116*7c478bd9Sstevel@tonic-gate dt_list_t dh_list; /* list prev/next pointers for dt_idstack */ 117*7c478bd9Sstevel@tonic-gate const char *dh_name; /* name of this hash table */ 118*7c478bd9Sstevel@tonic-gate void (*dh_defer)(struct dt_idhash *, dt_ident_t *); /* defer callback */ 119*7c478bd9Sstevel@tonic-gate const dt_ident_t *dh_tmpl; /* template for initial ident population */ 120*7c478bd9Sstevel@tonic-gate uint_t dh_nextid; /* next id to be returned by idhash_nextid() */ 121*7c478bd9Sstevel@tonic-gate uint_t dh_minid; /* min id to be returned by idhash_nextid() */ 122*7c478bd9Sstevel@tonic-gate uint_t dh_maxid; /* max id to be returned by idhash_nextid() */ 123*7c478bd9Sstevel@tonic-gate ulong_t dh_nelems; /* number of identifiers in hash table */ 124*7c478bd9Sstevel@tonic-gate ulong_t dh_hashsz; /* number of entries in dh_buckets array */ 125*7c478bd9Sstevel@tonic-gate dt_ident_t *dh_hash[1]; /* array of hash table bucket pointers */ 126*7c478bd9Sstevel@tonic-gate } dt_idhash_t; 127*7c478bd9Sstevel@tonic-gate 128*7c478bd9Sstevel@tonic-gate typedef struct dt_idstack { 129*7c478bd9Sstevel@tonic-gate dt_list_t dids_list; /* list meta-data for dt_idhash_t stack */ 130*7c478bd9Sstevel@tonic-gate } dt_idstack_t; 131*7c478bd9Sstevel@tonic-gate 132*7c478bd9Sstevel@tonic-gate extern const dt_idops_t dt_idops_assc; /* associative array or aggregation */ 133*7c478bd9Sstevel@tonic-gate extern const dt_idops_t dt_idops_func; /* function call built-in */ 134*7c478bd9Sstevel@tonic-gate extern const dt_idops_t dt_idops_args; /* args[] built-in */ 135*7c478bd9Sstevel@tonic-gate extern const dt_idops_t dt_idops_regs; /* regs[]/uregs[] built-in */ 136*7c478bd9Sstevel@tonic-gate extern const dt_idops_t dt_idops_type; /* predefined type name string */ 137*7c478bd9Sstevel@tonic-gate extern const dt_idops_t dt_idops_thaw; /* prefrozen type identifier */ 138*7c478bd9Sstevel@tonic-gate extern const dt_idops_t dt_idops_inline; /* inline variable */ 139*7c478bd9Sstevel@tonic-gate extern const dt_idops_t dt_idops_probe; /* probe definition */ 140*7c478bd9Sstevel@tonic-gate 141*7c478bd9Sstevel@tonic-gate extern dt_idhash_t *dt_idhash_create(const char *, const dt_ident_t *, 142*7c478bd9Sstevel@tonic-gate uint_t, uint_t); 143*7c478bd9Sstevel@tonic-gate extern void dt_idhash_destroy(dt_idhash_t *); 144*7c478bd9Sstevel@tonic-gate extern void dt_idhash_update(dt_idhash_t *); 145*7c478bd9Sstevel@tonic-gate extern dt_ident_t *dt_idhash_lookup(dt_idhash_t *, const char *); 146*7c478bd9Sstevel@tonic-gate extern int dt_idhash_nextid(dt_idhash_t *, uint_t *); 147*7c478bd9Sstevel@tonic-gate extern ulong_t dt_idhash_size(const dt_idhash_t *); 148*7c478bd9Sstevel@tonic-gate extern const char *dt_idhash_name(const dt_idhash_t *); 149*7c478bd9Sstevel@tonic-gate 150*7c478bd9Sstevel@tonic-gate extern dt_ident_t *dt_idhash_insert(dt_idhash_t *, const char *, ushort_t, 151*7c478bd9Sstevel@tonic-gate ushort_t, uint_t, dtrace_attribute_t, uint_t, 152*7c478bd9Sstevel@tonic-gate const dt_idops_t *, void *, ulong_t); 153*7c478bd9Sstevel@tonic-gate 154*7c478bd9Sstevel@tonic-gate extern void dt_idhash_xinsert(dt_idhash_t *, dt_ident_t *); 155*7c478bd9Sstevel@tonic-gate extern void dt_idhash_delete(dt_idhash_t *, dt_ident_t *); 156*7c478bd9Sstevel@tonic-gate 157*7c478bd9Sstevel@tonic-gate typedef int dt_idhash_f(dt_idhash_t *, dt_ident_t *, void *); 158*7c478bd9Sstevel@tonic-gate extern int dt_idhash_iter(dt_idhash_t *, dt_idhash_f *, void *); 159*7c478bd9Sstevel@tonic-gate 160*7c478bd9Sstevel@tonic-gate extern dt_ident_t *dt_idstack_lookup(dt_idstack_t *, const char *); 161*7c478bd9Sstevel@tonic-gate extern void dt_idstack_push(dt_idstack_t *, dt_idhash_t *); 162*7c478bd9Sstevel@tonic-gate extern void dt_idstack_pop(dt_idstack_t *, dt_idhash_t *); 163*7c478bd9Sstevel@tonic-gate 164*7c478bd9Sstevel@tonic-gate extern dt_ident_t *dt_ident_create(const char *, ushort_t, ushort_t, uint_t, 165*7c478bd9Sstevel@tonic-gate dtrace_attribute_t, uint_t, const dt_idops_t *, void *, ulong_t); 166*7c478bd9Sstevel@tonic-gate extern void dt_ident_destroy(dt_ident_t *); 167*7c478bd9Sstevel@tonic-gate extern void dt_ident_morph(dt_ident_t *, ushort_t, const dt_idops_t *, void *); 168*7c478bd9Sstevel@tonic-gate extern dtrace_attribute_t dt_ident_cook(struct dt_node *, 169*7c478bd9Sstevel@tonic-gate dt_ident_t *, struct dt_node **); 170*7c478bd9Sstevel@tonic-gate 171*7c478bd9Sstevel@tonic-gate extern void dt_ident_type_assign(dt_ident_t *, ctf_file_t *, ctf_id_t); 172*7c478bd9Sstevel@tonic-gate extern dt_ident_t *dt_ident_resolve(dt_ident_t *); 173*7c478bd9Sstevel@tonic-gate extern size_t dt_ident_size(dt_ident_t *); 174*7c478bd9Sstevel@tonic-gate extern int dt_ident_unref(const dt_ident_t *); 175*7c478bd9Sstevel@tonic-gate 176*7c478bd9Sstevel@tonic-gate extern const char *dt_idkind_name(uint_t); 177*7c478bd9Sstevel@tonic-gate 178*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 179*7c478bd9Sstevel@tonic-gate } 180*7c478bd9Sstevel@tonic-gate #endif 181*7c478bd9Sstevel@tonic-gate 182*7c478bd9Sstevel@tonic-gate #endif /* _DT_IDENT_H */ 183