Elements of C
Vue supports a subset of C.
The following table describes how the support the ProbeVue compiler provides for the specified C keywords. All C keywords remain restricted in Vue. Use of any of these keywords as variable names or other symbols is not flagged as a syntax error, however, the behavior of such usage is undefined.
Note: The keywords in the second column can be present in type or structure definitions or function
declarations. The Vue compiler ignores them. However,
these keywords must not be applied when declaring Vue
script variables.
Supported | Allowed in header files or in declaration section | Unsupported |
---|---|---|
char | auto | break |
double | const | case |
else | extern | continue |
enum | register | default |
float | static | do |
if | typedef | for |
int | volatile | goto |
long | switch | |
return | while | |
short | ||
signed | ||
sizeof | ||
struct | ||
union | ||
unsigned | ||
void |
The following list describes the set of C features that Vue supports:
- Statements
- All C statements except for loop and some control flow statements.
- Operators
- All C unary, binary, and ternary operators except for the comma operator. Operator precedence and associativity follows C language rules.
- Data types
- Most legal C-89 defined variable types including all statements and keywords (struct, union,
enum, typedef, and so on) for declaring types subject to the restrictions. This includes the types
for kernel or application variables and parameters. Note: Vue has its own rules on scope and storage classes.
- Type conversions
- Implicit type conversions as well as explicit conversions with type casts.
- Subroutine
- The syntax for calling subroutines and passing parameters to functions. There are, however, restrictions on what functions can be called.
- Variable names
- The naming conventions for variables follow C identifier rules. The complete variable specification can include colons if a variable class name is prefixed to the variable name.
- Header files
- Header files can be included for explicitly declaring the types of kernel global variables or the prototypes of functions in applications and the kernel. There are some restrictions on how the header files are included.
- Punctuators
- All C punctuators are supported and their rules are enforced. Thus, statements must be separated by the semicolon (;) character. All C white space rules are followed.
- Literals
- Representation of strings (using double quotes characters(")), character literals (using single quotes characters (')), octal and hexadecimal integers, and special characters like the \n and \t escape sequences.
- Comments
- C-style and C++-style comments. Comments can appear both inside and outside of a clause. Any line starting with a # character is ignored. Avoid using the character to indicate a comment line.
Differences from the C language
Vue has a different behavior for some C features. Some restrictions are imposed for maintaining efficiency or for ensuring that a Vue script can be issued safely inside the kernel and that it does not affect the probed process.
- Loop statements
- Loop statements are not accepted by a Vue script. This is a precaution to prevent any Vue probe from never completing.
- Conditional flow statements
- Only the "if-else" style control flow statement is accepted by a Vue script. Most conditional logic flow can be achieved through the proper use of "if" statements. Predicates are a more efficient way to do high-level conditional logic in a Vue script.
- Return statement
- The return statement is accepted by Vue to signal that the execution of the action block is to be ended immediately. However, the return statement does not take any expressions in Vue, as the Vue action block has no return values.
- Subroutines
- Vue scripts do not have access to the functions provided by the AIX system or general user libraries. There is no support for creating archives (libraries of functions) or user functions callable from within the probes. Instead, a special internal library is available for you that provide a set of functions generally useful for dynamic tracing programs.
- Floating point
- Floating-point variables are not accepted by any clause associated with a kernel probe point. You can only use floating-point variables in simple assignment statements and as parameters to Vue functions that print data. Vue language support for floating-point variables is restricted to its capture.
- Variable modifications
- External variables are not accepted by the left-hand side of an assignment statement, that is, they cannot be modified in a Vue script.
- Header files
- Vue does not support an explicit inclusion of the header file in the Vue script itself. Instead, the name of a header file to be included must be passed through command line arguments to the probevue command. Any C-preprocessor operators or directives in the header file are ignored. This might cause unexpected behavior. To avoid this, hand-code the header file or explicitly run the C-preprocessor directly on the set of relevant header files and generate a post-processed header file for inclusion. You can include the function prototypes and structure or union definitions in the Vue script itself if they are inserted at the very beginning before starting any of the probe clauses.
- C-preprocessor
- C-preprocessor operators, macro definitions, line or pragma directives and pre-defined macro names are ignored.
- Pointer operations
- Vue does not accept pointers to script variables. For example, the address of a script variable cannot be taken. However, the address of a kernel variable can be taken and assigned to a Vue pointer variable and pointer operations supported using the pointer variable.
- Miscellaneous
-
- Trigraphs are not accepted.
- The comma operator is not accepted.
- Declaration statements cannot contain any initialization.