Merge pull request #154 from Hearen/manual-improvement

improve the descriptions and fix some typos
This commit is contained in:
hengyunabc 2018-09-26 10:15:43 +08:00 committed by GitHub
commit afa9bab5ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 95 additions and 89 deletions

View File

@ -9,17 +9,17 @@ It can be a great help for `ResourceNotFoundException` when you can use command
|Name|Specification|
|---:|:---|
|[l]|count based on the class loader instance|
|[t]|print all the inheritance structure of the class loaders|
|[l]|list all class loader instances based on thread count|
|[t]|print the inheritance structure of the class loaders|
|[a]|list all the classes loaded by all the class loaders (use it with great caution since the output can be huge)|
|`[c:]`|get the hashcode of the class loader|
|`[c: r:]`|using class loader to search resource|
|[c:]|get the hashcode of the class loader|
|[c: r:]|using class loader to search resource|
### Usage
* categorised by class loader
* Categorised by class loader
```s
```sh
$ classloader
name numberOfInstances loadedCountTotal
com.taobao.pandora.service.loader.ModuleClassLoader 29 11659
@ -100,7 +100,7 @@ $ classloader -t
| | +-sun.reflect.DelegatingClassLoader@73f44f24
```
* Check the real urls of `URLClassLoader`
* Check URL of the class loader
```shell
$ classloader -c 5ffe9775

View File

@ -1,6 +1,19 @@
Commands List
All Commands
=============
### Basic
* help - check the assistant info for the command
* cls - clear out the current screen area
* session - check the current session profile
* [reset](reset.md) - clear the injected code from the classes (B.T.W when Arthas server closed, all the injected will also be cleared)
* version - the version of the working Arthas
* quit - exit the current Arthas client without affecting other clients
* shutdown - terminate the Arthas server and all clients
* [keymap](keymap.md) - shortcuts for Arthas and also you can define your own
### Advanced
* [dashboard](dashboard.md)
* [thread](thread.md)
* [jvm](jvm.md)
@ -25,13 +38,3 @@ Commands List
* [options](options.md)
### Arthas Basic Commands
* help - check the assistant info for the command
* cls - clear out the current screen area
* session - check the current session profile
* [reset](reset.md) - clear the injected code from the classes (B.T.W when Arthas server closed, all the injected will also be cleared)
* version - the version of the working Arthas
* quit - exit the current Arthas client without affecting other clients
* shutdown - terminate the Arthas server and all clients
* [keymap](keymap.md) - shortcuts for Arthas and also you can define your own

View File

@ -8,13 +8,13 @@ Dump the bytecode the loaded classes to a specified directory.
|Name|Specification|
|---:|:---|
|*class-pattern*|pattern for the class name|
|`[c:]`|hashcode of the class loader that loaded the class|
|[E]|turn on regx matching while the default is wildcards matching|
|[c:]|hashcode of the [class loader](classloader.md) that loaded the class|
|[E]|turn on regex matching while the default is wildcard matching|
### Usage
```shell
$ dump -E org\.apache\.commons\.lang\.StringUtils
```bash
$ dump org.apache.commons.lang.StringUtils
HASHCODE CLASSLOADER LOCATION
29505d69 +-tddl-client's ModuleClassLoader /Users/zhuyong/middleware/taobao-tomcat/output/build/bin/classdump/com.taobao.pandora
.service.loader.ModuleClassLoader-29505d69/org.apache.commons.lang.StringUtils.class

View File

@ -36,7 +36,7 @@ Arthas is born to solve these issues. You can trouble-shoot your production issu
Contents
--------
English version is on the way, if you would like to contribute, please leave a message [here](https://github.com/alibaba/arthas/issues/51)
English version has just been finished. If you would like to make it better, please check [here](https://github.com/alibaba/arthas/issues/51) and submit your PM.
* [Installation](install-detail.md)
* [Quick start](quick-start.md)

View File

@ -6,22 +6,22 @@ De-compile specified loaded classes.
`jad` helps to *de-compile* the byte code in JVM to the source code to assist you to better understand the logic behind.
F.Y.I
* the de-compiled code will be grammatically highlighted for readability in Arthas Console;
* you have to understand there might be some trivial grammar errors but it won't affect the logic understanding.
* the de-compiled code will be grammatically highlighted for readability in Arthas console;
* there might be some trivial grammar errors but it won't affect the logic understanding.
### Options
|Name|Specification|
|---:|:---|
|*class-pattern*|pattern for the class name|
|`[c:]`|hashcode of the class loader that loaded the class|
|[E]|turn on regx matching while the default is wildcards matching|
|[c:]|hashcode of the class loader that loaded the class|
|[E]|turn on regex matching while the default is wildcard matching|
### Usage
When several class loaders loaded the same class:
1. `jad` to get the hashcode of the class loader;
2. `jad -c <hashcode>` to get the de-compiled class loaded by the class loader.
2. `jad -c <hashcode>` to get the de-compiled class loaded by the specified class loader.
```java
$ jad org.apache.log4j.Logger
@ -156,3 +156,7 @@ private Map<String, Object> directMetrics(String ip, String[] metrics) {
Affect(row-cnt:1) cost in 1508 ms.
```
F.Y.I
Inner class is not yet supported, you can just check the *outer* class to further check the inner class.

View File

@ -1,14 +1,14 @@
monitor
=======
Monitor the `class-pattern` & `method-pattern` matched methods invoking traces.
Monitor methods calling stack traces.
F.Y.I
1. `monitor` is a persistent command, it never returns until `Ctrl+C` to manually stop it.
2. the server runs the tasks in the background;
3. injected code will become invalid automatically once the tasks being terminated;
4. in theory, Arthas commands will not change any original behaviors.
1. `monitor` is a persistent command, it never returns until you press `Ctrl+C` to manually stop it;
2. the server runs the jobs in the background;
3. injected monitoring code will become invalid automatically once the monitoring jobs being terminated;
4. in theory, Arthas will not change any original behaviors but if it does, please do not hesitate to start an [issue](https://github.com/alibaba/arthas/issues).
### Properties monitored
@ -29,8 +29,8 @@ F.Y.I
|---:|:---|
|*class-pattern*|pattern for the class name|
|*method-pattern*|pattern for the method name|
|[E]|turn on regx matching while the default is wildcards matching|
|`[c:]`|cycle of output with default value: `120 s`|
|[E]|turn on regex matching while the default is wildcard matching|
|[c:]|cycle of output with default value: `60 s`|
### Usage

View File

@ -1,12 +1,12 @@
options
===
> Global options
### Global options
|&nbsp;&nbsp;&nbsp;Name&nbsp;&nbsp;&nbsp;| Default Value | Description |
|Name| Default Value | Description |
| ------------------------- | ----- | ---------------------------------------- |
| unsafe | false | Enable system-level class enhancement; JVM might crash, if you turn it on (use with great caution :exclamation:) |
| dump | false | Enable support for dumping enhanced class to external file; if turned on, class file will be dumped to`/${application dir}/arthas-class-dump/`please check console output for specific location |
| dump | false | Enable support for dumping enhanced class to external files; if turned on, class file will be dumped to`/${application dir}/arthas-class-dump/`please check console output for specific location |
| batch-re-transform | true | re-transform matched classes in batch |
| json-format | false | Enable output in JSON format |
| disable-sub-class | false | Disabling child class matching: by default child class will be matched while matching target class; if you wish exact matching, you should turn it off |

View File

@ -1,14 +1,14 @@
redefine
========
Load the external `*.class` files and *re-define* the JVM-loaded classes.
Load the external `*.class` files to **re-define** the JVM-loaded classes.
Reference: [Instrumentation#redefineClasses](https://docs.oracle.com/javase/8/docs/api/java/lang/instrument/Instrumentation.html#redefineClasses-java.lang.instrument.ClassDefinition...-)
F.Y.I
1. Re-defined classes cannot be restores any more;
2. Re-definition can fail (like adding a new field); for more information, please refer to JDK documentation
2. Re-definition can fail (like adding a new field/method); for more information, please refer to JDK documentation
### Options
@ -21,6 +21,6 @@ F.Y.I
### Usage
```
redefine -p /tmp/Test.class
redefine -c 327a647b -p /tmp/Test.class /tmp/Test\$Inner.class
redefine -p /tmp/Test.class
redefine -c 327a647b -p /tmp/Test.class /tmp/Test$Inner.class
```

View File

@ -3,7 +3,7 @@ sc
Check the profiles of the loaded classes.
Abbreviated from “Search-Class”; with the help of this command, you can search out all the loaded classes in JVM. Supported options are: `[d]`、`[E]`、`[f]` and `[x:]`.
Abbreviated from *Search-Class*; with the help of this command, you can search out all the loaded classes in JVM. Supported options are: `[d]`、`[E]`、`[f]` and `[x:]`.
Options
-------
@ -16,12 +16,12 @@ Options
|*method-pattern*|pattern for the method name|
|[d]|print the details of the current class including the source file, class declaration, the class loaders and the like.<br/>F.Y.I if a class is loaded by several class loaders, then the class will be printed several times|
|[E]|turn on regx matching while the default is wildcards matching|
|[f]|print the fields info of the current class, which should be used along with `-d`|
|[f]|print the fields info of the current class, which ***must*** be used with `-d`|
|[x:]|the depth to print the static fields, whose default is `0` - directly invoke the `toString()`|
Tip:
1. *class-patten* supports full qualified class name (e.g. com.taobao.test.AAA and com/taobao/test/AAA)
2. `sc` turned on the `sub-class` matching in default mode, if you do want to hide the `sub-class` please just turn it off via `options disable-sub-class true`.
2. `sc` turned on the `sub-class` matching in default mode; if you do want to hide `sub-class`, you can just turn it off with [options](options.md) as `options disable-sub-class true`.
### Usage

View File

@ -3,7 +3,7 @@ sm
Check the method profile of the loaded classes;
Abbreviated from “Search-Method”, with which you can search out all methods profiles of the loaded classes.
Abbreviated from *Search-Method*, with which you can check all methods profiles of the loaded classes.
F.Y.I
`sm` only shows the methods declared in the current class; methods declared in ancestors will not be presented.
@ -15,7 +15,7 @@ F.Y.I
|*class-pattern*|pattern for class name|
|*method-pattern*|pattern for method name|
|[d]|print the details of the method|
|[E]|turn the regex matching on while the default mode is wildcards matching|
|[E]|turn on regex matching while the default mode is wildcard matching|
### Usage

View File

@ -11,16 +11,16 @@ Most of the time, we know the method being invoked but not always we know **HOW
|---:|:---|
|*class-pattern*|pattern for the class name|
|*method-pattern*|pattern for the method name|
|*condition-express*|condition expression|
|[E]|turn on regx matching while the default is wildcards matching|
|`[n:]`|calling times|
|*condition-expression*|condition expression|
|[E]|turn on regex matching while the default is wildcard matching|
|[n:]|calling times|
F.Y.I
1. any valid OGNL expression as `"{params,returnObj}"` supported;
2. filter by time cost as `trace *StringUtils isBlank '$cost>100'`; calling stack with only time cost higher than `100ms` will be printed.
2. filter by time cost as `trace *StringUtils isBlank '#cost>100'`; calling stack with only time cost higher than `100ms` will be printed.
Attention:
1. `$cost` can be used in `watch/stack/trace`;
1. `#cost` can be used in `watch/stack/trace`;
2. using `#cost` in Arthas 3.0 instead of `$cost`.
@ -32,7 +32,7 @@ Advanced:
### Usage
The quoting rules: if there are quotes within the expression, use another type of quotes to quote the whole expression.
The quoting rules: if there are quotes within the expression, use another type of quotes to quote the whole expression (single `''` or double `""` quotes).
```
$ stack com.alibaba.sample.petstore.dal.dao.ProductDao getProductById 'params[0]=="K9-BD-01"'
@ -68,7 +68,7 @@ thread_name="http-bio-8080-exec-2" thread_id=0x48;is_daemon=true;priority=5;
at com.alibaba.citrus.service.pipeline.impl.PipelineImpl$PipelineContextImpl.invoke(PipelineImpl.java:210)
at com.alibaba.citrus.service.pipeline.impl.valve.ChooseValve.invoke(ChooseValve.java:98)
at com.alibaba.citrus.service.pipeline.impl.PipelineImpl$PipelineContextImpl.invokeNext(PipelineImpl.java:157)
......
...
```
Filtering by time cost:
@ -110,5 +110,5 @@ thread_name=http-nio-8080-exec-10;id=31;is_daemon=true;priority=5;TCCL=com.taoba
at com.alibaba.citrus.webx.impl.WebxControllerImpl.service(WebxControllerImpl.java:43)
at com.alibaba.citrus.webx.impl.WebxRootControllerImpl.handleRequest(WebxRootControllerImpl.java:53)
at com.alibaba.citrus.webx.support.AbstractWebxRootController.service(AbstractWebxRootController.java:165)
.........
...
```

View File

@ -1,7 +1,7 @@
trace
=====
Track the `class-pattern` & `method-pattern` matched method calling trace and print the time cost in each call.
Track methods calling stack trace and print the time cost in each call.
### Parameters
@ -11,19 +11,18 @@ Track the `class-pattern` & `method-pattern` matched method calling trace and pr
|*method-pattern*|pattern for the method name|
|*condition-express*|condition expression|
|[E]|turn on regx matching while the default is wildcards matching|
|`[n:]`|calling times|
|`#cost`|time cost|
|[n:]|calling times|
|#cost|time cost|
F.Y.I
1. any valid OGNL expression as `"{params,returnObj}"` supported;
2. filter by time cost as `trace *StringUtils isBlank '$cost>100'`; calling stack with only time cost higher than `100ms` will be printed.
2. filter by time cost as `trace *StringUtils isBlank '#cost>100'`; calling stack with only time cost higher than `100ms` will be printed.
Attention:
1. `$cost` can be used in `watch/stack/trace`;
1. `#cost` can be used in `watch/stack/trace`;
2. using `#cost` in Arthas 3.0 instead of `$cost`.
3. `trace` can help to locate the performance lurking issue but only `level-one` method invoking considered.
Advanced:
* [Critical fields in expression](advice-class.md)
* [Special usage](https://github.com/alibaba/arthas/issues/71)
@ -101,8 +100,8 @@ trace com.alibaba.sample.petstore.web.store.module.screen.ItemList execute #cost
Only the calling trace of the time cost higher than `4ms`presented now.
F.Y.I
1. just like JProfile and the like commercial software, you can `trace` down the specified method calling in Arthas;
1. like JProfile and other similar commercial software, you can `trace` down the specified method calling stack with time cost in Arthas;
2. there will be some overhead using `trace` but not much;
3. the time cost is an instructive clue for troubleshooting, which means it's not that accurate ignoring the cost it itself causes; the deeper or more the call is, the accuracy is becoming worse;
3. the time cost is an instructive clue for troubleshooting, which means it's not that accurate ignoring the cost it itself causes; the deeper or more the call is, the worse accuracy the time cost will be;
4. `[0,0,0ms,11]xxx:yyy() [throws Exception]`the same method calling aggregated into one line here while `throws Exception` indicates there is an exception.

View File

@ -1,13 +1,13 @@
tt
==
Check the parameters, return values and exceptions of the methods at different times.
Check the `parameters`, `return values` and `exceptions` of the methods at different times.
`watch` is a powerful command but due to its feasibility and complexity, it's quite hard to locate the issue effectively.
In such difficulties, `tt` comes into play.
With the help of `tt` (abbreviated from *TimeTunnel*), you can check the contexts of the methods at different times.
With the help of `tt` (*TimeTunnel*), you can check the contexts of the methods at different times in execution history.
### Usage
@ -37,7 +37,7 @@ Let's record the whole calling contexts:
- `-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 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
@ -46,8 +46,8 @@ Let's record the whole calling contexts:
|INDEX|the index for each call based on time|
|TIMESTAMP|time to invoke the method|
|COST(ms)|time cost of the method call|
|IS-RET|end with normal return|
|IS-EXP|end with exceptions|
|IS-RET|whether method exits with normal return|
|IS-EXP|whether method failed with exceptions|
|OBJECT|`hashCode()` of the object invoking the method|
|CLASS|class name of the object invoking the method|
|METHOD|method being invoked|
@ -55,7 +55,7 @@ Let's record the whole calling contexts:
#### Condition expression
Tips:
1. `tt -t *Test print params[0].length==1` with different amount of parameters;
1. `tt -t *Test print params[0].length==1` with different amounts of parameters;
2. `tt -t *Test print 'params[1] instanceof Integer'` with different types of parameters;
3. `tt -t *Test print params[0].mobile=="13989838402"` with specified parameter.
@ -67,7 +67,7 @@ Advanced:
### Searching for records
#### A specified time range
#### All the recorded
```
$ tt -l
@ -147,7 +147,7 @@ $
### Re-produce
Since Arthas stores the context of the call, you can even re-produce the method calling after some modifications with extra option `-p`.
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.
```
$ tt -i 1003 -p
@ -189,6 +189,6 @@ $
```
F.Y.I
1. the calling stack is little different using Arthas now instead of the original method;
2. **Loss** of the thread local variables will be a fact since there is no way for Arthas to record the thread local info.
3. **Potential** modifications of objects can happen since only a reference will be recorded by Arthas while later process might modify objects without Arthas's watch.
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)*).
3. **Potential** modifications of objects can happen since only a reference will be recorded while later operations might modify objects without Arthas's watch.

View File

@ -3,31 +3,31 @@ watch
Monitor methods in data aspect including `return values`, `exceptions` and `parameters`.
With the help of [OGNL](https://en.wikipedia.org/wiki/OGNL), you can easily check the details of variables.
With the help of [OGNL](https://en.wikipedia.org/wiki/OGNL), you can easily check the details of variables when methods being invoked.
### Parameters & Options
There are four different scenarios for `watch` command, which makes it a rather complicated command in Arthas.
There are four different scenarios for `watch` command, which makes it rather complicated.
|Name|Specification|
|---:|:---|
|*class-pattern*|pattern for the class name|
|*method-pattern*|pattern for the method name|
|*express*|expression to monitor|
|*condition-express*|condition expression to filter|
|*expression*|expression to monitor|
|*condition-expression*|condition expression to filter|
|[b]|before method being invoked|
|[e]|encountering exceptions|
|[s]|returned normally|
|[f]|returned normally and abnormally|
|[E]|turn on regex matching while the default is wildcards matching|
|[e]|when method encountering exceptions|
|[s]|when method exits normally|
|[f]|when method exits (either succeed or fail with exceptions)|
|[E]|turn on regex matching while the default is wildcard matching|
|[x:]|the depth to print the specified property with default value: 1|
F.Y.I
1. any valid OGNL expression as `"{params,returnObj}"` supported
2. there are four *watching* points: `-b`, `-e`, `-s` and `-f` (the first three are off in default while `-f` on);
3. at the *watching* point, Arthas will use the *expression* to evaluate the variables and print them out;
4. `in-parameters` and `out-parameters` are different since they can be modified within the invoked methods; `params` stands for `in-parameters` in `-b`while `out-parameters` in other *watching* points;
5. there is no `return values` and `exceptions` when using `-b`.
4. `in parameters` and `out parameters` are different since they can be modified within the invoked methods; `params` stands for `in parameters` in `-b`while `out parameters` in other *watching* points;
5. there are no `return values` and `exceptions` when using `-b`.
Advanced:
@ -57,7 +57,7 @@ A demo:
return list.size();
}
```
#### Check the `out-parameters` and `return value`
#### Check the `out parameters` and `return value`
```shell
$ watch com.alibaba.sample.petstore.web.store.module.screen.ItemList add "{params,returnObj}" -x 2
@ -73,7 +73,7 @@ Affect(class-cnt:1 , method-cnt:1) cost in 44 ms.
]
```
#### Check `in-parameters`
#### Check `in parameters`
```shell
$ watch com.alibaba.sample.petstore.web.store.module.screen.ItemList add "{params,returnObj}" -x 2 -b
@ -89,7 +89,7 @@ Affect(class-cnt:1 , method-cnt:1) cost in 48 ms.
]
```
Compared to the previous *check*:
Compared to the previous *check*, there are two differences:
1. size of `params[0]` is `2` instead of `4`;
2. `return value` is `null` since it's `-b`.
@ -122,7 +122,7 @@ F.Y.I
1. the first block of output is the *before watching* point;
2. the order of the output determined by the *watching* order itself (nothing to do with the order of the options `-b -s`).
#### Using `-x` to check more details
#### Use `-x` to check more details
```shell
$ watch com.alibaba.sample.petstore.web.store.module.screen.ItemList add "{params,returnObj}" -x 3
@ -150,7 +150,7 @@ Affect(class-cnt:1 , method-cnt:1) cost in 59 ms.
]
```
#### Using condition expressions to locate specific call
#### Use condition expressions to locate specific call
```shell
$ watch com.alibaba.sample.petstore.biz.impl.UserManagerImpl testAdd "{params, returnObj}" "params[0].equals('aaa')" -x 2