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