Sophie

Sophie

distrib > Fedora > 17 > i386 > media > updates > by-pkgid > 675c8c8167236dfcf8d66da674f931e8 > files > 1239

erlang-doc-R15B-03.3.fc17.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns:fn="http://www.w3.org/2005/02/xpath-functions">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../../../doc/otp_doc.css" type="text/css">
<title>Erlang -- dyntrace</title>
</head>
<body bgcolor="white" text="#000000" link="#0000ff" vlink="#ff00ff" alink="#ff0000"><div id="container">
<script id="js" type="text/javascript" language="JavaScript" src="../../../../doc/js/flipmenu/flipmenu.js"></script><script id="js2" type="text/javascript" src="../../../../doc/js/erlresolvelinks.js"></script><script language="JavaScript" type="text/javascript">
            <!--
              function getWinHeight() {
                var myHeight = 0;
                if( typeof( window.innerHeight ) == 'number' ) {
                  //Non-IE
                  myHeight = window.innerHeight;
                } else if( document.documentElement && ( document.documentElement.clientWidth ||
                                                         document.documentElement.clientHeight ) ) {
                  //IE 6+ in 'standards compliant mode'
                  myHeight = document.documentElement.clientHeight;
                } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
                  //IE 4 compatible
                  myHeight = document.body.clientHeight;
                }
                return myHeight;
              }

              function setscrollpos() {
                var objf=document.getElementById('loadscrollpos');
                 document.getElementById("leftnav").scrollTop = objf.offsetTop - getWinHeight()/2;
              }

              function addEvent(obj, evType, fn){
                if (obj.addEventListener){
                obj.addEventListener(evType, fn, true);
                return true;
              } else if (obj.attachEvent){
                var r = obj.attachEvent("on"+evType, fn);
                return r;
              } else {
                return false;
              }
             }

             addEvent(window, 'load', setscrollpos);

             //--></script><div id="leftnav"><div class="innertube">
<img alt="Erlang logo" src="../../../../doc/erlang-logo.png"><br><small><a href="index.html">Reference Manual</a><br><a href="release_notes.html">Release Notes</a><br><a href="../pdf/runtime_tools-1.8.9.pdf">PDF</a><br><a href="../../../../doc/index.html">Top</a></small><p><strong>Runtime_Tools</strong><br><strong>Reference Manual</strong><br><small>Version 1.8.9</small></p>
<br><a href="javascript:openAllFlips()">Expand All</a><br><a href="javascript:closeAllFlips()">Contract All</a><p><small><strong>Table of Contents</strong></small></p>
<ul class="flipMenu">
<li title="runtime_tools (App)"><a href="runtime_tools_app.html">runtime_tools (App)
                </a></li>
<li id="no" title="dbg " expanded="false">dbg<ul>
<li><a href="dbg.html">
                  Top of manual page
                </a></li>
<li title="fun2ms-1"><a href="dbg.html#fun2ms-1">fun2ms/1</a></li>
<li title="h-0"><a href="dbg.html#h-0">h/0</a></li>
<li title="h-1"><a href="dbg.html#h-1">h/1</a></li>
<li title="p-1"><a href="dbg.html#p-1">p/1</a></li>
<li title="p-2"><a href="dbg.html#p-2">p/2</a></li>
<li title="c-3"><a href="dbg.html#c-3">c/3</a></li>
<li title="c-4"><a href="dbg.html#c-4">c/4</a></li>
<li title="i-0"><a href="dbg.html#i-0">i/0</a></li>
<li title="tp-2"><a href="dbg.html#tp-2">tp/2</a></li>
<li title="tp-3"><a href="dbg.html#tp-3">tp/3</a></li>
<li title="tp-4"><a href="dbg.html#tp-4">tp/4</a></li>
<li title="tp-2"><a href="dbg.html#tp-2">tp/2</a></li>
<li title="tpl-2"><a href="dbg.html#tpl-2">tpl/2</a></li>
<li title="tpl-3"><a href="dbg.html#tpl-3">tpl/3</a></li>
<li title="tpl-4"><a href="dbg.html#tpl-4">tpl/4</a></li>
<li title="tpl-2"><a href="dbg.html#tpl-2">tpl/2</a></li>
<li title="ctp-0"><a href="dbg.html#ctp-0">ctp/0</a></li>
<li title="ctp-1"><a href="dbg.html#ctp-1">ctp/1</a></li>
<li title="ctp-2"><a href="dbg.html#ctp-2">ctp/2</a></li>
<li title="ctp-3"><a href="dbg.html#ctp-3">ctp/3</a></li>
<li title="ctp-1"><a href="dbg.html#ctp-1">ctp/1</a></li>
<li title="ctpl-0"><a href="dbg.html#ctpl-0">ctpl/0</a></li>
<li title="ctpl-1"><a href="dbg.html#ctpl-1">ctpl/1</a></li>
<li title="ctpl-2"><a href="dbg.html#ctpl-2">ctpl/2</a></li>
<li title="ctpl-3"><a href="dbg.html#ctpl-3">ctpl/3</a></li>
<li title="ctpl-1"><a href="dbg.html#ctpl-1">ctpl/1</a></li>
<li title="ctpg-0"><a href="dbg.html#ctpg-0">ctpg/0</a></li>
<li title="ctpg-1"><a href="dbg.html#ctpg-1">ctpg/1</a></li>
<li title="ctpg-2"><a href="dbg.html#ctpg-2">ctpg/2</a></li>
<li title="ctpg-3"><a href="dbg.html#ctpg-3">ctpg/3</a></li>
<li title="ctpg-1"><a href="dbg.html#ctpg-1">ctpg/1</a></li>
<li title="ltp-0"><a href="dbg.html#ltp-0">ltp/0</a></li>
<li title="dtp-0"><a href="dbg.html#dtp-0">dtp/0</a></li>
<li title="dtp-1"><a href="dbg.html#dtp-1">dtp/1</a></li>
<li title="wtp-1"><a href="dbg.html#wtp-1">wtp/1</a></li>
<li title="rtp-1"><a href="dbg.html#rtp-1">rtp/1</a></li>
<li title="n-1"><a href="dbg.html#n-1">n/1</a></li>
<li title="cn-1"><a href="dbg.html#cn-1">cn/1</a></li>
<li title="ln-0"><a href="dbg.html#ln-0">ln/0</a></li>
<li title="tracer-0"><a href="dbg.html#tracer-0">tracer/0</a></li>
<li title="tracer-2"><a href="dbg.html#tracer-2">tracer/2</a></li>
<li title="tracer-3"><a href="dbg.html#tracer-3">tracer/3</a></li>
<li title="trace_port-2"><a href="dbg.html#trace_port-2">trace_port/2</a></li>
<li title="flush_trace_port-0"><a href="dbg.html#flush_trace_port-0">flush_trace_port/0</a></li>
<li title="flush_trace_port-1"><a href="dbg.html#flush_trace_port-1">flush_trace_port/1</a></li>
<li title="trace_port_control-1"><a href="dbg.html#trace_port_control-1">trace_port_control/1</a></li>
<li title="trace_port_control-2"><a href="dbg.html#trace_port_control-2">trace_port_control/2</a></li>
<li title="trace_client-2"><a href="dbg.html#trace_client-2">trace_client/2</a></li>
<li title="trace_client-3"><a href="dbg.html#trace_client-3">trace_client/3</a></li>
<li title="stop_trace_client-1"><a href="dbg.html#stop_trace_client-1">stop_trace_client/1</a></li>
<li title="get_tracer-0"><a href="dbg.html#get_tracer-0">get_tracer/0</a></li>
<li title="get_tracer-1"><a href="dbg.html#get_tracer-1">get_tracer/1</a></li>
<li title="stop-0"><a href="dbg.html#stop-0">stop/0</a></li>
<li title="stop_clear-0"><a href="dbg.html#stop_clear-0">stop_clear/0</a></li>
</ul>
</li>
<li id="loadscrollpos" title="dyntrace " expanded="true">dyntrace<ul>
<li><a href="dyntrace.html">
                  Top of manual page
                </a></li>
<li title="available-0"><a href="dyntrace.html#available-0">available/0</a></li>
<li title="p-0"><a href="dyntrace.html#p-0">p/0</a></li>
<li title="p-1"><a href="dyntrace.html#p-1">p/1</a></li>
<li title="p-2"><a href="dyntrace.html#p-2">p/2</a></li>
<li title="p-3"><a href="dyntrace.html#p-3">p/3</a></li>
<li title="p-4"><a href="dyntrace.html#p-4">p/4</a></li>
<li title="p-5"><a href="dyntrace.html#p-5">p/5</a></li>
<li title="p-6"><a href="dyntrace.html#p-6">p/6</a></li>
<li title="p-7"><a href="dyntrace.html#p-7">p/7</a></li>
<li title="p-8"><a href="dyntrace.html#p-8">p/8</a></li>
<li title="get_tag-0"><a href="dyntrace.html#get_tag-0">get_tag/0</a></li>
<li title="get_tag-0"><a href="dyntrace.html#get_tag-0">get_tag/0</a></li>
<li title="put_tag-1"><a href="dyntrace.html#put_tag-1">put_tag/1</a></li>
<li title="spread_tag-1"><a href="dyntrace.html#spread_tag-1">spread_tag/1</a></li>
<li title="restore_tag-1"><a href="dyntrace.html#restore_tag-1">restore_tag/1</a></li>
</ul>
</li>
<li id="no" title="erts_alloc_config " expanded="false">erts_alloc_config<ul>
<li><a href="erts_alloc_config.html">
                  Top of manual page
                </a></li>
<li title="save_scenario-0"><a href="erts_alloc_config.html#save_scenario-0">save_scenario/0</a></li>
<li title="make_config-0"><a href="erts_alloc_config.html#make_config-0">make_config/0</a></li>
<li title="make_config-1"><a href="erts_alloc_config.html#make_config-1">make_config/1</a></li>
<li title="stop-0"><a href="erts_alloc_config.html#stop-0">stop/0</a></li>
</ul>
</li>
</ul>
</div></div>
<div id="content">
<div class="innertube">
<!-- refpage --><center><h1>dyntrace</h1></center>
  
  <h3>MODULE</h3>
<div class="REFBODY">dyntrace</div>
  <h3>MODULE SUMMARY</h3>
<div class="REFBODY">Interface to dynamic tracing</div>
  <h3>DESCRIPTION</h3>
<div class="REFBODY"><p>
    <p>This module implements interfaces to dynamic tracing, should such be compiled into the virtual machine. For a standard and/or commercial build, no dynamic tracing is available, in which case none of the functions in this module is usable or give any effect.</p>
    <p>Should dynamic tracing be enabled in the current build, either by configuring with <span class="code">./configure --with-dynamic-trace=dtrace</span> or with  <span class="code">./configure --with-dynamic-trace=systemtap</span>, the module can be used for two things:</p>
    <ul>
      <li>Trigger the user-probe <span class="code">user_trace_i4s4</span> in the NIF library <span class="code">dyntrace.so</span> by calling <span class="code">dyntrace:p/{1,2,3,4,5,6,7,8}</span>.</li>
      <li>Set a user specified tag that will be present in the trace messages of both the <span class="code">efile_drv</span> and the user-probe mentioned above.</li>
    </ul>
      <p>Both building with dynamic trace probes and using them is experimental and unsupported by Erlang/OTP. It is included as an option for the developer to trace and debug performance issues in their systems.</p>
      <p>The original implementation is mostly done by Scott Lystiger Fritchie as an Open Source Contribution and it should be viewed as such even though the source for dynamic tracing as well as this module is included in the main distribution. However, the ability to use dynamic tracing of the virtual machine is a very valuable contribution which OTP has every intention to maintain as a tool for the developer.</p>
      <p>How to write <span class="code">d</span> programs or <span class="code">systemtap</span> scripts can be learned from books and from a lot of pages on the Internet. This manual page does not include any documentation about using the dynamic trace tools of respective platform. The <span class="code">examples</span> directory of the <span class="code">runtime_tools</span> application however contains comprehensive examples of both <span class="code">d</span> and <span class="code">systemtap</span> programs that will help you get started. Another source of information is the <span class="code">README.dtrace(.md)</span> and <span class="code">README.systemtap(.md)</span> files in the Erlang source top directory.</p> 
  </p></div>
  <h3>EXPORTS</h3>
    <p><a name="available-0"><span class="bold_code">available() -&gt; boolean()</span></a><br></p>
<div class="REFBODY"><p>
	<p>This function uses the NIF library to determine if dynamic
	tracing is available. Usually calling <span class="bold_code"><a href="javascript:erlhref('../../../../doc/../','erts','erlang.html#system_info-1');">erlang:system_info/1</a></span>
	is a better indicator of the availability of dynamic
	tracing.</p>
	<p>The function will throw an exception if the <span class="code">dyntrace</span> NIF library could not be loaded by the on_load function of this module.</p>
      </p></div>
    <p><a name="p-0"><span class="bold_code">p() -&gt; true | false | error | badarg</span></a><br></p>
<div class="REFBODY"><p>
        <p>Calling this function will trigger the "user" trace probe user_trace_i4s4 in the dyntrace NIF module, sending a trace message only containing the user tag and zeroes/empty strings in all other fields.</p>
      </p></div>
    <p><a name="p-1"><span class="bold_code">p(integer() | string()) -&gt; true | false | error | badarg</span></a><br></p>
<div class="REFBODY"><p>
        <p>Calling this function will trigger the "user" trace probe user_trace_i4s4 in the dyntrace NIF module, sending a trace message containing the user tag and the integer or string parameter in the first integer/string field.</p>
      </p></div>
    <p><a name="p-2"><span class="bold_code">p(integer() | string(), integer() | string()) -&gt; true | false | error | badarg</span></a><br></p>
<div class="REFBODY"><p>
        <p>Calling this function will trigger the "user" trace probe user_trace_i4s4 in the dyntrace NIF module, sending a trace message containing the user tag and the integer() or string() parameters as the first fields of respective type. integer() parameters should be put before any string() parameters. I.e. <span class="code">p(1,"Hello")</span> is ok, as is <span class="code">p(1,1)</span> and <span class="code">p("Hello","Again")</span>, but not <span class="code">p("Hello",1)</span>.</p>
      </p></div>
    <p><a name="p-3"><span class="bold_code">p(integer() | string(), integer() | string(), integer() | string()) -&gt; true | false | error | badarg</span></a><br></p>
<div class="REFBODY"><p>
        <p>Calling this function will trigger the "user" trace probe user_trace_i4s4 in the dyntrace NIF module, sending a trace message containing the user tag and the integer() or string() parameters as the first fields of respective type. integer() parameters should be put before any string() parameters, as in <span class="bold_code"><a href="#p-2">p/2</a></span>.</p>
      </p></div>
    <p><a name="p-4"><span class="bold_code">p(integer() | string(), integer() | string(), integer() | string(), integer() | string()) -&gt; true | false | error | badarg</span></a><br></p>
<div class="REFBODY"><p>
        <p>Calling this function will trigger the "user" trace probe user_trace_i4s4 in the dyntrace NIF module, sending a trace message containing the user tag and the integer() or string() parameters as the first fields of respective type. integer() parameters should be put before any string() parameters, as in <span class="bold_code"><a href="#p-2">p/2</a></span>.</p>
      </p></div>
    <p><a name="p-5"><span class="bold_code">p(integer(), integer() | string(), integer() | string(), integer() | string(), string()) -&gt; true | false | error | badarg</span></a><br></p>
<div class="REFBODY"><p>
        <p>Calling this function will trigger the "user" trace probe user_trace_i4s4 in the dyntrace NIF module, sending a trace message containing the user tag and the integer() or string() parameters as the first fields of respective type. integer() parameters should be put before any string() parameters, as in <span class="bold_code"><a href="#p-2">p/2</a></span>.</p>
	<p>There can be no more than four parameters of any type (integer() or string()), so the first parameter has to be an integer() and the last a string().</p> 
      </p></div>
     <p><a name="p-6"><span class="bold_code">p(integer(), integer(), integer() | string(), integer() | string(), string(), string()) -&gt; true | false | error | badarg</span></a><br></p>
<div class="REFBODY"><p>
        <p>Calling this function will trigger the "user" trace probe user_trace_i4s4 in the dyntrace NIF module, sending a trace message containing the user tag and the integer() or string() parameters as the first fields of respective type. integer() parameters should be put before any string() parameters, as in <span class="bold_code"><a href="#p-2">p/2</a></span>.</p>
	<p>There can be no more than four parameters of any type (integer() or string()), so the first two parameters has to be integer()'s and the last two string()'s.</p> 
      </p></div>
     <p><a name="p-7"><span class="bold_code">p(integer(), integer(), integer(), integer() | string(), string(), string(), string()) -&gt; true | false | error | badarg</span></a><br></p>
<div class="REFBODY"><p>
        <p>Calling this function will trigger the "user" trace probe user_trace_i4s4 in the dyntrace NIF module, sending a trace message containing the user tag and the integer() or string() parameters as the first fields of respective type. integer() parameters should be put before any string() parameters, as in <span class="bold_code"><a href="#p-2">p/2</a></span>.</p>
	<p>There can be no more than four parameters of any type (integer() or string()), so the first three parameters has to be integer()'s and the last three string()'s.</p> 
      </p></div>
     <p><a name="p-8"><span class="bold_code">p(integer(), integer(), integer(), integer(), string(), string(), string(), string()) -&gt; true | false | error | badarg</span></a><br></p>
<div class="REFBODY"><p>
        <p>Calling this function will trigger the "user" trace probe user_trace_i4s4 in the dyntrace NIF module, sending a trace message containing all the integer()'s and string()'s provided, as well as any user tag set in the current process.</p> 
      </p></div>
    <p><a name="get_tag-0"><span class="bold_code">get_tag() -&gt; binary() | undefined</span></a><br></p>
<div class="REFBODY"><p>
	<p>This function returns the user tag set in the current
	process. If no tag is set or dynamic tracing is not available,
	it returns <span class="code">undefined</span></p>
      </p></div>
    <p><a name="get_tag-0"><span class="bold_code">get_tag() -&gt; binary() | undefined</span></a><br></p>
<div class="REFBODY"><p>
	<p>This function returns the user tag set in the current
	process or, if no user tag is present, the last user tag sent
	to the process together with a message (in the same way as
	<span class="bold_code"><a href="javascript:erlhref('../../../../doc/../','kernel','seq_trace.html');">sequential trace
	tokens</a></span> are spread to other processes together with
	messages. For an explanation of how user tags can be spread
	together with messages, see <span class="bold_code"><a href="#spread_tag-1">spread_tag/1</a></span>. If no tag is
	found or dynamic tracing is not available, it returns
	<span class="code">undefined</span></p>
      </p></div>
    
    <p><a name="put_tag-1"><span class="bold_code">put_tag(Item) -&gt; binary() | undefined </span></a><br></p>
<div class="REFBODY">
<p>Types:</p>
        <div class="REFTYPES">
<span class="bold_code">Item = iodata()</span><br>
</div>
      </div>
<div class="REFBODY"><p>
        <p>This function sets the user tag of the current process. The user tag is a binary(), but can be specified as any iodata(), which is automatically converted to a binary by this function.</p>
	<p>The user tag is provided to the user probes triggered by calls top <span class="code">dyntrace:p/{1,2,3,4,5,6,7,8}</span> as well as probes in the efile_driver. In the future, user tags might be added to more probes.</p>
	<p>The old user tag (if any) is returned, or <span class="code">undefined</span> if no user tag was present or dynamic tracing is not enabled.</p>
      </p></div>
    <p><a name="spread_tag-1"><span class="bold_code">spread_tag(boolean()) -&gt; TagData</span></a><br></p>
<div class="REFBODY">
<p>Types:</p>
        <div class="REFTYPES">
<span class="bold_code">TagData = opaque data that can be used as parameter to <span class="bold_code"><a href="#restore_tag-1">restore_tag/1</a></span></span><br>
</div>
      </div>
<div class="REFBODY"><p>
        <p>This function controls if user tags are to be spread to other processes with the next message. Spreading of user tags work like spreading of sequential trace tokens, so that a received user tag will be active in the process until the next message arrives (if that message does not also contain the user tag.</p>
	<p>This functionality is used when a client process communicates with a file i/o-server to spread the user tag to the I/O-server and then down to the efile_drv driver. By using <span class="code">spread_tag/1</span> and <span class="code">restore_tag/1</span>, one can enable or disable spreading of user tags to other processes and then restore the previous state of the user tag. The TagData returned from this call contains all previous information so the state (including any previously spread user tags) will be completely restored by a later call to <span class="code">restore_tag/1</span>.</p> 
	<p>The <span class="bold_code"><a href="javascript:erlhref('../../../../doc/../','kernel','file.html');">file</a></span> module already spread's tags, so there is noo need to manually call these function to get user tags spread to the efile driver through that module.</p>
	<p>The most use of this function would be if one for example uses the <span class="bold_code"><a href="javascript:erlhref('../../../../doc/../','stdlib','io.html');">io</a></span> module to communicate with an I/O-server for a regular file, like in the following example:</p>
<div class="example"><pre>
f() -&gt;
   {ok, F} = file:open("test.tst",[write]),
   Saved = dyntrace:spread_tag(true),
   io:format(F,"Hello world!",[]),
   dyntrace:restore_tag(Saved),
   file:close(F).
</pre></div>
          <p>In this example, any user tag set in the calling process will be spread to the I/O-server when the io:format call is done.</p>
      </p></div>
    <p><a name="restore_tag-1"><span class="bold_code">restore_tag(TagData) -&gt; true</span></a><br></p>
<div class="REFBODY">
<p>Types:</p>
        <div class="REFTYPES">
<span class="bold_code">TagData = opaque data returned by <span class="bold_code"><a href="#spread_tag-1">spread_tag/1</a></span></span><br>
</div>
      </div>
<div class="REFBODY"><p>
	<p>Restores the previous state of user tags and their spreading as it was before a call to <span class="bold_code"><a href="#spread_tag-1">spread_tag/1</a></span>. Note that the restoring is not limited to the same process, one can utilize this to turn off spreding in one process and restore it in a newly created, the one that actually is going to send messages:</p>
<div class="example"><pre>
f() -&gt;
    TagData=dyntrace:spread_tag(false),
    spawn(fun() -&gt;
             dyntrace:restore_tag(TagData),
             do_something()
          end),
    do_something_else(),
    dyntrace:restore_tag(TagData).
</pre></div>
        <p>Correctly handling user tags and their spreading might take some effort, as Erlang programs tend to send and receive messages so that sometimes the user tag gets lost due to various things, like double receives or communication with a port (ports do not handle user tags, in the same way as they do not handle regular sequential trace tokens).</p>
      </p></div>
  
 </div>
<div class="footer">
<hr>
<p>Copyright © 1999-2012 Ericsson AB. All Rights Reserved.</p>
</div>
</div>
</div></body>
</html>