Global class variables
Variables of global class have global scope and are visible everywhere within a Vue script. You can use a global variable in one or more clauses of a Vue script. They can also be declared at the beginning textually before the first clause for clarity. Global variables are initialized to zero or NULL as appropriate.
All variables in a Vue script are by default assigned global class, unless an explicit non-global class specifier is prefixed to the declaration. You can also explicitly declare global variables by using the __global class specifier when declaring a variable. List variables are, by definition, always created as variables of global class.
Reads and updates of global variables are not serialized unless they are of the list type. There are no guarantees on data races when probes are issued simultaneously. Global variables, which are not of the list type, are useful for collecting profiling and other statistics.
You can use global variables in the predicate section of a Vue clause.
The following scripts are examples for initializing and using global variables:
int wcount; /* Global variable declared before first clause */
@@BEGIN
{
int f_count; /* Global variable declared inside @@BEGIN */
__global int z_count; /* Global variable declared with __global prefix */
f_count = 12;
}
@@syscall:*:read:entry
when (z_count == 0)
{
int m_count; /* Global variable declared inside a probe */
m_count += f_count; /* f_count already declared in earlier probe */
printf("m_count = %d\n", m_count);
if (wcount == 1)
exit();
}
@@syscall:*:write:entry
{
m_count++; /* m_count already declared in earlier probe */
}
@@syscall:*:write:exit
{
wcount = 1; /* w_count declared globally */
}