Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
keyescgm
jadx
提交
440357d2
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,发现更多精彩内容 >>
提交
440357d2
编写于
6月 01, 2020
作者:
S
Skylot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: allow cross-block move inline (#946)
Signed-off-by:
N
Skylot
<
skylot@gmail.com
>
上级
5e62b907
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
22 addition
and
41 deletion
+22
-41
jadx-core/src/main/java/jadx/core/Jadx.java
jadx-core/src/main/java/jadx/core/Jadx.java
+0
-3
jadx-core/src/main/java/jadx/core/dex/visitors/MoveInlineVisitor.java
...c/main/java/jadx/core/dex/visitors/MoveInlineVisitor.java
+14
-24
jadx-core/src/test/java/jadx/tests/integration/TestReturnWrapping.java
.../test/java/jadx/tests/integration/TestReturnWrapping.java
+8
-14
未找到文件。
jadx-core/src/main/java/jadx/core/Jadx.java
浏览文件 @
440357d2
...
...
@@ -113,9 +113,6 @@ public class Jadx {
passes
.
add
(
new
MarkFinallyVisitor
());
passes
.
add
(
new
ConstInlineVisitor
());
passes
.
add
(
new
TypeInferenceVisitor
());
if
(
args
.
isRawCFGOutput
())
{
passes
.
add
(
DotGraphVisitor
.
dumpRaw
());
}
if
(
args
.
isDebugInfo
())
{
passes
.
add
(
new
DebugInfoApplyVisitor
());
}
...
...
jadx-core/src/main/java/jadx/core/dex/visitors/MoveInlineVisitor.java
浏览文件 @
440357d2
package
jadx.core.dex.visitors
;
import
java.util.ArrayList
;
import
java.util.List
;
import
jadx.core.dex.attributes.AType
;
import
jadx.core.dex.attributes.nodes.RegDebugInfoAttr
;
...
...
@@ -35,12 +34,9 @@ public class MoveInlineVisitor extends AbstractVisitor {
InsnRemover
remover
=
new
InsnRemover
(
mth
);
for
(
BlockNode
block
:
mth
.
getBasicBlocks
())
{
remover
.
setBlock
(
block
);
List
<
InsnNode
>
insns
=
block
.
getInstructions
();
int
size
=
insns
.
size
();
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
InsnNode
insn
=
insns
.
get
(
i
);
for
(
InsnNode
insn
:
block
.
getInstructions
())
{
if
(
insn
.
getType
()
==
InsnType
.
MOVE
&&
processMove
(
mth
,
block
,
insn
,
i
))
{
&&
processMove
(
mth
,
insn
))
{
remover
.
addAndUnbind
(
insn
);
}
}
...
...
@@ -48,7 +44,7 @@ public class MoveInlineVisitor extends AbstractVisitor {
}
}
private
static
boolean
processMove
(
MethodNode
mth
,
BlockNode
block
,
InsnNode
move
,
int
i
)
{
private
static
boolean
processMove
(
MethodNode
mth
,
InsnNode
move
)
{
RegisterArg
resultArg
=
move
.
getResult
();
InsnArg
moveArg
=
move
.
getArg
(
0
);
if
(
resultArg
.
sameRegAndSVar
(
moveArg
))
{
...
...
@@ -58,21 +54,26 @@ public class MoveInlineVisitor extends AbstractVisitor {
if
(
ssaVar
.
isUsedInPhi
())
{
return
false
;
}
RegDebugInfoAttr
debugInfo
=
result
Arg
.
get
(
AType
.
REG_DEBUG_INFO
);
RegDebugInfoAttr
debugInfo
=
move
Arg
.
get
(
AType
.
REG_DEBUG_INFO
);
for
(
RegisterArg
useArg
:
ssaVar
.
getUseList
())
{
InsnNode
useInsn
=
useArg
.
getParentInsn
();
if
(
useInsn
==
null
||
!
fromThisBlock
(
block
,
useInsn
,
i
)
)
{
if
(
useInsn
==
null
)
{
return
false
;
}
RegDebugInfoAttr
debugInfoAttr
=
useArg
.
get
(
AType
.
REG_DEBUG_INFO
);
if
(
debugInfoAttr
!=
null
)
{
debugInfo
=
debugInfoAttr
;
if
(
debugInfo
==
null
)
{
RegDebugInfoAttr
debugInfoAttr
=
useArg
.
get
(
AType
.
REG_DEBUG_INFO
);
if
(
debugInfoAttr
!=
null
)
{
debugInfo
=
debugInfoAttr
;
}
}
}
// all checks passed, execute inline
for
(
RegisterArg
useArg
:
new
ArrayList
<>(
ssaVar
.
getUseList
()))
{
InsnNode
useInsn
=
useArg
.
getParentInsn
();
if
(
useInsn
==
null
)
{
continue
;
}
InsnArg
replaceArg
;
if
(
moveArg
.
isRegister
())
{
replaceArg
=
((
RegisterArg
)
moveArg
).
duplicate
(
useArg
.
getInitType
());
...
...
@@ -83,21 +84,10 @@ public class MoveInlineVisitor extends AbstractVisitor {
if
(
debugInfo
!=
null
)
{
replaceArg
.
addAttr
(
debugInfo
);
}
if
(
useInsn
==
null
||
!
useInsn
.
replaceArg
(
useArg
,
replaceArg
))
{
if
(!
useInsn
.
replaceArg
(
useArg
,
replaceArg
))
{
mth
.
addWarnComment
(
"Failed to replace arg in insn: "
+
useInsn
);
}
}
return
true
;
}
private
static
boolean
fromThisBlock
(
BlockNode
block
,
InsnNode
insn
,
int
curPos
)
{
List
<
InsnNode
>
list
=
block
.
getInstructions
();
int
size
=
list
.
size
();
for
(
int
j
=
curPos
;
j
<
size
;
j
++)
{
if
(
list
.
get
(
j
)
==
insn
)
{
return
true
;
}
}
return
false
;
}
}
jadx-core/src/test/java/jadx/tests/integration/TestReturnWrapping.java
浏览文件 @
440357d2
...
...
@@ -24,15 +24,14 @@ public class TestReturnWrapping extends IntegrationTest {
int
i
=
arg1
;
if
(
arg0
==
null
)
{
return
ret
+
Integer
.
toHexString
(
i
);
}
else
{
i
++;
try
{
ret
=
new
Object
().
getClass
();
}
catch
(
Exception
e
)
{
ret
=
"Qwerty"
;
}
return
i
>
128
?
arg0
.
toString
()
+
ret
.
toString
()
:
i
;
}
i
++;
try
{
ret
=
new
Object
().
getClass
();
}
catch
(
Exception
e
)
{
ret
=
"Qwerty"
;
}
return
i
>
128
?
arg0
.
toString
()
+
ret
.
toString
()
:
i
;
}
public
static
int
f3
(
int
arg0
)
{
...
...
@@ -54,12 +53,7 @@ public class TestReturnWrapping extends IntegrationTest {
assertThat
(
code
,
containsString
(
"return 255;"
));
assertThat
(
code
,
containsString
(
"return arg0 + 1;"
));
// TODO: reduce code vars by name
// assertThat(code, containsString("return i > 128 ? arg0.toString() + ret.toString() :
// Integer.valueOf(i);"));
assertThat
(
code
,
containsString
(
"return i2 > 128 ? arg0.toString() + ret.toString() : Integer.valueOf(i2);"
));
assertThat
(
code
,
containsString
(
"return i > 128 ? arg0.toString() + ret.toString() : Integer.valueOf(i);"
));
assertThat
(
code
,
containsString
(
"return arg0 + 2;"
));
assertThat
(
code
,
containsString
(
"arg0 -= 951;"
));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录