Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2301_76393173
jadx
提交
53cac58e
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,体验更适合开发者的 AI 搜索 >>
提交
53cac58e
编写于
10月 11, 2014
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
core: fix processing of last instruction in 'try' block
上级
adc32ed3
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
86 addition
and
7 deletion
+86
-7
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/dex/visitors/ssa/SSATransform.java
...rc/main/java/jadx/core/dex/visitors/ssa/SSATransform.java
+31
-5
jadx-core/src/test/java/jadx/tests/integration/loops/TestNestedLoops3.java
...t/java/jadx/tests/integration/loops/TestNestedLoops3.java
+0
-1
jadx-core/src/test/java/jadx/tests/integration/trycatch/TestTryCatch6.java
...t/java/jadx/tests/integration/trycatch/TestTryCatch6.java
+53
-0
未找到文件。
jadx-core/src/main/java/jadx/core/dex/visitors/regions/RegionMaker.java
浏览文件 @
53cac58e
...
...
@@ -356,7 +356,8 @@ public class RegionMaker {
if
(
loopExit
==
exit
)
{
// try/catch at loop end
BlockNode
source
=
exitEdge
.
getSource
();
if
(
source
.
contains
(
AType
.
CATCH_BLOCK
))
{
if
(
source
.
contains
(
AType
.
CATCH_BLOCK
)
&&
source
.
getSuccessors
().
size
()
==
2
)
{
BlockNode
other
=
BlockUtils
.
selectOther
(
loopExit
,
source
.
getSuccessors
());
if
(
other
!=
null
&&
other
.
contains
(
AType
.
EXC_HANDLER
))
{
insertBlock
=
source
;
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/ssa/SSATransform.java
浏览文件 @
53cac58e
package
jadx.core.dex.visitors.ssa
;
import
jadx.core.dex.attributes.AFlag
;
import
jadx.core.dex.attributes.AType
;
import
jadx.core.dex.attributes.nodes.PhiListAttr
;
import
jadx.core.dex.instructions.InsnType
;
...
...
@@ -40,7 +41,11 @@ public class SSATransform extends AbstractVisitor {
placePhi
(
mth
,
i
,
la
);
}
renameVariables
(
mth
);
removeUselessPhi
(
mth
);
fixLastTryCatchAssign
(
mth
);
if
(
removeUselessPhi
(
mth
))
{
renameVariables
(
mth
);
}
}
private
static
void
placePhi
(
MethodNode
mth
,
int
regNum
,
LiveVarAnalysis
la
)
{
...
...
@@ -147,7 +152,27 @@ public class SSATransform extends AbstractVisitor {
System
.
arraycopy
(
inputVars
,
0
,
vars
,
0
,
vars
.
length
);
}
private
static
void
removeUselessPhi
(
MethodNode
mth
)
{
private
static
void
fixLastTryCatchAssign
(
MethodNode
mth
)
{
for
(
BlockNode
block
:
mth
.
getBasicBlocks
())
{
PhiListAttr
phiList
=
block
.
get
(
AType
.
PHI_LIST
);
if
(
phiList
==
null
||
!
block
.
contains
(
AType
.
EXC_HANDLER
))
{
continue
;
}
for
(
PhiInsn
phi
:
phiList
.
getList
())
{
for
(
int
i
=
0
;
i
<
phi
.
getArgsCount
();
i
++)
{
RegisterArg
arg
=
phi
.
getArg
(
i
);
InsnNode
parentInsn
=
arg
.
getAssignInsn
();
if
(
parentInsn
!=
null
&&
parentInsn
.
getResult
()
!=
null
&&
parentInsn
.
contains
(
AFlag
.
TRY_LEAVE
))
{
phi
.
removeArg
(
arg
);
}
}
}
}
}
private
static
boolean
removeUselessPhi
(
MethodNode
mth
)
{
List
<
PhiInsn
>
insnToRemove
=
new
ArrayList
<
PhiInsn
>();
for
(
SSAVar
var
:
mth
.
getSVars
())
{
// phi result not used
...
...
@@ -167,7 +192,7 @@ public class SSATransform extends AbstractVisitor {
removePhiWithSameArgs
(
phi
,
insnToRemove
);
}
}
removePhiList
(
mth
,
insnToRemove
);
re
turn
re
movePhiList
(
mth
,
insnToRemove
);
}
private
static
void
removePhiWithSameArgs
(
PhiInsn
phi
,
List
<
PhiInsn
>
insnToRemove
)
{
...
...
@@ -194,9 +219,9 @@ public class SSATransform extends AbstractVisitor {
}
}
private
static
void
removePhiList
(
MethodNode
mth
,
List
<
PhiInsn
>
insnToRemove
)
{
private
static
boolean
removePhiList
(
MethodNode
mth
,
List
<
PhiInsn
>
insnToRemove
)
{
if
(
insnToRemove
.
isEmpty
())
{
return
;
return
false
;
}
for
(
BlockNode
block
:
mth
.
getBasicBlocks
())
{
PhiListAttr
phiList
=
block
.
get
(
AType
.
PHI_LIST
);
...
...
@@ -217,5 +242,6 @@ public class SSATransform extends AbstractVisitor {
}
}
insnToRemove
.
clear
();
return
true
;
}
}
jadx-core/src/test/java/jadx/tests/integration/loops/TestNestedLoops3.java
浏览文件 @
53cac58e
...
...
@@ -62,7 +62,6 @@ public class TestNestedLoops3 extends IntegrationTest {
@Test
public
void
test
()
{
setOutputCFG
();
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
...
...
jadx-core/src/test/java/jadx/tests/integration/trycatch/TestTryCatch6.java
0 → 100644
浏览文件 @
53cac58e
package
jadx.tests.integration.trycatch
;
import
jadx.core.dex.nodes.ClassNode
;
import
jadx.tests.api.IntegrationTest
;
import
java.io.IOException
;
import
org.junit.Test
;
import
static
jadx
.
tests
.
api
.
utils
.
JadxMatchers
.
containsOne
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
public
class
TestTryCatch6
extends
IntegrationTest
{
public
static
class
TestCls
{
private
static
boolean
test
(
Object
obj
)
{
boolean
res
=
false
;
while
(
true
)
{
try
{
res
=
exc
(
obj
);
return
res
;
}
catch
(
IOException
e
)
{
res
=
true
;
}
catch
(
Throwable
e
)
{
if
(
obj
==
null
)
{
obj
=
new
Object
();
}
}
}
}
private
static
boolean
exc
(
Object
obj
)
throws
IOException
{
if
(
obj
==
null
)
{
throw
new
IOException
();
}
return
true
;
}
public
void
check
()
{
assertTrue
(
test
(
new
Object
()));
}
}
@Test
public
void
test
()
{
noDebugInfo
();
ClassNode
cls
=
getClassNode
(
TestCls
.
class
);
String
code
=
cls
.
getCode
().
toString
();
assertThat
(
code
,
containsOne
(
"try {"
));
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录