Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ql04210214
jadx
提交
f0a73b32
J
jadx
项目概览
ql04210214
/
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,发现更多精彩内容 >>
提交
f0a73b32
编写于
8月 06, 2014
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
core: fix processing conditions in loop
上级
c97678a4
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
94 addition
and
2 deletion
+94
-2
jadx-core/src/main/java/jadx/core/dex/nodes/BlockNode.java
jadx-core/src/main/java/jadx/core/dex/nodes/BlockNode.java
+5
-0
jadx-core/src/main/java/jadx/core/dex/visitors/regions/IfMakerHelper.java
...in/java/jadx/core/dex/visitors/regions/IfMakerHelper.java
+12
-1
jadx-core/src/main/java/jadx/core/dex/visitors/regions/RegionMaker.java
...main/java/jadx/core/dex/visitors/regions/RegionMaker.java
+2
-1
jadx-core/src/main/java/jadx/core/utils/BlockUtils.java
jadx-core/src/main/java/jadx/core/utils/BlockUtils.java
+21
-0
jadx-core/src/test/java/jadx/tests/internal/others/TestLoopInTry.java
...c/test/java/jadx/tests/internal/others/TestLoopInTry.java
+54
-0
未找到文件。
jadx-core/src/main/java/jadx/core/dex/nodes/BlockNode.java
浏览文件 @
f0a73b32
...
...
@@ -86,6 +86,11 @@ public class BlockNode extends AttrNode implements IBlock {
for
(
BlockNode
b
:
sucList
)
{
if
(
b
.
contains
(
AType
.
EXC_HANDLER
))
{
toRemove
.
add
(
b
);
}
else
if
(
b
.
contains
(
AFlag
.
SYNTHETIC
))
{
List
<
BlockNode
>
s
=
b
.
getSuccessors
();
if
(
s
.
size
()
==
1
&&
s
.
get
(
0
).
contains
(
AType
.
EXC_HANDLER
))
{
toRemove
.
add
(
b
);
}
}
}
if
(
block
.
contains
(
AFlag
.
LOOP_END
))
{
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/IfMakerHelper.java
浏览文件 @
f0a73b32
...
...
@@ -18,9 +18,13 @@ import java.util.Collection;
import
java.util.List
;
import
java.util.Set
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
static
jadx
.
core
.
utils
.
BlockUtils
.
isPathExists
;
public
class
IfMakerHelper
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
IfMakerHelper
.
class
);
private
IfMakerHelper
()
{
}
...
...
@@ -59,10 +63,12 @@ public class IfMakerHelper {
}
else
if
(
badElse
)
{
info
=
new
IfInfo
(
info
.
getCondition
(),
thenBlock
,
null
);
info
.
setOutBlock
(
null
);
LOG
.
debug
(
"Stop processing blocks after bad 'else' in 'if': {}, method: {}"
,
info
,
mth
);
}
else
{
info
=
IfInfo
.
invert
(
info
);
info
=
new
IfInfo
(
info
.
getCondition
(),
info
.
getThenBlock
(),
null
);
info
.
setOutBlock
(
null
);
LOG
.
debug
(
"Stop processing blocks after bad 'then' in 'if': {}, method: {}"
,
info
,
mth
);
}
}
else
{
List
<
BlockNode
>
thenSC
=
thenBlock
.
getCleanSuccessors
();
...
...
@@ -93,7 +99,12 @@ public class IfMakerHelper {
private
static
boolean
allPathsFromIf
(
BlockNode
block
,
IfInfo
info
)
{
List
<
BlockNode
>
preds
=
block
.
getPredecessors
();
Set
<
BlockNode
>
ifBlocks
=
info
.
getMergedBlocks
();
return
ifBlocks
.
containsAll
(
preds
);
for
(
BlockNode
pred
:
preds
)
{
if
(!
ifBlocks
.
contains
(
pred
)
&&
!
pred
.
contains
(
AFlag
.
LOOP_END
))
{
return
false
;
}
}
return
true
;
}
private
static
boolean
sameElements
(
Collection
<
BlockNode
>
c1
,
Collection
<
BlockNode
>
c2
)
{
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/regions/RegionMaker.java
浏览文件 @
f0a73b32
...
...
@@ -231,7 +231,8 @@ public class RegionMaker {
}
LoopRegion
loopRegion
=
new
LoopRegion
(
curRegion
,
block
,
block
==
loop
.
getEnd
());
boolean
found
;
if
(
block
==
loop
.
getStart
()
||
block
==
loop
.
getEnd
())
{
if
(
block
==
loop
.
getStart
()
||
block
==
loop
.
getEnd
()
||
BlockUtils
.
isEmptySimplePath
(
loop
.
getStart
(),
block
))
{
found
=
true
;
}
else
if
(
block
.
getPredecessors
().
contains
(
loop
.
getStart
()))
{
loopRegion
.
setPreCondition
(
loop
.
getStart
());
...
...
jadx-core/src/main/java/jadx/core/utils/BlockUtils.java
浏览文件 @
f0a73b32
...
...
@@ -301,4 +301,25 @@ public class BlockUtils {
}
return
list
.
isEmpty
()
?
Collections
.<
BlockNode
>
emptyList
()
:
list
;
}
/**
* Return true if on path from start to end no instructions and no branches.
*/
public
static
boolean
isEmptySimplePath
(
BlockNode
start
,
BlockNode
end
)
{
if
(
start
==
end
&&
start
.
getInstructions
().
isEmpty
())
{
return
true
;
}
if
(!
start
.
getInstructions
().
isEmpty
()
||
start
.
getCleanSuccessors
().
size
()
!=
1
)
{
return
false
;
}
BlockNode
block
=
getNextBlock
(
start
);
while
(
block
!=
null
&&
block
!=
end
&&
block
.
getCleanSuccessors
().
size
()
<
2
&&
block
.
getPredecessors
().
size
()
==
1
&&
block
.
getInstructions
().
isEmpty
())
{
block
=
getNextBlock
(
block
);
}
return
block
==
end
;
}
}
jadx-core/src/test/java/jadx/tests/internal/others/TestLoopInTry.java
0 → 100644
浏览文件 @
f0a73b32
package
jadx.tests.internal.others
;
import
jadx.api.InternalJadxTest
;
import
jadx.core.dex.nodes.ClassNode
;
import
org.junit.Test
;
import
static
jadx
.
tests
.
utils
.
JadxMatchers
.
containsOne
;
import
static
org
.
junit
.
Assert
.
assertThat
;
public
class
TestLoopInTry
extends
InternalJadxTest
{
public
static
class
TestCls
{
private
static
boolean
b
=
true
;
public
int
test
()
{
try
{
if
(
b
)
{
throw
new
Exception
();
}
while
(
f
())
{
s
();
}
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"exception"
);
return
1
;
}
return
0
;
}
private
static
void
s
()
{
}
private
static
boolean
f
()
{
return
false
;
}
}
@Test
public
void
test
()
{
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
System
.
out
.
println
(
code
);
assertThat
(
code
,
containsOne
(
"try {"
));
assertThat
(
code
,
containsOne
(
"if (b) {"
));
assertThat
(
code
,
containsOne
(
"throw new Exception();"
));
assertThat
(
code
,
containsOne
(
"while (f()) {"
));
assertThat
(
code
,
containsOne
(
"s();"
));
assertThat
(
code
,
containsOne
(
"} catch (Exception e) {"
));
assertThat
(
code
,
containsOne
(
"return 1;"
));
assertThat
(
code
,
containsOne
(
"return 0;"
));
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录