Exit class variables
Clauses associated with a probe point that is at the exit location points of a system call or user function can access the return value of the system call or user function.
There is only one exit class variable that is defined by the Vue language. This is the return value from a function or a system call, which can be accessed by using the special built-in variable name __rv.
Probes at exit location points are supported by the system call probe manager. For example, the read system call returns the actual number of bytes read or an error return code of -1. This returned value can be accessed at the @@syscall:*:read:exit probe point, which identifies all exit points from the read system call.
Similar to entry class variables, the use of exit class variables in a Vue clause is legal only if the probe specification associated with the clause identifies a unique probe point. Thus, __rv cannot be used in a Vue clause that has multiple probe points specified in the probe specification. Furthermore, the C-style declaration of the function being probed, specifically the data type of the return value, must be explicitly provided in the Vue script. In fact, it is an error to specify a function declaration without providing its return type.
You can use exit class variables in the predicate section of a clause.
The following script is an illegal script and will cause the ProbeVue compiler to fail with a syntax error since the return type of the read function is not specified:
/* Bad example. */
int read(int fd, char *buf, unsigned long size);
@@syscall:*:read:exit
when (__rv > 0)
{
/* Entered on read success: return value = # of bytes read */
printf("Number of bytes read = %d\n", __rv);
}
The following modified script can work:
/* Good example. */
int read(int fd, char *buf, unsigned long size);
@@syscall:*:read:exit
when (__rv > 0)
{
/* Entered on read success: return value = # of bytes read */
printf("Number of bytes read = %d\n", __rv);
}