From 518f6dfdd0c449edc142706a70898dd37f595cf3 Mon Sep 17 00:00:00 2001 From: ddomingo Date: Wed, 22 Oct 2008 14:22:44 +1000 Subject: more edits as per wcohen --- doc/SystemTap_Beginners_Guide/en-US/Scripts.xml | 39 ++++++++++++++++++------- 1 file changed, 29 insertions(+), 10 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 2c69057b..f35bb058 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Scripts.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Scripts.xml @@ -530,7 +530,7 @@ probe timer.jiffies(100) { count_jiffies ++ } -
+
Conditional Statements In some cases, the output of a SystemTap script may be too big. To address this, you need to further refine the script's logic in order to delimit the output into something more relevant or useful to your probe. @@ -553,17 +553,22 @@ if (condition) ifelse.stp -global foo -probe begin { foo = 1 } -probe timer.s(1) { -foo++ -if (foo<6) {printf("hello world\n")} -else {printf("goodbye world\n")} +global countread, countnonread +probe vfs.read,vfs.write +{ + if (probefunc()=="vfs_read") { + countread ++ } + else {countnonread ++} } +probe timer.s(5) { + exit()} +probe end { + printf("VFS reads total %d\n VFS writes total %d\n", countread, countnonread)} - is a script that prints hello world if less than 6 seconds has passed. If more than 6 seconds have passed, it prints goodbye world instead. + is a script that counts how many virtual file system reads (vfs.read) and writes (vfs.write) the system performs within a 5-second span. When run, the script increments the value of the variable countread by 1 if the name of the function it probed matches vfs_read (as noted by the condition if (probefunc()=="vfs_read")); otherwise, it increments countnonread (else {countnonread ++}). + @@ -573,8 +578,22 @@ else {printf("goodbye world\n")} Format: while (condition) {handler} - - + + -- cgit