Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2301_76393173
jadx
提交
343bddc6
J
jadx
项目概览
2301_76393173
/
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,发现更多精彩内容 >>
提交
343bddc6
编写于
5月 04, 2014
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
core: fix 'break' detection in loop
上级
632a742e
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
66 addition
and
8 deletion
+66
-8
jadx-core/src/main/java/jadx/api/Decompiler.java
jadx-core/src/main/java/jadx/api/Decompiler.java
+0
-1
jadx-core/src/main/java/jadx/core/dex/nodes/ClassNode.java
jadx-core/src/main/java/jadx/core/dex/nodes/ClassNode.java
+2
-1
jadx-core/src/main/java/jadx/core/dex/visitors/regions/RegionMaker.java
...main/java/jadx/core/dex/visitors/regions/RegionMaker.java
+8
-6
jadx-core/src/main/java/jadx/core/utils/BlockUtils.java
jadx-core/src/main/java/jadx/core/utils/BlockUtils.java
+12
-0
jadx-core/src/test/java/jadx/tests/internal/loops/TestLoopDetection3.java
...st/java/jadx/tests/internal/loops/TestLoopDetection3.java
+44
-0
未找到文件。
jadx-core/src/main/java/jadx/api/Decompiler.java
浏览文件 @
343bddc6
...
@@ -181,7 +181,6 @@ public final class Decompiler {
...
@@ -181,7 +181,6 @@ public final class Decompiler {
}
}
void
processClass
(
ClassNode
cls
)
{
void
processClass
(
ClassNode
cls
)
{
LOG
.
debug
(
"processing class {} ..."
,
cls
);
ProcessClass
.
process
(
cls
,
passes
);
ProcessClass
.
process
(
cls
,
passes
);
}
}
...
...
jadx-core/src/main/java/jadx/core/dex/nodes/ClassNode.java
浏览文件 @
343bddc6
...
@@ -104,7 +104,8 @@ public class ClassNode extends LineAttrNode implements ILoadable {
...
@@ -104,7 +104,8 @@ public class ClassNode extends LineAttrNode implements ILoadable {
int
sfIdx
=
cls
.
getSourceFileIndex
();
int
sfIdx
=
cls
.
getSourceFileIndex
();
if
(
sfIdx
!=
DexNode
.
NO_INDEX
)
{
if
(
sfIdx
!=
DexNode
.
NO_INDEX
)
{
String
fileName
=
dex
.
getString
(
sfIdx
);
String
fileName
=
dex
.
getString
(
sfIdx
);
if
(!
this
.
getFullName
().
contains
(
fileName
.
replace
(
".java"
,
""
)))
{
if
(!
this
.
getFullName
().
contains
(
fileName
.
replace
(
".java"
,
""
))
&&
!
fileName
.
equals
(
"SourceFile"
))
{
this
.
getAttributes
().
add
(
new
SourceFileAttr
(
fileName
));
this
.
getAttributes
().
add
(
new
SourceFileAttr
(
fileName
));
LOG
.
debug
(
"Class '{}' compiled from '{}'"
,
this
,
fileName
);
LOG
.
debug
(
"Class '{}' compiled from '{}'"
,
this
,
fileName
);
}
}
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/RegionMaker.java
浏览文件 @
343bddc6
...
@@ -238,8 +238,9 @@ public class RegionMaker {
...
@@ -238,8 +238,9 @@ public class RegionMaker {
exitBlocks
.
remove
(
condBlock
);
exitBlocks
.
remove
(
condBlock
);
if
(
exitBlocks
.
size
()
>
0
)
{
if
(
exitBlocks
.
size
()
>
0
)
{
BlockNode
loopExit
=
BlockUtils
.
selectOtherSafe
(
loopBody
,
condBlock
.
getCleanSuccessors
());
if
(
loopExit
!=
null
)
{
// add 'break' instruction before path cross between main loop exit and subexit
// add 'break' instruction before path cross between main loop exit and subexit
BlockNode
loopExit
=
BlockUtils
.
selectOther
(
loopBody
,
condBlock
.
getCleanSuccessors
());
for
(
Edge
exitEdge
:
loop
.
getExitEdges
())
{
for
(
Edge
exitEdge
:
loop
.
getExitEdges
())
{
if
(!
exitBlocks
.
contains
(
exitEdge
.
getSource
()))
{
if
(!
exitBlocks
.
contains
(
exitEdge
.
getSource
()))
{
continue
;
continue
;
...
@@ -247,6 +248,7 @@ public class RegionMaker {
...
@@ -247,6 +248,7 @@ public class RegionMaker {
insertBreak
(
stack
,
loopExit
,
exitEdge
);
insertBreak
(
stack
,
loopExit
,
exitEdge
);
}
}
}
}
}
BlockNode
out
;
BlockNode
out
;
if
(
loopRegion
.
isConditionAtEnd
())
{
if
(
loopRegion
.
isConditionAtEnd
())
{
...
...
jadx-core/src/main/java/jadx/core/utils/BlockUtils.java
浏览文件 @
343bddc6
...
@@ -45,6 +45,18 @@ public class BlockUtils {
...
@@ -45,6 +45,18 @@ public class BlockUtils {
}
}
}
}
public
static
BlockNode
selectOtherSafe
(
BlockNode
node
,
List
<
BlockNode
>
blocks
)
{
int
size
=
blocks
.
size
();
if
(
size
==
1
)
{
BlockNode
first
=
blocks
.
get
(
0
);
return
first
!=
node
?
first
:
null
;
}
else
if
(
size
==
2
)
{
BlockNode
first
=
blocks
.
get
(
0
);
return
first
!=
node
?
first
:
blocks
.
get
(
1
);
}
return
null
;
}
private
static
List
<
BlockNode
>
cleanBlockList
(
List
<
BlockNode
>
list
)
{
private
static
List
<
BlockNode
>
cleanBlockList
(
List
<
BlockNode
>
list
)
{
List
<
BlockNode
>
ret
=
new
ArrayList
<
BlockNode
>(
list
.
size
());
List
<
BlockNode
>
ret
=
new
ArrayList
<
BlockNode
>(
list
.
size
());
for
(
BlockNode
block
:
list
)
{
for
(
BlockNode
block
:
list
)
{
...
...
jadx-core/src/test/java/jadx/tests/internal/loops/TestLoopDetection3.java
0 → 100644
浏览文件 @
343bddc6
package
jadx.tests.internal.loops
;
import
jadx.api.InternalJadxTest
;
import
jadx.core.dex.nodes.ClassNode
;
import
org.junit.Test
;
import
static
org
.
hamcrest
.
CoreMatchers
.
containsString
;
import
static
org
.
junit
.
Assert
.
assertThat
;
public
class
TestLoopDetection3
extends
InternalJadxTest
{
public
static
class
TestCls
{
private
void
test
(
TestCls
parent
,
int
pos
)
{
Object
item
;
while
(--
pos
>=
0
)
{
item
=
parent
.
get
(
pos
);
if
(
item
instanceof
String
)
{
func
((
String
)
item
);
return
;
}
}
}
private
Object
get
(
int
pos
)
{
return
null
;
}
private
void
func
(
String
item
)
{
}
}
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
System
.
out
.
println
(
code
);
assertThat
(
code
,
containsString
(
"while"
));
// TODO
// assertThat(code, containsString("while (--pos >= 0) {"));
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录