Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
keyescgm
jadx
提交
c54dd77f
J
jadx
项目概览
keyescgm
/
jadx
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jadx
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
c54dd77f
编写于
3月 02, 2022
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(gui): resolve NPE and fix code style in BreakpointManager
上级
17fbc99f
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
25 addition
and
27 deletion
+25
-27
jadx-gui/src/main/java/jadx/gui/device/debugger/BreakpointManager.java
...main/java/jadx/gui/device/debugger/BreakpointManager.java
+25
-27
未找到文件。
jadx-gui/src/main/java/jadx/gui/device/debugger/BreakpointManager.java
浏览文件 @
c54dd77f
package
jadx.gui.device.debugger
;
package
jadx.gui.device.debugger
;
import
java.io.Reader
;
import
java.lang.reflect.Type
;
import
java.lang.reflect.Type
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.file.Files
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.util.AbstractMap.SimpleEntry
;
import
java.util.AbstractMap.SimpleEntry
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Collections
;
...
@@ -14,6 +16,8 @@ import java.util.Map;
...
@@ -14,6 +16,8 @@ import java.util.Map;
import
java.util.Map.Entry
;
import
java.util.Map.Entry
;
import
java.util.Objects
;
import
java.util.Objects
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -28,52 +32,39 @@ import jadx.gui.treemodel.JClass;
...
@@ -28,52 +32,39 @@ import jadx.gui.treemodel.JClass;
public
class
BreakpointManager
{
public
class
BreakpointManager
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
BreakpointManager
.
class
);
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
BreakpointManager
.
class
);
private
static
Gson
gson
=
null
;
private
static
final
Gson
GSON
=
new
GsonBuilder
().
setPrettyPrinting
().
create
()
;
private
static
final
Type
TYPE_TOKEN
=
new
TypeToken
<
Map
<
String
,
List
<
FileBreakpoint
>>>()
{
private
static
final
Type
TYPE_TOKEN
=
new
TypeToken
<
Map
<
String
,
List
<
FileBreakpoint
>>>()
{
}.
getType
();
}.
getType
();
private
static
Map
<
String
,
List
<
FileBreakpoint
>>
bpm
;
private
static
@NotNull
Map
<
String
,
List
<
FileBreakpoint
>>
bpm
=
Collections
.
emptyMap
()
;
private
static
Path
savePath
;
private
static
@Nullable
Path
savePath
;
private
static
DebugController
debugController
;
private
static
DebugController
debugController
;
private
static
Map
<
String
,
Entry
<
ClassNode
,
Listener
>>
listeners
=
Collections
.
emptyMap
();
// class full name as key
private
static
Map
<
String
,
Entry
<
ClassNode
,
Listener
>>
listeners
=
Collections
.
emptyMap
();
// class full name as key
public
static
void
saveAndExit
()
{
public
static
void
saveAndExit
()
{
if
(
bpm
!=
null
)
{
if
(
bpm
.
size
()
==
0
&&
!
Files
.
exists
(
savePath
))
{
return
;
// user didn't do anything with breakpoint so don't output breakpoint file.
}
sync
();
sync
();
bpm
=
null
;
bpm
=
Collections
.
emptyMap
()
;
savePath
=
null
;
savePath
=
null
;
listeners
=
Collections
.
emptyMap
();
listeners
=
Collections
.
emptyMap
();
}
}
}
public
static
void
init
(
Path
dirPath
)
{
public
static
void
init
(
@Nullable
Path
baseDir
)
{
if
(
gson
==
null
)
{
Path
saveDir
=
baseDir
!=
null
?
baseDir
:
Paths
.
get
(
"."
);
gson
=
new
GsonBuilder
()
savePath
=
saveDir
.
resolve
(
"breakpoints.json"
);
// TODO: move into project file or same dir as project file
.
setPrettyPrinting
()
.
create
();
}
savePath
=
dirPath
.
resolve
(
"breakpoints.json"
);
if
(
Files
.
exists
(
savePath
))
{
if
(
Files
.
exists
(
savePath
))
{
try
{
try
(
Reader
reader
=
Files
.
newBufferedReader
(
savePath
,
StandardCharsets
.
UTF_8
))
{
byte
[]
bytes
=
Files
.
readAllBytes
(
savePath
);
bpm
=
GSON
.
fromJson
(
reader
,
TYPE_TOKEN
);
bpm
=
gson
.
fromJson
(
new
String
(
bytes
,
StandardCharsets
.
UTF_8
),
TYPE_TOKEN
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
LOG
.
error
(
"Failed to read breakpoints config: {}"
,
savePath
,
e
);
LOG
.
error
(
"Failed to read breakpoints config: {}"
,
savePath
,
e
);
}
}
}
}
if
(
bpm
==
null
)
{
bpm
=
Collections
.
emptyMap
();
}
}
}
/**
/**
* @param listener When breakpoint is failed to set during debugging, this listener will be called.
* @param listener When breakpoint is failed to set during debugging, this listener will be called.
*/
*/
public
static
void
addListener
(
JClass
topCls
,
Listener
listener
)
{
public
static
void
addListener
(
JClass
topCls
,
Listener
listener
)
{
if
(
listeners
==
Collections
.
EMPTY_MAP
)
{
if
(
listeners
.
isEmpty
()
)
{
listeners
=
new
HashMap
<>();
listeners
=
new
HashMap
<>();
}
}
listeners
.
put
(
DbgUtils
.
getRawFullName
(
topCls
),
listeners
.
put
(
DbgUtils
.
getRawFullName
(
topCls
),
...
@@ -149,8 +140,15 @@ public class BreakpointManager {
...
@@ -149,8 +140,15 @@ public class BreakpointManager {
}
}
private
static
void
sync
()
{
private
static
void
sync
()
{
if
(
savePath
==
null
)
{
return
;
}
if
(
bpm
.
isEmpty
()
&&
!
Files
.
exists
(
savePath
))
{
// user didn't do anything with breakpoint so don't output breakpoint file.
return
;
}
try
{
try
{
Files
.
write
(
savePath
,
gson
.
toJson
(
bpm
).
getBytes
(
StandardCharsets
.
UTF_8
));
Files
.
write
(
savePath
,
GSON
.
toJson
(
bpm
).
getBytes
(
StandardCharsets
.
UTF_8
));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
LOG
.
error
(
"Failed to write breakpoints config: {}"
,
savePath
,
e
);
LOG
.
error
(
"Failed to write breakpoints config: {}"
,
savePath
,
e
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录