Package soot.dexpler

Class DexBody


  • public class DexBody
    extends Object
    A DexBody contains the code of a DexMethod and is used as a wrapper around JimpleBody in the jimplification process.
    Author:
    Michael Markert, Frank Hartmann
    • Field Detail

      • registerLocals

        protected Local[] registerLocals
      • storeResultLocal

        protected Local storeResultLocal
      • numRegisters

        protected int numRegisters
      • numParameterRegisters

        protected int numParameterRegisters
      • parameterTypes

        protected final List<Type> parameterTypes
      • parameterNames

        protected final List<String> parameterNames
      • isStatic

        protected boolean isStatic
      • tries

        protected List<? extends org.jf.dexlib2.iface.TryBlock<? extends org.jf.dexlib2.iface.ExceptionHandler>> tries
      • declaringClassType

        protected RefType declaringClassType
      • dexEntry

        protected final org.jf.dexlib2.iface.MultiDexContainer.DexEntry<? extends org.jf.dexlib2.iface.DexFile> dexEntry
      • method

        protected final org.jf.dexlib2.iface.Method method
      • takenLocalNames

        protected Set<String> takenLocalNames
    • Constructor Detail

      • DexBody

        protected DexBody​(org.jf.dexlib2.iface.MultiDexContainer.DexEntry<? extends org.jf.dexlib2.iface.DexFile> dexFile,
                          org.jf.dexlib2.iface.Method method,
                          RefType declaringClassType)
        Parameters:
        code - the codeitem that is contained in this body
        method - the method that is associated with this body
    • Method Detail

      • freshLocalName

        protected String freshLocalName​(String hint)
        Allocate a fresh name for Jimple local
        Parameters:
        hint - A name that the fresh name will look like
      • extractDexInstructions

        protected void extractDexInstructions​(org.jf.dexlib2.iface.MethodImplementation code)
        Extracts the list of dalvik instructions from dexlib and converts them into our own instruction data model
        Parameters:
        code - The dexlib method implementation
      • usedTypes

        public Set<Type> usedTypes()
        Return the types that are used in this body.
      • add

        public void add​(Unit u)
        Add unit to this body.
        Parameters:
        u - Unit to add.
      • addDeferredJimplification

        public void addDeferredJimplification​(DeferableInstruction i)
        Add a deferred instruction to this body.
        Parameters:
        i - the deferred instruction.
      • addRetype

        public void addRetype​(RetypeableInstruction i)
        Add a retypeable instruction to this body.
        Parameters:
        i - the retypeable instruction.
      • getBody

        public Body getBody()
        Return the associated JimpleBody.
        Throws:
        RuntimeException - if no jimplification happened yet.
      • getRegisterLocals

        public Local[] getRegisterLocals()
        Return the Locals that are associated with the current register state.
      • getRegisterLocal

        public Local getRegisterLocal​(int num)
                               throws InvalidDalvikBytecodeException
        Return the Local that are associated with the number in the current register state.

        Handles if the register number actually points to a method parameter.

        Parameters:
        num - the register number
        Throws:
        InvalidDalvikBytecodeException
      • getStoreResultLocal

        public Local getStoreResultLocal()
      • instructionAtAddress

        public DexlibAbstractInstruction instructionAtAddress​(int address)
        Return the instruction that is present at the byte code address.
        Parameters:
        address - the byte code address.
        Throws:
        RuntimeException - if address is not part of this body.
      • jimplify

        public Body jimplify​(Body b,
                             SootMethod m)
        Return the jimple equivalent of this body.
        Parameters:
        m - the SootMethod that contains this body
      • fixLineNumbers

        protected void fixLineNumbers()
        Fixes the line numbers. If there is a unit without a line number, it gets the line number of the last (transitive) predecessor that has a line number.
      • setDanglingInstruction

        public void setDanglingInstruction​(DanglingInstruction i)
        Set a dangling instruction for this body.
      • instructionsAfter

        public List<DexlibAbstractInstruction> instructionsAfter​(DexlibAbstractInstruction instruction)
        Return the instructions that appear (lexically) after the given instruction.
        Parameters:
        instruction - the instruction which successors will be returned.
      • instructionsBefore

        public List<DexlibAbstractInstruction> instructionsBefore​(DexlibAbstractInstruction instruction)
        Return the instructions that appear (lexically) before the given instruction.

        The instruction immediately before the given is the first instruction and so on.

        Parameters:
        instruction - the instruction which successors will be returned.