2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 2N/A return (
ddp);
/* nothing to check if the type is not yet set */ 2N/A "long may not be used with char type\n");
2N/A "may not be used with void type\n");
2N/A "unsigned may only be used with integer type\n");
2N/A "long long may only be used with integer or " 2N/A "floating-point type\n");
2N/A "for function or associative array parameter\n");
2N/A "incorrect type specified\n");
2N/A "in a declaration\n");
2N/A * Set the kind and name of the current declaration. If none is allocated, 2N/A * make a new decl and push it on to the top of our stack. If the name or kind 2N/A * is already set for the current decl, then we need to fail this declaration. 2N/A * This can occur because too many types were given (e.g. "int int"), etc. 2N/A * If we already have a type name specified and we see another type 2N/A * name, this is an error if the declaration is a typedef. If the 2N/A * declaration is not a typedef, then the user may be trying to declare 2N/A * a variable whose name has been returned by lex as a TNAME token: 2N/A * call dt_decl_ident() as if the grammar's IDENT rule was matched. 2N/A "in a type name\n");
2N/A * Examine the list of formal parameters 'flist' and determine if the formal 2N/A * name fnp->dn_string is defined in this list (B_TRUE) or not (B_FALSE). 2N/A * If 'fnp' is in 'flist', do not search beyond 'fnp' itself in 'flist'. 2N/A * Common code for parsing array, function, and probe definition prototypes. 2N/A * The prototype node list is specified as 'plist'. The formal prototype 2N/A * against which to compare the prototype is specified as 'flist'. If plist 2N/A * and flist are the same, we require that named parameters are unique. If 2N/A * plist and flist are different, we require that named parameters in plist 2N/A * match a name that is present in flist. 2N/A "not use a variable-length argument list\n",
kind);
2N/A "use parameter of type %s: %s, parameter #%d\n",
2N/A "use parameter of type %s: %s, parameter #%d\n",
2N/A "%s declared in %s prototype: %s, parameter #%d\n",
2N/A "requires a name: parameter #%d\n", i);
2N/A return (v ? 0 : i -
1);
/* return zero if sole parameter is 'void' */ 2N/A * After pushing the array on to the decl stack, scan ahead for multi- 2N/A * dimensional array declarations and push the current decl to the 2N/A * bottom to match the resulting CTF type tree and data layout. Refer 2N/A * to the comments in dt_decl_type() and ISO C 6.5.2.1 for more info. 2N/A "cannot declare array of associative arrays\n");
2N/A "expression or tuple signature expected as " 2N/A "array declaration subscript\n");
2N/A * When a function is declared, we need to fudge the decl stack a bit if the 2N/A * declaration uses the function pointer (*)() syntax. In this case, the 2N/A * dt_decl_func() call occurs *after* the dt_decl_ptr() call, even though the 2N/A * resulting type is "pointer to function". To make the pointer land on top, 2N/A * we check to see if 'pdp' is non-NULL and a pointer. If it is, we search 2N/A * backward for a decl tagged with DT_DA_PAREN, and if one is found, the func 2N/A * decl is inserted behind this node in the decl list instead of at the top. 2N/A * In all cases, the func decl's dd_next pointer is set to the decl chain 2N/A * for the function's return type and the function parameter list is discarded. 2N/A const char *
idname =
ident ?
ident :
"(anon)";
2N/A "in a member name (%s)\n",
ident);
2N/A "cannot have dynamic member: %s\n",
ident);
2N/A n,
sizeof (n)),
ident);
2N/A * If a bit-field qualifier was part of the member declaration, create 2N/A * a new integer type of the same name and attributes as the base type 2N/A * and size equal to the specified number of bits. We reset 'dtt' to 2N/A * refer to this new bit-field type and continue on to add the member. 2N/A * A bit-field member with no declarator is permitted to have 2N/A * size zero and indicates that no more fields are to be packed 2N/A * into the current storage unit. We ignore these directives 2N/A * as the underlying ctf code currently does so for all fields. 2N/A "expression expected as bit-field size\n");
2N/A * If the member type is not defined in the same CTF container as the 2N/A * one associated with the current scope (i.e. the container for the 2N/A * struct or union itself) or its parent, copy the member type into 2N/A * this container and reset dtt to refer to the copied type. 2N/A return (
1);
/* abort search and return true if a member exists */ 2N/A "an enumerator name (%s)\n",
name);
2N/A * If the enumerator is being assigned a value, cook and check the node 2N/A * and then free it after we get the value. We also permit references 2N/A * to identifiers which are previously defined enumerators in the type. 2N/A "be assigned to an integral constant " 2N/A * If the enumerator name matches an identifier in the global scope, 2N/A * flag this as an error. We only do this for "D" enumerators to 2N/A * prevent "C" header file enumerators from conflicting with the ever- 2N/A * growing list of D built-in global variables and inlines. If a "C" 2N/A * enumerator conflicts with a global identifier, we add the enumerator 2N/A * but do not insert a corresponding inline (i.e. the D variable wins). 2N/A "identifier redeclared: %s\n",
name);
2N/A * Remove the INT node from the node allocation list and store it in 2N/A * din_list and din_root so it persists with and is freed by the ident. 2N/A * Look up the type corresponding to the specified decl stack. The scoping of 2N/A * the underlying type names is handled by dt_type_lookup(). We build up the 2N/A * name from the specified string and prefixes and then lookup the type. If 2N/A * we fail, an errmsg is saved and the caller must abort with EDT_COMPILER. 2N/A * Based on our current #include depth and decl stack depth, determine 2N/A * which dynamic CTF module and scope to use when adding any new types. 2N/A * If we have already cached a CTF type for this decl, then we just 2N/A * return the type information for the cached type. 2N/A * Currently CTF treats all function pointers identically. We cache a 2N/A * representative ID of kind CTF_K_FUNCTION and just return that type. 2N/A * If we want to support full function declarations, dd_next refers to 2N/A * the declaration of the function return type, and the parameter list 2N/A * should be parsed and hung off a new pointer inside of this decl. 2N/A * If the decl is a pointer, resolve the rest of the stack by calling 2N/A * dt_decl_type() recursively and then compute a pointer to the result. 2N/A * Similar to the code above, we return a cached id for function ptrs. 2N/A * If the decl is an array, we must find the base type and then call 2N/A * dt_decl_type() recursively and then build an array of the result. 2N/A * The C and D multi-dimensional array syntax requires that consecutive 2N/A * array declarations be processed from right-to-left (i.e. top-down 2N/A * from the perspective of the declaration stack). For example, an 2N/A * array declaration such as int x[3][5] is stored on the stack as: 2N/A * (bottom) NULL <- ( INT "int" ) <- ( ARR [3] ) <- ( ARR [5] ) (top) 2N/A * but means that x is declared to be an array of 3 objects each of 2N/A * which is an array of 5 integers, or in CTF representation: 2N/A * type T1:( content=int, nelems=5 ) type T2:( content=T1, nelems=3 ) 2N/A * For more details, refer to K&R[5.7] and ISO C 6.5.2.1. Rather than 2N/A * overcomplicate the implementation of dt_decl_type(), we push array 2N/A * declarations down into the stack in dt_decl_array(), above, so that 2N/A * by the time dt_decl_type() is called, the decl stack looks like: 2N/A * (bottom) NULL <- ( INT "int" ) <- ( ARR [5] ) <- ( ARR [3] ) (top) 2N/A * which permits a straightforward recursive descent of the decl stack 2N/A * to build the corresponding CTF type tree in the appropriate order. 2N/A * If the array decl has a parameter list associated with it, 2N/A * this is an associative array declaration: return <DYN>. 2N/A * If the array base type is not defined in the target 2N/A * container or its parent, copy the type to the target 2N/A * container and reset dtt_ctfp and dtt_type to the copy. 2N/A * The array index type is irrelevant in C and D: just set it 2N/A * to "long" for all array types that we create on-the-fly. 2N/A * Allocate space for the type name and enough space for the maximum 2N/A * additional text ("unsigned long long \0" requires 20 more bytes). 2N/A * Add dd_name unless a short, long, or long long is explicitly 2N/A * suffixed by int. We use the C/CTF canonical names for integers. 2N/A * Lookup the type. If we find it, we're done. Otherwise create a 2N/A * forward tag for the type if it is a struct, union, or enum. If 2N/A * we can't find it and we can't create a tag, return failure.