From 986ad45b8bdbe661a44da48cae26977d923fa47d Mon Sep 17 00:00:00 2001 From: ddomingo Date: Mon, 6 Oct 2008 16:17:03 +1000 Subject: added target(), -c and -x to functions, also added Basic Constructs (conditional statements and variables) --- doc/SystemTap_Beginners_Guide/en-US/Scripts.xml | 131 +++++++++++++++++++-- .../en-US/Using_SystemTap.xml | 13 ++ 2 files changed, 134 insertions(+), 10 deletions(-) (limited to 'doc/SystemTap_Beginners_Guide') diff --git a/doc/SystemTap_Beginners_Guide/en-US/Scripts.xml b/doc/SystemTap_Beginners_Guide/en-US/Scripts.xml index b928372b..4abd81a5 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Scripts.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Scripts.xml @@ -76,7 +76,7 @@ probe event, The entry to the kernel function function. For example, kernel.function("sys_open") refers to the "event" that occurs when the kernel function sys_open is called by any thread in the system. To specify the return of the kernel function sys_open, append the return string to the event statement; i.e. kernel.function("sys_open").return. When defining functions, you can use asterisk (*) for wildcards. You can also trace the entry or exit of a function in a kernel source file. Consider the following example: -Wildcards and Kernel Source Files in an Event +wildcards.stp probe kernel.function("*@net/socket.c") { } probe kernel.function("*@net/socket.c").return { } @@ -101,11 +101,11 @@ probe kernel.function("*@net/socket.c").return { } Allows you to probe functions within modules. For example: - Module Probe - - probe module("ext3").function("*") { } - probe module("ext3").function("*").return { } - +moduleprobe.stp + +probe module("ext3").function("*") { } +probe module("ext3").function("*").return { } + @@ -152,7 +152,7 @@ probe kernel.function("*@net/socket.c").return { } An event that specifies a handler to be executed every specified period of time. For example: -Using timer.ms +timer-ms.stp probe timer.ms(4000) { @@ -224,7 +224,7 @@ probe timer.ms(4000) Consider the following sample script: -Hello World +helloworld.stp probe begin { @@ -269,7 +269,7 @@ printf ("format string\n", argument - Using Variables In printf ( ) Statements + variables-in-printf-statements.stp # This probe will need to be manually terminated with Ctrl-C probe syscall.open @@ -368,7 +368,7 @@ hald(2360) open Consider the following example on the use of thread_indent(): -Using thread_indent() +thread_indent.stp probe kernel.function("*@net/socket.c") { @@ -405,6 +405,41 @@ probe kernel.function("*@net/socket.c").return + + + name + + Identifies the name of a specific system call. + + + + + target() + + Used in conjunction with stap script -x process ID or stap script -c command. If you want to specify a script to take an argument of a process ID or command, use target() as the variable in the script to refer to it. For example: + + + targetexample.stp + +probe syscall.* { + if (pid() == target()) { + printf("%s/n", name) + }} + + + + When is run with the argument -x process ID, it watches all system calls (as specified by the event syscall.*) and prints out the name of all system calls made by the specified process. + + This has the same effect as specifying if (pid() == process ID each time you wish to target a specific process. However, using target() makes it easier for you to re-use the script, giving you the ability to simply pass a process ID as an argument each time you wish to run the script (i.e. stap allsyscalls.stp -x process ID). + + + + + + + + + + + +