Search in sources :

Example 6 with SmaliDebuggerException

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

the class DebugController method setDelayBreakpoint.

private void setDelayBreakpoint(FileBreakpoint bp) {
    boolean hasSet = bpStore.hasSetDelaied(bp.cls);
    bpStore.add(bp, null);
    if (!hasSet) {
        updateQueue.execute(() -> {
            try {
                debugger.regClassPrepareEventForBreakpoint(bp.cls, id -> {
                    List<FileBreakpoint> list = bpStore.get(bp.cls);
                    for (FileBreakpoint fbp : list) {
                        setBreakpoint(id, fbp);
                    }
                });
            } catch (SmaliDebuggerException e) {
                logErr(e);
                failBreakpoint(bp, "");
            }
        });
    }
}
Also used : FileBreakpoint(jadx.gui.device.debugger.BreakpointManager.FileBreakpoint) SmaliDebuggerException(jadx.gui.device.debugger.SmaliDebugger.SmaliDebuggerException)

Example 7 with SmaliDebuggerException

use of jadx.gui.device.debugger.SmaliDebugger.SmaliDebuggerException 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)

Example 8 with SmaliDebuggerException

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

the class DebugController method refreshCurFrame.

private void refreshCurFrame(long threadID, long codeOffset) {
    try {
        Frame frame = debugger.getCurrentFrame(threadID);
        cur.frame.setFrame(frame);
        cur.frame.updateCodeOffset(codeOffset);
    } catch (SmaliDebuggerException e) {
        logErr(e);
    }
}
Also used : Frame(jadx.gui.device.debugger.SmaliDebugger.Frame) SmaliDebuggerException(jadx.gui.device.debugger.SmaliDebugger.SmaliDebuggerException)

Example 9 with SmaliDebuggerException

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

the class DebugController method stopAtOnCreate.

private void stopAtOnCreate() {
    JClass mainActivity = DbgUtils.searchMainActivity(debuggerPanel.getMainWindow());
    if (mainActivity == null) {
        debuggerPanel.log("Failed to set breakpoint at onCreate, you have to do it yourself.");
        return;
    }
    lazyQueue.execute(() -> openMainActivityTab(mainActivity));
    String clsSig = DbgUtils.getRawFullName(mainActivity);
    try {
        long id = debugger.getClassID(clsSig, true);
        if (id != -1) {
            // this app is running, we can't stop at onCreate anymore.
            return;
        }
        debuggerPanel.log(String.format("Breakpoint will set at %s.%s", clsSig, ONCREATE_SIGNATURE));
        debugger.regMethodEntryEventSync(clsSig, ONCREATE_SIGNATURE::equals);
    } catch (SmaliDebuggerException e) {
        logErr(e, String.format("Failed set breakpoint at %s.%s", clsSig, ONCREATE_SIGNATURE));
    }
}
Also used : SmaliDebuggerException(jadx.gui.device.debugger.SmaliDebugger.SmaliDebuggerException) JClass(jadx.gui.treemodel.JClass)

Example 10 with SmaliDebuggerException

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

the class DebugController method updateAllFields.

private void updateAllFields(FrameNode frame) {
    List<FieldNode> fldNodes = Collections.emptyList();
    String clsSig = frame.getClsSig();
    if (clsSig != null) {
        ClassNode clsNode = DbgUtils.getClassNodeBySig(clsSig, debuggerPanel.getMainWindow());
        if (clsNode != null) {
            fldNodes = clsNode.getFields();
        }
    }
    try {
        long thisID = debugger.getThisID(frame.getThreadID(), frame.getFrame().getID());
        List<RuntimeField> flds = debugger.getAllFieldsSync(frame.getClsID());
        List<FieldTreeNode> nodes = new ArrayList<>(flds.size());
        for (RuntimeField fld : flds) {
            FieldTreeNode fldNode = new FieldTreeNode(fld, thisID);
            fldNodes.stream().filter(f -> f.getName().equals(fldNode.getName())).findFirst().ifPresent(smaliFld -> fldNode.setAlias(smaliFld.getAlias()));
            nodes.add(fldNode);
        }
        debuggerPanel.updateThisFieldNodes(nodes);
        frame.setFieldNodes(nodes);
        if (thisID > 0 && nodes.size() > 0) {
            lazyQueue.execute(() -> updateAllFieldValues(thisID, frame));
        }
    } catch (SmaliDebuggerException e) {
        logErr(e);
    }
}
Also used : ClassNode(jadx.core.dex.nodes.ClassNode) FieldNode(jadx.core.dex.nodes.FieldNode) SmaliDebuggerException(jadx.gui.device.debugger.SmaliDebugger.SmaliDebuggerException) RuntimeField(jadx.gui.device.debugger.SmaliDebugger.RuntimeField) ArrayList(java.util.ArrayList)

Aggregations

SmaliDebuggerException (jadx.gui.device.debugger.SmaliDebugger.SmaliDebuggerException)11 FileBreakpoint (jadx.gui.device.debugger.BreakpointManager.FileBreakpoint)3 ArrayList (java.util.ArrayList)3 Frame (jadx.gui.device.debugger.SmaliDebugger.Frame)2 RuntimeBreakpoint (jadx.gui.device.debugger.SmaliDebugger.RuntimeBreakpoint)2 RuntimeField (jadx.gui.device.debugger.SmaliDebugger.RuntimeField)2 RuntimeRegister (jadx.gui.device.debugger.SmaliDebugger.RuntimeRegister)2 RuntimeType (jadx.gui.device.debugger.SmaliDebugger.RuntimeType)2 RuntimeValue (jadx.gui.device.debugger.SmaliDebugger.RuntimeValue)2 ClassNode (jadx.core.dex.nodes.ClassNode)1 FieldNode (jadx.core.dex.nodes.FieldNode)1 JClass (jadx.gui.treemodel.JClass)1