Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
hengyunabc committed Feb 13, 2019
1 parent 0eb32d0 commit 0fe1ab4
Show file tree
Hide file tree
Showing 12 changed files with 130 additions and 4 deletions.
9 changes: 9 additions & 0 deletions site/src/site/sphinx/cat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cat
===

> 打印文件内容,和linux里的cat命令类似。

```bash
$ cat /tmp/a.txt
```
3 changes: 3 additions & 0 deletions site/src/site/sphinx/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

* [jad](jad.md)
* [classloader](classloader.md)
* [mc](mc.md)
* [redefine](redefine.md)

* [monitor](monitor.md)
Expand All @@ -24,6 +25,8 @@
* [stack](stack.md)
* [tt](tt.md)

* [cat](cat.md)
* [pwd](pwd.md)
* [options](options.md)

### Arthas 基础命令
Expand Down
9 changes: 9 additions & 0 deletions site/src/site/sphinx/en/cat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cat
===

> Concatenate and print files

```bash
$ cat /tmp/a.txt
```
3 changes: 3 additions & 0 deletions site/src/site/sphinx/en/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ All Commands

* [jad](jad.md)
* [classloader](classloader.md)
* [mc](mc.md)
* [redefine](redefine.md)

* [monitor](monitor.md)
Expand All @@ -24,6 +25,8 @@ All Commands
* [stack](stack.md)
* [tt](tt.md)

* [cat](cat.md)
* [pwd](pwd.md)
* [options](options.md)


Expand Down
22 changes: 22 additions & 0 deletions site/src/site/sphinx/en/mc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
mc
===

> Memory compiler, compiles java files into bytecode and class files in memory.
```bash
mc /tmp/Test.java
```

The classloader can be specified with the `-c` option:

```bash
mc -c 327a647b /tmp/Test.java
```

The output directory can be specified with the `-d` option:

```bash
mc -d /tmp/output /tmp/ClassA.java /tmp/ClassB.java
```

After compiling the `.class` file, you can use the [`redefine`](redefine.md) command to re-define the loaded classes in JVM.
9 changes: 9 additions & 0 deletions site/src/site/sphinx/en/pwd.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
pwd
===

> Return working directory name

```bash
$ pwd
```
19 changes: 17 additions & 2 deletions site/src/site/sphinx/en/redefine.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,25 @@ Reference: [Instrumentation#redefineClasses](https://docs.oracle.com/javase/8/do
### Usage

```bash
redefine -p /tmp/Test.class
redefine -c 327a647b -p /tmp/Test.class /tmp/Test$Inner.class
redefine /tmp/Test.class
redefine -c 327a647b /tmp/Test.class /tmp/Test$Inner.class
```

### Use with the jad/mc command

```bash
jad --source-only com.example.demo.arthas.user.UserController > /tmp/UserController.java

mc /tmp/UserController.java -d /tmp

redefine /tmp/com/example/demo/arthas/user/UserController.class
```

* Use `jad` command to decompile bytecode, and then you can use other editors, such as vim to modify the source code.
* `mc` command to compile the modified code
* Load new bytecode with `redefine` command


### Restrictions of the redefine command

* New field/method is not allowed
Expand Down
5 changes: 5 additions & 0 deletions site/src/site/sphinx/en/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Release Notes
=============

v3.1.0
---

* [https://github.com/alibaba/arthas/releases/tag/arthas-all-3.1.0](https://github.com/alibaba/arthas/releases/tag/arthas-all-3.1.0)


v3.0.5
---
Expand Down
22 changes: 22 additions & 0 deletions site/src/site/sphinx/mc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
mc
===

> Memory Compiler/内存编绎器,编绎`.java`文件生成`.class`
```bash
mc /tmp/Test.java
```

可以通过`-c`参数指定classloader:

```bash
mc -c 327a647b /tmp/Test.java
```

可以通过`-d`命令指定输出目录:

```bash
mc -d /tmp/output /tmp/ClassA.java /tmp/ClassB.java
```

编绎生成`.class`文件之后,可以结合[`redefine`](redefine.md)命令实现热更新代码。
9 changes: 9 additions & 0 deletions site/src/site/sphinx/pwd.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
pwd
===

> 返回当前的工作目录,和linux命令类似

```bash
$ pwd
```
18 changes: 16 additions & 2 deletions site/src/site/sphinx/redefine.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,24 @@ redefine
### 使用参考

```bash
redefine -p /tmp/Test.class
redefine -c 327a647b -p /tmp/Test.class /tmp/Test\$Inner.class
redefine /tmp/Test.class
redefine -c 327a647b /tmp/Test.class /tmp/Test\$Inner.class
```

### 结合 jad/mc 命令使用

```bash
jad --source-only com.example.demo.arthas.user.UserController > /tmp/UserController.java

mc /tmp/UserController.java -d /tmp

redefine /tmp/com/example/demo/arthas/user/UserController.class
```

* jad命令反编绎,然后可以用其它编绎器,比如vim来修改源码
* mc命令来内存编绎修改过的代码
* 用redefine命令加载新的字节码

### redefine的限制

* 不允许新增加field/method
Expand Down
6 changes: 6 additions & 0 deletions site/src/site/sphinx/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
Release Notes
===

v3.1.0
---

* [https://github.com/alibaba/arthas/releases/tag/arthas-all-3.1.0](https://github.com/alibaba/arthas/releases/tag/arthas-all-3.1.0)


v3.0.5
---

Expand Down

0 comments on commit 0fe1ab4

Please sign in to comment.