ProveVue variables

The Vue language supports most of the traditional C data types, namely those recognized by the C-89 specification. In addition, Vue includes some extensions to make powerful dynamic tracing programs be written easily.

Vue supports variables with three different scope rules:

  • Variables that are local to one action block only
  • Variables that have global scope
  • Variables that have thread-local scope

In addition, Vue can access variables with external scope like global variables in the kernel or user data in an application being probed.

In general, variables need to be declared before their first use in the script, although Vue also supports a very limited form of implicit type recognition. Variable declaration statements inside an action block must appear before any of the executable statements. They cannot be inside nested blocks like within an if statement. In some cases, you can declare variables outside any of the action blocks, but in this case, all such declarations must appear before the first action block.

Variable classes

Vue supports several classes of variables with varying rules on scope, on how they are initialized, on whether they can be updated or not and on how their types are determined. As in the C language, any declaration statement for a variable must textually precede its first use in the script.

Vue provides special type qualifiers that are added to the declaration statement to indicate the class of the variables being declared. For example, the __global keyword is a class qualifier that you can include in the declaration statement to specify that the variables being declared have "global" class.

In the following example, both foo and bar are declared to be variables of global class:

__global int foo, bar;

Vue also supports implicit recognition of the type of a variable based on its first usage in the script. In this case, there is no declaration statement, but the class of the variable can still be provided by directly attaching a class qualifier to the variable as follows on its first textual reference in the script:

global:count = 5;	/* First reference to variable count in the script */

In the preceding example, the global: keyword is a qualifier that specifies the count variable to be a variable of global class. This variable will also implicitly be assigned the int type because the first reference to it is an assignment expression whose right hand side is an integer constant.

Note: You need to use the __global keyword when specifying the class qualifier with the declaration statement, but the global: keyword when defining it at the first use of the variable in the script. The syntax rules are similar for the other class qualifiers supported by Vue.