From fc03e8e8d406640d6dfa73f9e3890086c9bfb75f Mon Sep 17 00:00:00 2001 From: ddomingo Date: Tue, 28 Oct 2008 14:04:21 +1000 Subject: changes as per wcohen, minor additions --- .../en-US/ScriptConstructs.xml | 63 ++++++++++++++++------ 1 file changed, 46 insertions(+), 17 deletions(-) (limited to 'doc/SystemTap_Beginners_Guide/en-US/ScriptConstructs.xml') diff --git a/doc/SystemTap_Beginners_Guide/en-US/ScriptConstructs.xml b/doc/SystemTap_Beginners_Guide/en-US/ScriptConstructs.xml index 42054cb9..b1f40669 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/ScriptConstructs.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/ScriptConstructs.xml @@ -47,9 +47,7 @@ probe timer.jiffies(100) { count_jiffies ++ } In some cases, such as in , a variable may be declared without any specific value as yet. You need to declare such values as integers using the notation ++. --> - - - +
Conditional Statements @@ -74,20 +72,21 @@ if (condition) ifelse.stp global countread, countnonread -probe vfs.read,vfs.write +probe kernel.function("vfs_read"),kernel.function("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)} +probe timer.s(5) { exit() } +probe end +{ + printf("VFS reads total %d\n VFS writes total %d\n", countread, countnonread) +} - 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 ++}). + 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 ++}). @@ -103,11 +102,11 @@ while (condition) {statement while.stp -global foo -probe timer.s(1) { -foo ++ -while (foo<6) {printf("hello world\n")} -printf("goodbye world\n") +global foo +probe timer.s(1) { +foo ++ +while (foo<6) {printf("hello world\n")} +printf("goodbye world\n") @@ -137,10 +136,40 @@ for (argument1; argument2; --> - -These constructs are better illustrated in the different examples available in . + + +need simple, simple examples for FOR and WHILE + + + Conditional Operators +Aside from == ("is equal to"), you can also use the following operators in your conditional statements: + + + + + + >= + + Greater than or equal to + + + + + <= + + Less than or equal to + + + + + != + + Is not equal to + + -will get back to these ones later +
Command-Line Arguments -- cgit