Sophie

Sophie

distrib > Mageia > 7 > aarch64 > by-pkgid > ca236e080672a3aa5beda2fe21b8473d > files > 814

erlang-doc-21.2.5-1.mga7.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns:erl="http://erlang.org" 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 -- dbg</title>
</head>
<body>
<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">
<div class="erlang-logo-wrapper"><a href="../../../../doc/index.html"><img alt="Erlang Logo" src="../../../../doc/erlang-logo.png" class="erlang-logo"></a></div>
<p class="section-title">Runtime_Tools</p>
<p class="section-subtitle">Reference Manual</p>
<p class="section-version">Version 1.13.1</p>
<ul class="panel-sections">
<li><a href="users_guide.html">User's Guide</a></li>
<li><a href="index.html">Reference Manual</a></li>
<li><a href="release_notes.html">Release Notes</a></li>
<li><a href="../pdf/runtime_tools-1.13.1.pdf">PDF</a></li>
<li><a href="../../../../doc/index.html">Top</a></li>
</ul>
<ul class="expand-collapse-items">
<li><a href="javascript:openAllFlips()">Expand All</a></li>
<li><a href="javascript:closeAllFlips()">Contract All</a></li>
</ul>
<h3>Table of Contents</h3>
<ul class="flipMenu">
<li title="runtime_tools (App)"><a href="runtime_tools_app.html">runtime_tools (App)
                </a></li>
<li id="loadscrollpos" title="dbg " expanded="true">dbg<ul>
<li><a href="dbg.html">
                  Top of manual page
                </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="cn-1"><a href="dbg.html#cn-1">cn/1</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="ctpe-1"><a href="dbg.html#ctpe-1">ctpe/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="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="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="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="fun2ms-1"><a href="dbg.html#fun2ms-1">fun2ms/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="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="i-0"><a href="dbg.html#i-0">i/0</a></li>
    <li title="ln-0"><a href="dbg.html#ln-0">ln/0</a></li>
    <li title="ltp-0"><a href="dbg.html#ltp-0">ltp/0</a></li>
    <li title="n-1"><a href="dbg.html#n-1">n/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="rtp-1"><a href="dbg.html#rtp-1">rtp/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>
    <li title="stop_trace_client-1"><a href="dbg.html#stop_trace_client-1">stop_trace_client/1</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="tpe-2"><a href="dbg.html#tpe-2">tpe/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="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="trace_port-2"><a href="dbg.html#trace_port-2">trace_port/2</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="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="wtp-1"><a href="dbg.html#wtp-1">wtp/1</a></li>
    </ul>
</li>
<li id="no" title="dyntrace " expanded="false">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="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="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="put_tag-1"><a href="dyntrace.html#put_tag-1">put_tag/1</a></li>
    <li title="restore_tag-1"><a href="dyntrace.html#restore_tag-1">restore_tag/1</a></li>
    <li title="spread_tag-1"><a href="dyntrace.html#spread_tag-1">spread_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="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="save_scenario-0"><a href="erts_alloc_config.html#save_scenario-0">save_scenario/0</a></li>
    <li title="stop-0"><a href="erts_alloc_config.html#stop-0">stop/0</a></li>
    </ul>
</li>
<li id="no" title="msacc " expanded="false">msacc<ul>
<li><a href="msacc.html">
                  Top of manual page
                </a></li>
    <li title="available-0"><a href="msacc.html#available-0">available/0</a></li>
    <li title="from_file-1"><a href="msacc.html#from_file-1">from_file/1</a></li>
    <li title="print-0"><a href="msacc.html#print-0">print/0</a></li>
    <li title="print-1"><a href="msacc.html#print-1">print/1</a></li>
    <li title="print-2"><a href="msacc.html#print-2">print/2</a></li>
    <li title="print-3"><a href="msacc.html#print-3">print/3</a></li>
    <li title="reset-0"><a href="msacc.html#reset-0">reset/0</a></li>
    <li title="start-0"><a href="msacc.html#start-0">start/0</a></li>
    <li title="start-1"><a href="msacc.html#start-1">start/1</a></li>
    <li title="stats-0"><a href="msacc.html#stats-0">stats/0</a></li>
    <li title="stats-2"><a href="msacc.html#stats-2">stats/2</a></li>
    <li title="stop-0"><a href="msacc.html#stop-0">stop/0</a></li>
    <li title="to_file-1"><a href="msacc.html#to_file-1">to_file/1</a></li>
    </ul>
</li>
<li id="no" title="scheduler " expanded="false">scheduler<ul>
<li><a href="scheduler.html">
                  Top of manual page
                </a></li>
    <li title="sample-0"><a href="scheduler.html#sample-0">sample/0</a></li>
    <li title="sample_all-0"><a href="scheduler.html#sample_all-0">sample_all/0</a></li>
    <li title="utilization-1"><a href="scheduler.html#utilization-1">utilization/1</a></li>
    <li title="utilization-2"><a href="scheduler.html#utilization-2">utilization/2</a></li>
    </ul>
</li>
<li id="no" title="system_information " expanded="false">system_information<ul>
<li><a href="system_information.html">
                  Top of manual page
                </a></li>
    <li title="sanity_check-0"><a href="system_information.html#sanity_check-0">sanity_check/0</a></li>
    <li title="to_file-1"><a href="system_information.html#to_file-1">to_file/1</a></li>
    </ul>
</li>
</ul>
</div></div>
<div id="content">
<div class="innertube">
<!-- refpage --><center><h1>dbg</h1></center>
  
  <h3><span onMouseOver="document.getElementById('ghlink-module-idm281472335101480').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-module-idm281472335101480').style.visibility = 'hidden';"><span id="ghlink-module-idm281472335101480"></span><a class="title_link" name="module" href="#module">Module</a></span></h3>
<div class="REFBODY module-body">dbg</div>
  <h3><span onMouseOver="document.getElementById('ghlink-module-summary-idm281472335101096').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-module-summary-idm281472335101096').style.visibility = 'hidden';"><span id="ghlink-module-summary-idm281472335101096"></span><a class="title_link" name="module-summary" href="#module-summary">Module Summary</a></span></h3>
<div class="REFBODY module-summary-body">The Text Based Trace Facility</div>
  <h3><span onMouseOver="document.getElementById('ghlink-description-idm281472335100712').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-description-idm281472335100712').style.visibility = 'hidden';"><span id="ghlink-description-idm281472335100712" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L37" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="description" href="#description">Description</a></span></h3>
<div class="REFBODY description-body"><p>
    <p>This module implements a text based interface to the
      <span class="bold_code bc-13"><a href="javascript:erlhref('../../../../doc/../','erts','erlang.html#trace-3');"><span class="code">trace/3</span></a></span> and the
      <span class="bold_code bc-13"><a href="javascript:erlhref('../../../../doc/../','erts','erlang.html#trace_pattern-2');"><span class="code">trace_pattern/2</span></a></span> BIFs.  It makes it
      possible to trace functions, processes, ports and messages.
    </p>
    <p>
      To quickly get started on tracing function calls you can use the following
      code in the Erlang shell:
    </p>
    <div class="example"><pre>
1&gt; dbg:tracer(). %% Start the default trace message receiver
{ok,&lt;0.36.0&gt;}
2&gt; dbg:p(all, c). %% Setup call (c) tracing on all processes
{ok,[{matched,nonode@nohost,26}]}
3&gt; dbg:tp(lists, seq, x). %% Setup an exception return trace (x) on lists:seq
{ok,[{matched,nonode@nohost,2},{saved,x}]}
4&gt; lists:seq(1,10).
(&lt;0.34.0&gt;) call lists:seq(1,10)
(&lt;0.34.0&gt;) returned from lists:seq/2 -&gt; [1,2,3,4,5,6,7,8,9,10]
[1,2,3,4,5,6,7,8,9,10]
    </pre></div>
    <p>
      For more examples of how to use <span class="code">dbg</span> from the Erlang
      shell, see the <span class="bold_code bc-17"><a href="#simple_example">simple example</a></span> section.
    </p>
    <p>The utilities are also suitable to use in system testing on
      large systems, where other tools have too much impact on the
      system performance.  Some primitive support for sequential tracing
      is also included, see the <span class="bold_code bc-17"><a href="#advanced">advanced topics</a></span> section.
      </p>
  </p></div>
  <h3><span onMouseOver="document.getElementById('ghlink-exports-idm281472335317528').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-exports-idm281472335317528').style.visibility = 'hidden';"><span id="ghlink-exports-idm281472335317528"></span><a class="title_link" name="exports" href="#exports">Exports</a></span></h3>
<div class="exports-body">
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-fun2ms-1-idm281472334865080').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-fun2ms-1-idm281472334865080').style.visibility = 'hidden';"><span id="ghlink-fun2ms-1-idm281472334865080" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L70" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="fun2ms-1" href="#fun2ms-1">fun2ms(LiteralFun) -&gt; MatchSpec</a></span></div></p>
<div class="REFBODY rb-5">
<h3 class="func-types-title">Types</h3>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">LiteralFun = fun() literal</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">MatchSpec = term()</span><br>
</div>
      </div>
<div class="REFBODY rb-7"><p>
        <p>Pseudo function that by means of a <span class="code">parse_transform</span>
          translates the <strong>literal</strong><span class="code">fun()</span> typed as parameter in
          the function call to a match specification as described in
          the <span class="code">match_spec</span> manual of ERTS users guide.
          (with literal I mean that the <span class="code">fun()</span> needs to
          textually be written as the parameter of the function, it
          cannot be held in a variable which in turn is passed to the 
          function). </p>
        <p>The parse transform is implemented in the module
          <span class="code">ms_transform</span> and the source <strong>must</strong> include the
          file <span class="code">ms_transform.hrl</span> in STDLIB for this
          pseudo function to work. Failing to include the hrl file in
          the source will result in a runtime error, not a compile
          time ditto. The include file is easiest included by adding
          the line
          <span class="code">-include_lib("stdlib/include/ms_transform.hrl").</span> to
          the source file.</p>
        <p>The <span class="code">fun()</span> is very restricted, it can take only a
          single parameter (the parameter list to match), a sole variable or a
          list. It needs to use the <span class="code">is_</span>XXX guard tests and one
          cannot use language constructs that have no representation
          in a match_spec (like <span class="code">if</span>, <span class="code">case</span>,
          <span class="code">receive</span> etc). The return value from the fun will be
          the return value of the resulting match_spec.</p>
        <p>Example:</p>
        <div class="example"><pre>
1&gt; <span class="bold_code bc-12">dbg:fun2ms(fun([M,N]) when N &gt; 3 -&gt; return_trace() end).</span>
[{['$1','$2'],[{'&gt;','$2',3}],[{return_trace}]}]</pre></div>
        <p>Variables from the environment can be imported, so that this
          works:</p>
        <div class="example"><pre>
2&gt; <span class="bold_code bc-12">X=3.</span>
3
3&gt; <span class="bold_code bc-12">dbg:fun2ms(fun([M,N]) when N &gt; X  -&gt; return_trace() end).</span>
[{['$1','$2'],[{'&gt;','$2',{const,3}}],[{return_trace}]}]</pre></div>
        <p>The imported variables will be replaced by match_spec
          <span class="code">const</span> expressions, which is consistent with the
          static scoping for Erlang <span class="code">fun()</span>s. Local or global
          function calls can not be in the guard or body of the fun
          however. Calls to builtin match_spec functions of course is
          allowed:</p>
        <div class="example"><pre>
4&gt; <span class="bold_code bc-12">dbg:fun2ms(fun([M,N]) when N &gt; X, is_atomm(M)  -&gt; return_trace() end).</span>
Error: fun containing local erlang function calls ('is_atomm' called in guard)\
 cannot be translated into match_spec
{error,transform_error}
5&gt; <span class="bold_code bc-12">dbg:fun2ms(fun([M,N]) when N &gt; X, is_atom(M)  -&gt; return_trace() end).</span>
[{['$1','$2'],[{'&gt;','$2',{const,3}},{is_atom,'$1'}],[{return_trace}]}]</pre></div>
        <p>As you can see by the example, the function can be called from
          the shell too. The <span class="code">fun()</span> needs to be literally in the
          call when used from the shell as well. Other means than the 
          parse_transform are used in the shell case, but more or less
          the same restrictions apply (the exception being records,
          as they are not handled by the shell).</p>
        <div class="warning">
<div class="label">Warning</div>
<div class="content"><p>
          <p>If the parse_transform is not applied to a module which calls this
            pseudo function, the call will fail in runtime (with a 
            <span class="code">badarg</span>). The module <span class="code">dbg</span> actually exports a
            function with this name, but it should never really be called
            except for when using the function in the shell. If the
            <span class="code">parse_transform</span> is properly applied by including
            the <span class="code">ms_transform.hrl</span> header file, compiled code
            will never call the function, but the function call is
            replaced by a literal match_spec.</p>
        </p></div>
</div>
        <p>More information is provided by the <span class="code">ms_transform</span>
          manual page in STDLIB.</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-h-0-idm281472334495544').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-h-0-idm281472334495544').style.visibility = 'hidden';"><span id="ghlink-h-0-idm281472334495544" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L147" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="h-0" href="#h-0">h() -&gt; ok </a></span></div></p>
<div class="REFBODY rb-7"><p>
        <p>Gives a list of items for brief online help.</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-h-1-idm281472334580456').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-h-1-idm281472334580456').style.visibility = 'hidden';"><span id="ghlink-h-1-idm281472334580456" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L154" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="h-1" href="#h-1">h(Item) -&gt; ok </a></span></div></p>
<div class="REFBODY rb-5">
<h3 class="func-types-title">Types</h3>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Item = atom()</span><br>
</div>
      </div>
<div class="REFBODY rb-7"><p>
        <p>Gives a brief help text for functions in the dbg module. The
          available items can be listed with <span class="code">dbg:h/0</span></p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-p-1-idm281472334518488').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-p-1-idm281472334518488').style.visibility = 'hidden';"><span id="ghlink-p-1-idm281472334518488" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L165" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="p-1" href="#p-1">p(Item) -&gt; {ok, MatchDesc} | {error, term()} </a></span></div></p>
<div class="REFBODY rb-7"><p>
        <p>Equivalent to <span class="code">p(Item, [m])</span>.</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-p-2-idm281472334342376').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-p-2-idm281472334342376').style.visibility = 'hidden';"><span id="ghlink-p-2-idm281472334342376" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L172" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="p-2" href="#p-2">p(Item, Flags) -&gt; {ok, MatchDesc} | {error, term()}</a></span></div></p>
<div class="REFBODY rb-5">
<h3 class="func-types-title">Types</h3>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">MatchDesc = [MatchNum]</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">MatchNum = {matched, node(), integer()} | {matched, node(), 0, RPCError}</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">RPCError = term()</span><br>
</div>
      </div>
<div class="REFBODY rb-7"><p>
        <p>Traces <span class="code">Item</span> in accordance to the value specified
          by <span class="code">Flags</span>. The variation of <span class="code">Item</span> is listed below:</p>
        <dl>
          <dt><strong><span class="code">pid()</span> or <span class="code">port()</span></strong></dt>
          <dd>The corresponding process or port is traced. The process or port may
           be a remote process or port (on another Erlang node). The node must
           be in the list of traced nodes (see <span class="bold_code bc-17"><a href="#n-1"><span class="code">n/1</span></a></span>
           and <span class="bold_code bc-17"><a href="#tracer-3"><span class="code">tracer/3</span></a></span>).</dd>
          <dt><strong><span class="code">all</span></strong></dt>
          <dd>All processes and ports in the system as well as all processes and ports
           created hereafter are to be traced.</dd>
          <dt><strong><span class="code">processes</span></strong></dt>
          <dd>All processes in the system as well as all processes created hereafter are to be traced.</dd>
          <dt><strong><span class="code">ports</span></strong></dt>
          <dd>All ports in the system as well as all ports created hereafter are to be traced.</dd>
          <dt><strong><span class="code">new</span></strong></dt>
          <dd>All processes and ports created after the call is are to be traced.</dd>
          <dt><strong><span class="code">new_processes</span></strong></dt>
          <dd>All processes created after the call is are to be traced.</dd>
          <dt><strong><span class="code">new_ports</span></strong></dt>
          <dd>All ports created after the call is are to be traced.</dd>
          <dt><strong><span class="code">existing</span></strong></dt>
          <dd>All existing processes and ports are traced.</dd>
          <dt><strong><span class="code">existing_processes</span></strong></dt>
          <dd>All existing processes are traced.</dd>
          <dt><strong><span class="code">existing_ports</span></strong></dt>
          <dd>All existing ports are traced.</dd>
          <dt><strong><span class="code">atom()</span></strong></dt>
          <dd>The process or port with the corresponding registered name is traced. The process or
           port may be a remote process (on another Erlang node). The node must be
           added with the <span class="bold_code bc-17"><a href="#n-1"><span class="code">n/1</span></a></span> or
           <span class="bold_code bc-17"><a href="#tracer-3"><span class="code">tracer/3</span></a></span> function.</dd>
          <dt><strong><span class="code">integer()</span></strong></dt>
          <dd>The process <span class="code">&lt;0.Item.0&gt;</span> is traced.</dd>
          <dt><strong><span class="code">{X, Y, Z}</span></strong></dt>
          <dd>The process <span class="code">&lt;X.Y.Z&gt;</span> is traced. </dd>
              <dt><strong><span class="code">string()</span></strong></dt>
              <dd>If the <span class="code">Item</span> is a string "&lt;X.Y.Z&gt;"
                      as returned from <span class="bold_code bc-13"><a href="javascript:erlhref('../../../../doc/../','erts','erlang.html#pid_to_list-1');"><span class="code">pid_to_list/1</span></a></span>,
                      the process <span class="code">&lt;X.Y.Z&gt;</span> is traced.
              </dd>
          </dl>

        <p>When enabling an <span class="code">Item</span> that represents a group of processes,
        the <span class="code">Item</span> is enabled on all nodes added with the
        <span class="bold_code bc-17"><a href="#n-1"><span class="code">n/1</span></a></span> or
        <span class="bold_code bc-17"><a href="#tracer-3"><span class="code">tracer/3</span></a></span> function.</p>

        <p><span class="code">Flags</span> can be a single atom,
          or a list of flags. The available flags are:
          </p>
        <dl>
          <dt><strong><span class="code">s (send)</span></strong></dt>
          <dd>
            <p>Traces the messages the process or port sends.</p>
          </dd>
          <dt><strong><span class="code">r (receive)</span></strong></dt>
          <dd>
            <p>Traces the messages the process or port receives.</p>
          </dd>
          <dt><strong><span class="code">m (messages)</span></strong></dt>
          <dd>
            <p>Traces the messages the process or port receives and sends.</p>
          </dd>
          <dt><strong><span class="code">c (call)</span></strong></dt>
          <dd>
            <p>Traces global function calls for the process
              according to the trace patterns set in the system (see tp/2).</p>
          </dd>
          <dt><strong><span class="code">p (procs)</span></strong></dt>
          <dd>
            <p>Traces process related events to the process.</p>
          </dd>
          <dt><strong><span class="code">ports</span></strong></dt>
          <dd>
            <p>Traces port related events to the port.</p>
          </dd>
          <dt><strong><span class="code">sos (set on spawn)</span></strong></dt>
          <dd>
            <p>Lets all processes created by the traced
              process inherit the trace flags 
              of the traced process.</p>
          </dd>
          <dt><strong><span class="code">sol (set on link)</span></strong></dt>
          <dd>
            <p>Lets another process, <span class="code">P2</span>, inherit the
              trace flags of the traced 
              process whenever the traced process links to <span class="code">P2</span>.</p>
          </dd>
          <dt><strong><span class="code">sofs (set on first spawn)</span></strong></dt>
          <dd>
            <p>This is the same as <span class="code">sos</span>, but only 
              for the first process spawned by the traced process.</p>
          </dd>
          <dt><strong><span class="code">sofl (set on first link)</span></strong></dt>
          <dd>
            <p>This is the same as <span class="code">sol</span>, but only for
              the first call to
              <span class="bold_code bc-13"><a href="javascript:erlhref('../../../../doc/../','erts','erlang.html#link-1');"><span class="code">link/1</span></a></span> by the traced process.</p>
          </dd>
          <dt><strong><span class="code">all</span></strong></dt>
          <dd>
            <p>Sets all flags except <span class="code">silent</span>.</p>
          </dd>
          <dt><strong><span class="code">clear</span></strong></dt>
          <dd>
            <p>Clears all flags.
              </p>
          </dd>
        </dl>
        <p>The list can also include any of the flags allowed in 
            <span class="bold_code bc-13"><a href="javascript:erlhref('../../../../doc/../','erts','erlang.html#trace-3');"><span class="code">erlang:trace/3</span></a></span></p>
        <p>The function returns either an error tuple or a tuple
          <span class="code">{ok, List}</span>. The <span class="code">List</span> consists of
          specifications of how many processes and ports that matched (in the
          case of a pure pid() exactly 1). The specification of
          matched processes is <span class="code">{matched, Node, N}</span>. If the
          remote processor call,<span class="code">rpc</span>, to a remote node fails,
          the <span class="code">rpc</span> error message is delivered as a fourth
          argument and the number of matched processes are 0. Note
          that the result {ok, List} may contain a list where
          <span class="code">rpc</span> calls to one, several or even all nodes failed.</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-c-3-idm281472333581368').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-c-3-idm281472333581368').style.visibility = 'hidden';"><span id="ghlink-c-3-idm281472333581368" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L305" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="c-3" href="#c-3">c(Mod, Fun, Args)</a></span></div></p>
<div class="REFBODY rb-7"><p>
        <p>Equivalent to <span class="code">c(Mod, Fun, Args, all)</span>.</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-c-4-idm281472334421128').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-c-4-idm281472334421128').style.visibility = 'hidden';"><span id="ghlink-c-4-idm281472334421128" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L312" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="c-4" href="#c-4">c(Mod, Fun, Args, Flags)</a></span></div></p>
<div class="REFBODY rb-7"><p>
        <p>Evaluates the expression <span class="code">apply(Mod, Fun, Args)</span> with the trace
          flags in <span class="code">Flags</span> set. This is a convenient way to trace processes 
          from the Erlang shell.</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-i-0-idm281472334416936').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-i-0-idm281472334416936').style.visibility = 'hidden';"><span id="ghlink-i-0-idm281472334416936" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L321" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="i-0" href="#i-0">i() -&gt; ok</a></span></div></p>
<div class="REFBODY rb-7"><p>
        <p>Displays information about all traced processes and ports.</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-tp-2-idm281472334414568').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-tp-2-idm281472334414568').style.visibility = 'hidden';"><span id="ghlink-tp-2-idm281472334414568" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L328" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="tp-2" href="#tp-2">tp(Module,MatchSpec)</a></span></div></p>
<div class="REFBODY rb-7"><p>
        <p>Same as tp({Module, '_', '_'}, MatchSpec)</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-tp-3-idm281472334411960').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-tp-3-idm281472334411960').style.visibility = 'hidden';"><span id="ghlink-tp-3-idm281472334411960" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L335" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="tp-3" href="#tp-3">tp(Module,Function,MatchSpec)</a></span></div></p>
<div class="REFBODY rb-7"><p>
        <p>Same as tp({Module, Function, '_'}, MatchSpec)</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-tp-4-idm281472334409336').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-tp-4-idm281472334409336').style.visibility = 'hidden';"><span id="ghlink-tp-4-idm281472334409336" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L342" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="tp-4" href="#tp-4">tp(Module, Function, Arity, MatchSpec)</a></span></div></p>
<div class="REFBODY rb-7"><p>
        <p>Same as tp({Module, Function, Arity}, MatchSpec)</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-tp-2-idm281472334406712').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-tp-2-idm281472334406712').style.visibility = 'hidden';"><span id="ghlink-tp-2-idm281472334406712" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L349" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="tp-2" href="#tp-2">tp({Module, Function, Arity}, MatchSpec) -&gt; {ok, MatchDesc} | {error, term()}</a></span></div></p>
<div class="REFBODY rb-5">
<h3 class="func-types-title">Types</h3>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Module = atom() | '_'</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Function = atom() | '_'</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Arity = integer() |'_'</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">MatchSpec = integer() | Built-inAlias | [] | match_spec()</span><br>
</div>
	<div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Built-inAlias = x | c | cx</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">MatchDesc = [MatchInfo]</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">MatchInfo = {saved, integer()} | MatchNum</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">MatchNum = {matched, node(), integer()} | {matched, node(), 0, RPCError}</span><br>
</div>
      </div>
<div class="REFBODY rb-7"><p>
        <p>This function enables call trace for one or more
          functions. All exported functions matching the <span class="code">{Module, Function, Arity}</span>
          argument will be concerned, but the
          <span class="code">match_spec()</span> may further narrow down the set of function
          calls generating trace messages.</p>
        <p>For a description of the <span class="code">match_spec()</span> syntax,
          please turn to the
          <strong>User's guide</strong> part of the online
          documentation for the runtime system (<strong>erts</strong>). The
          chapter <span class="bold_code bc-18"><a href="javascript:erlhref('../../../../doc/../','erts','match_spec.html');"><strong>Match Specifications in Erlang</strong></a></span>
          explains the general match specification "language".
          The most common generic match specifications used can be
          found as <span class="code">Built-inAlias</span>', see
          <span class="bold_code bc-17"><a href="#ltp-0"><span class="code">ltp/0</span></a></span> below for details.
          </p>
        <p>The Module, Function and/or Arity parts of the tuple may
          be specified as the atom <span class="code">'_'</span> which is a "wild-card"
          matching all modules/functions/arities. Note, if the
          Module is specified as <span class="code">'_'</span>, the Function and Arity
          parts have to be specified as '_' too. The same holds for the
          Functions relation to the Arity.</p>
        <p>All nodes added with <span class="bold_code bc-17"><a href="#n-1"><span class="code">n/1</span></a></span> or
            <span class="bold_code bc-17"><a href="#tracer-3"><span class="code">tracer/3</span></a></span> will
          be affected by this call, and if Module is not <span class="code">'_'</span>
          the module will be loaded on all nodes.</p>
        <p>The function returns either an error tuple or a tuple
          <span class="code">{ok, List}</span>. The <span class="code">List</span> consists of specifications of how
          many functions that matched, in the same way as the processes and ports
          are presented in the return value of <span class="bold_code bc-17"><a href="#p-2"><span class="code">p/2</span></a></span>. </p>
        <p>There may be a tuple <span class="code">{saved, N}</span> in the return value,
          if the MatchSpec is other
          than []. The integer <span class="code">N</span> may then be used in
          subsequent calls to this function and will stand as an
          "alias" for the given expression. There are also a couple of
          built-in aliases for common expressions, see
          <span class="bold_code bc-17"><a href="#ltp-0"><span class="code">ltp/0</span></a></span> below for details.</p>
        <p>If an error is returned, it can be due to errors in
          compilation of the match specification. Such errors are
          presented as a list of tuples <span class="code">{error, string()}</span> where
          the string is a textual explanation of the compilation
          error. An example:</p>
        <div class="example"><pre>
(x@y)4&gt; <span class="bold_code bc-12">dbg:tp({dbg,ltp,0},[{[],[],[{message, two, arguments}, {noexist}]}]).</span>
{error,
 [{error,"Special form 'message' called with wrong number of
          arguments in {message,two,arguments}."},
  {error,"Function noexist/1 does_not_exist."}]}</pre></div>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-tpl-2-idm281472334289960').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-tpl-2-idm281472334289960').style.visibility = 'hidden';"><span id="ghlink-tpl-2-idm281472334289960" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L412" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="tpl-2" href="#tpl-2">tpl(Module,MatchSpec)</a></span></div></p>
<div class="REFBODY rb-7"><p>
        <p>Same as tpl({Module, '_', '_'}, MatchSpec)</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-tpl-3-idm281472334287336').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-tpl-3-idm281472334287336').style.visibility = 'hidden';"><span id="ghlink-tpl-3-idm281472334287336" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L419" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="tpl-3" href="#tpl-3">tpl(Module,Function,MatchSpec)</a></span></div></p>
<div class="REFBODY rb-7"><p>
        <p>Same as tpl({Module, Function, '_'}, MatchSpec)</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-tpl-4-idm281472334284696').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-tpl-4-idm281472334284696').style.visibility = 'hidden';"><span id="ghlink-tpl-4-idm281472334284696" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L426" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="tpl-4" href="#tpl-4">tpl(Module, Function, Arity, MatchSpec)</a></span></div></p>
<div class="REFBODY rb-7"><p>
        <p>Same as tpl({Module, Function, Arity}, MatchSpec)</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-tpl-2-idm281472334282056').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-tpl-2-idm281472334282056').style.visibility = 'hidden';"><span id="ghlink-tpl-2-idm281472334282056" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L433" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="tpl-2" href="#tpl-2">tpl({Module, Function, Arity}, MatchSpec) -&gt; {ok, MatchDesc} | {error, term()}</a></span></div></p>
<div class="REFBODY rb-7"><p>
          <p>This function works as <span class="bold_code bc-17"><a href="#tp-2"><span class="code">tp/2</span></a></span>, but enables
          tracing for local calls (and local functions) as well as for
          global calls (and functions).</p>
      </p></div>


    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-tpe-2-idm281472334278680').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-tpe-2-idm281472334278680').style.visibility = 'hidden';"><span id="ghlink-tpe-2-idm281472334278680" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L444" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="tpe-2" href="#tpe-2">tpe(Event, MatchSpec) -&gt; {ok, MatchDesc} | {error, term()}</a></span></div></p>
<div class="REFBODY rb-5">
<h3 class="func-types-title">Types</h3>
	<div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Event = send | 'receive'</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">MatchSpec = integer() | Built-inAlias | [] | match_spec()</span><br>
</div>
	<div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Built-inAlias = x | c | cx</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">MatchDesc = [MatchInfo]</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">MatchInfo = {saved, integer()} | MatchNum</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">MatchNum = {matched, node(), 1} | {matched, node(), 0, RPCError}</span><br>
</div>
      </div>
<div class="REFBODY rb-7"><p>
        <p>This function associates a match specification with trace event
	  <span class="code">send</span> or <span class="code">'receive'</span>. By default all executed <span class="code">send</span>
	  and <span class="code">'receive'</span> events are traced if enabled for a process.
	  A match specification can be used to filter traced events
	  based on sender, receiver and/or message content.</p>
        <p>For a description of the <span class="code">match_spec()</span> syntax,
          please turn to the <strong>User's guide</strong> part of the online
          documentation for the runtime system (<strong>erts</strong>). The
          chapter <span class="bold_code bc-18"><a href="javascript:erlhref('../../../../doc/../','erts','match_spec.html');"><strong>Match Specifications in Erlang</strong></a></span>
          explains the general match specification "language".</p>
	<p>For <span class="code">send</span>, the matching is done on the list <span class="code">[Receiver, Msg]</span>.
	  <span class="code">Receiver</span> is the process or port identity of the receiver and
	  <span class="code">Msg</span> is the message term. The pid of the sending process can be
	  accessed with the guard function <span class="code">self/0</span>.</p>
	<p>For <span class="code">'receive'</span>, the matching is done on the list <span class="code">[Node, Sender, Msg]</span>.
	  <span class="code">Node</span> is the node name of the sender. <span class="code">Sender</span> is the
	  process or port identity of the sender, or the atom
	  <span class="code">undefined</span> if the sender is not known (which may
	  be the case for remote senders). <span class="code">Msg</span> is the
	  message term. The pid of the receiving process can be
	  accessed with the guard function <span class="code">self/0</span>.</p>
        <p>All nodes added with <span class="bold_code bc-17"><a href="#n-1"><span class="code">n/1</span></a></span> or
          <span class="bold_code bc-17"><a href="#tracer-3"><span class="code">tracer/3</span></a></span> will
          be affected by this call.</p>
        <p>The return value is the same as for
	  <span class="bold_code bc-17"><a href="#tp-2"><span class="code">tp/2</span></a></span>. The number of matched
	  events are never larger than 1 as <span class="code">tpe/2</span> does not
	  accept any form of wildcards for argument <span class="code">Event</span>.</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-ctp-0-idm281472334257144').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-ctp-0-idm281472334257144').style.visibility = 'hidden';"><span id="ghlink-ctp-0-idm281472334257144" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L486" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="ctp-0" href="#ctp-0">ctp()</a></span></div></p>
<div class="REFBODY rb-7"><p>
        <p>Same as ctp({'_', '_', '_'})</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-ctp-1-idm281472334254552').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-ctp-1-idm281472334254552').style.visibility = 'hidden';"><span id="ghlink-ctp-1-idm281472334254552" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L493" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="ctp-1" href="#ctp-1">ctp(Module)</a></span></div></p>
<div class="REFBODY rb-7"><p>
        <p>Same as ctp({Module, '_', '_'})</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-ctp-2-idm281472334251960').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-ctp-2-idm281472334251960').style.visibility = 'hidden';"><span id="ghlink-ctp-2-idm281472334251960" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L500" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="ctp-2" href="#ctp-2">ctp(Module, Function)</a></span></div></p>
<div class="REFBODY rb-7"><p>
        <p>Same as ctp({Module, Function, '_'})</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-ctp-3-idm281472334249368').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-ctp-3-idm281472334249368').style.visibility = 'hidden';"><span id="ghlink-ctp-3-idm281472334249368" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L507" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="ctp-3" href="#ctp-3">ctp(Module, Function, Arity)</a></span></div></p>
<div class="REFBODY rb-7"><p>
        <p>Same as ctp({Module, Function, Arity})</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-ctp-1-idm281472334246760').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-ctp-1-idm281472334246760').style.visibility = 'hidden';"><span id="ghlink-ctp-1-idm281472334246760" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L514" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="ctp-1" href="#ctp-1">ctp({Module, Function, Arity}) -&gt; {ok, MatchDesc} | {error, term()}</a></span></div></p>
<div class="REFBODY rb-5">
<h3 class="func-types-title">Types</h3>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Module = atom() | '_'</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Function = atom() | '_'</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Arity = integer() | '_'</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">MatchDesc = [MatchNum]</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">MatchNum = {matched, node(), integer()} | {matched, node(), 0, RPCError}</span><br>
</div>
      </div>
<div class="REFBODY rb-7"><p>
        <p>This function disables call tracing on the specified
          functions. The semantics of the parameter is the same
          as for the corresponding function specification in
          <span class="bold_code bc-17"><a href="#tp-2"><span class="code">tp/2</span></a></span> or <span class="bold_code bc-17"><a href="#tpl-2"><span class="code">tpl/2</span></a></span>. Both local and global call trace
          is disabled. </p>
        <p>The return value reflects how many functions that matched,
            and is constructed as described in <span class="bold_code bc-17"><a href="#tp-2"><span class="code">tp/2</span></a></span>. No tuple
          <span class="code">{saved, N}</span> is however ever returned (for obvious reasons).</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-ctpl-0-idm281472334203608').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-ctpl-0-idm281472334203608').style.visibility = 'hidden';"><span id="ghlink-ctpl-0-idm281472334203608" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L535" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="ctpl-0" href="#ctpl-0">ctpl()</a></span></div></p>
<div class="REFBODY rb-7"><p>
        <p>Same as ctpl({'_', '_', '_'})</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-ctpl-1-idm281472334201064').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-ctpl-1-idm281472334201064').style.visibility = 'hidden';"><span id="ghlink-ctpl-1-idm281472334201064" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L542" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="ctpl-1" href="#ctpl-1">ctpl(Module)</a></span></div></p>
<div class="REFBODY rb-7"><p>
        <p>Same as ctpl({Module, '_', '_'})</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-ctpl-2-idm281472334198472').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-ctpl-2-idm281472334198472').style.visibility = 'hidden';"><span id="ghlink-ctpl-2-idm281472334198472" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L549" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="ctpl-2" href="#ctpl-2">ctpl(Module, Function)</a></span></div></p>
<div class="REFBODY rb-7"><p>
        <p>Same as ctpl({Module, Function, '_'})</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-ctpl-3-idm281472334195880').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-ctpl-3-idm281472334195880').style.visibility = 'hidden';"><span id="ghlink-ctpl-3-idm281472334195880" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L556" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="ctpl-3" href="#ctpl-3">ctpl(Module, Function, Arity)</a></span></div></p>
<div class="REFBODY rb-7"><p>
        <p>Same as ctpl({Module, Function, Arity})</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-ctpl-1-idm281472334193272').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-ctpl-1-idm281472334193272').style.visibility = 'hidden';"><span id="ghlink-ctpl-1-idm281472334193272" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L563" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="ctpl-1" href="#ctpl-1">ctpl({Module, Function, Arity}) -&gt; {ok, MatchDesc} | {error, term()}</a></span></div></p>
<div class="REFBODY rb-7"><p>
          <p>This function works as <span class="bold_code bc-17"><a href="#ctp-1"><span class="code">ctp/1</span></a></span>, but only disables
              tracing set up with <span class="bold_code bc-17"><a href="#tpl-2"><span class="code">tpl/2</span></a></span>
              (not with <span class="bold_code bc-17"><a href="#tp-2"><span class="code">tp/2</span></a></span>).</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-ctpg-0-idm281472334188056').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-ctpg-0-idm281472334188056').style.visibility = 'hidden';"><span id="ghlink-ctpg-0-idm281472334188056" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L572" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="ctpg-0" href="#ctpg-0">ctpg()</a></span></div></p>
<div class="REFBODY rb-7"><p>
        <p>Same as ctpg({'_', '_', '_'})</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-ctpg-1-idm281472334185464').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-ctpg-1-idm281472334185464').style.visibility = 'hidden';"><span id="ghlink-ctpg-1-idm281472334185464" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L579" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="ctpg-1" href="#ctpg-1">ctpg(Module)</a></span></div></p>
<div class="REFBODY rb-7"><p>
        <p>Same as ctpg({Module, '_', '_'})</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-ctpg-2-idm281472334182872').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-ctpg-2-idm281472334182872').style.visibility = 'hidden';"><span id="ghlink-ctpg-2-idm281472334182872" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L586" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="ctpg-2" href="#ctpg-2">ctpg(Module, Function)</a></span></div></p>
<div class="REFBODY rb-7"><p>
        <p>Same as ctpg({Module, Function, '_'})</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-ctpg-3-idm281472334180280').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-ctpg-3-idm281472334180280').style.visibility = 'hidden';"><span id="ghlink-ctpg-3-idm281472334180280" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L593" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="ctpg-3" href="#ctpg-3">ctpg(Module, Function, Arity)</a></span></div></p>
<div class="REFBODY rb-7"><p>
        <p>Same as ctpg({Module, Function, Arity})</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-ctpg-1-idm281472334177672').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-ctpg-1-idm281472334177672').style.visibility = 'hidden';"><span id="ghlink-ctpg-1-idm281472334177672" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L600" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="ctpg-1" href="#ctpg-1">ctpg({Module, Function, Arity}) -&gt; {ok, MatchDesc} | {error, term()}</a></span></div></p>
<div class="REFBODY rb-7"><p>
          <p>This function works as <span class="bold_code bc-17"><a href="#ctp-1"><span class="code">ctp/1</span></a></span>, but only disables
              tracing set up with <span class="bold_code bc-17"><a href="#tp-2"><span class="code">tp/2</span></a></span>
              (not with <span class="bold_code bc-17"><a href="#tpl-2"><span class="code">tpl/2</span></a></span>).</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-ctpe-1-idm281472334172456').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-ctpe-1-idm281472334172456').style.visibility = 'hidden';"><span id="ghlink-ctpe-1-idm281472334172456" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L609" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="ctpe-1" href="#ctpe-1">ctpe(Event) -&gt; {ok, MatchDesc} | {error, term()}</a></span></div></p>
<div class="REFBODY rb-5">
<h3 class="func-types-title">Types</h3>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Event = send | 'receive'</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">MatchDesc = [MatchNum]</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">MatchNum = {matched, node(), 1} | {matched, node(), 0, RPCError}</span><br>
</div>
      </div>
<div class="REFBODY rb-7"><p>
        <p>This function clears match specifications for the specified
	  trace event (<span class="code">send</span> or <span class="code">'receive'</span>). It will revert back
	  to the default behavior of tracing all triggered events.</p>
        <p>The return value follow the same style as for
	  <span class="bold_code bc-17"><a href="#ctp-1"><span class="code">ctp/1</span></a></span>.</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-ltp-0-idm281472334165832').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-ltp-0-idm281472334165832').style.visibility = 'hidden';"><span id="ghlink-ltp-0-idm281472334165832" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L625" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="ltp-0" href="#ltp-0">ltp() -&gt; ok</a></span></div></p>
<div class="REFBODY rb-7"><p>
        <p>Use this function to recall all match specifications previously
          used in the session (i. e. previously saved during calls
          to <span class="bold_code bc-17"><a href="#tp-2"><span class="code">tp/2</span></a></span>, and built-in match specifications.
          This is very useful, as a complicated
          match_spec can be quite awkward to write. Note that the
          match specifications are lost if <span class="bold_code bc-17"><a href="#stop-0"><span class="code">stop/0</span></a></span> is called.</p>
        <p>Match specifications used can be saved in a file (if a
          read-write file system is present) for use in later
          debugging sessions, see <span class="bold_code bc-17"><a href="#wtp-1"><span class="code">wtp/1</span></a></span>
          and <span class="bold_code bc-17"><a href="#rtp-1"><span class="code">rtp/1</span></a></span></p>
	<p>There are three built-in trace patterns:
	  <span class="code">exception_trace</span>, <span class="code">caller_trace</span> 
	  and <span class="code">caller_exception_trace</span> (or <span class="code">x</span>, <span class="code">c</span> and 
	  <span class="code">cx</span> respectively). 
	  Exception trace sets a trace which will show function names, 
	  parameters, return values and exceptions thrown from functions. 
	  Caller traces display function names, parameters and information 
	  about which function called it. An example using a built-in alias:</p>
	  <div class="example"><pre>
(x@y)4&gt; <span class="bold_code bc-12">dbg:tp(lists,sort,cx).</span>
{ok,[{matched,nonode@nohost,2},{saved,cx}]}
(x@y)4&gt; <span class="bold_code bc-12">lists:sort([2,1]).</span>
(&lt;0.32.0&gt;) call lists:sort([2,1]) ({erl_eval,do_apply,5})
(&lt;0.32.0&gt;) returned from lists:sort/1 -&gt; [1,2]
[1,2]</pre></div>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-dtp-0-idm281472334155048').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-dtp-0-idm281472334155048').style.visibility = 'hidden';"><span id="ghlink-dtp-0-idm281472334155048" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L656" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="dtp-0" href="#dtp-0">dtp() -&gt; ok</a></span></div></p>
<div class="REFBODY rb-7"><p>
        <p>Use this function to "forget" all match specifications
            saved during calls to <span class="bold_code bc-17"><a href="#tp-2"><span class="code">tp/2</span></a></span>.
            This is useful when one wants to restore other match
            specifications from a file with <span class="bold_code bc-17"><a href="#rtp-1"><span class="code">rtp/1</span></a></span>. Use
            <span class="bold_code bc-17"><a href="#dtp-1"><span class="code">dtp/1</span></a></span> to delete specific saved match specifications.</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-dtp-1-idm281472334149736').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-dtp-1-idm281472334149736').style.visibility = 'hidden';"><span id="ghlink-dtp-1-idm281472334149736" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L667" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="dtp-1" href="#dtp-1">dtp(N) -&gt; ok</a></span></div></p>
<div class="REFBODY rb-5">
<h3 class="func-types-title">Types</h3>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">N = integer()</span><br>
</div>
      </div>
<div class="REFBODY rb-7"><p>
        <p>Use this function to "forget" a specific match specification
            saved during calls to <span class="bold_code bc-17"><a href="#tp-2"><span class="code">tp/2</span></a></span>.</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-wtp-1-idm281472334145352').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-wtp-1-idm281472334145352').style.visibility = 'hidden';"><span id="ghlink-wtp-1-idm281472334145352" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L678" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="wtp-1" href="#wtp-1">wtp(Name) -&gt; ok | {error, IOError}</a></span></div></p>
<div class="REFBODY rb-5">
<h3 class="func-types-title">Types</h3>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Name = string()</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">IOError = term()</span><br>
</div>
      </div>
<div class="REFBODY rb-7"><p>
        <p>This function will save all match specifications saved
            during the session (during calls to <span class="bold_code bc-17"><a href="#tp-2"><span class="code">tp/2</span></a></span>)
          and built-in match specifications in a text
          file with the name designated by <span class="code">Name</span>. The format
          of the file is textual, why it can be edited with an
          ordinary text editor, and then restored with
          <span class="bold_code bc-17"><a href="#rtp-1"><span class="code">rtp/1</span></a></span>. </p>
        <p>Each match spec in the file ends with a full stop
          (<span class="code">.</span>) and new (syntactically correct) match
          specifications can be added to the file manually.</p>
        <p>The function returns <span class="code">ok</span> or an error tuple where the
          second element contains the I/O error that made the
          writing impossible.</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-rtp-1-idm281472333578040').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-rtp-1-idm281472333578040').style.visibility = 'hidden';"><span id="ghlink-rtp-1-idm281472333578040" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L701" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="rtp-1" href="#rtp-1">rtp(Name) -&gt; ok | {error, Error}</a></span></div></p>
<div class="REFBODY rb-5">
<h3 class="func-types-title">Types</h3>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Name = string()</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Error = term()</span><br>
</div>
      </div>
<div class="REFBODY rb-7"><p>
        <p>This function reads match specifications from a file
           (possibly) generated by the <span class="bold_code bc-17"><a href="#wtp-1"><span class="code">wtp/1</span></a></span>
           function. It checks
          the syntax of all match specifications and verifies that
          they are correct. The error handling principle is "all or
          nothing", i. e. if some of the match specifications are
          wrong, none of the specifications are added to the list of
          saved match specifications for the running system. </p>
        <p>The match specifications in the file are <strong>merged</strong>
          with the current match specifications, so that no duplicates
          are generated. Use <span class="bold_code bc-17"><a href="#ltp-0"><span class="code">ltp/0</span></a></span>
          to see what numbers were
          assigned to the specifications from the file.</p>
        <p>The function will return an error, either due to I/O
          problems (like a non existing or non readable file) or due
          to file format problems. The errors from a bad format file
          are in a more or less textual format, which will give a hint
          to what's causing the problem.
        </p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-n-1-idm281472333571736').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-n-1-idm281472333571736').style.visibility = 'hidden';"><span id="ghlink-n-1-idm281472333571736" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L730" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="n-1" href="#n-1">n(Nodename) -&gt; {ok, Nodename} | {error, Reason}</a></span></div></p>
<div class="REFBODY rb-5">
<h3 class="func-types-title">Types</h3>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Nodename = atom()</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Reason = term()</span><br>
</div>
      </div>
<div class="REFBODY rb-7"><p>
        <p>The <span class="code">dbg</span> server keeps a list of nodes where tracing
            should be performed. Whenever a <span class="bold_code bc-17"><a href="#tp-2"><span class="code">tp/2</span></a></span> call or a
            <span class="bold_code bc-17"><a href="#p-2"><span class="code">p/2</span></a></span> call is made, it is executed for all nodes in this
            list including the local node (except for <span class="bold_code bc-17"><a href="#p-2"><span class="code">p/2</span></a></span> with a
          specific <span class="code">pid()</span> or <span class="code">port()</span> as first argument, in which case the
          command is executed only on the node where the designated
          process or port resides).
          </p>
        <p>This function adds a remote node (<span class="code">Nodename</span>) to the
          list of nodes where tracing is performed. It starts a tracer
          process on the remote node, which will send all trace messages
          to the tracer process on the local node (via the Erlang
          distribution). If no tracer process is running on the local
          node, the error reason <span class="code">no_local_tracer</span> is returned. The
          tracer process on the local node must be started with the
          <span class="bold_code bc-17"><a href="#tracer-2"><span class="code">tracer/0/2</span></a></span> function.
          </p>
        <p>If <span class="code">Nodename</span> is the local node, the error reason
          <span class="code">cant_add_local_node</span> is returned.
          </p>
        <p>If a trace port (see <span class="bold_code bc-17"><a href="#trace_port-2"><span class="code">trace_port/2</span></a></span>) is
          running on the local node, remote nodes can not be traced with
          a tracer process. The error reason
          <span class="code">cant_trace_remote_pid_to_local_port</span> is returned. A
          trace port can however be started on the remote node with the
          <span class="bold_code bc-17"><a href="#tracer-3"><span class="code">tracer/3</span></a></span> function.
          </p>
        <p>The function will also return an error if the node
          <span class="code">Nodename</span> is not reachable.</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-cn-1-idm281472333556808').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-cn-1-idm281472333556808').style.visibility = 'hidden';"><span id="ghlink-cn-1-idm281472333556808" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L769" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="cn-1" href="#cn-1">cn(Nodename) -&gt; ok</a></span></div></p>
<div class="REFBODY rb-5">
<h3 class="func-types-title">Types</h3>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Nodename = atom()</span><br>
</div>
      </div>
<div class="REFBODY rb-7"><p>
        <p>Clears a node from the list of traced nodes. Subsequent
            calls to <span class="bold_code bc-17"><a href="#tp-2"><span class="code">tp/2</span></a></span> and
            <span class="bold_code bc-17"><a href="#p-2"><span class="code">p/2</span></a></span> will not consider that
            node, but tracing already activated on the node will continue
            to be in effect.</p>
        <p>Returns <span class="code">ok</span>, cannot fail.</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-ln-0-idm281472333550664').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-ln-0-idm281472333550664').style.visibility = 'hidden';"><span id="ghlink-ln-0-idm281472333550664" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L784" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="ln-0" href="#ln-0">ln() -&gt; ok</a></span></div></p>
<div class="REFBODY rb-7"><p>
        <p>Shows the list of traced nodes on the console.</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-tracer-0-idm281472333548056').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-tracer-0-idm281472333548056').style.visibility = 'hidden';"><span id="ghlink-tracer-0-idm281472333548056" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L791" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="tracer-0" href="#tracer-0">tracer() -&gt; {ok, pid()} | {error, already_started}</a></span></div></p>
<div class="REFBODY rb-7"><p>
        <p>This function starts a server on the local node that will
          be the recipient of all trace messages. All subsequent calls
          to <span class="bold_code bc-17"><a href="#p-2"><span class="code">p/2</span></a></span> will result in messages sent to the newly
          started trace server.</p>
        <p>A trace server started in this way will simply display the
          trace messages in a formatted way in the Erlang shell
          (i. e. use io:format). See <span class="bold_code bc-17"><a href="#tracer-2"><span class="code">tracer/2</span></a></span>
          for a description of how the trace message handler can be customized.
        </p>
        <p>To start a similar tracer on a remote node, use <span class="bold_code bc-17"><a href="#n-1"><span class="code">n/1</span></a></span>.</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-tracer-2-idm281472333541832').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-tracer-2-idm281472333541832').style.visibility = 'hidden';"><span id="ghlink-tracer-2-idm281472333541832" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L807" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="tracer-2" href="#tracer-2">tracer(Type, Data) -&gt; {ok, pid()} | {error, Error}</a></span></div></p>
<div class="REFBODY rb-5">
<h3 class="func-types-title">Types</h3>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Type = port | process | module</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Data = PortGenerator | HandlerSpec | ModuleSpec</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">PortGenerator = fun() (no arguments)</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Error = term()</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">HandlerSpec = {HandlerFun, InitialData}</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">HandlerFun = fun() (two arguments)</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">ModuleSpec = fun() (no arguments) | {TracerModule, TracerState}</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">TracerModule = atom()</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">InitialData = TracerState = term()</span><br>
</div>
      </div>
<div class="REFBODY rb-7"><p>
        <p>This function starts a tracer server with additional
          parameters on the local node. The first parameter, the
          <span class="code">Type</span>, indicates if trace messages should be handled
          by a receiving process (<span class="code">process</span>), by a tracer port
          (<span class="code">port</span>) or by a tracer module
          (<span class="code">module</span>). For a description about tracer ports see
          <span class="bold_code bc-17"><a href="#trace_port-2"><span class="code">trace_port/2</span></a></span>
          and for a tracer modules see
          <span class="bold_code bc-18"><a href="javascript:erlhref('../../../../doc/../','erts','erl_tracer.html');"><span class="code">erl_tracer</span></a></span>.
          </p>
        <p>If <span class="code">Type</span> is <span class="code">process</span>, a message handler function can
          be specified (<span class="code">HandlerSpec</span>). The handler function, which
          should be a <span class="code">fun</span> taking two arguments, will be called
          for each trace message, with the first argument containing the
          message as it is and the second argument containing the return
          value from the last invocation of the fun. The initial value
          of the second parameter is specified in the <span class="code">InitialData</span>
          part of the <span class="code">HandlerSpec</span>. The <span class="code">HandlerFun</span> may
          choose any appropriate action to take when invoked, and can
          save a state for the next invocation by returning it.
          </p>
        <p>If <span class="code">Type</span> is <span class="code">port</span>, then the second parameter should
          be a <strong>fun</strong> which takes no arguments and returns a
          newly opened trace port when called. Such a <strong>fun</strong> is
          preferably generated by calling <span class="bold_code bc-17"><a href="#trace_port-2"><span class="code">trace_port/2</span></a></span>.
          </p>
        <p>if <span class="code">Type</span> is <span class="code">module</span>, then the second parameter should
            be either a tuple describing the <span class="bold_code bc-18"><a href="javascript:erlhref('../../../../doc/../','erts','erl_tracer.html');"><span class="code">erl_tracer</span></a></span>
          module to be used for tracing and the state to be used for
          that tracer module or a fun returning the same tuple.</p>
        <p>If an error is returned, it can either be due to a tracer
          server already running (<span class="code">{error,already_started}</span>) or
          due to the <span class="code">HandlerFun</span> throwing an exception.
          </p>
        <p>To start a similar tracer on a remote node, use
            <span class="bold_code bc-17"><a href="#tracer-3"><span class="code">tracer/3</span></a></span>.
        </p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-tracer-3-idm281472333518856').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-tracer-3-idm281472333518856').style.visibility = 'hidden';"><span id="ghlink-tracer-3-idm281472333518856" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L861" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="tracer-3" href="#tracer-3">tracer(Nodename, Type, Data) -&gt; {ok, Nodename} | {error, Reason}</a></span></div></p>
<div class="REFBODY rb-5">
<h3 class="func-types-title">Types</h3>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Nodename = atom()</span><br>
</div>
      </div>
<div class="REFBODY rb-7"><p>
          <p>This function is equivalent to <span class="bold_code bc-17"><a href="#tracer-2"><span class="code">tracer/2</span></a></span>, but acts on
          the given node. A tracer is started on the node
          (<span class="code">Nodename</span>) and the node is added to the list of traced nodes.
          </p>
        <div class="note">
<div class="label">Note</div>
<div class="content"><p>
            <p>This function is not equivalent to <span class="bold_code bc-17"><a href="#n-1"><span class="code">n/1</span></a></span>. While
                <span class="bold_code bc-17"><a href="#n-1"><span class="code">n/1</span></a></span> starts a process tracer which redirects all trace
            information to a process tracer on the local node (i.e. the
            trace control node), <span class="bold_code bc-17"><a href="#tracer-3"><span class="code">tracer/3</span></a></span> starts a tracer of any
            type which is independent of the tracer on the trace control
            node.</p>
        </p></div>
</div>
        <p>For details, see <span class="bold_code bc-17"><a href="#tracer-2"><span class="code">tracer/2</span></a></span>.</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-trace_port-2-idm281472333509160').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-trace_port-2-idm281472333509160').style.visibility = 'hidden';"><span id="ghlink-trace_port-2-idm281472333509160" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L883" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="trace_port-2" href="#trace_port-2">trace_port(Type, Parameters) -&gt; fun()</a></span></div></p>
<div class="REFBODY rb-5">
<h3 class="func-types-title">Types</h3>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Type = ip | file</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Parameters = Filename | WrapFilesSpec | IPPortSpec</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Filename = string() | [string()] | atom()</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">WrapFilesSpec = {Filename, wrap, Suffix} | {Filename, wrap, Suffix, WrapSize} | {Filename, wrap, Suffix, WrapSize, WrapCnt}</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Suffix = string()</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">WrapSize = integer() &gt;= 0 | {time, WrapTime}</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">WrapTime = integer() &gt;= 1</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">WrapCnt = integer() &gt;= 1</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">IpPortSpec = PortNumber | {PortNumber, QueSize}</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">PortNumber = integer()</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">QueSize = integer()</span><br>
</div>
      </div>
<div class="REFBODY rb-7"><p>
        <p>This function creates a trace port generating <strong>fun</strong>.
          The <strong>fun</strong> takes no arguments and returns a newly opened
          trace port. The return value from this function is suitable as
          a second parameter to tracer/2, i.e. <span class="code">dbg:tracer(port, dbg:trace_port(ip, 4711))</span>. </p>
        <p>A trace port is an
          Erlang port to a dynamically linked in driver that handles
          trace messages directly, without the overhead of sending them
          as messages in the Erlang virtual machine.</p>
        <p>Two trace drivers are currently implemented, the
          <span class="code">file</span> and the <span class="code">ip</span> trace drivers. The file driver
          sends all trace messages into one or several binary files, 
          from where they later can be fetched and processed with the
          <span class="bold_code bc-17"><a href="#trace_client-2"><span class="code">trace_client/2</span></a></span> function. The ip driver opens a TCP/IP
          port where it listens for connections. When a client
          (preferably started by calling <span class="bold_code bc-17"><a href="#trace_client-2"><span class="code">trace_client/2</span></a></span> on
          another Erlang node) connects, all trace messages are sent
          over the IP network for further processing by the remote
          client. </p>
        <p>Using a trace port significantly lowers the overhead
          imposed by using tracing.</p>
        <p>The file trace driver expects a filename or a wrap files 
          specification as parameter. A file is written with a high
          degree of buffering, why all trace messages are <strong>not</strong>
          guaranteed to be saved in the file in case of a system
          crash. That is the price to pay for low tracing overhead.</p>
        <p>A wrap files specification is used to limit the disk
          space consumed by the trace. The trace is written to a
          limited number of files each with a limited size. 
          The actual filenames are <span class="code">Filename ++ SeqCnt ++ Suffix</span>, where <span class="code">SeqCnt</span> counts as a decimal string
          from <span class="code">0</span> to <span class="code">WrapCnt</span> and then around again from
          <span class="code">0</span>. When a trace term written to 
          the current file makes it longer than <span class="code">WrapSize</span>,
          that file is closed, if the number of files in this 
          wrap trace is as many as <span class="code">WrapCnt</span> the oldest file
          is deleted then a new file is opened to become the current.
          Thus, when a wrap trace has been stopped, there are at most
          <span class="code">WrapCnt</span> trace files saved with a size of at least
          <span class="code">WrapSize</span> (but not much bigger), except for 
          the last file that might even be empty. The default values
          are <span class="code">WrapSize = 128*1024</span> and <span class="code">WrapCnt = 8</span>.</p>
        <p>The <span class="code">SeqCnt</span> values in the filenames are all in the
          range <span class="code">0</span> through <span class="code">WrapCnt</span> with a gap in the
          circular sequence. The gap is needed to find the end of the
          trace.</p>
        <p>If the <span class="code">WrapSize</span> is specified as 
          <span class="code">{time, WrapTime}</span>, the current file is closed when it
          has been open more than <span class="code">WrapTime</span> milliseconds,
          regardless of it being empty or not.</p>
        <p>The ip trace driver has a queue of <span class="code">QueSize</span> messages
          waiting to be delivered. If the driver cannot deliver messages
          as fast as they are produced by the runtime system, a special
          message is sent, which indicates how many messages that are
          dropped. That message will arrive at the handler function
          specified in <span class="bold_code bc-17"><a href="#trace_client-3"><span class="code">trace_client/3</span></a></span>
          as the tuple <span class="code">{drop, N}</span> where <span class="code">N</span> is the number of consecutive messages
          dropped. In case of heavy tracing, drop's are likely to occur,
          and they surely occur if no client is reading the trace
          messages. The default value of <span class="code">QueSize</span> is 200.</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-flush_trace_port-0-idm281472333481016').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-flush_trace_port-0-idm281472333481016').style.visibility = 'hidden';"><span id="ghlink-flush_trace_port-0-idm281472333481016" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L960" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="flush_trace_port-0" href="#flush_trace_port-0">flush_trace_port()</a></span></div></p>
<div class="REFBODY rb-7"><p>
        <p>Equivalent to <span class="code">flush_trace_port(node())</span>.</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-flush_trace_port-1-idm281472333477992').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-flush_trace_port-1-idm281472333477992').style.visibility = 'hidden';"><span id="ghlink-flush_trace_port-1-idm281472333477992" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L967" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="flush_trace_port-1" href="#flush_trace_port-1">flush_trace_port(Nodename) -&gt; ok | {error, Reason}</a></span></div></p>
<div class="REFBODY rb-7"><p>
        <p>Equivalent to <span class="code">trace_port_control(Nodename,flush)</span>.</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-trace_port_control-1-idm281472333474904').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-trace_port_control-1-idm281472333474904').style.visibility = 'hidden';"><span id="ghlink-trace_port_control-1-idm281472333474904" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L974" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="trace_port_control-1" href="#trace_port_control-1">trace_port_control(Operation)</a></span></div></p>
<div class="REFBODY rb-7"><p>
        <p>Equivalent to <span class="code">trace_port_control(node(),Operation)</span>.</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-trace_port_control-2-idm281472333471848').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-trace_port_control-2-idm281472333471848').style.visibility = 'hidden';"><span id="ghlink-trace_port_control-2-idm281472333471848" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L981" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="trace_port_control-2" href="#trace_port_control-2">trace_port_control(Nodename,Operation) -&gt;  ok | {ok, Result} | {error, Reason}</a></span></div></p>
<div class="REFBODY rb-5">
<h3 class="func-types-title">Types</h3>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Nodename = atom()</span><br>
</div>
      </div>
<div class="REFBODY rb-7"><p>
        <p>This function is used to do a control operation on the
          active trace port driver on the given node
          (<span class="code">Nodename</span>). Which operations are allowed as well
          as their return values depend on which trace driver
          is used.</p>
        <p>Returns either <span class="code">ok</span> or <span class="code">{ok, Result}</span> 
          if the operation was successful, or <span class="code">{error, Reason}</span> 
          if the current tracer is a process 
          or if it is a port not supporting the operation.</p>
        <p>The allowed values for <span class="code">Operation</span> are:</p>
        <dl>
          <dt><strong><span class="code">flush</span></strong></dt>
          <dd>
            <p>This function is used to flush the internal buffers 
              held by a trace port driver. Currently only the 
              file trace driver supports this operation. 
              Returns <span class="code">ok</span>.</p>
          </dd>
          <dt><strong><span class="code">get_listen_port</span></strong></dt>
          <dd>
            <p>Returns <span class="code">{ok, IpPort}</span> where <span class="code">IpPort</span> is
              the IP port number used by the driver listen socket.
              Only the ip trace driver supports this operation.</p>
          </dd>
        </dl>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-trace_client-2-idm281472333460088').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-trace_client-2-idm281472333460088').style.visibility = 'hidden';"><span id="ghlink-trace_client-2-idm281472333460088" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L1015" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="trace_client-2" href="#trace_client-2">trace_client(Type, Parameters) -&gt; pid()</a></span></div></p>
<div class="REFBODY rb-5">
<h3 class="func-types-title">Types</h3>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Type = ip | file | follow_file</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Parameters = Filename | WrapFilesSpec | IPClientPortSpec</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Filename = string() | [string()] | atom()</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">WrapFilesSpec = see trace_port/2</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Suffix = string()</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">IpClientPortSpec = PortNumber | {Hostname, PortNumber}</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">PortNumber = integer()</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Hostname = string()</span><br>
</div>
      </div>
<div class="REFBODY rb-7"><p>
        <p>This function starts a trace client that reads the output
          created by a trace port driver and handles it in mostly the
          same way as a tracer process created by the
          <span class="bold_code bc-17"><a href="#tracer-0"><span class="code">tracer/0</span></a></span> function.</p>
        <p>If <span class="code">Type</span> is <span class="code">file</span>, the client reads all trace
          messages stored in the file named <span class="code">Filename</span> or 
          specified by <span class="code">WrapFilesSpec</span> (must be the same as used
          when creating the trace, see trace_port/2)
          and let's the default handler function format the
          messages on the console. This is one way to interpret the data
          stored in a file by the file trace port driver.</p>
        <p>If <span class="code">Type</span> is <span class="code">follow_file</span>, the client behaves as
          in the <span class="code">file</span> case, but keeps trying to read (and
          process) more data
          from the file until stopped by <span class="bold_code bc-17"><a href="#stop_trace_client-1"><span class="code">stop_trace_client/1</span></a></span>.
          <span class="code">WrapFilesSpec</span> is not allowed as second argument 
          for this <span class="code">Type</span>.</p>
        <p>If <span class="code">Type</span> is <span class="code">ip</span>, the client connects to the
          TCP/IP port <span class="code">PortNumber</span> on the host <span class="code">Hostname</span>,
          from where it reads trace messages until the TCP/IP connection
          is closed. If no <span class="code">Hostname</span> is specified, the local host
          is assumed.</p>
        <p>As an example, one can let trace messages be sent over the
          network to another Erlang node (preferably <strong>not</strong>
          distributed), where the formatting occurs:</p>
        <p>On the node <span class="code">stack</span> there's an Erlang node
          <span class="code">ant@stack</span>, in the shell, type the following:</p>
        <div class="example"><pre>
ant@stack&gt; <span class="bold_code bc-12">dbg:tracer(port, dbg:trace_port(ip,4711)).</span>
&lt;0.17.0&gt;
ant@stack&gt; <span class="bold_code bc-12">dbg:p(self(), send).</span>
{ok,1}</pre></div>
        <p>All trace messages are now sent to the trace port driver,
          which in turn listens for connections on the TCP/IP port
          4711. If we want to see the messages on another node,
          preferably on another host, we do like this:</p>
        <div class="example"><pre>
-&gt; <span class="bold_code bc-12">dbg:trace_client(ip, {"stack", 4711}).</span>
&lt;0.42.0&gt;</pre></div>
        <p>If we now send a message from the shell on the node
          <span class="code">ant@stack</span>, where all sends from the shell are traced:</p>
        <div class="example"><pre>
ant@stack&gt; <span class="bold_code bc-12">self() ! hello.</span>
hello</pre></div>
        <p>The following will appear at the console on the node that
          started the trace client:</p>
        <div class="example"><pre>
(&lt;0.23.0&gt;) &lt;0.23.0&gt; ! hello
(&lt;0.23.0&gt;) &lt;0.22.0&gt; ! {shell_rep,&lt;0.23.0&gt;,{value,hello,[],[]}}</pre></div>
        <p>The last line is generated due to internal message passing
          in the Erlang shell. The process id's will vary.</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-trace_client-3-idm281472333434888').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-trace_client-3-idm281472333434888').style.visibility = 'hidden';"><span id="ghlink-trace_client-3-idm281472333434888" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L1082" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="trace_client-3" href="#trace_client-3">trace_client(Type, Parameters, HandlerSpec) -&gt; pid()</a></span></div></p>
<div class="REFBODY rb-5">
<h3 class="func-types-title">Types</h3>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Type = ip | file | follow_file</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Parameters = Filename | WrapFilesSpec | IPClientPortSpec</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Filename = string() | [string()] | atom()</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">WrapFilesSpec = see trace_port/2</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Suffix = string()</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">IpClientPortSpec = PortNumber | {Hostname, PortNumber}</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">PortNumber = integer()</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Hostname = string()</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">HandlerSpec = {HandlerFun, InitialData}</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">HandlerFun = fun() (two arguments)</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">InitialData = term()</span><br>
</div>
      </div>
<div class="REFBODY rb-7"><p>
          <p>This function works exactly as <span class="bold_code bc-17"><a href="#trace_client-2"><span class="code">trace_client/2</span></a></span>,
          but allows you to write your own handler function. The handler
          function works mostly as the one described in
          <span class="bold_code bc-17"><a href="#tracer-2"><span class="code">tracer/2</span></a></span>, but will also have to be prepared to handle
          trace messages of the form <span class="code">{drop, N}</span>, where <span class="code">N</span> is
          the number of dropped messages. This pseudo trace message will
          only occur if the ip trace driver is used.</p>
        <p>For trace type <span class="code">file</span>, the pseudo trace message
          <span class="code">end_of_trace</span> will appear at the end of the trace. The
          return value from the handler function is in this case
          ignored.</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-stop_trace_client-1-idm281472333422296').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-stop_trace_client-1-idm281472333422296').style.visibility = 'hidden';"><span id="ghlink-stop_trace_client-1-idm281472333422296" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L1112" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="stop_trace_client-1" href="#stop_trace_client-1">stop_trace_client(Pid) -&gt; ok</a></span></div></p>
<div class="REFBODY rb-5">
<h3 class="func-types-title">Types</h3>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Pid = pid()</span><br>
</div>
      </div>
<div class="REFBODY rb-7"><p>
        <p>This function shuts down a previously started trace
          client. The <span class="code">Pid</span> argument is the process id returned
          from the <span class="bold_code bc-17"><a href="#trace_client-2"><span class="code">trace_client/2</span></a></span>
          or <span class="bold_code bc-17"><a href="#trace_client-3"><span class="code">trace_client/3</span></a></span> call.</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-get_tracer-0-idm281472333416568').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-get_tracer-0-idm281472333416568').style.visibility = 'hidden';"><span id="ghlink-get_tracer-0-idm281472333416568" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L1125" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="get_tracer-0" href="#get_tracer-0">get_tracer()</a></span></div></p>
<div class="REFBODY rb-7"><p>
        <p>Equivalent to <span class="code">get_tracer(node())</span>.</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-get_tracer-1-idm281472333413560').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-get_tracer-1-idm281472333413560').style.visibility = 'hidden';"><span id="ghlink-get_tracer-1-idm281472333413560" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L1132" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="get_tracer-1" href="#get_tracer-1">get_tracer(Nodename) -&gt; {ok, Tracer}</a></span></div></p>
<div class="REFBODY rb-5">
<h3 class="func-types-title">Types</h3>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Nodename = atom()</span><br>
</div>
        <div class="REFTYPES rt-4">
<span class="bold_code fun-param-type">Tracer = port() | pid() | {module(), term()}</span><br>
</div>
      </div>
<div class="REFBODY rb-7"><p>
        <p>Returns the process, port or tracer module to which all trace
          messages are sent.</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-stop-0-idm281472333409496').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-stop-0-idm281472333409496').style.visibility = 'hidden';"><span id="ghlink-stop-0-idm281472333409496" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L1144" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="stop-0" href="#stop-0">stop() -&gt; ok</a></span></div></p>
<div class="REFBODY rb-7"><p>
        <p>Stops the <span class="code">dbg</span> server and clears all trace flags for
          all processes and all local trace patterns for all functions. Also
          shuts down all trace clients and closes all trace ports.</p>
        <p>Note that no global trace patterns are affected by this
          function.</p>
      </p></div>
    <p><div class="bold_code fun-type"><span onMouseOver="document.getElementById('ghlink-stop_clear-0-idm281472333405352').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-stop_clear-0-idm281472333405352').style.visibility = 'hidden';"><span id="ghlink-stop_clear-0-idm281472333405352" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L1155" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="stop_clear-0" href="#stop_clear-0">stop_clear() -&gt; ok</a></span></div></p>
<div class="REFBODY rb-7"><p>
        <p>Same as stop/0, but also clears all trace patterns on global functions calls.</p>
      </p></div>
  </div>

  <h3>
<a name="simple_example"></a><span onMouseOver="document.getElementById('ghlink-simple-examples---tracing-from-the-shell-idm281472333402680').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-simple-examples---tracing-from-the-shell-idm281472333402680').style.visibility = 'hidden';"><span id="ghlink-simple-examples---tracing-from-the-shell-idm281472333402680" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L1164" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="simple-examples---tracing-from-the-shell" href="#simple-examples---tracing-from-the-shell">Simple examples - tracing from the shell</a></span>
</h3>
<div class="REFBODY rb-3">
    
    
    <p>The simplest way of tracing from the Erlang shell is to use
      <span class="code">dbg:c/3</span> or <span class="code">dbg:c/4</span>, e.g. tracing the function
      <span class="code">dbg:get_tracer/0</span>:</p>
    <div class="example"><pre>
(tiger@durin)84&gt; <span class="bold_code bc-12">dbg:c(dbg,get_tracer,[]).</span>
(&lt;0.154.0&gt;) &lt;0.152.0&gt; ! {&lt;0.154.0&gt;,{get_tracer,tiger@durin}}
(&lt;0.154.0&gt;) out {dbg,req,1}
(&lt;0.154.0&gt;) &lt;&lt; {dbg,{ok,&lt;0.153.0&gt;}}
(&lt;0.154.0&gt;) in {dbg,req,1}
(&lt;0.154.0&gt;) &lt;&lt; timeout
{ok,&lt;0.153.0&gt;}
(tiger@durin)85&gt;</pre></div>
    <p>Another way of tracing from the shell is to explicitly start a
      <strong>tracer</strong> and then set the <strong>trace flags</strong> of your
      choice on the processes you want to trace, e.g. trace messages and
      process events:</p>
    <div class="example"><pre>
(tiger@durin)66&gt; <span class="bold_code bc-12">Pid = spawn(fun() -&gt; receive {From,Msg} -&gt; From ! Msg end end).</span>
&lt;0.126.0&gt;
(tiger@durin)67&gt; <span class="bold_code bc-12">dbg:tracer().</span>
{ok,&lt;0.128.0&gt;}
(tiger@durin)68&gt; <span class="bold_code bc-12">dbg:p(Pid,[m,procs]).</span>
{ok,[{matched,tiger@durin,1}]}
(tiger@durin)69&gt; <span class="bold_code bc-12">Pid ! {self(),hello}.</span>
(&lt;0.126.0&gt;) &lt;&lt; {&lt;0.116.0&gt;,hello}
{&lt;0.116.0&gt;,hello}
(&lt;0.126.0&gt;) &lt;&lt; timeout
(&lt;0.126.0&gt;) &lt;0.116.0&gt; ! hello
(&lt;0.126.0&gt;) exit normal
(tiger@durin)70&gt; <span class="bold_code bc-12">flush().</span>
Shell got hello
ok
(tiger@durin)71&gt;</pre></div>
    <p>If you set the <span class="code">call</span> trace flag, you also have to set a
      <strong>trace pattern</strong> for the functions you want to trace:</p>
    <div class="example"><pre>
(tiger@durin)77&gt; <span class="bold_code bc-12">dbg:tracer().</span>
{ok,&lt;0.142.0&gt;}
(tiger@durin)78&gt; <span class="bold_code bc-12">dbg:p(all,call).</span>
{ok,[{matched,tiger@durin,3}]}
(tiger@durin)79&gt; <span class="bold_code bc-12">dbg:tp(dbg,get_tracer,0,[]).</span>
{ok,[{matched,tiger@durin,1}]}
(tiger@durin)80&gt; <span class="bold_code bc-12">dbg:get_tracer().</span>
(&lt;0.116.0&gt;) call dbg:get_tracer()
{ok,&lt;0.143.0&gt;}
(tiger@durin)81&gt; <span class="bold_code bc-12">dbg:tp(dbg,get_tracer,0,[{'_',[],[{return_trace}]}]).</span>
{ok,[{matched,tiger@durin,1},{saved,1}]}
(tiger@durin)82&gt; <span class="bold_code bc-12">dbg:get_tracer().</span>
(&lt;0.116.0&gt;) call dbg:get_tracer()
(&lt;0.116.0&gt;) returned from dbg:get_tracer/0 -&gt; {ok,&lt;0.143.0&gt;}
{ok,&lt;0.143.0&gt;}
(tiger@durin)83&gt;</pre></div>
  </div>

  <h3>
<a name="advanced"></a><span onMouseOver="document.getElementById('ghlink-advanced-topics---combining-with-seq_trace-idm281472333388872').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-advanced-topics---combining-with-seq_trace-idm281472333388872').style.visibility = 'hidden';"><span id="ghlink-advanced-topics---combining-with-seq_trace-idm281472333388872" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L1221" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="advanced-topics---combining-with-seq_trace" href="#advanced-topics---combining-with-seq_trace">Advanced topics - combining with seq_trace</a></span>
</h3>
<div class="REFBODY rb-3">
    
    
    <p>The <span class="code">dbg</span> module is primarily targeted towards
      tracing through the <span class="code">erlang:trace/3</span> function. It is
      sometimes desired to trace messages in a more delicate way, which
      can be done with the help of the <span class="code">seq_trace</span> module. 
      </p>
    <p><span class="code">seq_trace</span> implements sequential tracing (known in the
      AXE10 world, and sometimes called "forlopp tracing"). <span class="code">dbg</span>
      can interpret messages generated from <span class="code">seq_trace</span> and the
      same tracer function for both types of tracing can be used. The
      <span class="code">seq_trace</span> messages can even be sent to a trace port for
      further analysis.
      </p>
    <p>As a match specification can turn on sequential tracing, the
      combination of <span class="code">dbg</span> and <span class="code">seq_trace</span> can be quite
      powerful.  This brief example shows a session where sequential
      tracing is used:</p>
    <div class="example"><pre>
1&gt; <span class="bold_code bc-12">dbg:tracer().</span>
{ok,&lt;0.30.0&gt;}
2&gt; <span class="bold_code bc-12">{ok, Tracer} = dbg:get_tracer().</span>
{ok,&lt;0.31.0&gt;}
3&gt; <span class="bold_code bc-12">seq_trace:set_system_tracer(Tracer).</span>
false
4&gt; <span class="bold_code bc-12">dbg:tp(dbg, get_tracer, 0, [{[],[],[{set_seq_token, send, true}]}]).</span>
{ok,[{matched,nonode@nohost,1},{saved,1}]}
5&gt; <span class="bold_code bc-12">dbg:p(all,call).</span>
{ok,[{matched,nonode@nohost,22}]}
6&gt; <span class="bold_code bc-12">dbg:get_tracer(), seq_trace:set_token([]).</span>
(&lt;0.25.0&gt;) call dbg:get_tracer()
SeqTrace [0]: (&lt;0.25.0&gt;) &lt;0.30.0&gt; ! {&lt;0.25.0&gt;,get_tracer} [Serial: {2,4}]
SeqTrace [0]: (&lt;0.30.0&gt;) &lt;0.25.0&gt; ! {dbg,{ok,&lt;0.31.0&gt;}} [Serial: {4,5}]
{1,0,5,&lt;0.30.0&gt;,4}</pre></div>
    <p>This session sets the system_tracer to the same process as
      the ordinary tracer process (i. e. &lt;0.31.0&gt;) and sets the
      trace pattern for the function <span class="code">dbg:get_tracer</span> to one that
      has the action of setting a sequential token. When the function
      is called by a traced process (all processes are traced in this
      case), the process gets "contaminated" by the token and
      <span class="code">seq_trace</span> messages are sent both for the server request
      and the response. The <span class="code">seq_trace:set_token([])</span> after the
      call clears the <span class="code">seq_trace</span> token, why no messages are sent
      when the answer propagates via the shell to the console port. 
      The output would otherwise have been more noisy.</p>
  </div>

  <h3><span onMouseOver="document.getElementById('ghlink-note-of-caution-idm281472333375000').style.visibility = 'visible';" onMouseOut="document.getElementById('ghlink-note-of-caution-idm281472333375000').style.visibility = 'hidden';"><span id="ghlink-note-of-caution-idm281472333375000" class="ghlink"><a href="https://github.com/erlang/otp/edit/maint/lib/runtime_tools/doc/src/dbg.xml#L1269" title="Found an issue with the documentation? Fix it by clicking here!"><span class="pencil"></span></a></span><a class="title_link" name="note-of-caution" href="#note-of-caution">Note of caution</a></span></h3>
<div class="REFBODY rb-3">
    
    <p>When tracing function calls on a group leader process (an IO process), there is risk 
      of causing a deadlock. This will happen if a group leader process generates a trace 
      message and the tracer process, by calling the trace handler function, sends an IO 
      request to the same group leader. The problem can only occur if the trace handler 
      prints to tty using an <span class="code">io</span> function such as <span class="bold_code bc-13"><a href="javascript:erlhref('../../../../doc/../','stdlib','io.html#format-2');"><span class="code">format/2</span></a></span>.
      Note that when
      <span class="code">dbg:p(all,call)</span> is called, IO processes are also traced.
      Here's an example:</p>
    <div class="example"><pre>
%% Using a default line editing shell
1&gt; <span class="bold_code bc-12">dbg:tracer(process, {fun(Msg,_) -&gt; io:format("~p~n", [Msg]), 0 end, 0}).</span>
{ok,&lt;0.37.0&gt;}
2&gt; <span class="bold_code bc-12">dbg:p(all, [call]).</span>
{ok,[{matched,nonode@nohost,25}]}
3&gt; <span class="bold_code bc-12">dbg:tp(mymod,[{'_',[],[]}]).</span>
{ok,[{matched,nonode@nohost,0},{saved,1}]}
4&gt; <span class="bold_code bc-12">mymod:</span> % TAB pressed here
%% -- Deadlock --</pre></div>
    <p>Here's another example:</p>
    <div class="example"><pre>
%% Using a shell without line editing (oldshell)
1&gt; <span class="bold_code bc-12">dbg:tracer(process).</span>
{ok,&lt;0.31.0&gt;}
2&gt; <span class="bold_code bc-12">dbg:p(all, [call]).</span>
{ok,[{matched,nonode@nohost,25}]}
3&gt; <span class="bold_code bc-12">dbg:tp(lists,[{'_',[],[]}]).</span>
{ok,[{matched,nonode@nohost,0},{saved,1}]}
% -- Deadlock --</pre></div>
    <p>The reason we get a deadlock in the first example is because when TAB is pressed 
      to expand the function name, the group leader (which handles character input) calls
      <span class="code">mymod:module_info()</span>. This generates a trace message which, in turn, causes the 
      tracer process to send an IO request to the group leader (by calling <span class="code">io:format/2</span>).
      We end up in a deadlock.</p>
    <p>In the second example we use the default trace handler function. This handler
      prints to tty by sending IO requests to the <span class="code">user</span> process. When Erlang is
      started in oldshell mode, the shell process will have <span class="code">user</span> as its
      group leader and so will the tracer process in this example. Since <span class="code">user</span> calls 
      functions in <span class="code">lists</span> we end up in a deadlock as soon as the first IO request is sent.</p>
    <p>Here are a few suggestions for how to avoid deadlock:</p>
    <ul>
      <li>Don't trace the group leader of the tracer process. If tracing has been switched on
       for all processes, call <span class="code">dbg:p(TracerGLPid,clear)</span> to stop tracing the group leader
       (<span class="code">TracerGLPid</span>). <span class="code">process_info(TracerPid,group_leader)</span> tells you 
       which process this is (<span class="code">TracerPid</span> is returned from <span class="code">dbg:get_tracer/0</span>).</li>
      <li>Don't trace the <span class="code">user</span> process if using the default trace handler function.</li>
      <li>In your own trace handler function, call <span class="code">erlang:display/1</span> instead of an
      <span class="code">io</span> function or, if <span class="code">user</span> is not used as group leader, print to 
      <span class="code">user</span> instead of the default group leader. Example:
      <span class="code">io:format(user,Str,Args)</span>.</li>
    </ul>
  </div>
</div>
<div class="footer">
<hr>
<p>Copyright © 1999-2019 Ericsson AB. All Rights Reserved.</p>
</div>
</div>
</div>
<script type="text/javascript">window.__otpTopDocDir = '../../../../doc/js/';</script><script type="text/javascript" src="../../../../doc/js/highlight.js"></script>
</body>
</html>