Package jadx.gui.device.debugger
Class SmaliDebugger
- java.lang.Object
-
- jadx.gui.device.debugger.SmaliDebugger
-
public class SmaliDebugger extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceSmaliDebugger.ClassListenerstatic interfaceSmaliDebugger.ClassPrepareListenerstatic classSmaliDebugger.Framestatic interfaceSmaliDebugger.MethodEntryListenerstatic classSmaliDebugger.RuntimeBreakpointstatic classSmaliDebugger.RuntimeDebugInfostatic classSmaliDebugger.RuntimeFieldstatic classSmaliDebugger.RuntimeRegisterstatic classSmaliDebugger.RuntimeValuestatic classSmaliDebugger.RuntimeVarInfostatic interfaceSmaliDebugger.SuspendListenerListener for breakpoint, watch, step, etc.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SmaliDebuggerattach(java.lang.String host, int port, SmaliDebugger.SuspendListener suspendListener)After a successful attach the remote app will be suspended, so we have times to set breakpoints or do any other things, after that call resume() to activate the app.voiddetach()booleanerrIsInvalidObject(int errCode)booleanerrIsInvalidSlot(int errCode)booleanerrIsTypeMismatched(int errCode)voidexit()java.util.List<SmaliDebugger.RuntimeField>getAllFieldsSync(long clsID)voidgetAllFieldValuesSync(long thisID, java.util.List<SmaliDebugger.RuntimeField> flds)java.util.List<java.lang.Long>getAllThreadsSync()longgetClassID(java.lang.String clsSig, boolean fetch)@Nullable java.lang.StringgetClassSignatureSync(long classID)SmaliDebugger.FramegetCurrentFrame(long threadID)SmaliDebugger.FramegetCurrentFrameInternal(long threadID)voidgetFieldValueSync(long clsID, SmaliDebugger.RuntimeField fld)java.util.List<SmaliDebugger.Frame>getFramesSync(long threadID)longgetMethodID(long cid, java.lang.String mthSig)@Nullable java.lang.StringgetMethodSignatureSync(long classID, long methodID)SmaliDebugger.RuntimeRegistergetRegisterSync(long threadID, long frameID, int regNum, RuntimeType type)@Nullable SmaliDebugger.RuntimeDebugInfogetRuntimeDebugInfo(long clsID, long mthID)longgetThisID(long threadID, long frameID)@Nullable java.lang.StringgetThreadNameSync(long threadID)voidgetValueSync(long objID, SmaliDebugger.RuntimeField fld)voidinitClassCache(long clsID)SmaliDebugger.RuntimeBreakpointmakeBreakpoint(long cid, long mid, long offset)longreadAll(SmaliDebugger.RuntimeValue val)java.util.Map.Entry<java.lang.Integer,java.util.List<java.lang.Long>>readArray(SmaliDebugger.RuntimeValue reg, int startIndex, int len)intreadArrayLength(SmaliDebugger.RuntimeValue val)java.lang.StringreadArraySignature(SmaliDebugger.RuntimeValue val)bytereadByte(SmaliDebugger.RuntimeValue val)charreadChar(SmaliDebugger.RuntimeValue val)doublereadDouble(SmaliDebugger.RuntimeValue val)floatreadFloat(SmaliDebugger.RuntimeValue val)longreadID(SmaliDebugger.RuntimeValue val)intreadInt(SmaliDebugger.RuntimeValue val)java.lang.StringreadObjectSignatureSync(SmaliDebugger.RuntimeValue val)shortreadShort(SmaliDebugger.RuntimeValue val)java.lang.StringreadStringSync(long id)java.lang.StringreadStringSync(SmaliDebugger.RuntimeValue val)voidregClassPrepareEventForBreakpoint(java.lang.String clsSig, SmaliDebugger.ClassPrepareListener l)voidregMethodEntryEventSync(java.lang.String clsSig, SmaliDebugger.MethodEntryListener l)voidremoveBreakpoint(SmaliDebugger.RuntimeBreakpoint bp)voidresume()voidsetBreakpoint(SmaliDebugger.RuntimeBreakpoint bp)voidsetClassListener(SmaliDebugger.ClassListener listener)Listens for class preparation and unload events.booleansetValueSync(int runtimeRegNum, RuntimeType type, java.lang.Object val, long threadID, long frameID)booleansetValueSync(long objID, long fldID, RuntimeType type, java.lang.Object val)voidstepInto()voidstepOut()voidstepOver()voidsuspend()
-
-
-
Method Detail
-
attach
public static SmaliDebugger attach(java.lang.String host, int port, SmaliDebugger.SuspendListener suspendListener) throws SmaliDebuggerException
After a successful attach the remote app will be suspended, so we have times to set breakpoints or do any other things, after that call resume() to activate the app.- Throws:
SmaliDebuggerException
-
stepInto
public void stepInto() throws SmaliDebuggerException- Throws:
SmaliDebuggerException
-
stepOver
public void stepOver() throws SmaliDebuggerException- Throws:
SmaliDebuggerException
-
stepOut
public void stepOut() throws SmaliDebuggerException- Throws:
SmaliDebuggerException
-
exit
public void exit() throws SmaliDebuggerException- Throws:
SmaliDebuggerException
-
detach
public void detach() throws SmaliDebuggerException- Throws:
SmaliDebuggerException
-
getRegisterSync
public SmaliDebugger.RuntimeRegister getRegisterSync(long threadID, long frameID, int regNum, RuntimeType type) throws SmaliDebuggerException
- Parameters:
regNum- If it's an argument, just pass its index, non-static method should be index + 1. e.g. void a(int b, int c), you want the value of b, then should pass 1 (0 + 1), this is a virtual method, so 0 is for the this object and 1 is the real index of b.If it's a variable then should be the reg number + number of arguments and + 1 if it's in a non-static method. e.g. to get the value of v3 in a virtual method with 2 arguments, should pass 6 (3 + 2 + 1 = 6).
- Throws:
SmaliDebuggerException
-
getThisID
public long getThisID(long threadID, long frameID) throws SmaliDebuggerException- Throws:
SmaliDebuggerException
-
getAllFieldsSync
public java.util.List<SmaliDebugger.RuntimeField> getAllFieldsSync(long clsID) throws SmaliDebuggerException
- Throws:
SmaliDebuggerException
-
getFieldValueSync
public void getFieldValueSync(long clsID, SmaliDebugger.RuntimeField fld) throws SmaliDebuggerException- Throws:
SmaliDebuggerException
-
getAllFieldValuesSync
public void getAllFieldValuesSync(long thisID, java.util.List<SmaliDebugger.RuntimeField> flds) throws SmaliDebuggerException- Throws:
SmaliDebuggerException
-
getCurrentFrame
public SmaliDebugger.Frame getCurrentFrame(long threadID) throws SmaliDebuggerException
- Throws:
SmaliDebuggerException
-
getFramesSync
public java.util.List<SmaliDebugger.Frame> getFramesSync(long threadID) throws SmaliDebuggerException
- Throws:
SmaliDebuggerException
-
getAllThreadsSync
public java.util.List<java.lang.Long> getAllThreadsSync() throws SmaliDebuggerException- Throws:
SmaliDebuggerException
-
getThreadNameSync
@Nullable public @Nullable java.lang.String getThreadNameSync(long threadID) throws SmaliDebuggerException- Throws:
SmaliDebuggerException
-
getClassSignatureSync
@Nullable public @Nullable java.lang.String getClassSignatureSync(long classID) throws SmaliDebuggerException- Throws:
SmaliDebuggerException
-
getMethodSignatureSync
@Nullable public @Nullable java.lang.String getMethodSignatureSync(long classID, long methodID) throws SmaliDebuggerException- Throws:
SmaliDebuggerException
-
errIsTypeMismatched
public boolean errIsTypeMismatched(int errCode)
-
errIsInvalidSlot
public boolean errIsInvalidSlot(int errCode)
-
errIsInvalidObject
public boolean errIsInvalidObject(int errCode)
-
setClassListener
public void setClassListener(SmaliDebugger.ClassListener listener) throws SmaliDebuggerException
Listens for class preparation and unload events.- Throws:
SmaliDebuggerException
-
regClassPrepareEventForBreakpoint
public void regClassPrepareEventForBreakpoint(java.lang.String clsSig, SmaliDebugger.ClassPrepareListener l) throws SmaliDebuggerException- Throws:
SmaliDebuggerException
-
regMethodEntryEventSync
public void regMethodEntryEventSync(java.lang.String clsSig, SmaliDebugger.MethodEntryListener l) throws SmaliDebuggerException- Throws:
SmaliDebuggerException
-
readObjectSignatureSync
public java.lang.String readObjectSignatureSync(SmaliDebugger.RuntimeValue val) throws SmaliDebuggerException
- Throws:
SmaliDebuggerException
-
readStringSync
public java.lang.String readStringSync(SmaliDebugger.RuntimeValue val) throws SmaliDebuggerException
- Throws:
SmaliDebuggerException
-
readStringSync
public java.lang.String readStringSync(long id) throws SmaliDebuggerException- Throws:
SmaliDebuggerException
-
setValueSync
public boolean setValueSync(int runtimeRegNum, RuntimeType type, java.lang.Object val, long threadID, long frameID) throws SmaliDebuggerException- Throws:
SmaliDebuggerException
-
setValueSync
public boolean setValueSync(long objID, long fldID, RuntimeType type, java.lang.Object val) throws SmaliDebuggerException- Throws:
SmaliDebuggerException
-
getValueSync
public void getValueSync(long objID, SmaliDebugger.RuntimeField fld) throws SmaliDebuggerException- Throws:
SmaliDebuggerException
-
readID
public long readID(SmaliDebugger.RuntimeValue val)
-
readArraySignature
public java.lang.String readArraySignature(SmaliDebugger.RuntimeValue val) throws SmaliDebuggerException
- Throws:
SmaliDebuggerException
-
readArrayLength
public int readArrayLength(SmaliDebugger.RuntimeValue val) throws SmaliDebuggerException
- Throws:
SmaliDebuggerException
-
readArray
public java.util.Map.Entry<java.lang.Integer,java.util.List<java.lang.Long>> readArray(SmaliDebugger.RuntimeValue reg, int startIndex, int len) throws SmaliDebuggerException
- Parameters:
startIndex- less than 0 means 0len- less than or equals 0 means the maximum value 99 or the rest of the elements.- Returns:
- An entry, The key is the total length of this array when len is <= 0, otherwise 0, the value, if this array is an object array then it's object ids.
- Throws:
SmaliDebuggerException
-
readByte
public byte readByte(SmaliDebugger.RuntimeValue val)
-
readChar
public char readChar(SmaliDebugger.RuntimeValue val)
-
readShort
public short readShort(SmaliDebugger.RuntimeValue val)
-
readInt
public int readInt(SmaliDebugger.RuntimeValue val)
-
readFloat
public float readFloat(SmaliDebugger.RuntimeValue val)
-
readAll
public long readAll(SmaliDebugger.RuntimeValue val)
- Parameters:
val- has 8 bytes mostly
-
readDouble
public double readDouble(SmaliDebugger.RuntimeValue val)
-
getRuntimeDebugInfo
@Nullable public @Nullable SmaliDebugger.RuntimeDebugInfo getRuntimeDebugInfo(long clsID, long mthID) throws SmaliDebuggerException
- Throws:
SmaliDebuggerException
-
resume
public void resume() throws SmaliDebuggerException- Throws:
SmaliDebuggerException
-
suspend
public void suspend() throws SmaliDebuggerException- Throws:
SmaliDebuggerException
-
setBreakpoint
public void setBreakpoint(SmaliDebugger.RuntimeBreakpoint bp) throws SmaliDebuggerException
- Throws:
SmaliDebuggerException
-
getClassID
public long getClassID(java.lang.String clsSig, boolean fetch) throws SmaliDebuggerException- Throws:
SmaliDebuggerException
-
getMethodID
public long getMethodID(long cid, java.lang.String mthSig) throws SmaliDebuggerException- Throws:
SmaliDebuggerException
-
initClassCache
public void initClassCache(long clsID) throws SmaliDebuggerException- Throws:
SmaliDebuggerException
-
removeBreakpoint
public void removeBreakpoint(SmaliDebugger.RuntimeBreakpoint bp) throws SmaliDebuggerException
- Throws:
SmaliDebuggerException
-
getCurrentFrameInternal
public SmaliDebugger.Frame getCurrentFrameInternal(long threadID) throws SmaliDebuggerException
- Throws:
SmaliDebuggerException
-
makeBreakpoint
public SmaliDebugger.RuntimeBreakpoint makeBreakpoint(long cid, long mid, long offset)
-
-