当前位置:网站首页>阿里的arthas使用,入门报错:Unable to attach to 32-bit process running under WOW64
阿里的arthas使用,入门报错:Unable to attach to 32-bit process running under WOW64
2022-08-04 19:46:00 【爱的叹息】
学会 Arthas,让你 3 年经验掌握 5 年功力!
学会 Arthas,让你 3 年经验掌握 5 年功力! (qq.com)
简介
Arthas 是Alibaba开源的Java诊断工具,动态跟踪Java代码;实时监控JVM状态,可以在不中断程序执行的情况下轻松完成JVM相关问题排查工作 。支持JDK 6+,支持Linux/Mac/Windows。这个工具真的很好用,而且入门超简单,十分推荐。
使用场景
这个类从哪个 jar 包加载的?为什么会报各种类相关的 Exception?
我改的代码为什么没有执行到?难道是我没 commit?分支搞错了?
遇到问题无法在线上 debug,难道只能通过加日志再重新发布吗?
线上遇到某个用户的数据处理有问题,但线上同样无法 debug,线下无法重现!
是否有一个全局视角来查看系统的运行状况?
有什么办法可以监控到JVM的实时运行状态?接下来,围绕这6个问题,学习下Arthas的基本用法。
执行curl的时候会下载文件
在path中把JAVA_HOME变量放到最前面
保存环境变量配置后,重启cmd,执行java -version
启动 math-game
已经切换为64位jre了,然后在运行
curl -O https://arthas.aliyun.com/math-game.jar
java -jar math-game.jar
启动 arthas
再起cmd,执行
curl -O https://arthas.aliyun.com/arthas-boot.jar
java -jar arthas-boot.jar
选择刚才执行的math-game.jar,即4然后回车
如上表示连接成功
查看 dashboard
输入dashboard,按回车/enter
,会展示当前进程的信息,按ctrl+c
可以中断执行。
通过 thread 命令来获取到math-game
进程的 Main Class
thread 1
会打印线程 ID 1 的栈,通常是 main 函数的线程。
通过 jad 来反编译 Main Class
例如:
jad demo.MathGame
demo.MathGame是报名+类名
[[email protected]]$ jad demo.MathGame
ClassLoader:
[email protected]
[email protected]
Location:
/C:/Users/35725/math-game.jar
/*
* Decompiled with CFR.
*/
package demo;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.TimeUnit;
public class MathGame {
private static Random random = new Random();
private int illegalArgumentCount = 0;
public static void main(String[] args) throws InterruptedException {
MathGame game = new MathGame();
while (true) {
/*16*/ game.run();
/*17*/ TimeUnit.SECONDS.sleep(1L);
}
}
public void run() throws InterruptedException {
try {
/*23*/ int number = random.nextInt() / 10000;
/*24*/ List<Integer> primeFactors = this.primeFactors(number);
/*25*/ MathGame.print(number, primeFactors);
}
catch (Exception e) {
/*28*/ System.out.println(String.format("illegalArgumentCount:%3d, ", this.illegalArgumentCount) + e.getMessage());
}
}
public static void print(int number, List<Integer> primeFactors) {
StringBuffer sb = new StringBuffer(number + "=");
/*34*/ for (int factor : primeFactors) {
/*35*/ sb.append(factor).append('*');
}
/*37*/ if (sb.charAt(sb.length() - 1) == '*') {
/*38*/ sb.deleteCharAt(sb.length() - 1);
}
/*40*/ System.out.println(sb);
}
public List<Integer> primeFactors(int number) {
/*44*/ if (number < 2) {
/*45*/ ++this.illegalArgumentCount;
throw new IllegalArgumentException("number is: " + number + ", need >= 2");
}
ArrayList<Integer> result = new ArrayList<Integer>();
/*50*/ int i = 2;
/*51*/ while (i <= number) {
/*52*/ if (number % i == 0) {
/*53*/ result.add(i);
/*54*/ number /= i;
/*55*/ i = 2;
continue;
}
/*57*/ ++i;
}
/*61*/ return result;
}
}
Affect(row-cnt:1) cost in 392 ms.
[[email protected]]$
watch
通过watch命令来查看demo.MathGame#primeFactors
函数的返回值:
例如
watch demo.MathGame primeFactors returnObj
退出 arthas
如果只是退出当前的连接,可以用quit
或者exit
命令。Attach 到目标进程上的 arthas 还会继续运行,端口会保持开放,下次连接时可以直接连接上。
如果想完全退出 arthas,可以执行stop
命令。
更多的功能可以查看进阶使用。
边栏推荐
猜你喜欢
2022年国内手机满意度榜单:华为稳坐国产品牌第一
Polygon zkEVM 基本概念
2022年7月国产数据库大事记
Seata source code analysis: various message processing processes of seata server
Video Object Detection
【着色器实现Glitch单项故障闪烁效果(与Television效果不同)_Shader效果第十四篇】
Exploration and Practice of Database Governance
【Attention演变史】翻译模型seq2seq (第二弹)
[Sql brush topic] Query information data--Day1
Defaced Fingerprint Recovery and Identification
随机推荐
如何让远在的老板看到你!----------来自财富中国网
Yuanguo chain game system development
The book "The Essence of Alipay Experience Design", a record of knowledge related to testing
SAP 电商云 Accelerator 和 Spartacus UI 的工作机制差异
量化交易机器人系统开发
按需视觉识别:愿景和初步方案
成品升级程序
Elastic Search 根据匹配分和热度分排序
刷题-洛谷-P1317 低洼地
SIGIR 2022 | 邻域建模Graph-Masked Transformer,显著提高CTR预测性能
如何使用 jMeter Parallel Controller - 并行控制器以及一些常犯的错误
MySQL远程备份策略举例
力扣题(5)—— 最长回文子串
高效目标检测:动态候选较大程度提升检测精度(附论文下载)
拥抱Cmake小朋友 简单又实用,但是不灵活
Differences in the working mechanism between SAP E-commerce Cloud Accelerator and Spartacus UI
使用 Chrome 开发者工具的 lighthouse 功能分析 web 应用的性能问题
Storage resource activation system to help new infrastructure
【着色器实现Glitch单项故障闪烁效果(与Television效果不同)_Shader效果第十四篇】
5G NR 笔记记录