Package proguard.analysis.cpa.jvm.state
Class JvmAbstractState<StateT extends LatticeAbstractState<StateT>>
- java.lang.Object
-
- proguard.analysis.cpa.jvm.state.JvmAbstractState<StateT>
-
- Type Parameters:
StateT
- The type of the states contained in the JVM state. e.g., for taint analysis this would be aSetAbstractState
containing the taints and for value analysis aValueAbstractState
.
- All Implemented Interfaces:
LatticeAbstractState<JvmAbstractState<StateT>>
,AbstractState
,ProgramLocationDependent<JvmCfaNode,JvmCfaEdge,MethodSignature>
- Direct Known Subclasses:
JvmTaintAbstractState
,JvmValueAbstractState
public class JvmAbstractState<StateT extends LatticeAbstractState<StateT>> extends java.lang.Object implements LatticeAbstractState<JvmAbstractState<StateT>>, ProgramLocationDependent<JvmCfaNode,JvmCfaEdge,MethodSignature>
TheJvmAbstractState
consists of the method frameJvmFrameAbstractState
and the heapJvmHeapAbstractState
.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEFAULT_FIELD
protected JvmFrameAbstractState<StateT>
frame
protected JvmHeapAbstractState<StateT>
heap
protected JvmCfaNode
programLocation
protected MapAbstractState<java.lang.String,StateT>
staticFields
protected static JvmCfaNode
topLocation
-
Constructor Summary
Constructors Constructor Description JvmAbstractState(JvmCfaNode programLocation, JvmFrameAbstractState<StateT> frame, JvmHeapAbstractState<StateT> heap, MapAbstractState<java.lang.String,StateT> staticFields)
Create a JVM abstract state.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearOperandStack()
Empties the operand stack.JvmAbstractState<StateT>
copy()
Creates a copy of itself.boolean
equals(java.lang.Object obj)
<T> StateT
getArrayElementOrDefault(T array, StateT index, StateT abstractDefault)
Returns an abstract state for thearray
element at the givenindex
or theabstractDefault
if there is no information available.<T> StateT
getFieldOrDefault(T object, java.lang.String descriptor, StateT defaultValue)
Returns an abstract state representing the fielddescriptor
of theobject
ordefaultState
if there is no entry.<T> StateT
getFieldOrDefault(T object, StateT defaultValue)
Returns an abstract state representing the default field of theobject
ordefaultState
if there is no entry.JvmFrameAbstractState<StateT>
getFrame()
Returns the frame abstract state.JvmHeapAbstractState<StateT>
getHeap()
Returns the heap abstract state.JvmCfaNode
getProgramLocation()
Returns the program location.MapAbstractState<java.lang.String,StateT>
getStaticFields()
Returns the static field table abstract state.StateT
getStaticOrDefault(java.lang.String fqn, StateT defaultState)
Returns an abstract state representing the static fieldfqn
ordefaultState
if there is no entry.StateT
getVariableOrDefault(int index, StateT defaultState)
Returns an abstract state at theindex
th position of the variable array ordefaultState
if there is no entry.int
hashCode()
boolean
isLessOrEqual(JvmAbstractState<StateT> abstractState)
Compares itself to theabstractState
.JvmAbstractState<StateT>
join(JvmAbstractState<StateT> abstractState)
Computes a join over itself and theabstractState
.StateT
newArray(java.lang.String type, java.util.List<StateT> dimensions)
Returns an abstract state for a new array for the giventype
anddimentions
.StateT
newObject(java.lang.String className)
Returns an abstract state for a new object of the givenclassName
.StateT
newObject(Clazz clazz)
Returns an abstract state for a new object of the givenClazz
.StateT
peek()
Returns the top element of the operand stack.StateT
peek(int index)
Returns theindex
th element from the top of the operand stack.StateT
peekOrDefault(int index, StateT defaultState)
Returns theindex
th element from the top of the operand stack or returnsdefaultState
if the stack does not have enough elements.StateT
peekOrDefault(StateT defaultState)
Returns the top element of the operand stack or returnsdefaultState
if the stack is empty.StateT
pop()
Removes the top element of the operand stack end returns it.StateT
popOrDefault(StateT defaultState)
Removes the top element of the operand stack end returns it.StateT
push(StateT state)
Insertsstate
to the top of the operand stack and returns it.java.util.List<StateT>
pushAll(java.util.List<StateT> states)
Consequentially inserts elements ofstates
to the top of the operand stack and returnsstates
.<T> void
setArrayElement(T array, StateT index, StateT value)
Sets thearray
element at the givenindex
to thevalue
.<T> void
setField(T object, java.lang.String descriptor, StateT value)
Sets the fielddescriptor
of theobject
tovalue
.<T> void
setField(T object, StateT value)
Sets the default field of theobject
tovalue
.void
setProgramLocation(JvmCfaNode programLocation)
Sets the program location.void
setStatic(java.lang.String fqn, StateT value, StateT defaultState)
Sets the static fieldfqn
tovalue
, unless the value isdefaultState
.StateT
setVariable(int index, StateT state, StateT defaultState)
Sets theindex
th position of the variable array tostate
and returnsstate
.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface proguard.analysis.cpa.interfaces.AbstractState
getPrecision
-
Methods inherited from interface proguard.analysis.cpa.defaults.LatticeAbstractState
isLess
-
-
-
-
Field Detail
-
DEFAULT_FIELD
public static final java.lang.String DEFAULT_FIELD
- See Also:
- Constant Field Values
-
frame
protected final JvmFrameAbstractState<StateT extends LatticeAbstractState<StateT>> frame
-
heap
protected final JvmHeapAbstractState<StateT extends LatticeAbstractState<StateT>> heap
-
staticFields
protected final MapAbstractState<java.lang.String,StateT extends LatticeAbstractState<StateT>> staticFields
-
programLocation
protected JvmCfaNode programLocation
-
topLocation
protected static final JvmCfaNode topLocation
-
-
Constructor Detail
-
JvmAbstractState
public JvmAbstractState(JvmCfaNode programLocation, JvmFrameAbstractState<StateT> frame, JvmHeapAbstractState<StateT> heap, MapAbstractState<java.lang.String,StateT> staticFields)
Create a JVM abstract state.- Parameters:
programLocation
- a CFA nodeframe
- a frame abstract stateheap
- a heap abstract statestaticFields
- a static field table
-
-
Method Detail
-
join
public JvmAbstractState<StateT> join(JvmAbstractState<StateT> abstractState)
Description copied from interface:LatticeAbstractState
Computes a join over itself and theabstractState
.- Specified by:
join
in interfaceLatticeAbstractState<StateT extends LatticeAbstractState<StateT>>
-
isLessOrEqual
public boolean isLessOrEqual(JvmAbstractState<StateT> abstractState)
Description copied from interface:LatticeAbstractState
Compares itself to theabstractState
.- Specified by:
isLessOrEqual
in interfaceLatticeAbstractState<StateT extends LatticeAbstractState<StateT>>
-
getProgramLocation
public JvmCfaNode getProgramLocation()
Description copied from interface:ProgramLocationDependent
Returns the program location.- Specified by:
getProgramLocation
in interfaceProgramLocationDependent<JvmCfaNode,JvmCfaEdge,MethodSignature>
-
setProgramLocation
public void setProgramLocation(JvmCfaNode programLocation)
Description copied from interface:ProgramLocationDependent
Sets the program location.- Specified by:
setProgramLocation
in interfaceProgramLocationDependent<JvmCfaNode,JvmCfaEdge,MethodSignature>
-
copy
public JvmAbstractState<StateT> copy()
Description copied from interface:AbstractState
Creates a copy of itself.- Specified by:
copy
in interfaceAbstractState
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equals
in interfaceAbstractState
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfaceAbstractState
- Overrides:
hashCode
in classjava.lang.Object
-
peek
public StateT peek()
Returns the top element of the operand stack.
-
peek
public StateT peek(int index)
Returns theindex
th element from the top of the operand stack.
-
peekOrDefault
public StateT peekOrDefault(StateT defaultState)
Returns the top element of the operand stack or returnsdefaultState
if the stack is empty.
-
peekOrDefault
public StateT peekOrDefault(int index, StateT defaultState)
Returns theindex
th element from the top of the operand stack or returnsdefaultState
if the stack does not have enough elements.
-
pop
public StateT pop()
Removes the top element of the operand stack end returns it.
-
popOrDefault
public StateT popOrDefault(StateT defaultState)
Removes the top element of the operand stack end returns it. ReturnsdefaultState
if the stack is empty.
-
push
public StateT push(StateT state)
Insertsstate
to the top of the operand stack and returns it.
-
pushAll
public java.util.List<StateT> pushAll(java.util.List<StateT> states)
Consequentially inserts elements ofstates
to the top of the operand stack and returnsstates
.
-
clearOperandStack
public void clearOperandStack()
Empties the operand stack.
-
getVariableOrDefault
public StateT getVariableOrDefault(int index, StateT defaultState)
Returns an abstract state at theindex
th position of the variable array ordefaultState
if there is no entry.
-
setVariable
public StateT setVariable(int index, StateT state, StateT defaultState)
Sets theindex
th position of the variable array tostate
and returnsstate
. If the array has to be extended, the added cells are padded withdefaultState
.
-
getStaticOrDefault
public StateT getStaticOrDefault(java.lang.String fqn, StateT defaultState)
Returns an abstract state representing the static fieldfqn
ordefaultState
if there is no entry.
-
setStatic
public void setStatic(java.lang.String fqn, StateT value, StateT defaultState)
Sets the static fieldfqn
tovalue
, unless the value isdefaultState
.
-
getFieldOrDefault
public <T> StateT getFieldOrDefault(T object, java.lang.String descriptor, StateT defaultValue)
Returns an abstract state representing the fielddescriptor
of theobject
ordefaultState
if there is no entry.
-
getFieldOrDefault
public <T> StateT getFieldOrDefault(T object, StateT defaultValue)
Returns an abstract state representing the default field of theobject
ordefaultState
if there is no entry.
-
setField
public <T> void setField(T object, java.lang.String descriptor, StateT value)
Sets the fielddescriptor
of theobject
tovalue
.
-
setField
public <T> void setField(T object, StateT value)
Sets the default field of theobject
tovalue
.
-
getFrame
public JvmFrameAbstractState<StateT> getFrame()
Returns the frame abstract state.
-
getStaticFields
public MapAbstractState<java.lang.String,StateT> getStaticFields()
Returns the static field table abstract state.
-
getHeap
public JvmHeapAbstractState<StateT> getHeap()
Returns the heap abstract state.
-
newArray
public StateT newArray(java.lang.String type, java.util.List<StateT> dimensions)
Returns an abstract state for a new array for the giventype
anddimentions
.
-
newObject
public StateT newObject(java.lang.String className)
Returns an abstract state for a new object of the givenclassName
.
-
newObject
public StateT newObject(Clazz clazz)
Returns an abstract state for a new object of the givenClazz
.
-
getArrayElementOrDefault
public <T> StateT getArrayElementOrDefault(T array, StateT index, StateT abstractDefault)
Returns an abstract state for thearray
element at the givenindex
or theabstractDefault
if there is no information available.
-
-