Package proguard.analysis.cpa.jvm.state
Class JvmAbstractState<ContentT extends AbstractState<ContentT>>
- java.lang.Object
-
- proguard.analysis.cpa.jvm.state.JvmAbstractState<ContentT>
-
- Type Parameters:
ContentT
- 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:
AbstractState<JvmAbstractState<ContentT>>
,ProgramLocationDependent
- Direct Known Subclasses:
JvmValueAbstractState
public class JvmAbstractState<ContentT extends AbstractState<ContentT>> extends java.lang.Object implements AbstractState<JvmAbstractState<ContentT>>, ProgramLocationDependent
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<ContentT>
frame
protected JvmHeapAbstractState<ContentT>
heap
protected JvmCfaNode
programLocation
protected MapAbstractState<java.lang.String,ContentT>
staticFields
protected static JvmCfaNode
topLocation
-
Constructor Summary
Constructors Constructor Description JvmAbstractState(JvmCfaNode programLocation, JvmFrameAbstractState<ContentT> frame, JvmHeapAbstractState<ContentT> heap, MapAbstractState<java.lang.String,ContentT> 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<ContentT>
copy()
Creates a copy of itself.boolean
equals(java.lang.Object obj)
<T> ContentT
getArrayElementOrDefault(T array, ContentT index, ContentT abstractDefault)
Returns an abstract state for thearray
element at the givenindex
or theabstractDefault
if there is no information available.<T> ContentT
getFieldOrDefault(T object, ContentT defaultValue)
Returns an abstract state representing the default field of theobject
ordefaultState
if there is no entry.<T> ContentT
getFieldOrDefault(T object, java.lang.String descriptor, ContentT defaultValue)
Returns an abstract state representing the fielddescriptor
of theobject
ordefaultState
if there is no entry.JvmFrameAbstractState<ContentT>
getFrame()
Returns the frame abstract state.JvmHeapAbstractState<ContentT>
getHeap()
Returns the heap abstract state.JvmCfaNode
getProgramLocation()
Returns the program location.MapAbstractState<java.lang.String,ContentT>
getStaticFields()
Returns the static field table abstract state.ContentT
getStaticOrDefault(java.lang.String fqn, ContentT defaultState)
Returns an abstract state representing the static fieldfqn
ordefaultState
if there is no entry.ContentT
getVariableOrDefault(int index, ContentT defaultState)
Returns an abstract state at theindex
th position of the variable array ordefaultState
if there is no entry.int
hashCode()
boolean
isLessOrEqual(JvmAbstractState<ContentT> abstractState)
Compares itself to theabstractState
(i.e., compare the states on the partial order provided by the domain of the analysis).JvmAbstractState<ContentT>
join(JvmAbstractState<ContentT> abstractState)
Computes a join over itself and another abstract stateabstractState
(i.e., finds the least upper bound on the semilattice).ContentT
newArray(java.lang.String type, java.util.List<ContentT> dimensions)
Returns an abstract state for a new array for the giventype
anddimentions
.ContentT
newObject(java.lang.String className)
Returns an abstract state for a new object of the givenclassName
.ContentT
newObject(Clazz clazz)
Returns an abstract state for a new object of the givenClazz
.ContentT
peek()
Returns the top element of the operand stack.ContentT
peek(int index)
Returns theindex
th element from the top of the operand stack.ContentT
peekOrDefault(int index, ContentT defaultState)
Returns theindex
th element from the top of the operand stack or returnsdefaultState
if the stack does not have enough elements.ContentT
peekOrDefault(ContentT defaultState)
Returns the top element of the operand stack or returnsdefaultState
if the stack is empty.ContentT
pop()
Removes the top element of the operand stack end returns it.ContentT
popOrDefault(ContentT defaultState)
Removes the top element of the operand stack end returns it.ContentT
push(ContentT state)
Insertsstate
to the top of the operand stack and returns it.java.util.List<ContentT>
pushAll(java.util.List<ContentT> states)
Consequentially inserts elements ofstates
to the top of the operand stack and returnsstates
.<T> void
setArrayElement(T array, ContentT index, ContentT value)
Sets thearray
element at the givenindex
to thevalue
.<T> void
setField(T object, ContentT value)
Sets the default field of theobject
tovalue
.<T> void
setField(T object, java.lang.String descriptor, ContentT value)
Sets the fielddescriptor
of theobject
tovalue
.void
setProgramLocation(JvmCfaNode programLocation)
Sets the program location.void
setStatic(java.lang.String fqn, ContentT value, ContentT defaultState)
Sets the static fieldfqn
tovalue
, unless the value isdefaultState
.ContentT
setVariable(int index, ContentT state, ContentT 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, isLess
-
-
-
-
Field Detail
-
DEFAULT_FIELD
public static final java.lang.String DEFAULT_FIELD
- See Also:
- Constant Field Values
-
frame
protected final JvmFrameAbstractState<ContentT extends AbstractState<ContentT>> frame
-
heap
protected final JvmHeapAbstractState<ContentT extends AbstractState<ContentT>> heap
-
staticFields
protected final MapAbstractState<java.lang.String,ContentT extends AbstractState<ContentT>> staticFields
-
programLocation
protected JvmCfaNode programLocation
-
topLocation
protected static final JvmCfaNode topLocation
-
-
Constructor Detail
-
JvmAbstractState
public JvmAbstractState(JvmCfaNode programLocation, JvmFrameAbstractState<ContentT> frame, JvmHeapAbstractState<ContentT> heap, MapAbstractState<java.lang.String,ContentT> 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<ContentT> join(JvmAbstractState<ContentT> abstractState)
Description copied from interface:AbstractState
Computes a join over itself and another abstract stateabstractState
(i.e., finds the least upper bound on the semilattice).- Specified by:
join
in interfaceAbstractState<ContentT extends AbstractState<ContentT>>
-
isLessOrEqual
public boolean isLessOrEqual(JvmAbstractState<ContentT> abstractState)
Description copied from interface:AbstractState
Compares itself to theabstractState
(i.e., compare the states on the partial order provided by the domain of the analysis).- Specified by:
isLessOrEqual
in interfaceAbstractState<ContentT extends AbstractState<ContentT>>
-
getProgramLocation
public JvmCfaNode getProgramLocation()
Description copied from interface:ProgramLocationDependent
Returns the program location.- Specified by:
getProgramLocation
in interfaceProgramLocationDependent
-
setProgramLocation
public void setProgramLocation(JvmCfaNode programLocation)
Description copied from interface:ProgramLocationDependent
Sets the program location.- Specified by:
setProgramLocation
in interfaceProgramLocationDependent
-
copy
public JvmAbstractState<ContentT> copy()
Description copied from interface:AbstractState
Creates a copy of itself.- Specified by:
copy
in interfaceAbstractState<ContentT extends AbstractState<ContentT>>
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equals
in interfaceAbstractState<ContentT extends AbstractState<ContentT>>
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfaceAbstractState<ContentT extends AbstractState<ContentT>>
- Overrides:
hashCode
in classjava.lang.Object
-
peek
public ContentT peek()
Returns the top element of the operand stack.
-
peek
public ContentT peek(int index)
Returns theindex
th element from the top of the operand stack.
-
peekOrDefault
public ContentT peekOrDefault(ContentT defaultState)
Returns the top element of the operand stack or returnsdefaultState
if the stack is empty.
-
peekOrDefault
public ContentT peekOrDefault(int index, ContentT defaultState)
Returns theindex
th element from the top of the operand stack or returnsdefaultState
if the stack does not have enough elements.
-
pop
public ContentT pop()
Removes the top element of the operand stack end returns it.
-
popOrDefault
public ContentT popOrDefault(ContentT defaultState)
Removes the top element of the operand stack end returns it. ReturnsdefaultState
if the stack is empty.
-
push
public ContentT push(ContentT state)
Insertsstate
to the top of the operand stack and returns it.
-
pushAll
public java.util.List<ContentT> pushAll(java.util.List<ContentT> states)
Consequentially inserts elements ofstates
to the top of the operand stack and returnsstates
.
-
clearOperandStack
public void clearOperandStack()
Empties the operand stack.
-
getVariableOrDefault
public ContentT getVariableOrDefault(int index, ContentT defaultState)
Returns an abstract state at theindex
th position of the variable array ordefaultState
if there is no entry.
-
setVariable
public ContentT setVariable(int index, ContentT state, ContentT 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 ContentT getStaticOrDefault(java.lang.String fqn, ContentT defaultState)
Returns an abstract state representing the static fieldfqn
ordefaultState
if there is no entry.
-
setStatic
public void setStatic(java.lang.String fqn, ContentT value, ContentT defaultState)
Sets the static fieldfqn
tovalue
, unless the value isdefaultState
.
-
getFieldOrDefault
public <T> ContentT getFieldOrDefault(T object, java.lang.String descriptor, ContentT defaultValue)
Returns an abstract state representing the fielddescriptor
of theobject
ordefaultState
if there is no entry.
-
getFieldOrDefault
public <T> ContentT getFieldOrDefault(T object, ContentT 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, ContentT value)
Sets the fielddescriptor
of theobject
tovalue
.
-
setField
public <T> void setField(T object, ContentT value)
Sets the default field of theobject
tovalue
.
-
getFrame
public JvmFrameAbstractState<ContentT> getFrame()
Returns the frame abstract state.
-
getStaticFields
public MapAbstractState<java.lang.String,ContentT> getStaticFields()
Returns the static field table abstract state.
-
getHeap
public JvmHeapAbstractState<ContentT> getHeap()
Returns the heap abstract state.
-
newArray
public ContentT newArray(java.lang.String type, java.util.List<ContentT> dimensions)
Returns an abstract state for a new array for the giventype
anddimentions
.
-
newObject
public ContentT newObject(java.lang.String className)
Returns an abstract state for a new object of the givenclassName
.
-
newObject
public ContentT newObject(Clazz clazz)
Returns an abstract state for a new object of the givenClazz
.
-
getArrayElementOrDefault
public <T> ContentT getArrayElementOrDefault(T array, ContentT index, ContentT abstractDefault)
Returns an abstract state for thearray
element at the givenindex
or theabstractDefault
if there is no information available.
-
-