Search in sources :

Example 1 with RuntimeValue

use of jadx.gui.device.debugger.SmaliDebugger.RuntimeValue in project jadx by skylot.

the class DebugController method decodeRuntimeValue.

private boolean decodeRuntimeValue(RuntimeValueTreeNode valNode) {
    RuntimeValue rValue = valNode.getRuntimeValue();
    RuntimeType type = rValue.getType();
    if (!valNode.isAbsoluteType()) {
        valNode.updateType(null);
    }
    try {
        switch(type) {
            case OBJECT:
                return decodeObject(valNode);
            case STRING:
                String str = "\"" + debugger.readStringSync(rValue) + "\"";
                valNode.updateType("java.lang.String").updateTypeID(debugger.readID(rValue)).updateValue(str);
                break;
            case INT:
                valNode.updateValue(Integer.toString(debugger.readInt(rValue)));
                break;
            case LONG:
                valNode.updateValue(Long.toString(debugger.readAll(rValue)));
                break;
            case ARRAY:
                decodeArrayVal(valNode);
                break;
            case BOOLEAN:
                {
                    int b = debugger.readByte(rValue);
                    valNode.updateValue(b == 1 ? "true" : "false");
                    break;
                }
            case SHORT:
                valNode.updateValue(Short.toString(debugger.readShort(rValue)));
                break;
            case CHAR:
            case BYTE:
                {
                    int b = (int) debugger.readAll(rValue);
                    if (DbgUtils.isPrintableChar(b)) {
                        valNode.updateValue(type == RuntimeType.CHAR ? String.valueOf((char) b) : String.valueOf((byte) b));
                    } else {
                        valNode.updateValue(String.valueOf(b));
                    }
                    break;
                }
            case DOUBLE:
                double d = debugger.readDouble(rValue);
                valNode.updateValue(Double.toString(d));
                break;
            case FLOAT:
                float f = debugger.readFloat(rValue);
                valNode.updateValue(Float.toString(f));
                break;
            case VOID:
                valNode.updateType("void");
                break;
            case THREAD:
                valNode.updateType("thread").updateTypeID(debugger.readID(rValue));
                break;
            case THREAD_GROUP:
                valNode.updateType("thread_group").updateTypeID(debugger.readID(rValue));
                break;
            case CLASS_LOADER:
                valNode.updateType("class_loader").updateTypeID(debugger.readID(rValue));
                break;
            case CLASS_OBJECT:
                valNode.updateType("class_object").updateTypeID(debugger.readID(rValue));
                break;
        }
    } catch (SmaliDebuggerException e) {
        logErr(e);
        return false;
    }
    return true;
}
Also used : SmaliDebuggerException(jadx.gui.device.debugger.SmaliDebugger.SmaliDebuggerException) RuntimeType(jadx.gui.device.debugger.SmaliDebugger.RuntimeType) RuntimeValue(jadx.gui.device.debugger.SmaliDebugger.RuntimeValue)

Example 2 with RuntimeValue

use of jadx.gui.device.debugger.SmaliDebugger.RuntimeValue in project jadx by skylot.

the class DebugController method decodeObject.

private boolean decodeObject(RuntimeValueTreeNode valNode) {
    RuntimeValue rValue = valNode.getRuntimeValue();
    boolean ok = true;
    if (debugger.readID(rValue) == 0) {
        if (valNode.isAbsoluteType()) {
            valNode.updateValue("null");
            return ok;
        } else if (!art.readNullObject()) {
            valNode.updateType(art.typeForNull());
            valNode.updateValue("0");
            return ok;
        }
    }
    String sig;
    try {
        sig = debugger.readObjectSignatureSync(rValue);
        valNode.updateType(String.format("%s@%d", DbgUtils.classSigToRawFullName(sig), debugger.readID(rValue)));
    } catch (SmaliDebuggerException e) {
        ok = debugger.errIsInvalidObject(e.getErrCode()) && valNode instanceof RegTreeNode;
        if (ok) {
            try {
                RegTreeNode reg = (RegTreeNode) valNode;
                RuntimeRegister rr = debugger.getRegisterSync(cur.frame.getThreadID(), cur.frame.getFrame().getID(), reg.getRuntimeRegNum(), RuntimeType.INT);
                reg.updateReg(rr);
                rValue = rr;
                valNode.updateType(RuntimeType.INT.getDesc());
                valNode.updateValue(Long.toString((int) debugger.readAll(rValue)));
            } catch (SmaliDebuggerException except) {
                logErr(except, String.format("Update %s failed, %s", valNode.getName(), except.getMessage()));
                valNode.updateValue(except.getMessage());
                ok = false;
            }
        } else {
            logErr(e);
        }
    }
    return ok;
}
Also used : RuntimeRegister(jadx.gui.device.debugger.SmaliDebugger.RuntimeRegister) SmaliDebuggerException(jadx.gui.device.debugger.SmaliDebugger.SmaliDebuggerException) RuntimeValue(jadx.gui.device.debugger.SmaliDebugger.RuntimeValue)

Aggregations

RuntimeValue (jadx.gui.device.debugger.SmaliDebugger.RuntimeValue)2 SmaliDebuggerException (jadx.gui.device.debugger.SmaliDebugger.SmaliDebuggerException)2 RuntimeRegister (jadx.gui.device.debugger.SmaliDebugger.RuntimeRegister)1 RuntimeType (jadx.gui.device.debugger.SmaliDebugger.RuntimeType)1