Search in sources :

Example 1 with JadxErrorAttr

use of jadx.core.dex.attributes.nodes.JadxErrorAttr in project jadx by skylot.

the class MethodGen method addInstructions.

public void addInstructions(CodeWriter code) throws CodegenException {
    if (mth.contains(AType.JADX_ERROR) || mth.contains(AFlag.INCONSISTENT_CODE) || mth.getRegion() == null) {
        JadxErrorAttr err = mth.get(AType.JADX_ERROR);
        if (err != null) {
            code.startLine("/* JADX: method processing error */");
            Throwable cause = err.getCause();
            if (cause != null) {
                code.newLine();
                code.add("/*");
                code.newLine().add("Error: ").add(Utils.getStackTrace(cause));
                code.add("*/");
            }
        }
        code.startLine("/*");
        addFallbackMethodCode(code);
        code.startLine("*/");
        code.startLine("throw new UnsupportedOperationException(\"Method not decompiled: ").add(mth.toString()).add("\");");
    } else {
        RegionGen regionGen = new RegionGen(this);
        regionGen.makeRegion(code, mth.getRegion());
    }
}
Also used : JadxErrorAttr(jadx.core.dex.attributes.nodes.JadxErrorAttr)

Example 2 with JadxErrorAttr

use of jadx.core.dex.attributes.nodes.JadxErrorAttr in project jadx by skylot.

the class ErrorsCounter method addError.

private void addError(IAttributeNode node, String msg, Throwable e) {
    errorNodes.add(node);
    errorsCount++;
    if (e != null) {
        if (e.getClass() == JadxOverflowException.class) {
            // don't print full stack trace
            e = new JadxOverflowException(e.getMessage());
            LOG.error("{}, message: {}", msg, e.getMessage());
        } else {
            LOG.error(msg, e);
        }
        node.addAttr(new JadxErrorAttr(e));
    } else {
        node.add(AFlag.INCONSISTENT_CODE);
        LOG.error(msg);
    }
}
Also used : JadxOverflowException(jadx.core.utils.exceptions.JadxOverflowException) JadxErrorAttr(jadx.core.dex.attributes.nodes.JadxErrorAttr)

Example 3 with JadxErrorAttr

use of jadx.core.dex.attributes.nodes.JadxErrorAttr in project jadx by skylot.

the class MethodGen method addFallbackMethodCode.

public void addFallbackMethodCode(CodeWriter code) {
    if (mth.getInstructions() == null) {
        JadxErrorAttr errorAttr = mth.get(AType.JADX_ERROR);
        if (errorAttr == null || errorAttr.getCause() == null || !errorAttr.getCause().getClass().equals(DecodeException.class)) {
            // load original instructions
            try {
                mth.load();
                DepthTraversal.visit(new FallbackModeVisitor(), mth);
            } catch (DecodeException e) {
                LOG.error("Error reload instructions in fallback mode:", e);
                code.startLine("// Can't load method instructions: " + e.getMessage());
                return;
            }
        }
    }
    InsnNode[] insnArr = mth.getInstructions();
    if (insnArr == null) {
        code.startLine("// Can't load method instructions.");
        return;
    }
    if (mth.getThisArg() != null) {
        code.startLine(nameGen.useArg(mth.getThisArg())).add(" = this;");
    }
    addFallbackInsns(code, mth, insnArr, true);
}
Also used : InsnNode(jadx.core.dex.nodes.InsnNode) FallbackModeVisitor(jadx.core.dex.visitors.FallbackModeVisitor) DecodeException(jadx.core.utils.exceptions.DecodeException) JadxErrorAttr(jadx.core.dex.attributes.nodes.JadxErrorAttr)

Aggregations

JadxErrorAttr (jadx.core.dex.attributes.nodes.JadxErrorAttr)3 InsnNode (jadx.core.dex.nodes.InsnNode)1 FallbackModeVisitor (jadx.core.dex.visitors.FallbackModeVisitor)1 DecodeException (jadx.core.utils.exceptions.DecodeException)1 JadxOverflowException (jadx.core.utils.exceptions.JadxOverflowException)1