条目类变量

与系统调用或用户函数入口位置点处的探针点相关联的子句可访问传送到正被探测的系统调用或函数的参数。

系统调用和用户函数跟踪探针管理器支持入口位置点处的调查。 例如,read 系统调用采用三个参数:文件描述符标识、用户缓冲区指针和要读取的数据字节数值。 如果调查规范是 @@syscall:*:read:entry(指定 read 系统调用入口点处的调查),那么可访问这三个参数的值。

使用特殊内置条目类变量名 __arg1__arg2来引用函数的参数。 __arg3, ... 最多为传递给函数的自变量数。 例如,在与 read 系统调用入口点相关联的子句中,__arg1 引用文件描述符标识参数的值,__arg2 引用缓冲区指针参数的值,而 __arg3 引用要读取的数据的大小。
注: When one or more probe point tuples are specified, then __arg <x> variables are not allowed in the Action Block and will result in error as shown in the example below.
@@syscall:*:read:entry,@@syscall:*:write:entry
{
        char *argument;        
        argument=__arg2;  -> Not Allowed.
}
将存在具有下列错误消息的 Probevue:arg builtin 不能使用。 未定义函数

仅当 Vue 脚本中还提供了正在探测的函数的 C 样式声明 (尤其是传递给该函数的参数的数据类型) 时,在 Vue 子句中使用条目类变量才合法。 这必须以文本形式出现在引用条目子句的第一个 Vue 子句之前。 将声明以文本方式放在 Vue 脚本顶部的任何 Vue 子句之前。

以下脚本是使用入口类变量的示例:

	int read(int fd, char *buf, unsigned long size);

	@@syscall:*:read:entry 
	{
		printf("Number of bytes to read = %d\n", __arg3);
	}
注: 在前面的示例中,脚本中指定的读系统调用函数的定义与 /usr/include/unistd.h 文件中给出的定义不完全匹配,但它也同样有效。

第二个要求就是与子句相关联的调查规范标识唯一的探针点。 不能在具有探针规范中指定的多个探针点的 Vue 子句中使用条目类变量,而不考虑所探测的函数是相同还是具有相似的函数原型。 以下脚本是非法脚本,将导致 ProbeVue 编译器失败并产生语法错误,因为探测器规范包含两个探测器点:

	int read(int fd, char *buf, unsigned long size);
	int write(int fd, char *buf, unsigned long size);

	@@syscall:*:read:entry, @@syscall:*:write:entry 
	{
		/* Cannot use __arg3 in here, as this clause has multiple probe 
		 * points associated with it. This script will fail with a
		 * syntax error in the compilation phase of the probevue command.
		 */
		printf("Number of bytes to read/write = %d\n", __arg3);
	}

以下修改后的脚本有效:

	int read(int fd, char *buf, unsigned long size);
	int write(int fd, char *buf, unsigned long size);

	@@syscall:*:read:entry
	{
		printf("Number of bytes to read = %d\n", __arg3);
	}
	@@syscall:*:write:entry 
	{
		printf("Number of bytes to write = %d\n", __arg3);
	}