use of jadx.gui.device.debugger.SmaliDebugger.SmaliDebuggerException in project jadx by skylot.
the class DebugController method setBreakpoint.
protected void setBreakpoint(long cid, FileBreakpoint fbp) {
try {
long mid = debugger.getMethodID(cid, fbp.mth);
if (mid > -1) {
RuntimeBreakpoint rbp = debugger.makeBreakpoint(cid, mid, fbp.codeOffset);
debugger.setBreakpoint(rbp);
bpStore.add(fbp, rbp);
return;
}
} catch (SmaliDebuggerException e) {
logErr(e);
}
failBreakpoint(fbp, "Failed to get method for breakpoint, " + fbp.mth + ":" + fbp.codeOffset);
}
use of jadx.gui.device.debugger.SmaliDebugger.SmaliDebuggerException in project jadx by skylot.
the class DebugController method updateRegister.
public boolean updateRegister(RegTreeNode regNode, RuntimeType type, boolean retry) {
if (type == null) {
if (regNode.isAbsoluteType()) {
type = castType(regNode.getType());
} else {
type = POSSIBLE_TYPES[0];
}
}
boolean ok = false;
RuntimeRegister register = null;
try {
register = debugger.getRegisterSync(cur.frame.getThreadID(), cur.frame.getFrame().getID(), regNode.getRuntimeRegNum(), type);
} catch (SmaliDebuggerException e) {
if (retry) {
if (debugger.errIsTypeMismatched(e.getErrCode())) {
RuntimeType[] types = getPossibleTypes(type);
for (RuntimeType nextType : types) {
ok = updateRegister(regNode, nextType, false);
if (ok) {
regNode.updateType(nextType.getDesc());
break;
}
}
} else {
logErr(e.getMessage() + " for " + regNode.getName());
regNode.updateType(null);
regNode.updateValue(null);
}
}
}
if (register != null) {
regNode.updateReg(register);
decodeRuntimeValue(regNode);
}
debuggerPanel.updateRegTree(regNode);
return ok;
}
use of jadx.gui.device.debugger.SmaliDebugger.SmaliDebuggerException in project jadx by skylot.
the class DebugController method initBreakpoints.
private void initBreakpoints(List<FileBreakpoint> fbps) {
if (fbps.size() == 0) {
return;
}
boolean fetch = true;
for (FileBreakpoint fbp : fbps) {
try {
long id = debugger.getClassID(fbp.cls, fetch);
// only fetch classes from JVM once,
// if this time this class hasn't been loaded then it won't load next time, cuz JVM is freezed.
fetch = false;
if (id > -1) {
setBreakpoint(id, fbp);
} else {
setDelayBreakpoint(fbp);
}
} catch (SmaliDebuggerException e) {
logErr(e);
failBreakpoint(fbp, e.getMessage());
}
}
}
use of jadx.gui.device.debugger.SmaliDebugger.SmaliDebuggerException 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;
}
use of jadx.gui.device.debugger.SmaliDebugger.SmaliDebuggerException in project jadx by skylot.
the class DebugController method updateAllStackFrames.
private FrameNode updateAllStackFrames(long threadID) {
List<SmaliDebugger.Frame> frames = Collections.emptyList();
try {
frames = debugger.getFramesSync(threadID);
} catch (SmaliDebuggerException e) {
logErr(e);
}
if (frames.size() == 0) {
return null;
}
List<FrameNode> frameEleList = new ArrayList<>(frames.size());
for (SmaliDebugger.Frame frame : frames) {
FrameNode ele = new FrameNode(threadID, frame);
frameEleList.add(ele);
}
FrameNode curEle = frameEleList.get(0);
fetchStackFrameNames(curEle);
debuggerPanel.refreshStackFrameList(frameEleList);
lazyQueue.execute(() -> {
// get class & method names for frames
for (int i = 1; i < frameEleList.size(); i++) {
fetchStackFrameNames(frameEleList.get(i));
}
debuggerPanel.refreshStackFrameList(Collections.emptyList());
});
return frameEleList.get(0);
}
Aggregations