提交 733836ea 编写于 作者: N NeoSpb

core: fix processing of debug info (if local variable used before declaring a debug info)

上级 b4767626
......@@ -212,6 +212,21 @@ public class DebugInfoParser {
prev.end(addr, line);
setVar(prev);
}
RegisterArg activeReg = (RegisterArg) activeRegisters[var.getRegNum()];
if (activeReg != null) {
SSAVar ssaVar = activeReg.getSVar();
if ((ssaVar != null) && (ssaVar.getStartAddr() != -1)) {
if (ssaVar.getAssign() != null) {
if (ssaVar.getAssign().getParentInsn() != null) {
if (ssaVar.getAssign().getParentInsn().getOffset() >= 0) {
addr = ssaVar.getAssign().getParentInsn().getOffset();
}
}
}
}
}
var.start(addr, line);
locals[regNum] = var;
}
......
......@@ -21,6 +21,7 @@ import jadx.core.dex.nodes.BlockNode;
import jadx.core.dex.nodes.InsnNode;
import jadx.core.dex.nodes.MethodNode;
import jadx.core.dex.regions.conditions.IfCondition;
import jadx.core.utils.InsnUtils;
import java.util.ArrayList;
import java.util.Collections;
......@@ -78,9 +79,31 @@ public class SimplifyVisitor extends AbstractVisitor {
case CHECK_CAST:
InsnArg castArg = insn.getArg(0);
ArgType castArgType = castArg.getType();
/*
* Don't removes CHECK_CAST for wrapped INVOKE
* if invoked method returns different type
*/
if (castArg.isInsnWrap()) {
InsnWrapArg castWrapArg = (InsnWrapArg) castArg;
InsnNode wrapInsn = castWrapArg.getWrapInsn();
if (wrapInsn.getType() == InsnType.INVOKE) {
InvokeNode invkInsn = (InvokeNode) wrapInsn;
castArgType = invkInsn.getCallMth().getReturnType();
if (invkInsn.getResult().getType()
!= invkInsn.getCallMth().getReturnType()) {
LOG.warn("Invoke without cast at {} in {}", InsnUtils.formatOffset(invkInsn.getOffset()), mth);
}
}
}
ArgType castType = (ArgType) ((IndexInsnNode) insn).getIndex();
if (!ArgType.isCastNeeded(castArg.getType(), castType)) {
if (!ArgType.isCastNeeded(castArgType, castType)) {
InsnNode insnNode = new InsnNode(InsnType.MOVE, 1);
insnNode.setOffset(insn.getOffset());
insnNode.setResult(insn.getResult());
insnNode.addArg(castArg);
return insnNode;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册