Search in sources :

Example 16 with InsnNode

use of jadx.core.dex.nodes.InsnNode in project jadx by skylot.

the class DebugInfoParser method addrChange.

private int addrChange(int addr, int addrInc, int line) {
    int newAddr = addr + addrInc;
    int maxAddr = insnByOffset.length - 1;
    newAddr = Math.min(newAddr, maxAddr);
    for (int i = addr + 1; i <= newAddr; i++) {
        InsnNode insn = insnByOffset[i];
        if (insn == null) {
            continue;
        }
        for (InsnArg arg : insn.getArguments()) {
            if (arg.isRegister()) {
                activeRegisters[((RegisterArg) arg).getRegNum()] = arg;
            }
        }
        RegisterArg res = insn.getResult();
        if (res != null) {
            activeRegisters[res.getRegNum()] = res;
        }
    }
    setSourceLines(addr, newAddr, line);
    return newAddr;
}
Also used : InsnNode(jadx.core.dex.nodes.InsnNode) RegisterArg(jadx.core.dex.instructions.args.RegisterArg) InsnArg(jadx.core.dex.instructions.args.InsnArg)

Example 17 with InsnNode

use of jadx.core.dex.nodes.InsnNode in project jadx by skylot.

the class DebugInfoParser method setVar.

private void setVar(LocalVar var) {
    int start = var.getStartAddr();
    int end = var.getEndAddr();
    for (int i = start; i <= end; i++) {
        InsnNode insn = insnByOffset[i];
        if (insn != null) {
            fillLocals(insn, var);
        }
    }
    merge(activeRegisters[var.getRegNum()], var);
}
Also used : InsnNode(jadx.core.dex.nodes.InsnNode)

Example 18 with InsnNode

use of jadx.core.dex.nodes.InsnNode in project jadx by skylot.

the class DebugInfoParser method startVar.

private void startVar(LocalVar var, int addr, int line) {
    int regNum = var.getRegNum();
    LocalVar prev = locals[regNum];
    if (prev != null && !prev.isEnd()) {
        prev.end(addr, line);
        setVar(prev);
    }
    InsnArg activeReg = activeRegisters[var.getRegNum()];
    if (activeReg instanceof RegisterArg) {
        SSAVar ssaVar = ((RegisterArg) activeReg).getSVar();
        if (ssaVar != null && ssaVar.getStartAddr() != -1) {
            InsnNode parentInsn = ssaVar.getAssign().getParentInsn();
            if (parentInsn != null && parentInsn.getOffset() >= 0) {
                addr = parentInsn.getOffset();
            }
        }
    }
    var.start(addr, line);
    locals[regNum] = var;
}
Also used : InsnNode(jadx.core.dex.nodes.InsnNode) RegisterArg(jadx.core.dex.instructions.args.RegisterArg) SSAVar(jadx.core.dex.instructions.args.SSAVar) InsnArg(jadx.core.dex.instructions.args.InsnArg)

Example 19 with InsnNode

use of jadx.core.dex.nodes.InsnNode in project jadx by skylot.

the class ConditionGen method isArgWrapNeeded.

private static boolean isArgWrapNeeded(InsnArg arg) {
    if (!arg.isInsnWrap()) {
        return false;
    }
    InsnNode insn = ((InsnWrapArg) arg).getWrapInsn();
    InsnType insnType = insn.getType();
    if (insnType == InsnType.ARITH) {
        switch(((ArithNode) insn).getOp()) {
            case ADD:
            case SUB:
            case MUL:
            case DIV:
            case REM:
                return false;
        }
    } else {
        switch(insnType) {
            case INVOKE:
            case SGET:
            case IGET:
            case AGET:
            case CONST:
            case ARRAY_LENGTH:
                return false;
            default:
                return true;
        }
    }
    return true;
}
Also used : InsnNode(jadx.core.dex.nodes.InsnNode) InsnWrapArg(jadx.core.dex.instructions.args.InsnWrapArg) ArithNode(jadx.core.dex.instructions.ArithNode) InsnType(jadx.core.dex.instructions.InsnType)

Example 20 with InsnNode

use of jadx.core.dex.nodes.InsnNode in project jadx by skylot.

the class IfCondition method simplifyCmpOp.

private static void simplifyCmpOp(Compare c) {
    if (!c.getA().isInsnWrap()) {
        return;
    }
    if (!c.getB().isLiteral() || ((LiteralArg) c.getB()).getLiteral() != 0) {
        return;
    }
    InsnNode wrapInsn = ((InsnWrapArg) c.getA()).getWrapInsn();
    InsnType type = wrapInsn.getType();
    if (type != InsnType.CMP_L && type != InsnType.CMP_G) {
        return;
    }
    IfNode insn = c.getInsn();
    insn.changeCondition(insn.getOp(), wrapInsn.getArg(0), wrapInsn.getArg(1));
}
Also used : InsnNode(jadx.core.dex.nodes.InsnNode) LiteralArg(jadx.core.dex.instructions.args.LiteralArg) InsnWrapArg(jadx.core.dex.instructions.args.InsnWrapArg) IfNode(jadx.core.dex.instructions.IfNode) InsnType(jadx.core.dex.instructions.InsnType)

Aggregations

InsnNode (jadx.core.dex.nodes.InsnNode)123 BlockNode (jadx.core.dex.nodes.BlockNode)41 RegisterArg (jadx.core.dex.instructions.args.RegisterArg)39 IndexInsnNode (jadx.core.dex.instructions.IndexInsnNode)35 InsnArg (jadx.core.dex.instructions.args.InsnArg)32 InsnWrapArg (jadx.core.dex.instructions.args.InsnWrapArg)19 SSAVar (jadx.core.dex.instructions.args.SSAVar)16 ArrayList (java.util.ArrayList)14 ArgType (jadx.core.dex.instructions.args.ArgType)11 PhiInsn (jadx.core.dex.instructions.PhiInsn)10 FieldNode (jadx.core.dex.nodes.FieldNode)10 JadxRuntimeException (jadx.core.utils.exceptions.JadxRuntimeException)8 LiteralArg (jadx.core.dex.instructions.args.LiteralArg)7 ClassNode (jadx.core.dex.nodes.ClassNode)7 MethodNode (jadx.core.dex.nodes.MethodNode)7 FieldInfo (jadx.core.dex.info.FieldInfo)6 ArithNode (jadx.core.dex.instructions.ArithNode)6 ConstructorInsn (jadx.core.dex.instructions.mods.ConstructorInsn)6 InsnType (jadx.core.dex.instructions.InsnType)5 IContainer (jadx.core.dex.nodes.IContainer)5