mirror of https://github.com/alibaba/arthas.git
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.
74 lines
3.2 KiB
Markdown
74 lines
3.2 KiB
Markdown
3 years ago
|
# stack
|
||
7 years ago
|
|
||
5 years ago
|
[`stack` online tutorial](https://arthas.aliyun.com/doc/arthas-tutorials.html?language=en&id=command-stack)
|
||
5 years ago
|
|
||
3 years ago
|
::: tip
|
||
|
Print out the full call stack of the current method.
|
||
|
:::
|
||
7 years ago
|
|
||
6 years ago
|
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.
|
||
7 years ago
|
|
||
|
### Parameters
|
||
|
|
||
3 years ago
|
| 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 |
|
||
7 years ago
|
|
||
6 years ago
|
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.
|
||
7 years ago
|
|
||
6 years ago
|
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.
|
||
7 years ago
|
|
||
6 years ago
|
Pls. refer to [core parameters in expression](advice-class.md) for more details.
|
||
3 years ago
|
|
||
|
- 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)
|
||
7 years ago
|
|
||
|
### Usage
|
||
|
|
||
6 years ago
|
#### Start Demo
|
||
7 years ago
|
|
||
4 years ago
|
Start `math-game` in [Quick Start](quick-start.md).
|
||
6 years ago
|
|
||
|
#### stack
|
||
|
|
||
|
```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
|
||
6 years ago
|
|
||
|
```bash
|
||
6 years ago
|
$ stack demo.MathGame primeFactors 'params[0]<0' -n 2
|
||
7 years ago
|
Press Ctrl+C to abort.
|
||
6 years ago
|
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.
|
||
7 years ago
|
```
|
||
|
|
||
6 years ago
|
#### Filtering by cost
|
||
7 years ago
|
|
||
6 years ago
|
```bash
|
||
6 years ago
|
$ stack demo.MathGame primeFactors '#cost>5'
|
||
7 years ago
|
Press Ctrl+C to abort.
|
||
6 years ago
|
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)
|
||
7 years ago
|
```
|