You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
arthas/en/tt.html

487 lines
22 KiB
HTML

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<!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 &mdash; Arthas 3.1.7 documentation</title>
<link rel="shortcut icon" href="_static/favicon.ico"/>
<script type="text/javascript" src="_static/js/modernizr.min.js"></script>
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></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="_static/language_data.js"></script>
<script type="text/javascript" src="_static/js/theme.js"></script>
<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="profiler" href="profiler.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">
</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.1.7
</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 external" href="https://alibaba.github.io/arthas/arthas-tutorials?language=en">Online tutorials(Recommend)</a></li>
<li class="toctree-l1"><a class="reference internal" href="install-detail.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="download.html">Download</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="vmoption.html">vmoption</a></li>
<li class="toctree-l2"><a class="reference internal" href="perfcounter.html">perfcounter</a></li>
<li class="toctree-l2"><a class="reference internal" href="logger.html">logger</a></li>
<li class="toctree-l2"><a class="reference internal" href="mbean.html">mbean</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="heapdump.html">heapdump</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="mc.html">mc</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="profiler.html">profiler</a></li>
<li class="toctree-l2"><a class="reference internal" href="cat.html">cat</a></li>
<li class="toctree-l2"><a class="reference internal" href="grep.html">grep</a></li>
<li class="toctree-l2"><a class="reference internal" href="tee.html">tee</a></li>
<li class="toctree-l2"><a class="reference internal" href="pwd.html">pwd</a></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="web-console.html">WebConsole</a></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#">Compile and debug/CONTRIBUTING</a></li>
<li class="toctree-l1"><a class="reference external" href="https://github.com/alibaba/arthas/releases">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> &raquo;</li>
<li><a href="commands.html">All Commands</a> &raquo;</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">
<h1>tt<a class="headerlink" href="#tt" title="Permalink to this headline"></a></h1>
<p>Check the <code class="docutils literal notranslate"><span class="pre">parameters</span></code>, <code class="docutils literal notranslate"><span class="pre">return</span> <span class="pre">values</span></code> and <code class="docutils literal notranslate"><span class="pre">exceptions</span></code> of the methods at different times.</p>
<p><code class="docutils literal notranslate"><span class="pre">watch</span></code> is a powerful command but due to its feasibility and complexity, its quite hard to locate the issue effectively.</p>
<p>In such difficulties, <code class="docutils literal notranslate"><span class="pre">tt</span></code> comes into play.</p>
<p>With the help of <code class="docutils literal notranslate"><span class="pre">tt</span></code> (<em>TimeTunnel</em>), you can check the contexts of the methods at different times in execution history.</p>
<div class="section" id="usage">
<h2>Usage<a class="headerlink" href="#usage" title="Permalink to this headline"></a></h2>
<div class="section" id="start-demo">
<h3>Start Demo<a class="headerlink" href="#start-demo" title="Permalink to this headline"></a></h3>
<p>Start <code class="docutils literal notranslate"><span class="pre">arthas-demo</span></code> 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">
<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><code class="docutils literal notranslate"><span class="pre">-t</span></code></p>
<p>record the calling context of the method <code class="docutils literal notranslate"><span class="pre">demo.MathGame</span> <span class="pre">primeFactors</span></code></p>
</li>
<li><p><code class="docutils literal notranslate"><span class="pre">-n</span> <span class="pre">3</span></code></p>
<p>limit the number of the records (avoid overflow for too many records; with <code class="docutils literal notranslate"><span class="pre">-n</span></code> option, Arthas can automatically stop recording once the records reach the specified limit)</p>
</li>
<li><p>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><p>Condition expression</p></li>
</ul>
<p>Tips:</p>
<ol class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">tt</span> <span class="pre">-t</span> <span class="pre">*Test</span> <span class="pre">print</span> <span class="pre">params.length==1</span></code> with different amounts of parameters;</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">tt</span> <span class="pre">-t</span> <span class="pre">*Test</span> <span class="pre">print</span> <span class="pre">'params[1]</span> <span class="pre">instanceof</span> <span class="pre">Integer'</span></code> with different types of parameters;</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">tt</span> <span class="pre">-t</span> <span class="pre">*Test</span> <span class="pre">print</span> <span class="pre">params[0].mobile==&quot;13989838402&quot;</span></code> with specified parameter.</p></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">
<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">
<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 &#x27;method.name==&quot;primeFactors&quot;&#x27;
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">
<h3>Check context of the call<a class="headerlink" href="#check-context-of-the-call" title="Permalink to this headline"></a></h3>
<p>Using <code class="docutils literal notranslate"><span class="pre">tt</span> <span class="pre">-i</span> <span class="pre">&lt;index&gt;</span></code> 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 &gt;= 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">
<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 <code class="docutils literal notranslate"><span class="pre">-p</span></code> to replay the issue for advanced troubleshooting, option <code class="docutils literal notranslate"><span class="pre">--replay-times</span></code>
define the replay execution times, option <code class="docutils literal notranslate"><span class="pre">--replay-interval</span></code> define the interval(unit in ms,with default value 1000) of replays</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><strong>Loss</strong> of the <code class="docutils literal notranslate"><span class="pre">ThreadLocal</span></code></p>
<p>Arthas save params into an array, then invoke the method with the params again. The method execute in another thread, so the <code class="docutils literal notranslate"><span class="pre">ThreadLocal</span></code> <strong>lost</strong>.</p>
</li>
<li><p>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="profiler.html" class="btn btn-neutral float-right" title="profiler" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="stack.html" class="btn btn-neutral float-left" title="stack" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2018-2019, 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">
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" target="_blank">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");
if (window.location.hostname == "arthas.gitee.io") {
hm.src = "https://hm.baidu.com/hm.js?ecc1b0d9aeb73da1671876133211d4d3";
} else { // https://alibaba.github.io/arthas/
hm.src = "https://hm.baidu.com/hm.js?d5c5e25b100f0eb51a4c35c8a86ea9b4";
}
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
</body>
</html>