<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html xmlns:fn="http://www.w3.org/2005/02/xpath-functions"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="stylesheet" href="../../../../doc/otp_doc.css" type="text/css"> <title>Erlang -- ttb</title> </head> <body bgcolor="white" text="#000000" link="#0000ff" vlink="#ff00ff" alink="#ff0000"><div id="container"> <script id="js" type="text/javascript" language="JavaScript" src="../../../../doc/js/flipmenu/flipmenu.js"></script><script id="js2" type="text/javascript" src="../../../../doc/js/erlresolvelinks.js"></script><script language="JavaScript" type="text/javascript"> <!-- function getWinHeight() { var myHeight = 0; if( typeof( window.innerHeight ) == 'number' ) { //Non-IE myHeight = window.innerHeight; } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode' myHeight = document.documentElement.clientHeight; } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible myHeight = document.body.clientHeight; } return myHeight; } function setscrollpos() { var objf=document.getElementById('loadscrollpos'); document.getElementById("leftnav").scrollTop = objf.offsetTop - getWinHeight()/2; } function addEvent(obj, evType, fn){ if (obj.addEventListener){ obj.addEventListener(evType, fn, true); return true; } else if (obj.attachEvent){ var r = obj.attachEvent("on"+evType, fn); return r; } else { return false; } } addEvent(window, 'load', setscrollpos); //--></script><div id="leftnav"><div class="innertube"> <img alt="Erlang logo" src="../../../../doc/erlang-logo.png"><br><small><a href="users_guide.html">User's Guide</a><br><a href="index.html">Reference Manual</a><br><a href="release_notes.html">Release Notes</a><br><a href="../pdf/observer-0.9.8.2.pdf">PDF</a><br><a href="../../../../doc/index.html">Top</a></small><p><strong>Observer</strong><br><strong>Reference Manual</strong><br><small>Version 0.9.8.2</small></p> <br><a href="javascript:openAllFlips()">Expand All</a><br><a href="javascript:closeAllFlips()">Contract All</a><p><small><strong>Table of Contents</strong></small></p> <ul class="flipMenu"> <li title="observer (App)"><a href="observer_app.html">observer (App) </a></li> <li id="loadscrollpos" title="ttb " expanded="true">ttb<ul> <li><a href="ttb.html"> Top of manual page </a></li> <li title="tracer-0"><a href="ttb.html#tracer-0">tracer/0</a></li> <li title="tracer-1"><a href="ttb.html#tracer-1">tracer/1</a></li> <li title="tracer-2"><a href="ttb.html#tracer-2">tracer/2</a></li> <li title="p-2"><a href="ttb.html#p-2">p/2</a></li> <li title="-0"><a href="ttb.html#-0">/0</a></li> <li title="list_history-0"><a href="ttb.html#list_history-0">list_history/0</a></li> <li title="run_history-1"><a href="ttb.html#run_history-1">run_history/1</a></li> <li title="write_config-2"><a href="ttb.html#write_config-2">write_config/2</a></li> <li title="write_config-3"><a href="ttb.html#write_config-3">write_config/3</a></li> <li title="run_config-1"><a href="ttb.html#run_config-1">run_config/1</a></li> <li title="run_config-2"><a href="ttb.html#run_config-2">run_config/2</a></li> <li title="list_config-1"><a href="ttb.html#list_config-1">list_config/1</a></li> <li title="write_trace_info-2"><a href="ttb.html#write_trace_info-2">write_trace_info/2</a></li> <li title="seq_trigger_ms-0"><a href="ttb.html#seq_trigger_ms-0">seq_trigger_ms/0</a></li> <li title="seq_trigger_ms-1"><a href="ttb.html#seq_trigger_ms-1">seq_trigger_ms/1</a></li> <li title="stop-0"><a href="ttb.html#stop-0">stop/0</a></li> <li title="stop-1"><a href="ttb.html#stop-1">stop/1</a></li> <li title="format-1"><a href="ttb.html#format-1">format/1</a></li> <li title="format-2"><a href="ttb.html#format-2">format/2</a></li> </ul> </li> <li id="no" title="etop " expanded="false">etop<ul> <li><a href="etop.html"> Top of manual page </a></li> <li title="config-2"><a href="etop.html#config-2">config/2</a></li> <li title="dump-1"><a href="etop.html#dump-1">dump/1</a></li> <li title="stop-0"><a href="etop.html#stop-0">stop/0</a></li> </ul> </li> <li id="no" title="crashdump_viewer " expanded="false">crashdump_viewer<ul> <li><a href="crashdump_viewer.html"> Top of manual page </a></li> <li title="start-0"><a href="crashdump_viewer.html#start-0">start/0</a></li> <li title="stop-0"><a href="crashdump_viewer.html#stop-0">stop/0</a></li> </ul> </li> </ul> </div></div> <div id="content"> <div class="innertube"> <!-- refpage --><center><h1>ttb</h1></center> <h3>MODULE</h3> <div class="REFBODY">ttb</div> <h3>MODULE SUMMARY</h3> <div class="REFBODY">A base for building trace tools for distributed systems.</div> <h3>DESCRIPTION</h3> <div class="REFBODY"><p> <p>The Trace Tool Builder <span class="code">ttb</span> is a base for building trace tools for distributed systems. </p> <p>When using <span class="code">ttb</span>, <span class="code">dbg</span> shall not be used in parallel.</p> </p></div> <h3>EXPORTS</h3> <p><a name="tracer-0"><span class="bold_code">tracer() -> Result</span></a><br></p> <div class="REFBODY"><p> <p>This is equivalent to <span class="code">tracer(node())</span>.</p> </p></div> <p><a name="tracer-1"><span class="bold_code">tracer(Nodes) -> Result</span></a><br></p> <div class="REFBODY"><p> <p>This is equivalent to <span class="code">tracer(Nodes,[])</span>.</p> </p></div> <p><a name="tracer-2"><span class="bold_code">tracer(Nodes,Opts) -> Result</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Result = {ok, ActivatedNodes} | {error,Reason}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Nodes = atom() | [atom()] | all | existing | new</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Opts = [Opt]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Opt = {file,Client} | {handler, FormatHandler} | {process_info,PI}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Client = File | {local, File}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">File = Filename | Wrap</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Filename = string()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Wrap = {wrap,Filename} | {wrap,Filename,Size,Count}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">FormatHandler = See format/2</span><br> </div> <div class="REFTYPES"> <span class="bold_code">PI = true | false </span><br> </div> </div> <div class="REFBODY"><p> <p>This function starts a file trace port on all given nodes and also points the system tracer for sequential tracing to the same port. </p> <p>The given <span class="code">Filename</span> will be prefixed with the node name. Default <span class="code">Filename</span> is "ttb". </p> <p><span class="code">File={wrap,Filename,Size,Count}</span> can be used if the size of the trace logs must be limited. Default values are <span class="code">Size=128*1024</span> and <span class="code">Count=8</span>. </p> <p>When tracing diskless nodes, <span class="code">ttb</span> must be started from an external "trace control node" with disk access, and <span class="code">Client</span> must be <span class="code">{local, File}</span>. All trace information is then sent to the trace control node where it is written to file. </p> <p>The <span class="code">process_info</span> option indicates if process information should be collected. If <span class="code">PI = true</span> (which is default), each process identifier <span class="code">Pid</span> is replaced by a tuple <span class="code">{Pid,ProcessInfo,Node}</span>, where <span class="code">ProcessInfo</span> is the process' registered name its globally registered name, or its initial function. It is possible to turn off this functionality by setting <span class="code">PI = false</span>. </p> </p></div> <p><a name="p-2"><span class="bold_code">p(Procs,Flags) -> Return</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Return = {ok,[{Procs,MatchDesc}]}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Procs = Process | [Process] | all | new | existing</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Process = pid() | atom() | {global,atom()}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Flags = Flag | [Flag]</span><br> </div> </div> <div class="REFBODY"><p> <p>This function sets the given trace flags on the given processes. </p> <p>Please turn to the Reference manual for module <span class="code">dbg</span> for details about the possible trace flags. The parameter <span class="code">MatchDesc</span> is the same as returned from <span class="code">dbg:p/2</span></p> <p>Processes can be given as registered names, globally registered names or process identifiers. If a registered name is given, the flags are set on processes with this name on all active nodes.</p> </p></div> <p><a name="-0"><span class="bold_code">tp, tpl, ctp, ctpl, ctpg</span></a><br></p> <div class="REFBODY"><p> <p>These functions should be used in combination with the <span class="code">call</span> trace flag for setting and clearing trace patterns. When the <span class="code">call</span> trace flag is set on a process, function calls will be traced on that process if a trace pattern has been set for the called function. Trace patterns specifies how to trace a function by using match specifications. Match specifications are described in the User's Guide for the erlang runtime system <span class="code">erts</span>. </p> <p>These functions are equivalent to the corresponding functions in <span class="code">dbg</span>, but all calls are stored in the history. The history buffer makes it easy to create config files so that the same trace environment can be setup several times, e.g. if you want to compare two test runs. It also reduces the amount of typing when using <span class="code">ttb</span> from the erlang shell. </p> <dl> <dt><strong><span class="code">tp</span></strong></dt> <dd>Set trace pattern on global function calls</dd> <dt><strong><span class="code">tpl</span></strong></dt> <dd>Set trace pattern on local and global function calls</dd> <dt><strong><span class="code">ctp</span></strong></dt> <dd>Clear trace pattern on local and global function calls</dd> <dt><strong><span class="code">ctpl</span></strong></dt> <dd>Clear trace pattern on local function calls</dd> <dt><strong><span class="code">ctpg</span></strong></dt> <dd>Clear trace pattern on global function calls</dd> </dl> </p></div> <p><a name="list_history-0"><span class="bold_code">list_history() -> History</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">History = [{N,Func,Args}]</span><br> </div> </div> <div class="REFBODY"><p> <p>All calls to <span class="code">ttb</span> is stored in the history. This function returns the current content of the history. Any entry can be re-executed with <span class="code">run_history/1</span> or stored in a config file with <span class="code">write_config/2/3</span>.</p> </p></div> <p><a name="run_history-1"><span class="bold_code">run_history(N) -> ok | {error, Reason}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">N = integer() | [integer()]</span><br> </div> </div> <div class="REFBODY"><p> <p>Executes the given entry or entries from the history list. History can be listed with <span class="code">list_history/0</span>.</p> </p></div> <p><a name="write_config-2"><span class="bold_code">write_config(ConfigFile,Config)</span></a><br></p> <div class="REFBODY"><p> <p>Equivalent to <span class="code">write_config(ConfigFile,Config,[])</span>.</p> </p></div> <p><a name="write_config-3"><span class="bold_code">write_config(ConfigFile,Config,Opt) -> ok | {error,Reason}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">ConfigFile = string()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Config = all | [integer()] | [{Mod,Func,Args}]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Mod = atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Func = atom()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Args = [term()]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Opt = [] | [append]</span><br> </div> </div> <div class="REFBODY"><p> <p>This function creates or extends a config file which can be used for restoring a specific configuration later. </p> <p>The content of the config file can either be fetched from the history or given directly as a list of <span class="code">{Mod,Func,Args}</span>. </p> <p>If the complete history is to be stored in the config file <span class="code">Config</span> should be <span class="code">all</span>. If only a selected number of entries from the history should be stored, <span class="code">Config</span> should be a list of integers pointing out the entries to be stored. </p> <p>If <span class="code">Opt</span> is not given or if it is <span class="code">[]</span>, <span class="code">ConfigFile</span> is deleted and a new file is created. If <span class="code">Opt = [append]</span>, <span class="code">ConfigFile</span> will not be deleted. The new information will be appended at the end of the file.</p> </p></div> <p><a name="run_config-1"><span class="bold_code">run_config(ConfigFile) -> ok | {error,Reason}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">ConfigFile = string()</span><br> </div> </div> <div class="REFBODY"><p> <p>Executes all entries in the given config file.</p> </p></div> <p><a name="run_config-2"><span class="bold_code">run_config(ConfigFile,NumList) -> ok | {error,Reason}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">ConfigFile = string()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">NumList = [integer()]</span><br> </div> </div> <div class="REFBODY"><p> <p>Executes selected entries from the given config file. <span class="code">NumList</span> is a list of integers pointing out the entries to be executed. </p> <p>The content of a config file can be listed with <span class="code">list_config/1</span>.</p> </p></div> <p><a name="list_config-1"><span class="bold_code">list_config(ConfigFile) -> Config | {error,Reason}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">ConfigFile = string()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Config = [{N,Func,Args}]</span><br> </div> </div> <div class="REFBODY"><p> <p>Lists all entries in the given config file.</p> </p></div> <p><a name="write_trace_info-2"><span class="bold_code">write_trace_info(Key,Info) -> ok</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Key = term()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Info = Data | fun() -> Data</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Data = term()</span><br> </div> </div> <div class="REFBODY"><p> <p>The <span class="code">.ti</span> file contains <span class="code">{Key,ValueList}</span> tuples. This function adds <span class="code">Data</span> to the ValueList associated with <span class="code">Key</span>. All information written with this function will be included in the call to the format handler.</p> </p></div> <p><a name="seq_trigger_ms-0"><span class="bold_code">seq_trigger_ms() -> MatchSpec</span></a><br></p> <div class="REFBODY"><p> <p>Equivalent to <span class="code">seq_trigger_ms(all)</span></p> </p></div> <p><a name="seq_trigger_ms-1"><span class="bold_code">seq_trigger_ms(Flags) -> MatchSpec</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">MatchSpec = match_spec()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Flags = all | SeqTraceFlag | [SeqTraceFlag]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">SeqTraceFlag = atom()</span><br> </div> </div> <div class="REFBODY"><p> <p>A match specification can turn on or off sequential tracing. This function returns a match specification which turns on sequential tracing with the given <span class="code">Flags</span>. </p> <p>This match specification can be given as the last argument to <span class="code">tp</span> or <span class="code">tpl</span>. The activated <span class="code">Item</span> will then become a <strong>trigger</strong> for sequential tracing. This means that if the item is called on a process with the <span class="code">call</span> trace flag set, the process will be "contaminated" with the seq_trace token. </p> <p>If <span class="code">Flags = all</span>, all possible flags are set. </p> <p>Please turn to the reference manual for the <strong><span class="code">seq_trace</span></strong> module in the <strong><span class="code">kernel</span></strong> application to see the possible values for <span class="code">SeqTraceFlag</span>. For a description of the match_spec() syntax, please turn to the <strong>User's guide</strong> for the runtime system (<strong>erts</strong>). The chapter <strong>Match Specification in Erlang</strong> explains the general match specification "language". </p> <div class="note"> <div class="label">Note</div> <div class="content"><p> <p>The <strong>system tracer</strong> for sequential tracing is automatically initiated by <span class="code">ttb</span> when a trace port is started with <span class="code">ttb:tracer/0/1/2</span>.</p> </p></div> </div> <p>Example of how to use the <span class="code">seq_trigger_ms/0/1</span> function:</p> <div class="example"><pre> (tiger@durin)5> ttb:tracer(). {ok,[tiger@durin]} (tiger@durin)6> ttb:p(all,call). {ok,{[all],[call]}} (tiger@durin)7> ttb:tp(mod,func,ttb:seq_trigger_ms()). {ok,[{matched,1},{saved,1}]} (tiger@durin)8> </pre></div> <p>Whenever <span class="code">mod:func(...)</span> is called after this, the seq_trace token will be set on the executing process.</p> </p></div> <p><a name="stop-0"><span class="bold_code">stop()</span></a><br></p> <div class="REFBODY"><p> <p>Equivalent to <span class="code">stop([])</span>.</p> </p></div> <p><a name="stop-1"><span class="bold_code">stop(Opts) -> stopped</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">Opts = [Opt]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Opt = fetch | format</span><br> </div> </div> <div class="REFBODY"><p> <p>Stops tracing on all nodes. </p> <p>The <span class="code">fetch</span> option indicates that trace logs shall be collected from all nodes after tracing is stopped. This option is useful if nodes on remote machines are traced. Logs and trace information files are then sent to the trace control node and stored in a directory named <span class="code">ttb_upload-Timestamp</span>, where <span class="code">Timestamp</span> is on the form <span class="code">yyyymmdd-hhmmss</span>. Even logs from nodes on the same machine as the trace control node are moved to this directory. </p> <p>The <span class="code">format</span> option indicates that the trace logs shall be formatted after tracing is stopped. Note that this option also implies the <span class="code">fetch</span> option, i.e. logs are collected in a new directory on the trace control node before formatting. All logs in the directory will be merged.</p> </p></div> <p><a name="format-1"><span class="bold_code">format(File)</span></a><br></p> <div class="REFBODY"><p> <p>Same as <span class="code">format(File,[])</span>.</p> </p></div> <p><a name="format-2"><span class="bold_code">format(File,Options) -> ok | {error, Reason}</span></a><br></p> <div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"> <span class="bold_code">File = string() | [string()]</span><br> </div> <div class="REFBODY">This can be the name of a binary log, a list of such logs or the name of a directory containing one or more binary logs.</div> <div class="REFTYPES"> <span class="bold_code">Options = [Opt]</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Opt = {out,Out} | {handler,FormatHandler}</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Out = standard_io | string()</span><br> </div> <div class="REFTYPES"> <span class="bold_code">FormatHandler = {Function, InitialState} | et</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Function = fun(Fd,Trace,TraceInfo,State) -> State</span><br> </div> <div class="REFTYPES"> <span class="bold_code">Fd = standard_io | FileDescriptor</span><br> </div> <div class="REFBODY">This is the file descriptor of the destination file <span class="code">Out</span> </div> <div class="REFTYPES"> <span class="bold_code">Trace = tuple()</span><br> </div> <div class="REFBODY">This is the trace message. Please turn to the Reference manual for the <span class="code">erlang</span>module for details.</div> <div class="REFTYPES"> <span class="bold_code">TraceInfo = [{Key,ValueList}]</span><br> </div> <div class="REFBODY">This includes the keys <span class="code">flags</span>, <span class="code">client</span>and <span class="code">node</span>, and if <span class="code">handler</span>is given as option to the tracer function, this is also included. In addition all information written with the <span class="code">write_trace_info/2</span>function is included. </div> </div> <div class="REFBODY"><p> <p>Reads the given binary trace log(s). If a directory or a list of logs is given and the <span class="code">timestamp</span> flag was set during tracing, the trace messages from the different logs are merged according to the timestamps. </p> <p>If <span class="code">FormatHandler = {Function,InitialState}</span>, <span class="code">Function</span> will be called for each trace message. If <span class="code">FormatHandler = et</span>, <span class="code">et_viewer</span> in the <strong>Event Tracer</strong> application (<span class="code">et</span>) is used for presenting the trace log graphically. <span class="code">ttb</span> provides a few different filters which can be selected from the Filter menu in the <span class="code">et_viewer</span>. If <span class="code">FormatHandler</span> is not given, a default handler is used which presents each trace message as a line of text. </p> <p>If <span class="code">Out</span> is given, <span class="code">FormatHandler</span> gets the filedescriptor to <span class="code">Out</span> as the first parameter. </p> <p><span class="code">Out</span> is ignored if <span class="code">FormatHandler = et</span>. </p> <p>Wrap logs can be formatted one by one or all in one go. To format one of the wrap logs in a set, give the exact name of the file. To format the whole set of wrap logs, give the name with '*' instead of the wrap count. See examples in the <span class="code">ttb</span> User's Guide.</p> </p></div> </div> <div class="footer"> <hr> <p>Copyright © 2002-2010 Ericsson AB. All Rights Reserved.</p> </div> </div> </div></body> </html>