Arthas快速入门

275 阅读1分钟

1. 启动math-game

curl -O https://arthas.aliyun.com/math-game.jar
java -jar math-game.jar

2. 启动arthas

curl -O https://arthas.aliyun.com/arthas-boot.jar
java -jar arthas-boot.jar

QQ浏览器截图20210804153817.png

math-game进程是第1个,则输入1,再输入回车/enter

QQ浏览器截图20210804154006.png

3. 查看dashboard

输入dashboard,按回车/enter,会展示当前进程的信息,按ctrl+c可以中断执行。

QQ浏览器截图20210804154200.png

4. 通过thread命令来获取到math-game进程的Main Class

thread 1 | grep 'main('

QQ浏览器截图20210804154526.png

5. 通过jad来反编译Main Class

jad demo.MathGame

QQ浏览器截图20210804154703.png

QQ浏览器截图20210804154740.png

6. watch

通过watch命令来查看demo.MathGame#primeFactors函数的返回值:

watch demo.MathGame primeFactors returnObj

QQ浏览器截图20210804154933.png

7. 退出arthas

如果只是退出当前的连接,可以用quit或者exit命令。Attach到目标进程上的arthas还会继续运行,端口会保持开放,下次连接时可以直接连接上。

如果想完全退出arthas,可以执行stop命令。