<!DOCTYPE html> <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>tt — Arthas 3.0.5 documentation</title> <link rel="shortcut icon" href="_static/favicon.ico"/> <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <link rel="stylesheet" href="_static/overrides.css" type="text/css" /> <link rel="index" title="Index" href="genindex.html" /> <link rel="search" title="Search" href="search.html" /> <link rel="next" title="options" href="options.html" /> <link rel="prev" title="stack" href="stack.html" /> <script src="_static/center_page.js"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/styles/github.min.css"> <script src="_static/js/modernizr.min.js"></script> </head> <body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search"> <a href="index.html" class="icon icon-home"> Arthas </a> <div class="version"> 3.0.5 </div> <div role="search"> <form id="rtd-search-form" class="wy-form" action="search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> </div> </div> <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> <ul class="current"> <li class="toctree-l1"><a class="reference internal" href="install-detail.html">Installation</a></li> <li class="toctree-l1"><a class="reference internal" href="quick-start.html">Quick start</a></li> <li class="toctree-l1"><a class="reference internal" href="advanced-use.html">Advanced usage</a></li> <li class="toctree-l1 current"><a class="reference internal" href="commands.html">Commands</a><ul class="current"> <li class="toctree-l2"><a class="reference internal" href="dashboard.html">dashboard</a></li> <li class="toctree-l2"><a class="reference internal" href="thread.html">thread</a></li> <li class="toctree-l2"><a class="reference internal" href="jvm.html">jvm</a></li> <li class="toctree-l2"><a class="reference internal" href="sysprop.html">sysprop</a></li> <li class="toctree-l2"><a class="reference internal" href="sysenv.html">sysenv</a></li> <li class="toctree-l2"><a class="reference internal" href="getstatic.html">getstatic</a></li> <li class="toctree-l2"><a class="reference internal" href="ognl.html">ognl</a></li> <li class="toctree-l2"><a class="reference internal" href="sc.html">sc</a></li> <li class="toctree-l2"><a class="reference internal" href="sm.html">sm</a></li> <li class="toctree-l2"><a class="reference internal" href="dump.html">dump</a></li> <li class="toctree-l2"><a class="reference internal" href="jad.html">jad</a></li> <li class="toctree-l2"><a class="reference internal" href="classloader.html">classloader</a></li> <li class="toctree-l2"><a class="reference internal" href="redefine.html">redefine</a></li> <li class="toctree-l2"><a class="reference internal" href="monitor.html">monitor</a></li> <li class="toctree-l2"><a class="reference internal" href="watch.html">watch</a></li> <li class="toctree-l2"><a class="reference internal" href="trace.html">trace</a></li> <li class="toctree-l2"><a class="reference internal" href="stack.html">stack</a></li> <li class="toctree-l2 current"><a class="current reference internal" href="#">tt</a><ul> <li class="toctree-l3"><a class="reference internal" href="#usage">Usage</a><ul> <li class="toctree-l4"><a class="reference internal" href="#start-demo">Start Demo</a></li> <li class="toctree-l4"><a class="reference internal" href="#record-method-calls">Record method calls</a></li> <li class="toctree-l4"><a class="reference internal" href="#list-all-records">List all records</a></li> <li class="toctree-l4"><a class="reference internal" href="#searching-for-records">Searching for records</a></li> <li class="toctree-l4"><a class="reference internal" href="#check-context-of-the-call">Check context of the call</a></li> </ul> </li> <li class="toctree-l3"><a class="reference internal" href="#replay-record">Replay record</a></li> </ul> </li> <li class="toctree-l2"><a class="reference internal" href="options.html">options</a></li> <li class="toctree-l2"><a class="reference internal" href="commands.html#basic-arthas-commands">Basic Arthas Commands</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="docker.html">Docker</a></li> <li class="toctree-l1"><a class="reference external" href="https://github.com/alibaba/arthas/issues?q=label%3Auser-case">User cases</a></li> <li class="toctree-l1"><a class="reference external" href="https://github.com/alibaba/arthas/issues?q=label%3Aquestion-answered">Questions and answers</a></li> <li class="toctree-l1"><a class="reference external" href="https://github.com/alibaba/arthas">Fork me at GitHub</a></li> <li class="toctree-l1"><a class="reference external" href="https://github.com/alibaba/arthas/blob/master/CONTRIBUTING.md">CONTRIBUTING</a></li> <li class="toctree-l1"><a class="reference internal" href="release-notes.html">Release Notes</a></li> </ul> </div> </div> </nav> <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> <nav class="wy-nav-top" aria-label="top navigation"> <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="index.html">Arthas</a> </nav> <div class="wy-nav-content"> <div class="rst-content"> <div role="navigation" aria-label="breadcrumbs navigation"> <ul class="wy-breadcrumbs"> <li><a href="index.html">Docs</a> »</li> <li><a href="commands.html">All Commands</a> »</li> <li>tt</li> <li class="wy-breadcrumbs-aside"> <a href="https://github.com/alibaba/arthas/blob/master/site/src/site/sphinx/en/tt.md" class="fa fa-github"> Edit on GitHub</a> </li> </ul> <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> <div class="section" id="tt"> <span id="tt"></span><h1>tt<a class="headerlink" href="#tt" title="Permalink to this headline">¶</a></h1> <p>Check the <tt class="docutils literal">parameters</tt>, <tt class="docutils literal">return values</tt> and <tt class="docutils literal">exceptions</tt> of the methods at different times.</p> <p><tt class="docutils literal">watch</tt> is a powerful command but due to its feasibility and complexity, it’s quite hard to locate the issue effectively.</p> <p>In such difficulties, <tt class="docutils literal">tt</tt> comes into play.</p> <p>With the help of <tt class="docutils literal">tt</tt> (<em>TimeTunnel</em>), you can check the contexts of the methods at different times in execution history.</p> <div class="section" id="usage"> <span id="usage"></span><h2>Usage<a class="headerlink" href="#usage" title="Permalink to this headline">¶</a></h2> <div class="section" id="start-demo"> <span id="start-demo"></span><h3>Start Demo<a class="headerlink" href="#start-demo" title="Permalink to this headline">¶</a></h3> <p>Start <tt class="docutils literal">arthas-demo</tt> in <a class="reference internal" href="quick-start.html"><span class="doc">Quick Start</span></a>.</p> </div> <div class="section" id="record-method-calls"> <span id="record-method-calls"></span><h3>Record method calls<a class="headerlink" href="#record-method-calls" title="Permalink to this headline">¶</a></h3> <div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash">$ tt -t demo.MathGame primeFactors Press Ctrl+C to abort. Affect(class-cnt:1 , method-cnt:1) cost in 66 ms. INDEX TIMESTAMP COST(ms) IS-RET IS-EXP OBJECT CLASS METHOD ------------------------------------------------------------------------------------------------------------------------------------- 1000 2018-12-04 11:15:38 1.096236 false true 0x4b67cf4d MathGame primeFactors 1001 2018-12-04 11:15:39 0.191848 false true 0x4b67cf4d MathGame primeFactors 1002 2018-12-04 11:15:40 0.069523 false true 0x4b67cf4d MathGame primeFactors 1003 2018-12-04 11:15:41 0.186073 false true 0x4b67cf4d MathGame primeFactors 1004 2018-12-04 11:15:42 17.76437 true false 0x4b67cf4d MathGame primeFactors </pre></div> </div> <ul> <li><p class="first"><tt class="docutils literal">-t</tt></p> <p>record the calling context of the method <tt class="docutils literal">demo.MathGame primeFactors</tt></p> </li> <li><p class="first"><tt class="docutils literal">-n 3</tt></p> <p>limit the number of the records (avoid overflow for too many records; with <tt class="docutils literal">-n</tt> option, Arthas can automatically stop recording once the records reach the specified limit)</p> </li> <li><p class="first">Property</p> </li> </ul> <table border="1" class="docutils"> <thead> <tr> <th>Name</th> <th>Specification</th> </tr> </thead> <tbody> <tr> <td>INDEX</td> <td>the index for each call based on time</td> </tr> <tr> <td>TIMESTAMP</td> <td>time to invoke the method</td> </tr> <tr> <td>COST(ms)</td> <td>time cost of the method call</td> </tr> <tr> <td>IS-RET</td> <td>whether method exits with normal return</td> </tr> <tr> <td>IS-EXP</td> <td>whether method failed with exceptions</td> </tr> <tr> <td>OBJECT</td> <td><code>hashCode()</code> of the object invoking the method</td> </tr> <tr> <td>CLASS</td> <td>class name of the object invoking the method</td> </tr> <tr> <td>METHOD</td> <td>method being invoked</td> </tr> </tbody> </table><ul class="simple"> <li>Condition expression</li> </ul> <p>Tips:</p> <ol class="simple"> <li><tt class="docutils literal">tt -t *Test print params[0].length==1</tt> with different amounts of parameters;</li> <li><tt class="docutils literal">tt -t *Test print 'params[1] instanceof Integer'</tt> with different types of parameters;</li> <li><tt class="docutils literal">tt -t *Test print params[0].mobile=="13989838402"</tt> with specified parameter.</li> </ol> <p>Advanced:</p> <div class="toctree-wrapper compound"> <ul> <li class="toctree-l1"><a class="reference internal" href="advice-class.html">Critical fields in expression</a></li> <li class="toctree-l1"><a class="reference external" href="https://github.com/alibaba/arthas/issues/71">Special usage</a></li> <li class="toctree-l1"><a class="reference external" href="https://commons.apache.org/proper/commons-ognl/language-guide.html">OGNL official guide</a></li> </ul> </div> </div> <div class="section" id="list-all-records"> <span id="list-all-records"></span><h3>List all records<a class="headerlink" href="#list-all-records" title="Permalink to this headline">¶</a></h3> <div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash">$ tt -l INDEX TIMESTAMP COST(ms) IS-RET IS-EXP OBJECT CLASS METHOD ------------------------------------------------------------------------------------------------------------------------------------- 1000 2018-12-04 11:15:38 1.096236 false true 0x4b67cf4d MathGame primeFactors 1001 2018-12-04 11:15:39 0.191848 false true 0x4b67cf4d MathGame primeFactors 1002 2018-12-04 11:15:40 0.069523 false true 0x4b67cf4d MathGame primeFactors 1003 2018-12-04 11:15:41 0.186073 false true 0x4b67cf4d MathGame primeFactors 1004 2018-12-04 11:15:42 17.76437 true false 0x4b67cf4d MathGame primeFactors 9 1005 2018-12-04 11:15:43 0.4776 false true 0x4b67cf4d MathGame primeFactors Affect(row-cnt:6) cost in 4 ms. </pre></div> </div> </div> <div class="section" id="searching-for-records"> <span id="searching-for-records"></span><h3>Searching for records<a class="headerlink" href="#searching-for-records" title="Permalink to this headline">¶</a></h3> <div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash">$ tt -s 'method.name=="primeFactors"' INDEX TIMESTAMP COST(ms) IS-RET IS-EXP OBJECT CLASS METHOD ------------------------------------------------------------------------------------------------------------------------------------- 1000 2018-12-04 11:15:38 1.096236 false true 0x4b67cf4d MathGame primeFactors 1001 2018-12-04 11:15:39 0.191848 false true 0x4b67cf4d MathGame primeFactors 1002 2018-12-04 11:15:40 0.069523 false true 0x4b67cf4d MathGame primeFactors 1003 2018-12-04 11:15:41 0.186073 false true 0x4b67cf4d MathGame primeFactors 1004 2018-12-04 11:15:42 17.76437 true false 0x4b67cf4d MathGame primeFactors 9 1005 2018-12-04 11:15:43 0.4776 false true 0x4b67cf4d MathGame primeFactors Affect(row-cnt:6) cost in 607 ms. </pre></div> </div> <p>Advanced:</p> <div class="toctree-wrapper compound"> <ul> <li class="toctree-l1"><a class="reference internal" href="advice-class.html">Critical fields in expression</a></li> </ul> </div> </div> <div class="section" id="check-context-of-the-call"> <span id="check-context-of-the-call"></span><h3>Check context of the call<a class="headerlink" href="#check-context-of-the-call" title="Permalink to this headline">¶</a></h3> <p>Using <tt class="docutils literal">tt -i <index></tt> to check a specific calling details.</p> <div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash">$ tt -i 1003 INDEX 1003 GMT-CREATE 2018-12-04 11:15:41 COST(ms) 0.186073 OBJECT 0x4b67cf4d CLASS demo.MathGame METHOD primeFactors IS-RETURN false IS-EXCEPTION true PARAMETERS[0] @Integer[-564322413] THROW-EXCEPTION java.lang.IllegalArgumentException: number is: -564322413, need >= 2 at demo.MathGame.primeFactors(MathGame.java:46) at demo.MathGame.run(MathGame.java:24) at demo.MathGame.main(MathGame.java:16) Affect(row-cnt:1) cost in 11 ms. </pre></div> </div> </div> </div> <div class="section" id="replay-record"> <span id="replay-record"></span><h2>Replay record<a class="headerlink" href="#replay-record" title="Permalink to this headline">¶</a></h2> <p>Since Arthas stores the context of the call, you can even <em>replay</em> the method calling afterwards with extra option <tt class="docutils literal">-p</tt> to replay the issue for advanced troubleshooting.</p> <div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash">$ tt -i 1004 -p RE-INDEX 1004 GMT-REPLAY 2018-12-04 11:26:00 OBJECT 0x4b67cf4d CLASS demo.MathGame METHOD primeFactors PARAMETERS[0] @Integer[946738738] IS-RETURN true IS-EXCEPTION false RETURN-OBJ @ArrayList[ @Integer[2], @Integer[11], @Integer[17], @Integer[2531387], ] Time fragment[1004] successfully replayed. Affect(row-cnt:1) cost in 14 ms. </pre></div> </div> <p>F.Y.I</p> <ol> <li><p class="first"><strong>Loss</strong> of the <tt class="docutils literal">ThreadLocal</tt></p> <p>Arthas save params into an array, then invoke the method with the params again. The method execute in another thread, so the <tt class="docutils literal">ThreadLocal</tt> <strong>lost</strong>.</p> </li> <li><p class="first">params may be modified</p> <p>Arthas save params into an array, they are object references. The Objects may be modified by other code.</p> </li> </ol> </div> </div> </div> </div> <footer> <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> <a href="options.html" class="btn btn-neutral float-right" title="options" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> <a href="stack.html" class="btn btn-neutral" title="stack" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> </div> <hr/> <div role="contentinfo"> <p> © Copyright 2018, Alibaba Middleware Group, and contributors. </p> </div> Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. </footer> </div> </div> </section> </div> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT:'./', VERSION:'3.0.5', LANGUAGE:'en', COLLAPSE_INDEX:false, FILE_SUFFIX:'.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; </script> <script type="text/javascript" src="_static/jquery.js"></script> <script type="text/javascript" src="_static/underscore.js"></script> <script type="text/javascript" src="_static/doctools.js"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> <script type="text/javascript" src="_static/js/theme.js"></script> <script type="text/javascript"> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); </script> <div class="github-fork-ribbon-wrapper right"> <div class="github-fork-ribbon"> <a href="https://github.com/alibaba/arthas">Fork me at GitHub</a> </div> </div> <script type="text/javascript" src="_static/add_badges.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/highlight.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/highlightjs-line-numbers.js/2.5.0/highlightjs-line-numbers.min.js"></script> <script> document.querySelectorAll('div.hljs > pre').forEach(function(block) { hljs.highlightBlock(block); hljs.lineNumbersBlock(block); }); </script> <script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?d5c5e25b100f0eb51a4c35c8a86ea9b4"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> </body> </html>