</section>
<section id="arrayops-readvalues">
<title>Reading Values From Arrays</title>
- <para>You can also use the <command>=</command> operator to read values from an array. This is accomplished by simply including the <command><replaceable>array_name</replaceable>[<replaceable>index_expression</replaceable>]</command> as an element in a mathematical expression. For example:</para>
+ <para>You can also read values from an array the same way you would read the value of a variable.
+ To do so, include the
+ <command><replaceable>array_name</replaceable>[<replaceable>index_expression</replaceable>]</command>
+ statement as an element in a mathematical expression. For example:</para>
+<!--
+ <para>You can also use the <command>=</command> operator to read values from an array. This is accomplished by simply including the <command><replaceable>array_name</replaceable>[<replaceable>index_expression</replaceable>]</command> as an element in a mathematical expression. For example:</para>-->
<example id="arrayreadingvaluesfrom">
<title>Using Array Values in Simple Computations</title>
foreach (count in reads+)
printf("%s : %d \n", count, reads[count])
if(reads["stapio"] >= 20)
- {exit()}
+ {
+ exit()
+ }
}
</programlisting>
</example>
foreach (count in reads+)
printf("%s : %d \n", count, reads[count])
if(["stapio"] in reads)
- {printf("stapio read detected, exiting\n")
+ {
+ printf("stapio read detected, exiting\n")
exit()
}
}
<listitem><para><filename>kernel-devel</filename></para></listitem>
</itemizedlist>
+ <para>
+ Likewise, the necessary packages for the PAE kernel would be
+ <filename>kernel-PAE-debuginfo</filename>, <filename>kernel-PAE-debuginfo-common</filename>,
+ and <filename>kernel-PAE-devel</filename>.
+ </para>
+
+
+
<para> To determine what kernel your system is currently using, use:</para>
<screen>
<title>Important</title>
<para>
- The version and architecture of the <filename>-devel</filename>, <filename>-debuginfo</filename> and <filename>-debuginfo-common</filename> packages must match the kernel you wish to probe with SystemTap <emphasis>exactly</emphasis>.
+ The version, variant, and architecture of the <filename>-devel</filename>, <filename>-debuginfo</filename> and <filename>-debuginfo-common</filename> packages must match the kernel you wish to probe with SystemTap <emphasis>exactly</emphasis>.
</para>
</important>
<para>
- To help ease your deployment of SystemTap, you can use <xref linkend="stapprep"/>. You can use <xref linkend="stapprep"/> to detemine the kernel information packages you need to install in order to run SystemTap. If you run <xref linkend="stapprep"/> (as an ordinary, non-root user) without any arguments, it will display the kernel information packages required for the <emphasis>loaded</emphasis> kernel. You can also pass a specific kernel version to <xref linkend="stapprep"/> (e.g. <computeroutput>2.6.18-92.el5</computeroutput>) if you wish to probe a kernel that is not currently loaded.
+ To help ease your deployment of SystemTap, you can use <xref linkend="stapprep"/>.
+ <xref linkend="stapprep"/> determines the kernel information packages you need to install in order
+ to run SystemTap. If you run <xref linkend="stapprep"/> (as an ordinary, non-root user) without
+ any arguments, it will display the kernel information packages required for the
+ <emphasis>loaded</emphasis> kernel. You can also pass a specific kernel version to
+ <xref linkend="stapprep"/> (e.g. <computeroutput>2.6.18-92.el5</computeroutput>) if you wish
+ to probe a kernel that is not currently loaded.
</para>
<note>
</para>-->
<screen>
-Pass 1: parsed user script and 45 library script(s) in 340usr/0sys/358real ms.\r
-Pass 2: analyzed script: 1 probe(s), 1 function(s), 0 embed(s), 0 global(s) in 290usr/260sys/568real ms.\r
-Pass 3: translated to C into "/tmp/stapiArgLX/stap_e5886fa50499994e6a87aacdc43cd392_399.c" in 490usr/430sys/938real ms.\r
-Pass 4: compiled C into "stap_e5886fa50499994e6a87aacdc43cd392_399.ko" in 3310usr/430sys/3714real ms.\r
-Pass 5: starting run.\r
-read performed\r
-Pass 5: run completed in 10usr/40sys/73real ms.\r
+Pass 1: parsed user script and 45 library script(s) in 340usr/0sys/358real ms.
+Pass 2: analyzed script: 1 probe(s), 1 function(s), 0 embed(s), 0 global(s) in 290usr/260sys/568real ms.
+Pass 3: translated to C into "/tmp/stapiArgLX/stap_e5886fa50499994e6a87aacdc43cd392_399.c" in 490usr/430sys/938real ms.
+Pass 4: compiled C into "stap_e5886fa50499994e6a87aacdc43cd392_399.ko" in 3310usr/430sys/3714real ms.
+Pass 5: starting run.
+read performed
+Pass 5: run completed in 10usr/40sys/73real ms.
</screen>
<para> The last three lines of the output (i.e. beginning with
<example id="simpleifelseexample">
<title>ifelse.stp</title>
<programlisting>
-global countread, countnonread\r
-probe kernel.function("vfs_read"),kernel.function("vfs_write")\r
-{\r
- if (probefunc()=="vfs_read") {\r
- countread ++ }\r
- else {countnonread ++}\r
-}\r
-probe timer.s(5) { exit() }\r
-probe end \r
-{\r
- printf("VFS reads total %d\n VFS writes total %d\n", countread, countnonread)\r
-}\r
+global countread, countnonread
+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)
+}
+
</programlisting>
</example>
<term>stapdev</term>
<listitem>
<para>
- Members of this group can use <command>stap</command> to run SystemTap scripts, or <command>staprun</command> to run SystemTap instrumentation modules.
+ Members of this group can use <command>stap</command> to run SystemTap scripts, or <command>staprun</command> to run SystemTap instrumentation modules.
+</para>
+
+
+<para>
+ Running <command>stap</command> involves compiling SystemTap scripts into kernel modules and
+ loading them into the kernel. This requires elevated privileges to the system, which are granted
+ to <command>stapdev</command> members. Unfortunately, such privileges also grant effective root
+ access to <command>stapdev</command> members. As such, you should only grant
+ <command>stapdev</command> group membership to users whom you can trust root access.
</para>
+
</listitem>
</varlistentry>