10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 50Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 60Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 70Sstevel@tonic-gate * with the License. 80Sstevel@tonic-gate * 90Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate * See the License for the specific language governing permissions 120Sstevel@tonic-gate * and limitations under the License. 130Sstevel@tonic-gate * 140Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate * 200Sstevel@tonic-gate * CDDL HEADER END 210Sstevel@tonic-gate */ 220Sstevel@tonic-gate /* 230Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #ifndef _DT_IDENT_H 280Sstevel@tonic-gate #define _DT_IDENT_H 290Sstevel@tonic-gate 300Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 310Sstevel@tonic-gate 320Sstevel@tonic-gate #include <libctf.h> 330Sstevel@tonic-gate #include <dtrace.h> 340Sstevel@tonic-gate 350Sstevel@tonic-gate #ifdef __cplusplus 360Sstevel@tonic-gate extern "C" { 370Sstevel@tonic-gate #endif 380Sstevel@tonic-gate 390Sstevel@tonic-gate #include <dt_list.h> 400Sstevel@tonic-gate 410Sstevel@tonic-gate struct dt_node; 420Sstevel@tonic-gate struct dt_ident; 430Sstevel@tonic-gate struct dt_idhash; 440Sstevel@tonic-gate struct dt_irlist; 450Sstevel@tonic-gate struct dt_regset; 460Sstevel@tonic-gate 470Sstevel@tonic-gate typedef struct dt_idsig { 480Sstevel@tonic-gate int dis_varargs; /* argument index of start of varargs (or -1) */ 490Sstevel@tonic-gate int dis_optargs; /* argument index of start of optargs (or -1) */ 500Sstevel@tonic-gate int dis_argc; /* number of types in this signature */ 510Sstevel@tonic-gate struct dt_node *dis_args; /* array of nodes representing formal types */ 52*1017Sbmc uint64_t dis_auxinfo; /* auxiliary signature information, if any */ 530Sstevel@tonic-gate } dt_idsig_t; 540Sstevel@tonic-gate 550Sstevel@tonic-gate typedef struct dt_idnode { 560Sstevel@tonic-gate struct dt_node *din_list; /* allocation list for parse tree nodes */ 570Sstevel@tonic-gate struct dt_node *din_root; /* root of this identifier's parse tree */ 580Sstevel@tonic-gate struct dt_idhash *din_hash; /* identifiers private to this subtree */ 590Sstevel@tonic-gate struct dt_ident **din_argv; /* identifiers in din_hash for arguments */ 600Sstevel@tonic-gate int din_argc; /* length of din_argv[] array */ 610Sstevel@tonic-gate } dt_idnode_t; 620Sstevel@tonic-gate 630Sstevel@tonic-gate typedef struct dt_idops { 640Sstevel@tonic-gate void (*di_cook)(struct dt_node *, struct dt_ident *, 650Sstevel@tonic-gate int, struct dt_node *); 660Sstevel@tonic-gate void (*di_dtor)(struct dt_ident *); 670Sstevel@tonic-gate size_t (*di_size)(struct dt_ident *); 680Sstevel@tonic-gate } dt_idops_t; 690Sstevel@tonic-gate 700Sstevel@tonic-gate typedef struct dt_ident { 710Sstevel@tonic-gate char *di_name; /* identifier name */ 720Sstevel@tonic-gate ushort_t di_kind; /* identifier kind (see below) */ 730Sstevel@tonic-gate ushort_t di_flags; /* identifier flags (see below) */ 740Sstevel@tonic-gate uint_t di_id; /* variable or subr id (see <sys/dtrace.h>) */ 750Sstevel@tonic-gate dtrace_attribute_t di_attr; /* identifier stability attributes */ 760Sstevel@tonic-gate uint_t di_vers; /* identifier version number (dt_version_t) */ 770Sstevel@tonic-gate const dt_idops_t *di_ops; /* identifier's class-specific ops vector */ 780Sstevel@tonic-gate void *di_iarg; /* initial argument pointer for ops vector */ 790Sstevel@tonic-gate void *di_data; /* private data pointer for ops vector */ 800Sstevel@tonic-gate ctf_file_t *di_ctfp; /* CTF container for the variable data type */ 810Sstevel@tonic-gate ctf_id_t di_type; /* CTF identifier for the variable data type */ 820Sstevel@tonic-gate struct dt_ident *di_next; /* pointer to next ident in hash chain */ 830Sstevel@tonic-gate ulong_t di_gen; /* generation number (pass that created me) */ 840Sstevel@tonic-gate int di_lineno; /* line number that defined this identifier */ 850Sstevel@tonic-gate } dt_ident_t; 860Sstevel@tonic-gate 870Sstevel@tonic-gate #define DT_IDENT_ARRAY 0 /* identifier is an array variable */ 880Sstevel@tonic-gate #define DT_IDENT_SCALAR 1 /* identifier is a scalar variable */ 890Sstevel@tonic-gate #define DT_IDENT_PTR 2 /* identifier is a magic pointer */ 900Sstevel@tonic-gate #define DT_IDENT_FUNC 3 /* identifier is a built-in function */ 910Sstevel@tonic-gate #define DT_IDENT_AGG 4 /* identifier is an aggregation */ 920Sstevel@tonic-gate #define DT_IDENT_AGGFUNC 5 /* identifier is an aggregating function */ 930Sstevel@tonic-gate #define DT_IDENT_ACTFUNC 6 /* identifier is an action function */ 940Sstevel@tonic-gate #define DT_IDENT_XLSOU 7 /* identifier is a translated struct or union */ 950Sstevel@tonic-gate #define DT_IDENT_XLPTR 8 /* identifier is a translated pointer */ 960Sstevel@tonic-gate #define DT_IDENT_SYMBOL 9 /* identifier is an external symbol */ 970Sstevel@tonic-gate #define DT_IDENT_ENUM 10 /* identifier is an enumerator */ 980Sstevel@tonic-gate #define DT_IDENT_PRAGAT 11 /* identifier is #pragma attributes */ 990Sstevel@tonic-gate #define DT_IDENT_PRAGBN 12 /* identifier is #pragma binding */ 1000Sstevel@tonic-gate #define DT_IDENT_PROBE 13 /* identifier is a probe definition */ 1010Sstevel@tonic-gate 1020Sstevel@tonic-gate #define DT_IDFLG_TLS 0x0001 /* variable is thread-local storage */ 1030Sstevel@tonic-gate #define DT_IDFLG_LOCAL 0x0002 /* variable is local storage */ 1040Sstevel@tonic-gate #define DT_IDFLG_WRITE 0x0004 /* variable is writable (can be modified) */ 1050Sstevel@tonic-gate #define DT_IDFLG_INLINE 0x0008 /* variable is an inline definition */ 1060Sstevel@tonic-gate #define DT_IDFLG_REF 0x0010 /* variable is referenced by this program */ 1070Sstevel@tonic-gate #define DT_IDFLG_MOD 0x0020 /* variable is modified by this program */ 1080Sstevel@tonic-gate #define DT_IDFLG_DIFR 0x0040 /* variable is referenced by current DIFO */ 1090Sstevel@tonic-gate #define DT_IDFLG_DIFW 0x0080 /* variable is modified by current DIFO */ 1100Sstevel@tonic-gate #define DT_IDFLG_CGREG 0x0100 /* variable is inlined by code generator */ 1110Sstevel@tonic-gate #define DT_IDFLG_USER 0x0200 /* variable is associated with userland */ 1120Sstevel@tonic-gate #define DT_IDFLG_PRIM 0x0400 /* variable is associated with primary object */ 1130Sstevel@tonic-gate #define DT_IDFLG_DECL 0x0800 /* variable is associated with explicit decl */ 1140Sstevel@tonic-gate #define DT_IDFLG_ORPHAN 0x1000 /* variable is in a dt_node and not dt_idhash */ 1150Sstevel@tonic-gate 1160Sstevel@tonic-gate typedef struct dt_idhash { 1170Sstevel@tonic-gate dt_list_t dh_list; /* list prev/next pointers for dt_idstack */ 1180Sstevel@tonic-gate const char *dh_name; /* name of this hash table */ 1190Sstevel@tonic-gate void (*dh_defer)(struct dt_idhash *, dt_ident_t *); /* defer callback */ 1200Sstevel@tonic-gate const dt_ident_t *dh_tmpl; /* template for initial ident population */ 1210Sstevel@tonic-gate uint_t dh_nextid; /* next id to be returned by idhash_nextid() */ 1220Sstevel@tonic-gate uint_t dh_minid; /* min id to be returned by idhash_nextid() */ 1230Sstevel@tonic-gate uint_t dh_maxid; /* max id to be returned by idhash_nextid() */ 1240Sstevel@tonic-gate ulong_t dh_nelems; /* number of identifiers in hash table */ 1250Sstevel@tonic-gate ulong_t dh_hashsz; /* number of entries in dh_buckets array */ 1260Sstevel@tonic-gate dt_ident_t *dh_hash[1]; /* array of hash table bucket pointers */ 1270Sstevel@tonic-gate } dt_idhash_t; 1280Sstevel@tonic-gate 1290Sstevel@tonic-gate typedef struct dt_idstack { 1300Sstevel@tonic-gate dt_list_t dids_list; /* list meta-data for dt_idhash_t stack */ 1310Sstevel@tonic-gate } dt_idstack_t; 1320Sstevel@tonic-gate 1330Sstevel@tonic-gate extern const dt_idops_t dt_idops_assc; /* associative array or aggregation */ 1340Sstevel@tonic-gate extern const dt_idops_t dt_idops_func; /* function call built-in */ 1350Sstevel@tonic-gate extern const dt_idops_t dt_idops_args; /* args[] built-in */ 1360Sstevel@tonic-gate extern const dt_idops_t dt_idops_regs; /* regs[]/uregs[] built-in */ 1370Sstevel@tonic-gate extern const dt_idops_t dt_idops_type; /* predefined type name string */ 1380Sstevel@tonic-gate extern const dt_idops_t dt_idops_thaw; /* prefrozen type identifier */ 1390Sstevel@tonic-gate extern const dt_idops_t dt_idops_inline; /* inline variable */ 1400Sstevel@tonic-gate extern const dt_idops_t dt_idops_probe; /* probe definition */ 1410Sstevel@tonic-gate 1420Sstevel@tonic-gate extern dt_idhash_t *dt_idhash_create(const char *, const dt_ident_t *, 1430Sstevel@tonic-gate uint_t, uint_t); 1440Sstevel@tonic-gate extern void dt_idhash_destroy(dt_idhash_t *); 1450Sstevel@tonic-gate extern void dt_idhash_update(dt_idhash_t *); 1460Sstevel@tonic-gate extern dt_ident_t *dt_idhash_lookup(dt_idhash_t *, const char *); 1470Sstevel@tonic-gate extern int dt_idhash_nextid(dt_idhash_t *, uint_t *); 1480Sstevel@tonic-gate extern ulong_t dt_idhash_size(const dt_idhash_t *); 1490Sstevel@tonic-gate extern const char *dt_idhash_name(const dt_idhash_t *); 1500Sstevel@tonic-gate 1510Sstevel@tonic-gate extern dt_ident_t *dt_idhash_insert(dt_idhash_t *, const char *, ushort_t, 1520Sstevel@tonic-gate ushort_t, uint_t, dtrace_attribute_t, uint_t, 1530Sstevel@tonic-gate const dt_idops_t *, void *, ulong_t); 1540Sstevel@tonic-gate 1550Sstevel@tonic-gate extern void dt_idhash_xinsert(dt_idhash_t *, dt_ident_t *); 1560Sstevel@tonic-gate extern void dt_idhash_delete(dt_idhash_t *, dt_ident_t *); 1570Sstevel@tonic-gate 1580Sstevel@tonic-gate typedef int dt_idhash_f(dt_idhash_t *, dt_ident_t *, void *); 1590Sstevel@tonic-gate extern int dt_idhash_iter(dt_idhash_t *, dt_idhash_f *, void *); 1600Sstevel@tonic-gate 1610Sstevel@tonic-gate extern dt_ident_t *dt_idstack_lookup(dt_idstack_t *, const char *); 1620Sstevel@tonic-gate extern void dt_idstack_push(dt_idstack_t *, dt_idhash_t *); 1630Sstevel@tonic-gate extern void dt_idstack_pop(dt_idstack_t *, dt_idhash_t *); 1640Sstevel@tonic-gate 1650Sstevel@tonic-gate extern dt_ident_t *dt_ident_create(const char *, ushort_t, ushort_t, uint_t, 1660Sstevel@tonic-gate dtrace_attribute_t, uint_t, const dt_idops_t *, void *, ulong_t); 1670Sstevel@tonic-gate extern void dt_ident_destroy(dt_ident_t *); 1680Sstevel@tonic-gate extern void dt_ident_morph(dt_ident_t *, ushort_t, const dt_idops_t *, void *); 1690Sstevel@tonic-gate extern dtrace_attribute_t dt_ident_cook(struct dt_node *, 1700Sstevel@tonic-gate dt_ident_t *, struct dt_node **); 1710Sstevel@tonic-gate 1720Sstevel@tonic-gate extern void dt_ident_type_assign(dt_ident_t *, ctf_file_t *, ctf_id_t); 1730Sstevel@tonic-gate extern dt_ident_t *dt_ident_resolve(dt_ident_t *); 1740Sstevel@tonic-gate extern size_t dt_ident_size(dt_ident_t *); 1750Sstevel@tonic-gate extern int dt_ident_unref(const dt_ident_t *); 1760Sstevel@tonic-gate 1770Sstevel@tonic-gate extern const char *dt_idkind_name(uint_t); 1780Sstevel@tonic-gate 1790Sstevel@tonic-gate #ifdef __cplusplus 1800Sstevel@tonic-gate } 1810Sstevel@tonic-gate #endif 1820Sstevel@tonic-gate 1830Sstevel@tonic-gate #endif /* _DT_IDENT_H */ 184