mirror of
https://github.com/alibaba/arthas.git
synced 2026-11-30 15:33:59 +00:00
update tt doc
This commit is contained in:
1 parent
307e6bad5a
commit
a598382890
4 files changed
+184
-254
No files matched your search
@@ -42,10 +42,10 @@ import static java.lang.String.format;
|
|||||||
" tt -t *StringUtils isEmpty\n" +
|
" tt -t *StringUtils isEmpty\n" +
|
||||||
" tt -t *StringUtils isEmpty params[0].length==1\n" +
|
" tt -t *StringUtils isEmpty params[0].length==1\n" +
|
||||||
" tt -l\n" +
|
" tt -l\n" +
|
||||||
" tt --delete-all\n" +
|
|
||||||
" tt -i 1000 -w params[0]\n" +
|
|
||||||
" tt -i 1000 -d\n" +
|
|
||||||
" tt -i 1000\n" +
|
" tt -i 1000\n" +
|
||||||
|
" tt -i 1000 -w params[0]\n" +
|
||||||
|
" tt -i 1000 -p\n" +
|
||||||
|
" tt --delete-all\n" +
|
||||||
Constants.WIKI + Constants.WIKI_HOME + "tt")
|
Constants.WIKI + Constants.WIKI_HOME + "tt")
|
||||||
public class TimeTunnelCommand extends EnhancerCommand {
|
public class TimeTunnelCommand extends EnhancerCommand {
|
||||||
// 时间隧道(时间碎片的集合)
|
// 时间隧道(时间碎片的集合)
|
||||||
|
|||||||
+96
-129
@@ -11,35 +11,37 @@ With the help of `tt` (*TimeTunnel*), you can check the contexts of the methods
|
|||||||
|
|
||||||
### Usage
|
### Usage
|
||||||
|
|
||||||
Let's record the whole calling contexts:
|
|
||||||
|
|
||||||
```java
|
#### Start Demo
|
||||||
$ tt -t -n 3 *Test print
|
|
||||||
Press Ctrl+D or Ctrl+X to abort.
|
|
||||||
Affect(class-cnt:1 , method-cnt:1) cost in 115 ms.
|
|
||||||
+----------+----------------------+------------+----------+----------+-----------------+--------------------------------+--------------------------------+
|
|
||||||
| INDEX | TIMESTAMP | COST(ms) | IS-RET | IS-EXP | OBJECT | CLASS | METHOD |
|
|
||||||
+----------+----------------------+------------+----------+----------+-----------------+--------------------------------+--------------------------------+
|
|
||||||
| 1007 | 2015-07-26 12:23:21 | 138 | true | false | 0x42cc13a0 | GaOgnlUtilsTest | print |
|
|
||||||
+----------+----------------------+------------+----------+----------+-----------------+--------------------------------+--------------------------------+
|
|
||||||
| 1008 | 2015-07-26 12:23:22 | 143 | true | false | 0x42cc13a0 | GaOgnlUtilsTest | print |
|
|
||||||
+----------+----------------------+------------+----------+----------+-----------------+--------------------------------+--------------------------------+
|
|
||||||
| 1009 | 2015-07-26 12:23:23 | 130 | true | false | 0x42cc13a0 | GaOgnlUtilsTest | print |
|
|
||||||
+----------+----------------------+------------+----------+----------+-----------------+--------------------------------+--------------------------------+
|
|
||||||
$
|
|
||||||
```
|
|
||||||
|
|
||||||
#### F.Y.I
|
Start `arthas-demo` in [Quick Start](quick-start.md).
|
||||||
|
|
||||||
- `-t`
|
|
||||||
|
|
||||||
record the calling context of the method `*Test.print`
|
#### Record method calls
|
||||||
|
|
||||||
- `-n 3`
|
|
||||||
|
```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
|
||||||
|
```
|
||||||
|
|
||||||
|
* `-t`
|
||||||
|
|
||||||
|
record the calling context of the method `demo.MathGame primeFactors`
|
||||||
|
|
||||||
|
* `-n 3`
|
||||||
|
|
||||||
limit the number of the records (avoid overflow for too many records; with `-n` option, Arthas can automatically stop recording once the records reach the specified limit)
|
limit the number of the records (avoid overflow for too many records; with `-n` option, Arthas can automatically stop recording once the records reach the specified limit)
|
||||||
|
|
||||||
#### Property
|
* Property
|
||||||
|
|
||||||
|Name|Specification|
|
|Name|Specification|
|
||||||
|---|---|
|
|---|---|
|
||||||
@@ -52,7 +54,7 @@ Let's record the whole calling contexts:
|
|||||||
|CLASS|class name of the object invoking the method|
|
|CLASS|class name of the object invoking the method|
|
||||||
|METHOD|method being invoked|
|
|METHOD|method being invoked|
|
||||||
|
|
||||||
#### Condition expression
|
* Condition expression
|
||||||
|
|
||||||
Tips:
|
Tips:
|
||||||
1. `tt -t *Test print params[0].length==1` with different amounts of parameters;
|
1. `tt -t *Test print params[0].length==1` with different amounts of parameters;
|
||||||
@@ -64,131 +66,96 @@ Advanced:
|
|||||||
* [Special usage](https://github.com/alibaba/arthas/issues/71)
|
* [Special usage](https://github.com/alibaba/arthas/issues/71)
|
||||||
* [OGNL official guide](https://commons.apache.org/proper/commons-ognl/language-guide.html)
|
* [OGNL official guide](https://commons.apache.org/proper/commons-ognl/language-guide.html)
|
||||||
|
|
||||||
|
#### List all records
|
||||||
|
|
||||||
### Searching for records
|
```bash
|
||||||
|
|
||||||
#### All the recorded
|
|
||||||
|
|
||||||
```
|
|
||||||
$ tt -l
|
$ tt -l
|
||||||
+----------+----------------------+------------+----------+----------+-----------------+--------------------------------+--------------------------------+
|
INDEX TIMESTAMP COST(ms) IS-RET IS-EXP OBJECT CLASS METHOD
|
||||||
| 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
|
||||||
| 1000 | 2015-07-26 01:16:27 | 130 | true | false | 0x42cc13a0 | GaOgnlUtilsTest | print |
|
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
|
||||||
| 1001 | 2015-07-26 01:16:27 | 0 | false | true | 0x42cc13a0 | GaOgnlUtilsTest | printAddress |
|
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
|
||||||
| 1002 | 2015-07-26 01:16:28 | 119 | true | false | 0x42cc13a0 | GaOgnlUtilsTest | print |
|
9
|
||||||
+----------+----------------------+------------+----------+----------+-----------------+--------------------------------+--------------------------------+
|
1005 2018-12-04 11:15:43 0.4776 false true 0x4b67cf4d MathGame primeFactors
|
||||||
| 1003 | 2015-07-26 01:16:28 | 0 | false | true | 0x42cc13a0 | GaOgnlUtilsTest | printAddress |
|
Affect(row-cnt:6) cost in 4 ms.
|
||||||
+----------+----------------------+------------+----------+----------+-----------------+--------------------------------+--------------------------------+
|
|
||||||
| 1004 | 2015-07-26 12:21:56 | 130 | true | false | 0x42cc13a0 | GaOgnlUtilsTest | print |
|
|
||||||
+----------+----------------------+------------+----------+----------+-----------------+--------------------------------+--------------------------------+
|
|
||||||
| 1005 | 2015-07-26 12:21:57 | 138 | true | false | 0x42cc13a0 | GaOgnlUtilsTest | print |
|
|
||||||
+----------+----------------------+------------+----------+----------+-----------------+--------------------------------+--------------------------------+
|
|
||||||
| 1006 | 2015-07-26 12:21:58 | 130 | true | false | 0x42cc13a0 | GaOgnlUtilsTest | print |
|
|
||||||
+----------+----------------------+------------+----------+----------+-----------------+--------------------------------+--------------------------------+
|
|
||||||
Affect(row-cnt:7) cost in 2 ms.
|
|
||||||
$
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### A specified method
|
|
||||||
|
|
||||||
```
|
#### Searching for records
|
||||||
$ tt -s method.name=="printAddress"
|
|
||||||
+----------+----------------------+------------+----------+----------+-----------------+--------------------------------+--------------------------------+
|
```bash
|
||||||
| INDEX | TIMESTAMP | COST(ms) | IS-RET | IS-EXP | OBJECT | CLASS | METHOD |
|
$ tt -s 'method.name=="primeFactors"'
|
||||||
+----------+----------------------+------------+----------+----------+-----------------+--------------------------------+--------------------------------+
|
INDEX TIMESTAMP COST(ms) IS-RET IS-EXP OBJECT CLASS METHOD
|
||||||
| 1001 | 2015-07-26 01:16:27 | 0 | false | true | 0x42cc13a0 | GaOgnlUtilsTest | printAddress |
|
-------------------------------------------------------------------------------------------------------------------------------------
|
||||||
+----------+----------------------+------------+----------+----------+-----------------+--------------------------------+--------------------------------+
|
1000 2018-12-04 11:15:38 1.096236 false true 0x4b67cf4d MathGame primeFactors
|
||||||
| 1003 | 2015-07-26 01:16:28 | 0 | false | true | 0x42cc13a0 | GaOgnlUtilsTest | printAddress |
|
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
|
||||||
Affect(row-cnt:2) cost in 55 ms.
|
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.
|
||||||
```
|
```
|
||||||
|
|
||||||
Advanced:
|
Advanced:
|
||||||
* [Critical fields in expression](advice-class.md)
|
* [Critical fields in expression](advice-class.md)
|
||||||
|
|
||||||
### Check context of the call
|
#### Check context of the call
|
||||||
|
|
||||||
Using `tt -i <index>` to check a specific calling details.
|
Using `tt -i <index>` to check a specific calling details.
|
||||||
|
|
||||||
```
|
```bash
|
||||||
$
|
|
||||||
$ tt -i 1003
|
$ tt -i 1003
|
||||||
+-----------------+------------------------------------------------------------------------------------------------------+
|
INDEX 1003
|
||||||
| INDEX | 1003 |
|
GMT-CREATE 2018-12-04 11:15:41
|
||||||
+-----------------+------------------------------------------------------------------------------------------------------+
|
COST(ms) 0.186073
|
||||||
| GMT-CREATE | 2015-07-26 01:16:28 |
|
OBJECT 0x4b67cf4d
|
||||||
+-----------------+------------------------------------------------------------------------------------------------------+
|
CLASS demo.MathGame
|
||||||
| COST(ms) | 0 |
|
METHOD primeFactors
|
||||||
+-----------------+------------------------------------------------------------------------------------------------------+
|
IS-RETURN false
|
||||||
| OBJECT | 0x42cc13a0 |
|
IS-EXCEPTION true
|
||||||
+-----------------+------------------------------------------------------------------------------------------------------+
|
PARAMETERS[0] @Integer[-564322413]
|
||||||
| CLASS | GaOgnlUtilsTest |
|
THROW-EXCEPTION java.lang.IllegalArgumentException: number is: -564322413, need >= 2
|
||||||
+-----------------+------------------------------------------------------------------------------------------------------+
|
at demo.MathGame.primeFactors(MathGame.java:46)
|
||||||
| METHOD | printAddress |
|
at demo.MathGame.run(MathGame.java:24)
|
||||||
+-----------------+------------------------------------------------------------------------------------------------------+
|
at demo.MathGame.main(MathGame.java:16)
|
||||||
| IS-RETURN | false |
|
|
||||||
+-----------------+------------------------------------------------------------------------------------------------------+
|
Affect(row-cnt:1) cost in 11 ms.
|
||||||
| IS-EXCEPTION | true |
|
|
||||||
+-----------------+------------------------------------------------------------------------------------------------------+
|
|
||||||
| PARAMETERS[0] | Address@53448f87 |
|
|
||||||
+-----------------+------------------------------------------------------------------------------------------------------+
|
|
||||||
| THROW-EXCEPTION | java.lang.RuntimeException: test |
|
|
||||||
| | at GaOgnlUtilsTest.printAddress(Unknown Source) |
|
|
||||||
| | at GaOgnlUtilsTest.<init>(Unknown Source) |
|
|
||||||
| | at GaOgnlUtilsTest.main(Unknown Source) |
|
|
||||||
+-----------------+------------------------------------------------------------------------------------------------------+
|
|
||||||
Affect(row-cnt:1) cost in 1 ms.
|
|
||||||
$
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Re-produce
|
### Replay record
|
||||||
|
|
||||||
Since Arthas stores the context of the call, you can even *replay* the method calling afterwards with extra option `-p` to re-produce the issue for advanced troubleshooting.
|
Since Arthas stores the context of the call, you can even *replay* the method calling afterwards with extra option `-p` to replay the issue for advanced troubleshooting.
|
||||||
|
|
||||||
```
|
```bash
|
||||||
$ tt -i 1003 -p
|
$ tt -i 1004 -p
|
||||||
+-----------------+---------------------------------------------------------------------------------------------------------+
|
RE-INDEX 1004
|
||||||
| RE-INDEX | 1003 |
|
GMT-REPLAY 2018-12-04 11:26:00
|
||||||
+-----------------+---------------------------------------------------------------------------------------------------------+
|
OBJECT 0x4b67cf4d
|
||||||
| GMT-REPLAY | 2015-07-26 17:29:51 |
|
CLASS demo.MathGame
|
||||||
+-----------------+---------------------------------------------------------------------------------------------------------+
|
METHOD primeFactors
|
||||||
| OBJECT | 0x42cc13a0 |
|
PARAMETERS[0] @Integer[946738738]
|
||||||
+-----------------+---------------------------------------------------------------------------------------------------------+
|
IS-RETURN true
|
||||||
| CLASS | GaOgnlUtilsTest |
|
IS-EXCEPTION false
|
||||||
+-----------------+---------------------------------------------------------------------------------------------------------+
|
RETURN-OBJ @ArrayList[
|
||||||
| METHOD | printAddress |
|
@Integer[2],
|
||||||
+-----------------+---------------------------------------------------------------------------------------------------------+
|
@Integer[11],
|
||||||
| PARAMETERS[0] | Address@53448f87 |
|
@Integer[17],
|
||||||
+-----------------+---------------------------------------------------------------------------------------------------------+
|
@Integer[2531387],
|
||||||
| IS-RETURN | false |
|
]
|
||||||
+-----------------+---------------------------------------------------------------------------------------------------------+
|
Time fragment[1004] successfully replayed.
|
||||||
| IS-EXCEPTION | true |
|
Affect(row-cnt:1) cost in 14 ms.
|
||||||
+-----------------+---------------------------------------------------------------------------------------------------------+
|
|
||||||
| THROW-EXCEPTION | java.lang.RuntimeException: test |
|
|
||||||
| | at GaOgnlUtilsTest.printAddress(GaOgnlUtilsTest.java:78) |
|
|
||||||
| | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) |
|
|
||||||
| | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) |
|
|
||||||
| | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) |
|
|
||||||
| | at java.lang.reflect.Method.invoke(Method.java:483) |
|
|
||||||
| | at com.github.ompc.Arthas.util.GaMethod.invoke(GaMethod.java:81) |
|
|
||||||
| | at com.github.ompc.Arthas.command.TimeTunnelCommand$6.action(TimeTunnelCommand.java:592) |
|
|
||||||
| | at com.github.ompc.Arthas.server.DefaultCommandHandler.execute(DefaultCommandHandler.java:175) |
|
|
||||||
| | at com.github.ompc.Arthas.server.DefaultCommandHandler.executeCommand(DefaultCommandHandler.java:83) |
|
|
||||||
| | at com.github.ompc.Arthas.server.GaServer$4.run(GaServer.java:329) |
|
|
||||||
| | at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) |
|
|
||||||
| | at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) |
|
|
||||||
| | at java.lang.Thread.run(Thread.java:745) |
|
|
||||||
+-----------------+---------------------------------------------------------------------------------------------------------+
|
|
||||||
replay time fragment[1003] success.
|
|
||||||
Affect(row-cnt:1) cost in 3 ms.
|
|
||||||
$
|
|
||||||
```
|
```
|
||||||
|
|
||||||
F.Y.I
|
F.Y.I
|
||||||
1. the calling stack is little different using Arthas now unlike the original;
|
|
||||||
2. **Loss** of the thread local variables will be a undeniable fact since there is no way for Arthas to record the thread local info (*If you find one, please share with us in [issues tracker](https://github.com/alibaba/arthas/issues)*).
|
1. **Loss** of the `ThreadLocal`
|
||||||
3. **Potential** modifications of objects can happen since only a reference will be recorded while later operations might modify objects without Arthas's watch.
|
|
||||||
|
Arthas save params into an array, then invoke the method with the params again. The method execute in another thead, so the `ThreadLocal` **lost**.
|
||||||
|
|
||||||
|
1. params may be modified
|
||||||
|
|
||||||
|
Arthas save params into an array, they are object references. The Objects may be modified by other code.
|
||||||
|
|
||||||
@@ -4,8 +4,8 @@
|
|||||||
## 1. 启动Demo
|
## 1. 启动Demo
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
wget https://alibaba.github.io/arthas/arthas-demo.jar
|
$ wget https://alibaba.github.io/arthas/arthas-demo.jar
|
||||||
java -jar arthas-demo.jar
|
$ java -jar arthas-demo.jar
|
||||||
```
|
```
|
||||||
|
|
||||||
`arthas-demo`是一个简单的程序,每隔一秒生成一个随机数,再执行质因式分解,并打印出分解结果。
|
`arthas-demo`是一个简单的程序,每隔一秒生成一个随机数,再执行质因式分解,并打印出分解结果。
|
||||||
|
|||||||
+83
-120
@@ -9,27 +9,29 @@ tt
|
|||||||
|
|
||||||
于是乎,TimeTunnel 命令就诞生了。
|
于是乎,TimeTunnel 命令就诞生了。
|
||||||
|
|
||||||
### 记录方法的调用
|
### 使用参考
|
||||||
|
|
||||||
- 基本用法
|
|
||||||
|
|
||||||
对于一个最基本的使用来说,就是记录下当前方法的每次调用环境现场。
|
#### 启动 Demo
|
||||||
|
|
||||||
```java
|
启动[快速入门](quick-start.md)里的`arthas-demo`。
|
||||||
$ tt -t -n 3 *Test print
|
|
||||||
Press Ctrl+D or Ctrl+X to abort.
|
#### 记录调用
|
||||||
Affect(class-cnt:1 , method-cnt:1) cost in 115 ms.
|
|
||||||
+----------+----------------------+------------+----------+----------+-----------------+--------------------------------+--------------------------------+
|
对于一个最基本的使用来说,就是记录下当前方法的每次调用环境现场。
|
||||||
| INDEX | TIMESTAMP | COST(ms) | IS-RET | IS-EXP | OBJECT | CLASS | METHOD |
|
|
||||||
+----------+----------------------+------------+----------+----------+-----------------+--------------------------------+--------------------------------+
|
```bash
|
||||||
| 1007 | 2015-07-26 12:23:21 | 138 | true | false | 0x42cc13a0 | GaOgnlUtilsTest | print |
|
$ tt -t demo.MathGame primeFactors
|
||||||
+----------+----------------------+------------+----------+----------+-----------------+--------------------------------+--------------------------------+
|
Press Ctrl+C to abort.
|
||||||
| 1008 | 2015-07-26 12:23:22 | 143 | true | false | 0x42cc13a0 | GaOgnlUtilsTest | print |
|
Affect(class-cnt:1 , method-cnt:1) cost in 66 ms.
|
||||||
+----------+----------------------+------------+----------+----------+-----------------+--------------------------------+--------------------------------+
|
INDEX TIMESTAMP COST(ms) IS-RET IS-EXP OBJECT CLASS METHOD
|
||||||
| 1009 | 2015-07-26 12:23:23 | 130 | true | false | 0x42cc13a0 | GaOgnlUtilsTest | print |
|
-------------------------------------------------------------------------------------------------------------------------------------
|
||||||
+----------+----------------------+------------+----------+----------+-----------------+--------------------------------+--------------------------------+
|
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
|
||||||
|
```
|
||||||
|
|
||||||
- 命令参数解析
|
- 命令参数解析
|
||||||
|
|
||||||
@@ -59,8 +61,8 @@ tt
|
|||||||
- 条件表达式
|
- 条件表达式
|
||||||
|
|
||||||
不知道大家是否有在使用过程中遇到以下困惑
|
不知道大家是否有在使用过程中遇到以下困惑
|
||||||
* Arthas 似乎很难区分出重载的方法
|
* Arthas 似乎很难区分出重载的方法
|
||||||
* 我只需要观察特定参数,但是 tt 却全部都给我记录了下来
|
* 我只需要观察特定参数,但是 tt 却全部都给我记录了下来
|
||||||
|
|
||||||
条件表达式也是用 `OGNL` 来编写,核心的判断对象依然是 `Advice` 对象。除了 `tt` 命令之外,`watch`、`trace`、`stack` 命令也都支持条件表达式。
|
条件表达式也是用 `OGNL` 来编写,核心的判断对象依然是 `Advice` 对象。除了 `tt` 命令之外,`watch`、`trace`、`stack` 命令也都支持条件表达式。
|
||||||
|
|
||||||
@@ -80,130 +82,91 @@ tt
|
|||||||
|
|
||||||
前边看到了很多条件表达式中,都适用了 `params[0]`,有关这个变量的介绍,请参考[表达式核心变量](advice-class.md)
|
前边看到了很多条件表达式中,都适用了 `params[0]`,有关这个变量的介绍,请参考[表达式核心变量](advice-class.md)
|
||||||
|
|
||||||
### 检索调用记录
|
#### 检索调用记录
|
||||||
|
|
||||||
当你用 `tt` 记录了一大片的时间片段之后,你希望能从中筛选出自己需要的时间片段,这个时候你就需要对现有记录进行检索。
|
当你用 `tt` 记录了一大片的时间片段之后,你希望能从中筛选出自己需要的时间片段,这个时候你就需要对现有记录进行检索。
|
||||||
|
|
||||||
假设我们有这些记录
|
假设我们有这些记录
|
||||||
|
|
||||||
```
|
```bash
|
||||||
$ tt -l
|
$ tt -l
|
||||||
+----------+----------------------+------------+----------+----------+-----------------+--------------------------------+--------------------------------+
|
INDEX TIMESTAMP COST(ms) IS-RET IS-EXP OBJECT CLASS METHOD
|
||||||
| 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
|
||||||
| 1000 | 2015-07-26 01:16:27 | 130 | true | false | 0x42cc13a0 | GaOgnlUtilsTest | print |
|
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
|
||||||
| 1001 | 2015-07-26 01:16:27 | 0 | false | true | 0x42cc13a0 | GaOgnlUtilsTest | printAddress |
|
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
|
||||||
| 1002 | 2015-07-26 01:16:28 | 119 | true | false | 0x42cc13a0 | GaOgnlUtilsTest | print |
|
9
|
||||||
+----------+----------------------+------------+----------+----------+-----------------+--------------------------------+--------------------------------+
|
1005 2018-12-04 11:15:43 0.4776 false true 0x4b67cf4d MathGame primeFactors
|
||||||
| 1003 | 2015-07-26 01:16:28 | 0 | false | true | 0x42cc13a0 | GaOgnlUtilsTest | printAddress |
|
Affect(row-cnt:6) cost in 4 ms.
|
||||||
+----------+----------------------+------------+----------+----------+-----------------+--------------------------------+--------------------------------+
|
|
||||||
| 1004 | 2015-07-26 12:21:56 | 130 | true | false | 0x42cc13a0 | GaOgnlUtilsTest | print |
|
|
||||||
+----------+----------------------+------------+----------+----------+-----------------+--------------------------------+--------------------------------+
|
|
||||||
| 1005 | 2015-07-26 12:21:57 | 138 | true | false | 0x42cc13a0 | GaOgnlUtilsTest | print |
|
|
||||||
+----------+----------------------+------------+----------+----------+-----------------+--------------------------------+--------------------------------+
|
|
||||||
| 1006 | 2015-07-26 12:21:58 | 130 | true | false | 0x42cc13a0 | GaOgnlUtilsTest | print |
|
|
||||||
+----------+----------------------+------------+----------+----------+-----------------+--------------------------------+--------------------------------+
|
|
||||||
Affect(row-cnt:7) cost in 2 ms.
|
|
||||||
$
|
|
||||||
```
|
```
|
||||||
|
|
||||||
我需要筛选出 `printAddress` 方法的调用信息
|
我需要筛选出 `primeFactors` 方法的调用信息
|
||||||
|
|
||||||
```
|
```bash
|
||||||
$ tt -s method.name=="printAddress"
|
$ tt -s 'method.name=="primeFactors"'
|
||||||
+----------+----------------------+------------+----------+----------+-----------------+--------------------------------+--------------------------------+
|
INDEX TIMESTAMP COST(ms) IS-RET IS-EXP OBJECT CLASS METHOD
|
||||||
| 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 | 2015-07-26 01:16:27 | 0 | false | true | 0x42cc13a0 | GaOgnlUtilsTest | printAddress |
|
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 | 2015-07-26 01:16:28 | 0 | false | true | 0x42cc13a0 | GaOgnlUtilsTest | printAddress |
|
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
|
||||||
Affect(row-cnt:2) cost in 55 ms.
|
9
|
||||||
$
|
1005 2018-12-04 11:15:43 0.4776 false true 0x4b67cf4d MathGame primeFactors
|
||||||
|
Affect(row-cnt:6) cost in 607 ms.
|
||||||
```
|
```
|
||||||
|
|
||||||
你需要一个 `-s` 参数。<span style="color:red;">同样的,搜索表达式的核心对象依旧是 `Advice` 对象。</span>
|
你需要一个 `-s` 参数。<span style="color:red;">同样的,搜索表达式的核心对象依旧是 `Advice` 对象。</span>
|
||||||
|
|
||||||
### 查看调用信息
|
#### 查看调用信息
|
||||||
|
|
||||||
对于具体一个时间片的信息而言,你可以通过 `-i` 参数后边跟着对应的 `INDEX` 编号查看到他的详细信息。
|
对于具体一个时间片的信息而言,你可以通过 `-i` 参数后边跟着对应的 `INDEX` 编号查看到他的详细信息。
|
||||||
|
|
||||||
```
|
```bash
|
||||||
$
|
|
||||||
$ tt -i 1003
|
$ tt -i 1003
|
||||||
+-----------------+------------------------------------------------------------------------------------------------------+
|
INDEX 1003
|
||||||
| INDEX | 1003 |
|
GMT-CREATE 2018-12-04 11:15:41
|
||||||
+-----------------+------------------------------------------------------------------------------------------------------+
|
COST(ms) 0.186073
|
||||||
| GMT-CREATE | 2015-07-26 01:16:28 |
|
OBJECT 0x4b67cf4d
|
||||||
+-----------------+------------------------------------------------------------------------------------------------------+
|
CLASS demo.MathGame
|
||||||
| COST(ms) | 0 |
|
METHOD primeFactors
|
||||||
+-----------------+------------------------------------------------------------------------------------------------------+
|
IS-RETURN false
|
||||||
| OBJECT | 0x42cc13a0 |
|
IS-EXCEPTION true
|
||||||
+-----------------+------------------------------------------------------------------------------------------------------+
|
PARAMETERS[0] @Integer[-564322413]
|
||||||
| CLASS | GaOgnlUtilsTest |
|
THROW-EXCEPTION java.lang.IllegalArgumentException: number is: -564322413, need >= 2
|
||||||
+-----------------+------------------------------------------------------------------------------------------------------+
|
at demo.MathGame.primeFactors(MathGame.java:46)
|
||||||
| METHOD | printAddress |
|
at demo.MathGame.run(MathGame.java:24)
|
||||||
+-----------------+------------------------------------------------------------------------------------------------------+
|
at demo.MathGame.main(MathGame.java:16)
|
||||||
| IS-RETURN | false |
|
|
||||||
+-----------------+------------------------------------------------------------------------------------------------------+
|
Affect(row-cnt:1) cost in 11 ms.
|
||||||
| IS-EXCEPTION | true |
|
|
||||||
+-----------------+------------------------------------------------------------------------------------------------------+
|
|
||||||
| PARAMETERS[0] | Address@53448f87 |
|
|
||||||
+-----------------+------------------------------------------------------------------------------------------------------+
|
|
||||||
| THROW-EXCEPTION | java.lang.RuntimeException: test |
|
|
||||||
| | at GaOgnlUtilsTest.printAddress(Unknown Source) |
|
|
||||||
| | at GaOgnlUtilsTest.<init>(Unknown Source) |
|
|
||||||
| | at GaOgnlUtilsTest.main(Unknown Source) |
|
|
||||||
+-----------------+------------------------------------------------------------------------------------------------------+
|
|
||||||
Affect(row-cnt:1) cost in 1 ms.
|
|
||||||
$
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### 重做一次调用
|
#### 重做一次调用
|
||||||
|
|
||||||
当你稍稍做了一些调整之后,你可能需要前端系统重新触发一次你的调用,此时得求爷爷告奶奶的需要前端配合联调的同学再次发起一次调用。而有些场景下,这个调用不是这么好触发的。
|
当你稍稍做了一些调整之后,你可能需要前端系统重新触发一次你的调用,此时得求爷爷告奶奶的需要前端配合联调的同学再次发起一次调用。而有些场景下,这个调用不是这么好触发的。
|
||||||
|
|
||||||
`tt` 命令由于保存了当时调用的所有现场信息,所以我们可以自己主动对一个 `INDEX` 编号的时间片自主发起一次调用,从而解放你的沟通成本。此时你需要 `-p` 参数。
|
`tt` 命令由于保存了当时调用的所有现场信息,所以我们可以自己主动对一个 `INDEX` 编号的时间片自主发起一次调用,从而解放你的沟通成本。此时你需要 `-p` 参数。
|
||||||
|
|
||||||
```
|
```bash
|
||||||
$ tt -i 1003 -p
|
$ tt -i 1004 -p
|
||||||
+-----------------+---------------------------------------------------------------------------------------------------------+
|
RE-INDEX 1004
|
||||||
| RE-INDEX | 1003 |
|
GMT-REPLAY 2018-12-04 11:26:00
|
||||||
+-----------------+---------------------------------------------------------------------------------------------------------+
|
OBJECT 0x4b67cf4d
|
||||||
| GMT-REPLAY | 2015-07-26 17:29:51 |
|
CLASS demo.MathGame
|
||||||
+-----------------+---------------------------------------------------------------------------------------------------------+
|
METHOD primeFactors
|
||||||
| OBJECT | 0x42cc13a0 |
|
PARAMETERS[0] @Integer[946738738]
|
||||||
+-----------------+---------------------------------------------------------------------------------------------------------+
|
IS-RETURN true
|
||||||
| CLASS | GaOgnlUtilsTest |
|
IS-EXCEPTION false
|
||||||
+-----------------+---------------------------------------------------------------------------------------------------------+
|
RETURN-OBJ @ArrayList[
|
||||||
| METHOD | printAddress |
|
@Integer[2],
|
||||||
+-----------------+---------------------------------------------------------------------------------------------------------+
|
@Integer[11],
|
||||||
| PARAMETERS[0] | Address@53448f87 |
|
@Integer[17],
|
||||||
+-----------------+---------------------------------------------------------------------------------------------------------+
|
@Integer[2531387],
|
||||||
| IS-RETURN | false |
|
]
|
||||||
+-----------------+---------------------------------------------------------------------------------------------------------+
|
Time fragment[1004] successfully replayed.
|
||||||
| IS-EXCEPTION | true |
|
Affect(row-cnt:1) cost in 14 ms.
|
||||||
+-----------------+---------------------------------------------------------------------------------------------------------+
|
|
||||||
| THROW-EXCEPTION | java.lang.RuntimeException: test |
|
|
||||||
| | at GaOgnlUtilsTest.printAddress(GaOgnlUtilsTest.java:78) |
|
|
||||||
| | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) |
|
|
||||||
| | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) |
|
|
||||||
| | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) |
|
|
||||||
| | at java.lang.reflect.Method.invoke(Method.java:483) |
|
|
||||||
| | at com.github.ompc.Arthas.util.GaMethod.invoke(GaMethod.java:81) |
|
|
||||||
| | at com.github.ompc.Arthas.command.TimeTunnelCommand$6.action(TimeTunnelCommand.java:592) |
|
|
||||||
| | at com.github.ompc.Arthas.server.DefaultCommandHandler.execute(DefaultCommandHandler.java:175) |
|
|
||||||
| | at com.github.ompc.Arthas.server.DefaultCommandHandler.executeCommand(DefaultCommandHandler.java:83) |
|
|
||||||
| | at com.github.ompc.Arthas.server.GaServer$4.run(GaServer.java:329) |
|
|
||||||
| | at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) |
|
|
||||||
| | at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) |
|
|
||||||
| | at java.lang.Thread.run(Thread.java:745) |
|
|
||||||
+-----------------+---------------------------------------------------------------------------------------------------------+
|
|
||||||
replay time fragment[1003] success.
|
|
||||||
Affect(row-cnt:1) cost in 3 ms.
|
|
||||||
$
|
|
||||||
```
|
```
|
||||||
|
|
||||||
你会发现结果虽然一样,但调用的路径发生了变化,有原来的程序发起变成了 Arthas 自己的内部线程发起的调用了。
|
你会发现结果虽然一样,但调用的路径发生了变化,有原来的程序发起变成了 Arthas 自己的内部线程发起的调用了。
|
||||||
|
|||||||
Reference in new issue
Block a user