mirror of https://github.com/alibaba/arthas.git
parent
6b5a8f0ec9
commit
d490a6c583
@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
下载`arthas-demo.jar`,再用`java -jar`命令启动:
|
||||||
|
|
||||||
|
`wget https://alibaba.github.io/arthas/arthas-demo.jar
|
||||||
|
java -jar arthas-demo.jar`{{execute T1}}
|
||||||
|
|
||||||
|
`arthas-demo`是一个很简单的程序,它随机生成整数,再执行因式分解,把结果打印出来。如果生成的随机数是负数,则会打印提示信息。
|
@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"title": "Arthas stack命令",
|
||||||
|
"description": "Arthas stack命令",
|
||||||
|
"difficulty": "精通者",
|
||||||
|
"time": "10-20 分钟",
|
||||||
|
"details": {
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"title": "启动arthas demo",
|
||||||
|
"text": "arthas-demo.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "启动arthas-boot",
|
||||||
|
"text": "arthas-boot.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "stack命令",
|
||||||
|
"text": "stack.md"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"intro": {
|
||||||
|
"text": "intro.md"
|
||||||
|
},
|
||||||
|
"finish": {
|
||||||
|
"text": "finish.md"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"environment": {
|
||||||
|
"uilayout": "terminal"
|
||||||
|
},
|
||||||
|
"backend": {
|
||||||
|
"imageid": "java",
|
||||||
|
"environmentsprotocol": "http"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Download `arthas-demo.jar` and start with the `java -jar` command:
|
||||||
|
|
||||||
|
`wget https://alibaba.github.io/arthas/arthas-demo.jar
|
||||||
|
java -jar arthas-demo.jar`{{execute T1}}
|
||||||
|
|
||||||
|
`arthas-demo` is a very simple program that randomly generates integers, performs factorization, and prints the results.
|
||||||
|
If the generated random number is negative, a error message will be printed.
|
@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
The `stack Tutorial` demonstrates the usage of stack. If you have more tips or questions, please feel free to ask in Issue.
|
||||||
|
|
||||||
|
* Issues: https://github.com/alibaba/arthas/issues
|
||||||
|
* Documentation: https://alibaba.github.io/arthas
|
||||||
|
|
||||||
|
|
||||||
|
If you are using Arthas, please let us know. Your use is very important to us: [View](https://github.com/alibaba/arthas/issues/111)
|
@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"title": "Arthas stack Command",
|
||||||
|
"description": "Arthas stack Command",
|
||||||
|
"difficulty": "master",
|
||||||
|
"time": "10-20 minutes",
|
||||||
|
"details": {
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"title": "Arthas demo",
|
||||||
|
"text": "arthas-demo.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Start arthas-boot",
|
||||||
|
"text": "arthas-boot.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "stack Command",
|
||||||
|
"text": "stack.md"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"intro": {
|
||||||
|
"text": "intro.md"
|
||||||
|
},
|
||||||
|
"finish": {
|
||||||
|
"text": "finish.md"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"environment": {
|
||||||
|
"uilayout": "terminal"
|
||||||
|
},
|
||||||
|
"backend": {
|
||||||
|
"imageid": "java",
|
||||||
|
"environmentsprotocol": "http"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,71 @@
|
|||||||
|
|
||||||
|
> Print out the full call stack of the current method.
|
||||||
|
|
||||||
|
Most often we know one method gets called, but we have no idea on which code path gets executed or when the method gets called since there are so many code paths to the target method. The command `stack` comes to rescue in this difficult situation.
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
|Name|Specification|
|
||||||
|
|---:|:---|
|
||||||
|
|*class-pattern*|pattern for the class name|
|
||||||
|
|*method-pattern*|pattern for the method name|
|
||||||
|
|*condition-expression*|condition expression|
|
||||||
|
|`[E]`|turn on regex match, the default behavior is wildcard match|
|
||||||
|
|`[n:]`|execution times|
|
||||||
|
|
||||||
|
There's one thing worthy noting here is observation expression. The observation expression supports OGNL grammar, for example, you can come up a expression like this `"{params,returnObj}"`. All OGNL expressions are supported as long as they are legal to the grammar.
|
||||||
|
|
||||||
|
Thanks for `advice`'s data structure, it is possible to observe from varieties of different angles. Inside `advice` parameter, all necessary information for notification can be found.
|
||||||
|
|
||||||
|
* Pls. also refer to [https://github.com/alibaba/arthas/issues/71](https://github.com/alibaba/arthas/issues/71) for more advanced usage
|
||||||
|
* OGNL official site: [https://commons.apache.org/proper/commons-ognl/language-guide.html](https://commons.apache.org/proper/commons-ognl/language-guide.html)
|
||||||
|
|
||||||
|
### Usage
|
||||||
|
|
||||||
|
#### stack
|
||||||
|
|
||||||
|
`stack demo.MathGame primeFactors`{{execute T2}}
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ stack demo.MathGame primeFactors
|
||||||
|
Press Ctrl+C to abort.
|
||||||
|
Affect(class-cnt:1 , method-cnt:1) cost in 36 ms.
|
||||||
|
ts=2018-12-04 01:32:19;thread_name=main;id=1;is_daemon=false;priority=5;TCCL=sun.misc.Launcher$AppClassLoader@3d4eac69
|
||||||
|
@demo.MathGame.run()
|
||||||
|
at demo.MathGame.main(MathGame.java:16)
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Filtering by condition expression
|
||||||
|
|
||||||
|
`stack demo.MathGame primeFactors 'params[0]<0' -n 2`{{execute T2}}
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ stack demo.MathGame primeFactors 'params[0]<0' -n 2
|
||||||
|
Press Ctrl+C to abort.
|
||||||
|
Affect(class-cnt:1 , method-cnt:1) cost in 30 ms.
|
||||||
|
ts=2018-12-04 01:34:27;thread_name=main;id=1;is_daemon=false;priority=5;TCCL=sun.misc.Launcher$AppClassLoader@3d4eac69
|
||||||
|
@demo.MathGame.run()
|
||||||
|
at demo.MathGame.main(MathGame.java:16)
|
||||||
|
|
||||||
|
ts=2018-12-04 01:34:30;thread_name=main;id=1;is_daemon=false;priority=5;TCCL=sun.misc.Launcher$AppClassLoader@3d4eac69
|
||||||
|
@demo.MathGame.run()
|
||||||
|
at demo.MathGame.main(MathGame.java:16)
|
||||||
|
|
||||||
|
Command execution times exceed limit: 2, so command will exit. You can set it with -n option.
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
#### Filtering by cost
|
||||||
|
|
||||||
|
`stack demo.MathGame primeFactors '#cost>5'`{{execute T2}}
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ stack demo.MathGame primeFactors '#cost>5'
|
||||||
|
Press Ctrl+C to abort.
|
||||||
|
Affect(class-cnt:1 , method-cnt:1) cost in 35 ms.
|
||||||
|
ts=2018-12-04 01:35:58;thread_name=main;id=1;is_daemon=false;priority=5;TCCL=sun.misc.Launcher$AppClassLoader@3d4eac69
|
||||||
|
@demo.MathGame.run()
|
||||||
|
at demo.MathGame.main(MathGame.java:16)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue