Class AbstractAndroidModel
- Direct Known Subclasses:
SequentialAndroidModel
,SingleStartAndroidModel
Overload this class to change the structure of the model. When the model is being built the enterLABEL-functions are called when ever a label gets stepped over.
You can then add instructions to the body using the insts-Instruction factory. Instructions don't have to be in ascending order. Instead they will be sorted by their IIndex once the model gets finished.
If you want to add loops to the model you might want to have a look at AndroidModelParameterManager which aids in keeping track of SSA-Variables and adding Phi-Functions.
- Since:
- 2013-09-07
- Author:
- Tobias Blaschke <code@tobiasblaschke.de>
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected VolatileMethodSummary
protected Iterable
<? extends Entrypoint> protected TypeSafeInstructionFactory
protected SSAValueManager
-
Constructor Summary
ConstructorDescriptionAbstractAndroidModel
(VolatileMethodSummary body, TypeSafeInstructionFactory insts, SSAValueManager paramManager, Iterable<? extends Entrypoint> entryPoints) If you don't intend to use the paramManager, you can pass null. -
Method Summary
Modifier and TypeMethodDescriptionint
enter
(AndroidEntryPoint.ExecutionOrder section, int PC) Dispatches to the enterLABEL-functions.protected int
enterAFTER_LOOP
(int PC) Gets called when Label ExecutionOrder.AFTER_LOOP got stepped over.protected int
enterAT_FIRST
(int PC) Gets called when Label ExecutionOrder.AT_FIRST got stepped over.protected int
enterAT_LAST
(int PC) Gets called when Label ExecutionOrder.AT_LAST got stepped over.protected int
enterBEFORE_LOOP
(int PC) Gets called when Label ExecutionOrder.BEFORE_LOOP got stepped over.protected int
enterEND_OF_LOOP
(int PC) Gets called when Label ExecutionOrder.END_OF_LOOP got stepped over.protected int
enterMIDDLE_OF_LOOP
(int PC) Gets called when Label ExecutionOrder.MIDDLE_OF_LOOP got stepped over.protected int
enterMULTIPLE_TIMES_IN_LOOP
(int PC) Gets called when Label ExecutionOrder.MULTIPLE_TIMES_IN_LOOP got stepped over.protected int
enterSTART_OF_LOOP
(int PC) Gets called when Label ExecutionOrder.START_OF_LOOP got stepped over.int
finish
(int PC) Calls all remaining enterLABEL-functions, finally calls leaveAT_LAST.final boolean
Determines for an AndroidEntryPoint if a label got skipped over.protected int
leaveAT_LAST
(int PC) Gets called when the model gets finished.protected List
<TypeReference> Return a List of all Types returned by functions between start (inclusive) and end (exclusive).
-
Field Details
-
body
-
insts
-
paramManager
-
entryPoints
-
-
Constructor Details
-
AbstractAndroidModel
public AbstractAndroidModel(VolatileMethodSummary body, TypeSafeInstructionFactory insts, SSAValueManager paramManager, Iterable<? extends Entrypoint> entryPoints) If you don't intend to use the paramManager, you can pass null. However all other parameters are required.- Parameters:
body
- The MethodSummary to add instructions toinsts
- Will be used to generate the instructionsparamManager
- aids in handling SSA-ValuesentryPoints
- This iterable has to contain only instances of AnroidEntryPoint.
-
-
Method Details
-
returnTypesBetween
protected List<TypeReference> returnTypesBetween(AndroidEntryPoint.IExecutionOrder start, AndroidEntryPoint.IExecutionOrder end) Return a List of all Types returned by functions between start (inclusive) and end (exclusive).- Returns:
- That list
- Throws:
IllegalArgumentException
- if an EntryPoint was not an AndroidEntryPoint
-
hadSectionSwitch
Determines for an AndroidEntryPoint if a label got skipped over.If a label got skipped over special handling code has to be inserted before the entrypoints invocation.
This function is expected to be called on entrypoints in ascending order.
You are expected to call
enter(com.ibm.wala.dalvik.ipa.callgraph.impl.AndroidEntryPoint.ExecutionOrder, int)
iff a Label got skipped over.- Parameters:
order
- The entrypoint in question- Returns:
- true if a label got stepped over
- Throws:
IllegalArgumentException
- If the entrypoints weren't in ascending orderIllegalStateException
- if you didn't call enter()
-
enterAT_FIRST
protected int enterAT_FIRST(int PC) Gets called when Label ExecutionOrder.AT_FIRST got stepped over.In most cases you don't want to invoke this function directly but to use
enter(ExecutionOrder.AT_FIRST, int)
instead.Sideeffects: currentSection is updated, instructions are inserted into the body
- Parameters:
PC
- Program Counter instructions shall be placed at. In most cases you'll simply pass body.getNextProgramCounter()- Returns:
- Program Counter after insertion of the code
-
enterBEFORE_LOOP
protected int enterBEFORE_LOOP(int PC) Gets called when Label ExecutionOrder.BEFORE_LOOP got stepped over.In most cases you don't want to invoke this function directly but to use
enter(ExecutionOrder.BEFORE_LOOP, int)
insteadSideeffects: currentSection is updated, instructions are inserted into the body
- Parameters:
PC
- Program Counter instructions shall be placed at. In most cases you'll simply pass body.getNextProgramCounter()- Returns:
- Program Counter after insertion of the code
-
enterSTART_OF_LOOP
protected int enterSTART_OF_LOOP(int PC) Gets called when Label ExecutionOrder.START_OF_LOOP got stepped over.In most cases you don't want to invoke this function directly but to use
enter(ExecutionOrder.START_OF_LOOP, int)
insteadSideeffects: currentSection is updated, instructions are inserted into the body
- Parameters:
PC
- Program Counter instructions shall be placed at. In most cases you'll simply pass body.getNextProgramCounter()- Returns:
- Program Counter after insertion of the code
-
enterMIDDLE_OF_LOOP
protected int enterMIDDLE_OF_LOOP(int PC) Gets called when Label ExecutionOrder.MIDDLE_OF_LOOP got stepped over.In most cases you don't want to invoke this function directly but to use
enter(ExecutionOrder.MIDDLE_OF_LOOP, int)
insteadSideeffects: currentSection is updated, instructions are inserted into the body
- Parameters:
PC
- Program Counter instructions shall be placed at. In most cases you'll simply pass body.getNextProgramCounter()- Returns:
- Program Counter after insertion of the code
-
enterMULTIPLE_TIMES_IN_LOOP
protected int enterMULTIPLE_TIMES_IN_LOOP(int PC) Gets called when Label ExecutionOrder.MULTIPLE_TIMES_IN_LOOP got stepped over.In most cases you don't want to invoke this function directly but to use
enter(ExecutionOrder.MULTIPLE_TIMES_IN_LOOP, int)
insteadSideeffects: currentSection is updated, instructions are inserted into the body
- Parameters:
PC
- Program Counter instructions shall be placed at. In most cases you'll simply pass body.getNextProgramCounter()- Returns:
- Program Counter after insertion of the code
-
enterEND_OF_LOOP
protected int enterEND_OF_LOOP(int PC) Gets called when Label ExecutionOrder.END_OF_LOOP got stepped over.In most cases you don't want to invoke this function directly but to use
enter(ExecutionOrder.END_OF_LOOP, int)
insteadSideeffects: currentSection is updated, instructions are inserted into the body
- Parameters:
PC
- Program Counter instructions shall be placed at. In most cases you'll simply pass body.getNextProgramCounter()- Returns:
- Program Counter after insertion of the code
-
enterAFTER_LOOP
protected int enterAFTER_LOOP(int PC) Gets called when Label ExecutionOrder.AFTER_LOOP got stepped over.In most cases you don't want to invoke this function directly but to use
enter(ExecutionOrder.AFTER_LOOP, int)
insteadSideeffects: currentSection is updated, instructions are inserted into the body
- Parameters:
PC
- Program Counter instructions shall be placed at. In most cases you'll simply pass body.getNextProgramCounter()- Returns:
- Program Counter after insertion of the code
-
enterAT_LAST
protected int enterAT_LAST(int PC) Gets called when Label ExecutionOrder.AT_LAST got stepped over.In most cases you don't want to invoke this function directly but to use
enter(ExecutionOrder.AT_LAST, int)
insteadSideeffects: currentSection is updated, instructions are inserted into the body
- Parameters:
PC
- Program Counter instructions shall be placed at. In most cases you'll simply pass body.getNextProgramCounter()- Returns:
- Program Counter after insertion of the code
-
leaveAT_LAST
protected int leaveAT_LAST(int PC) Gets called when the model gets finished.In most cases you don't want to invoke this function directly but to use
finish(int)
insteadSideeffects: instructions are inserted into the body
- Parameters:
PC
- Program Counter instructions shall be placed at. In most cases you'll simply pass body.getNextProgramCounter()- Returns:
- Program Counter after insertion of the code
-
enter
Dispatches to the enterLABEL-functions. Does also call functions to any labels that got stepped over.- Parameters:
section
- The Section to enterPC
- Program Counter instructions shall be placed at. In most cases you'll simply pass body.getNextProgramCounter()- Returns:
- Program Counter after insertion of the code
- Throws:
IllegalArgumentException
- if you didn't use sections in ascending order, pc is negative
-
finish
public int finish(int PC) Calls all remaining enterLABEL-functions, finally calls leaveAT_LAST.Then Locks the model and frees some memory.
- Parameters:
PC
- Program Counter instructions shall be placed at. In most cases you'll simply pass body.getNextProgramCounter()- Returns:
- Program Counter after insertion of the code
- Throws:
IllegalStateException
- if called on an empty model
-