Sophie

Sophie

distrib > Fedora > 17 > i386 > by-pkgid > e2ec330d3ecf5110b4aa890342e53d96 > files > 728

systemtap-client-2.1-2.fc17.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" type="text/css" href="Common_Content/css/default.css" /><link rel="stylesheet" media="print" href="Common_Content/css/print.css" type="text/css" /><meta name="generator" content="publican 2.8" /><meta name="package" content="Systemtap-SystemTap_Beginners_Guide-2.1-en-US-2.1-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><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" id="arrayops-increment"><div class="titlepage"><div><div keep-together.within-column="always"><h3 class="title" id="arrayops-increment">3.5.3. Incrementing Associated Values</h3></div></div></div><a id="idp11324568" class="indexterm"></a><a id="idp37914472" class="indexterm"></a><a id="idm3456992" 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="idm20699976" class="indexterm"></a><a id="idp12740888" class="indexterm"></a><a id="idp36016328" class="indexterm"></a><a id="idm5586904" class="indexterm"></a><a id="idm2071424" class="indexterm"></a><div class="example" id="simplesimplevfsread"><h6>Example 3.16. vfsreads.stp</h6><div class="example-contents"><pre class="programlisting">probe vfs.read
{
  reads[execname()] ++
}</pre></div></div><br class="example-break" /><div class="para">
			In <a class="xref" href="arrayops-increment.html#simplesimplevfsread">Example 3.16, “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>