blob: 24eebb6910c9bb3d4f5d38e3d94b563a30ce75f6 (
plain) (
blame) 
 | 1 2 3 4 5 6 7 8 9 10 11 12 13  | <?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 xmlns:d="http://docbook.org/ns/docbook">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 xmlns:d="http://docbook.org/ns/docbook" name="generator" content="publican v4.1.3" /><meta xmlns:d="http://docbook.org/ns/docbook" name="package" content="SystemTap-SystemTap_Beginners_Guide-2.6-en-US-2.0-1" /><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="https://fedorahosted.org/publican"><img alt="Product Site" src="Common_Content/images//image_left.png" /></a><a class="right" href="https://fedorahosted.org/publican"><img alt="Documentation Site" src="Common_Content/images//image_right.png" /></a></p><ul class="docnav top"><li class="previous"><a accesskey="p" href="arrayops-readvalues.html"><strong>Prev</strong></a></li><li class="home">SystemTap Beginners Guide</li><li class="next"><a accesskey="n" href="arrayops-foreach.html"><strong>Next</strong></a></li></ul><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="arrayops-increment"> </a>3.5.3. Incrementing Associated Values</h3></div></div></div><a id="idm214008390576" class="indexterm"></a><a id="idm214012070256" class="indexterm"></a><a id="idm213973597664" 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">array_name</em>[<em class="replaceable">index_expression</em>] ++</pre><div class="para">	Again, you can also use a handler function for your <code class="command"><em class="replaceable">index_expression</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="idm214012423392" class="indexterm"></a><a id="idm214015255312" class="indexterm"></a><a id="idm214026397152" class="indexterm"></a><a id="idm214015968768" class="indexterm"></a><a id="idm213970540176" class="indexterm"></a><div class="example"><a id="simplesimplevfsread"> </a><p class="title"><strong>Example 3.16. vfsreads.stp</strong></p><div class="example-contents"><pre class="programlisting">probe vfs.read { reads[execname()] ++ }</pre></div></div><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> (that is, 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> 
 |