1178479Sjb/* 2178479Sjb * CDDL HEADER START 3178479Sjb * 4178479Sjb * The contents of this file are subject to the terms of the 5178479Sjb * Common Development and Distribution License, Version 1.0 only 6178479Sjb * (the "License"). You may not use this file except in compliance 7178479Sjb * with the License. 8178479Sjb * 9178479Sjb * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10178479Sjb * or http://www.opensolaris.org/os/licensing. 11178479Sjb * See the License for the specific language governing permissions 12178479Sjb * and limitations under the License. 13178479Sjb * 14178479Sjb * When distributing Covered Code, include this CDDL HEADER in each 15178479Sjb * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16178479Sjb * If applicable, add the following below this CDDL HEADER, with the 17178479Sjb * fields enclosed by brackets "[]" replaced with your own identifying 18178479Sjb * information: Portions Copyright [yyyy] [name of copyright owner] 19178479Sjb * 20178479Sjb * CDDL HEADER END 21178479Sjb */ 22178479Sjb/* 23178479Sjb * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24178479Sjb * Use is subject to license terms. 25178479Sjb */ 26267941Srpaulo/* 27267941Srpaulo * Copyright (c) 2013 by Delphix. All rights reserved. 28267941Srpaulo * Copyright (c) 2013 Joyent, Inc. All rights reserved. 29267941Srpaulo */ 30178479Sjb 31178479Sjb#ifndef _DT_DECL_H 32178479Sjb#define _DT_DECL_H 33178479Sjb 34178479Sjb#include <sys/types.h> 35178479Sjb#include <libctf.h> 36178479Sjb#include <dtrace.h> 37178479Sjb#include <stdio.h> 38178479Sjb 39178479Sjb#ifdef __cplusplus 40178479Sjbextern "C" { 41178479Sjb#endif 42178479Sjb 43178479Sjbstruct dt_node; /* forward declaration of dt_node_t */ 44178479Sjb 45178479Sjbtypedef struct dt_decl { 46178479Sjb ushort_t dd_kind; /* declaration kind (CTF_K_* kind) */ 47178479Sjb ushort_t dd_attr; /* attributes (DT_DA_* flags) */ 48178479Sjb ctf_file_t *dd_ctfp; /* CTF container for decl's type */ 49178479Sjb ctf_id_t dd_type; /* CTF identifier for decl's type */ 50178479Sjb char *dd_name; /* string name of this decl (or NULL) */ 51178479Sjb struct dt_node *dd_node; /* node for array size or parm list */ 52178479Sjb struct dt_decl *dd_next; /* next declaration in list */ 53178479Sjb} dt_decl_t; 54178479Sjb 55178479Sjb#define DT_DA_SIGNED 0x0001 /* signed integer value */ 56178479Sjb#define DT_DA_UNSIGNED 0x0002 /* unsigned integer value */ 57178479Sjb#define DT_DA_SHORT 0x0004 /* short integer value */ 58178479Sjb#define DT_DA_LONG 0x0008 /* long integer or double */ 59178479Sjb#define DT_DA_LONGLONG 0x0010 /* long long integer value */ 60178479Sjb#define DT_DA_CONST 0x0020 /* qualify type as const */ 61178479Sjb#define DT_DA_RESTRICT 0x0040 /* qualify type as restrict */ 62178479Sjb#define DT_DA_VOLATILE 0x0080 /* qualify type as volatile */ 63178479Sjb#define DT_DA_PAREN 0x0100 /* parenthesis tag */ 64267941Srpaulo#define DT_DA_USER 0x0200 /* user-land type specifier */ 65178479Sjb 66178479Sjbtypedef enum dt_dclass { 67178479Sjb DT_DC_DEFAULT, /* no storage class specified */ 68178479Sjb DT_DC_AUTO, /* automatic storage */ 69178479Sjb DT_DC_REGISTER, /* register storage */ 70178479Sjb DT_DC_STATIC, /* static storage */ 71178479Sjb DT_DC_EXTERN, /* extern storage */ 72178479Sjb DT_DC_TYPEDEF, /* type definition */ 73178479Sjb DT_DC_SELF, /* thread-local storage */ 74178479Sjb DT_DC_THIS /* clause-local storage */ 75178479Sjb} dt_dclass_t; 76178479Sjb 77178479Sjbtypedef struct dt_scope { 78178479Sjb dt_decl_t *ds_decl; /* pointer to top of decl stack */ 79178479Sjb struct dt_scope *ds_next; /* pointer to next scope */ 80178479Sjb char *ds_ident; /* identifier for this scope (if any) */ 81178479Sjb ctf_file_t *ds_ctfp; /* CTF container for this scope */ 82178479Sjb ctf_id_t ds_type; /* CTF id of enclosing type */ 83178479Sjb dt_dclass_t ds_class; /* declaration class for this scope */ 84178479Sjb int ds_enumval; /* most recent enumerator value */ 85178479Sjb} dt_scope_t; 86178479Sjb 87178479Sjbextern dt_decl_t *dt_decl_alloc(ushort_t, char *); 88178479Sjbextern void dt_decl_free(dt_decl_t *); 89178479Sjbextern void dt_decl_reset(void); 90178479Sjbextern dt_decl_t *dt_decl_push(dt_decl_t *); 91178479Sjbextern dt_decl_t *dt_decl_pop(void); 92178479Sjbextern dt_decl_t *dt_decl_pop_param(char **); 93178479Sjbextern dt_decl_t *dt_decl_top(void); 94178479Sjb 95178479Sjbextern dt_decl_t *dt_decl_ident(char *); 96178479Sjbextern void dt_decl_class(dt_dclass_t); 97178479Sjb 98178479Sjb#define DT_DP_VARARGS 0x1 /* permit varargs in prototype */ 99178479Sjb#define DT_DP_DYNAMIC 0x2 /* permit dynamic type in prototype */ 100178479Sjb#define DT_DP_VOID 0x4 /* permit void type in prototype */ 101178479Sjb#define DT_DP_ANON 0x8 /* permit anonymous parameters */ 102178479Sjb 103178479Sjbextern int dt_decl_prototype(struct dt_node *, struct dt_node *, 104178479Sjb const char *, uint_t); 105178479Sjb 106178479Sjbextern dt_decl_t *dt_decl_spec(ushort_t, char *); 107178479Sjbextern dt_decl_t *dt_decl_attr(ushort_t); 108178479Sjbextern dt_decl_t *dt_decl_array(struct dt_node *); 109178479Sjbextern dt_decl_t *dt_decl_func(dt_decl_t *, struct dt_node *); 110178479Sjbextern dt_decl_t *dt_decl_ptr(void); 111178479Sjb 112178479Sjbextern dt_decl_t *dt_decl_sou(uint_t, char *); 113178479Sjbextern void dt_decl_member(struct dt_node *); 114178479Sjb 115178479Sjbextern dt_decl_t *dt_decl_enum(char *); 116178479Sjbextern void dt_decl_enumerator(char *, struct dt_node *); 117178479Sjb 118178479Sjbextern int dt_decl_type(dt_decl_t *, dtrace_typeinfo_t *); 119178479Sjb 120178479Sjbextern void dt_scope_create(dt_scope_t *); 121178479Sjbextern void dt_scope_destroy(dt_scope_t *); 122178479Sjbextern void dt_scope_push(ctf_file_t *, ctf_id_t); 123178479Sjbextern dt_decl_t *dt_scope_pop(void); 124178479Sjb 125178479Sjb#ifdef __cplusplus 126178479Sjb} 127178479Sjb#endif 128178479Sjb 129178479Sjb#endif /* _DT_DECL_H */ 130