Sophie

Sophie

distrib > Fedora > 13 > i386 > by-pkgid > 95299258dbdf9a86cefd89b97c0d81e5 > files > 94

systemtap-1.2-1.fc13.i686.rpm

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>3.5.3. Incrementing Associated Values</title><link rel="stylesheet" href="./Common_Content/css/default.css" type="text/css" /><meta name="generator" content="publican 1.6" /><meta name="package" content="Systemtap-SystemTap_Beginners_Guide-1.0-en-US-2.0-2" /><link rel="home" href="index.html" title="SystemTap Beginners Guide" /><link rel="up" href="arrayoperators.html" title="3.5. Array Operations in SystemTap" /><link rel="prev" href="arrayops-readvalues.html" title="3.5.2. Reading Values From Arrays" /><link rel="next" href="arrayops-foreach.html" title="3.5.4. Processing Multiple Elements in an Array" /></head><body class=""><p id="title"><a class="left" href="http://www.fedoraproject.org"><img src="Common_Content/images/image_left.png" alt="Product Site" /></a><a class="right" href="http://docs.fedoraproject.org"><img src="Common_Content/images/image_right.png" alt="Documentation Site" /></a></p><ul class="docnav"><li class="previous"><a accesskey="p" href="arrayops-readvalues.html"><strong>Prev</strong></a></li><li class="next"><a accesskey="n" href="arrayops-foreach.html"><strong>Next</strong></a></li></ul><div class="section" title="3.5.3. Incrementing Associated Values"><div class="titlepage"><div><div><h3 class="title" id="arrayops-increment">3.5.3. Incrementing Associated Values</h3></div></div></div><a id="id2720306" class="indexterm"></a><a id="id2901454" class="indexterm"></a><a id="id2905625" class="indexterm"></a><div class="para">
			Use <code class="command">++</code> to increment the associated value of a unique key in an array, as in:
		</div><pre class="screen">
<em class="replaceable"><code>array_name</code></em>[<em class="replaceable"><code>index_expression</code></em>] ++
</pre><div class="para">
			Again, you can also use a handler function for your <code class="command"><em class="replaceable"><code>index_expression</code></em></code>. For example, if you wanted to tally how many times a specific process performed a read to the virtual file system (using the event <code class="command">vfs.read</code>), you can use the following probe:
		</div><a id="id2806780" class="indexterm"></a><a id="id2995040" class="indexterm"></a><a id="id2854013" class="indexterm"></a><a id="id2742939" class="indexterm"></a><a id="id2883538" class="indexterm"></a><div class="example" id="simplesimplevfsread"><div class="example-contents"><pre class="programlisting">
probe vfs.read
{
  reads[execname()] ++
}
</pre></div><h6>Example 3.14. vfsreads.stp</h6></div><br class="example-break" /><div class="para">
			In <a class="xref" href="arrayops-increment.html#simplesimplevfsread" title="Example 3.14. vfsreads.stp">Example 3.14, “vfsreads.stp”</a>, the first time that the probe returns the process name <code class="command">gnome-terminal</code> (i.e. the first time <code class="command">gnome-terminal</code> performs a VFS read), that process name is set as the unique key <code class="literal">gnome-terminal</code> with an associated value of 1. The next time that the probe returns the process name <code class="command">gnome-terminal</code>, SystemTap increments the associated value of <code class="literal">gnome-terminal</code> by 1. SystemTap performs this operation for <span class="emphasis"><em>all</em></span> process names as the probe returns them.
		</div></div><ul class="docnav"><li class="previous"><a accesskey="p" href="arrayops-readvalues.html"><strong>Prev</strong>3.5.2. Reading Values From Arrays</a></li><li class="up"><a accesskey="u" href="#"><strong>Up</strong></a></li><li class="home"><a accesskey="h" href="index.html"><strong>Home</strong></a></li><li class="next"><a accesskey="n" href="arrayops-foreach.html"><strong>Next</strong>3.5.4. Processing Multiple Elements in an Array</a></li></ul></body></html>