Vue scripts

Unlike procedures in procedural languages, an action block in Vue does not have an output or return value.

Unlike procedures in procedural languages, an action block in Vue does not have an output or return value. It also does not have inherent support for a set of input parameters. On the other hand, the context data at the point where a probe is entered can be accessed within the action block. For example, the parameters passed to a function can be referenced within the action block of a Vue clause if the probe point is at the function's entry point.

Predicates

You must use predicates when execution of clauses at probe points must be performed conditionally. The predicate section is identified by the presence of the when keyword immediately after the probe specification section. The predicate itself consists of regular C-style conditional expressions with the enclosing parentheses.

A predicate has the following format:
  	when ( <condition> )
For example:
when ( __pid == 1678 )

Vue script example

The following script is an example of a Vue script:

/* Global variables are auto-initialized to zero */ [1]

	int count; /[2]
	/* 
	 * File: count.e
	 *
	 * Count number of times the read or write system call is entered
	 * by process with Id 400 
	 */

	@@BEGIN
	{
		printf("Start probing\n");
	}

	@@syscall:*:read:entry, @@syscall:*:write:entry [3]
		when (__pid == 400)[4]

	{[5]

		count++;
		/* Print a message for every 20 system calls */
		if (count % 20 == 0)
			printf("Total read/writes so far: %d\n", count);
		/* Exit when we exceed 100 system calls */
		if (count > 100)
			exit();
	} [6]

	/* print some statistics at exit */
	@@END
	{
		printf("Terminating probe after %d system calls.\n", count);
	}

The following superscripts used in the above example identify the different elements of a Vue script:

  1. Comments
  2. (Optional) Declaration section
  3. Probe specification
  4. (Optional) Predicate
  5. Start of action block
  6. End of action block

You can start this simple script by issuing the following command. Note that this example displays some sample output.

# probevue count.e
	Total read/writes so far: 20
	Total read/writes so far: 40
	Total read/writes so far: 60
	...
	...

Running the probevue command requires privileges. To issue the above command successfully, you must have logged in as the superuser or been granted privileges to probe system calls made by any process in the system.