一、什么是Bistoury
去哪儿开源的应用诊断工具
详细可以看看这篇:
去哪儿一站式 Java 应用诊断解决方案 - Bistoury
二、快速开始
启动需要被debug的应用
java -jar web-quick-practice-1.0-SNAPSHOT.jar
启动bistoury
./quick_start.sh -p <pid> -i 127.0.0.1 start
然后就可以在localhost:9091访问,启动的东西比较多,所以还是要等下的。账号密码默认admin
三、Bistoury在线debug效果
选择应用
选择需要debug的类

如果没有配置代码仓库的地址,那就会展示Fernflower反编译后的代码

打断点,只能打1个断点,打多个需要先移除之前的。前端有校验行号对不对。
![[图片]](https://i-blog.csdnimg.cn/direct/f40ee1030ceb4c65b1356e688e1fa9ae.png)
每隔几秒,会自动发请求获取断点的执行结果。触发成功后自动移除断点集合中的断点
![[图片]](https://i-blog.csdnimg.cn/direct/65df4e8d3cf14deea8042c37f398af22.png)
四、Bistoury在线debug具体实现
行增强,增强了什么?
如果源代码是下面这样的话,我们在第四行添加断点
@GetMapping("/hello")
public String hello() {
String str = "hello";
return str; // 在这里添加断点
}
代码就会被增强为这样。增强的逻辑大概是,判断这个断点是否存在 --> 存储局部变量 --> 命中断点(这里会将断点从集合中移除)–> 之后把局部变量、静态变量、全局变量、调用栈存到DefaultSnapshotStore中(后续QDebugSearchCommand,会去查这些debug数据)
@GetMapping({
"/hello"})
public String hello() {
String str = "hello";
if (BistourySpys1.hasBreakpointSet("org/example/HelloContoller.java", 4)) {
BistourySpys1.putLocalVariable("this", this);
BistourySpys1.putLocalVariable("str", str);
if (BistourySpys1.isHit("org/example/HelloContoller.java", 4)) {
BistourySpys1.dump("org/example/HelloContoller.java", 4);
BistourySpys1.fillStacktrace("org/example/HelloContoller.java", 4, new Throwable());
BistourySpys1.endReceive("org/example/HelloContoller.java", 4);
}
}
return str;
}
怎么保证反编译后的行号和.class记录的行号一样?
传给前端的时候,会带上行号之间的映射,前端的行号校验也是根据这个映射来的
//
// Source code recreated from a .class file by Bistoury
// (powered by Fernflower decompiler)
//
package org

最低0.47元/天 解锁文章
2571





