</script><metaname="aes-config"content="pid=xux-opensource&user_type=101&uid=&username=&dim10=arthas"><scriptsrc="//g.alicdn.com/alilog/mlog/aplus_v2.js"id="beacon-aplus"exparams="clog=o&aplus&sidx=aplusSidx&ckx=aplusCkx"></script><scriptsrc="//g.alicdn.com/aes/??tracker/1.0.34/index.js,tracker-plugin-pv/2.4.5/index.js,tracker-plugin-event/1.2.5/index.js,tracker-plugin-jserror/1.0.13/index.js,tracker-plugin-api/1.1.14/index.js,tracker-plugin-perf/1.1.8/index.js,tracker-plugin-eventTiming/1.0.4/index.js"></script><title>tt | arthas</title><metaname="description"content="arthas user document">
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div></div></div><h3id="specify-the-max-number-of-matched-classes"tabindex="-1"><aclass="header-anchor"href="#specify-the-max-number-of-matched-classes"aria-hidden="true">#</a> Specify the max number of matched Classes</h3><divclass="language-bash ext-sh line-numbers-mode"><preclass="language-bash"><code>$ tt <spanclass="token parameter variable">-t</span><spanclass="token parameter variable">-m</span><spanclass="token number">1</span> demo.MathGame primeFactors
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div></div></div><ul><li><p><code>-t</code></p><p>record the calling context of the method <code>demo.MathGame primeFactors</code></p></li><li><p><code>-n 3</code></p><p>limit the number of the records (avoid overflow for too many records; with <code>-n</code> option, Arthas can automatically stop recording once the records reach the specified limit)</p></li><li><p><code>-m 1</code></p><p>limit the number of matched Classes to avoid JVM suspending when too many matched Classes. The default value is 50.</p></li><li><p>Property</p></li></ul><table><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><li>Condition expression</li></ul><p>Tips:</p><ol><li><code>tt -t *Test print params.length==1</code> with different amounts of parameters;</li><li><code>tt -t *Test print 'params[1] instanceof Integer'</code> with different types of parameters;</li><li><code>tt -t *Test print params[0].mobile=="13989838402"</code> with specified parameter.</li></ol><p>Advanced:</p><ul><li><ahref="/en/doc/advice-class.html"class="">Critical fields in expression</a></li><li><ahref="https://github.com/alibaba/arthas/issues/71"target="_blank"rel="noopener noreferrer">Special usage<span><svgclass="external-link-icon"xmlns="http://www.w3.org/2000/svg"aria-hidden="true"focusable="false"x="0px"y="0px"viewbox="0 0 100 100"width="15"height="15"><pathfill="currentColor"d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygonfill="currentColor"points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><spanclass="external-link-icon-sr-only">open in new window</span></span></a></li><li><ahref="https://commons.apache.org/proper/commons-ognl/language-guide.html"target="_blank"rel="noopener noreferrer">OGNL official guide<span><svgclass="external-link-icon"xmlns="http://www.w3.org/2000/svg"aria-hidden="true"focusable="false"x="0px"y="0px"viewbox="0 0 100 100"width="15"height="15"><pathfill="currentColor"d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygonfill="currentColor"points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><spanclass="external-link-icon-sr-only">open in new window</span></span></a></li></ul><h3id="list-all-records"tabindex="-1"><aclass="header-anchor"href="#list-all-records"aria-hidden="true">#</a> List all records</h3><divclass="language-bash ext-sh line-numbers-mode"><preclass="language-bash"><code>$ tt <spanclass="token parameter variable">-l</span>
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div></div></div><p>Advanced:</p><ul><li><ahref="/en/doc/advice-class.html"class="">Critical fields in expression</a></li></ul><h3id="check-context-of-the-call"tabindex="-1"><aclass="header-anchor"href="#check-context-of-the-call"aria-hidden="true">#</a> Check context of the call</h3><p>Using <code>tt -i <index></code> to check a specific calling details.</p><divclass="language-bash ext-sh line-numbers-mode"><preclass="language-bash"><code>$ tt <spanclass="token parameter variable">-i</span><spanclass="token number">1003</span>
THROW-EXCEPTION java.lang.IllegalArgumentException: number is: -564322413, need <spanclass="token operator">>=</span><spanclass="token number">2</span>
at demo.MathGame.primeFactors<spanclass="token punctuation">(</span>MathGame.java:46<spanclass="token punctuation">)</span>
at demo.MathGame.run<spanclass="token punctuation">(</span>MathGame.java:24<spanclass="token punctuation">)</span>
at demo.MathGame.main<spanclass="token punctuation">(</span>MathGame.java:16<spanclass="token punctuation">)</span>
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div></div></div><h3id="replay-record"tabindex="-1"><aclass="header-anchor"href="#replay-record"aria-hidden="true">#</a> Replay record</h3><p>Since Arthas stores the context of the call, you can even <em>replay</em> the method calling afterwards with extra option <code>-p</code> to replay the issue for advanced troubleshooting, option <code>--replay-times</code> define the replay execution times, option <code>--replay-interval</code> define the interval(unit in ms,with default value 1000) of replays</p><divclass="language-bash ext-sh line-numbers-mode"><preclass="language-bash"><code>$ tt <spanclass="token parameter variable">-i</span><spanclass="token number">1004</span><spanclass="token parameter variable">-p</span>
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div></div></div><h3id="watch-express"tabindex="-1"><aclass="header-anchor"href="#watch-express"aria-hidden="true">#</a> Watch express</h3><p><code>-w, --watch-express</code> watch the time fragment by ognl express.</p><ul><li>You can used all variables in <ahref="/en/doc/advice-class.html"class="">fundamental fields in expressions</a> for the watch express。</li></ul><divclass="language-bash ext-sh line-numbers-mode"><preclass="language-bash"><code><spanclass="token punctuation">[</span>arthas@10718<spanclass="token punctuation">]</span>$ tt <spanclass="token parameter variable">-t</span> demo.MathGame run <spanclass="token parameter variable">-n</span><spanclass="token number">5</span>
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div></div></div><ul><li>Get a static field and calling a static method</li></ul><divclass="language-bash ext-sh line-numbers-mode"><preclass="language-bash"><code><spanclass="token punctuation">[</span>arthas@10718<spanclass="token punctuation">]</span>$ tt <spanclass="token parameter variable">-t</span> demo.MathGame run <spanclass="token parameter variable">-n</span><spanclass="token number">5</span>
</code></pre><divclass="line-numbers"aria-hidden="true"><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div><divclass="line-number"></div></div></div><p>Note that <code>com.taobao.arthas.core.advisor.Advice#getLoader</code> is used here, and that it is better to use the exact <code>classloader</code><ahref="/en/doc/ognl.html"class="">ognl</a>.</p><p>Advanced usage <ahref="https://github.com/alibaba/arthas/issues/482"target="_blank"rel="noopener noreferrer">get spring context to call the bean method<span><svgclass="external-link-icon"xmlns="http://www.w3.org/2000/svg"aria-hidden="true"focusable="false"x="0px"y="0px"viewbox="0 0 100 100"width="15"height="15"><pathfill="currentColor"d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygonfill="currentColor"points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><spanclass="external-link-icon-sr-only">open in new window</span></span></a></p><p>F.Y.I</p><ol><li><p><strong>Loss</strong> of the <code>ThreadLocal</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>ThreadLocal</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><footerclass="page-meta right-menu-padding"data-v-fdd717e0><divclass="meta-item edit-link"><aclass="external-link meta-item-label"href="https://github.com/alibaba/arthas/edit/master/site/docs/en/doc/tt.md"rel="noopener noreferrer"target="_blank"aria-label="Edit this page on GitHub"><!--[--><!--]--><span>Edit this page on GitHub</span><span><svgclass="external-link-icon"xmlns="http://www.w3.org/2000/svg"aria-hidden="true"focusable="false"x="0px"y="0px"viewbox="0 0 100 100"width="15"height="15"><pathfill="currentColor"d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygonfill="currentColor"points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><spanclass="external-link-icon-sr-only">open in new window</span></span><!--[--><!--]--></a></div><divclass="meta-item last-updated"><spanclass="meta-item-label">Last Updated: </span><!----></div><divclass="meta-item contributors"><spanclass="meta-item-label">Contributors: </span><spanclass="meta-item-info"><!--[--><!--[--><spanclass="contributor"title="email: hengyunabc@gmail.com">hengyunabc</span><!--[-->, <!--]--><!--]--><!--[--><spanclass="contributor"title="email: lhearen@gmail.com">LHearen</span><!--[-->, <!--]--><!--]--><!--[--><spanclass="contributor"title="email: superheizai@aliyun.com">superheizai</span><!--[-->, <!--]--><!--]--><!--[--><spanclass="contributor"title="email: i@fatpandac.com">Fatpandac</span><!--[-->, <!--]--><!--]--><!--[--><spanclass="contributor"title="email: hengyunabc@users.noreply.github.com">hengyunabc</span><!--[-->, <!--]--><!--]--><!--[--><spanclass="contributor"title="email: 35672972+pandaapo@users.noreply.github.com">pandaapo</span><!--[-->, <!--]--><!--]--><!--[--><spanclass="contributor"title="email: LHearen@126.com">Hearen</span><!--[-->, <!--]--><!--]--><!--[--><spanclass="contributor"title="email: hollowman186@vip.qq.com">Hollow Man</span><!--[-->, <!--]--><!--]--><!--[--><spanclass="contributor"title="email: sergioescala@gmail.com">Sergio Escalante</span><!--[-->, <!--]--><!--]--><!--[--><spanclass="contributor"title="email: 983433479@qq.com">汪吉</span><!----><!--]--><!--]--></span></div></footer><navclass="page-nav right-menu-padding"data-v-fdd717e0><pclass="inner"><spanclass="prev"><ahref="/en/doc/trace.h