From 63265337e2b74c4a34fb9b4d67d0a695c88e7d5e Mon Sep 17 00:00:00 2001 From: ddomingo Date: Wed, 10 Sep 2008 16:25:23 +1000 Subject: added new content for Understanding, events --- doc/SystemTap_Beginners_Guide/en-US/Scripts.xml | 106 ++++++++++++++++++++++-- 1 file changed, 99 insertions(+), 7 deletions(-) (limited to 'doc/SystemTap_Beginners_Guide/en-US/Scripts.xml') diff --git a/doc/SystemTap_Beginners_Guide/en-US/Scripts.xml b/doc/SystemTap_Beginners_Guide/en-US/Scripts.xml index abb087bc..24ab8a83 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Scripts.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Scripts.xml @@ -6,7 +6,7 @@ SystemTap Scripts - For the most part, SystemTap scripts are the foundation of each SystemTap session. The SystemTap scripts you use or write yourself instruct SystemTap on what type of information to trap, and what to do once that information is trapped. + For the most part, SystemTap scripts are the foundation of each SystemTap session. SystemTap scripts instruct SystemTap on what type of information to trap, and what to do once that information is trapped. @@ -15,7 +15,7 @@ Note - An event and its corresponding handler is collectively called a probe. A SystemTap script can have multiple probes, in the same manner that each event can have multiple corresponding handlers. + An event and its corresponding handler is collectively called a probe. A SystemTap script can have multiple probes. @@ -26,13 +26,105 @@ SystemTap scripts go one step further by allowing you more flexibility with regard to handlers. Events serve as the triggers for handlers to run; handlers can be specified to trap specified data and print it in a certain manner. + + Format + + SystemTap scripts use the file extension .stp, and are written in the following format: + + + +probe [event], +[another event] + +{ + [handler] + + exit() +} + + The exit() condition is optional, but it is recommended since it safely terminates the session once the script successfully traps the required information. + + Important + + is designed to introduce readers to the basics of SystemTap scripts. To understand SystemTap scripts better, it is advisable that you refer to ; each section therein provides a detailed explanation of the script, its events, handlers, and expected output. + + +
+ Events + + + SystemTap supports multiple events per probe; as shown in , multiple events are delimited by a comma (,). Sample [event]s include: + + + + + begin + + The startup of a SystemTap session; i.e. as soon as the SystemTap script is run. + + + + + end + + The end of a SystemTap session. + + + + + kernel.function("[function]") + + The entry to the kernel function function. For example, kernel.function("sys_open") refers to the "event" that the kernel function sys_open is used. 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/exit of a function in a kernel source file. Consider the following example: +Wildcards and Kernel Source Files in an Event + +probe kernel.function("*@net/socket.c") { } +probe kernel.function("*@net/socket.c").return { } + + + +In the previous example, the first probe's event specifies the entry of ALL functions in the kernel source file net/socket.c. The second probe specifies the exit of all those functions. Note that in this example, no handler was specified; as such, no information will be displayed. + + + + + syscall.[system_call] + + The entry to the system call [system_call]. Similar to kerne.function, appending a return to the statement specifies the exit of the system call. For example, to specify the entry of the system call close, use syscall.close.return. + + To identify what system calls are made by a specific program/command, use strace command. + + + + + + + +
+ +
+ Handlers + + + SystemTap supports a wide variety of functions that can trap data when triggered by events. One way to display these functions is to use the print() + + + + -
- Format - - SystemTap scripts use the following format: -