From e9a2c05304d28c9f8d249eca323cbe507dcbdd32 Mon Sep 17 00:00:00 2001 From: ddomingo Date: Tue, 21 Oct 2008 16:25:00 +1000 Subject: minor changes throughout, esp in Scripts.xml --- doc/SystemTap_Beginners_Guide/en-US/Scripts.xml | 43 ++++++++++++++++++---- .../en-US/Useful_Scripts-inodewatch2.xml | 2 +- .../en-US/Useful_Scripts-paracallgraph.xml | 2 +- 3 files changed, 37 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 ced4d698..2c69057b 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Scripts.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Scripts.xml @@ -512,18 +512,30 @@ probe timer.ms(12345) Note - 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 ++. + The ++ notation in (i.e. count_jiffies ++ and count_ms ++) is used to increment the value of a variable by 1. In the following probe, count_jiffies is incremented by 1 every 100 jiffies: + +probe timer.jiffies(100) { count_jiffies ++ } + + In this instance, SystemTap understands that count_jiffies is an integer. Because no initial value was assigned to count_jiffies, its initial value is zero by default. + + - + +
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. - + You can do this by using conditionals in handlers. SystemTap accepts the following types of conditional statements: @@ -535,8 +547,23 @@ You can do this by using conditionals in handlers. SystemTa Format: if (condition) - {handler} [else {handler}] + {handler} else {handler} + + + + 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")} +} + + + 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. @@ -575,11 +602,11 @@ for (argument1; argument2; These constructs are better illustrated in the different examples available in . will get back to these ones later - - +
+
Command-Line Arguments You can also allow a SystemTap script to accept simple command-line arguments and declare them in the script without using target(). One way to do this is to use the variable notation $ or @. - + commandlineargs.stp @@ -601,4 +628,4 @@ probe kernel.function(@1).return { }
--> - + diff --git a/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-inodewatch2.xml b/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-inodewatch2.xml index 300029cc..28dbcf75 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-inodewatch2.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-inodewatch2.xml @@ -22,7 +22,7 @@ no script in examples inodewatch2.stp -global ATTR_MODE = 1 # .... +global ATTR_MODE = 1 probe kernel.function("inode_setattr") { dev_nr = $inode->i_sb->s_dev diff --git a/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-paracallgraph.xml b/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-paracallgraph.xml index 3540a2c4..8547a235 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-paracallgraph.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Useful_Scripts-paracallgraph.xml @@ -50,7 +50,7 @@ probe kernel.function(@2).return { trace(-1) } A trigger function (@1), which enables or disables tracing on a per-thread basis. - The probe function whose entry/exit you'd like to trace (@2). + The kernel function whose entry/exit call you'd like to trace (@2). please verify previous if correct; i'm particularly interested in finding out how to better describe "trigger function" -- cgit