Safe Haskell | None |
---|---|
Language | Haskell2010 |
Data.Macaw.AbsDomain.AbsState
Contents
Synopsis
- data AbsBlockState (r :: Type -> Type)
- setAbsIP :: forall (r :: Type -> Type). RegisterInfo r => MemSegmentOff (RegAddrWidth r) -> AbsBlockState r -> AbsBlockState r
- absRegState :: forall (r :: Type -> Type) f. Functor f => (RegState r (AbsValue (RegAddrWidth r)) -> f (RegState r (AbsValue (RegAddrWidth r)))) -> AbsBlockState r -> f (AbsBlockState r)
- absStackHasReturnAddr :: forall (r :: Type -> Type). AbsBlockState r -> Bool
- data CallParams (r :: Type -> Type) = CallParams {
- postCallStackDelta :: Integer
- stackGrowsDown :: !Bool
- preserveReg :: forall (tp :: Type). r tp -> Bool
- absEvalCall :: RegisterInfo (ArchReg arch) => CallParams (ArchReg arch) -> AbsProcessorState (ArchReg arch) ids -> RegState (ArchReg arch) (Value arch ids) -> ArchSegmentOff arch -> AbsBlockState (ArchReg arch)
- type AbsBlockStack (w :: Nat) = Map Int64 (StackEntry w)
- fnStartAbsBlockState :: forall (r :: Type -> Type). RegisterInfo r => MemSegmentOff (RegAddrWidth r) -> MapF r (AbsValue (RegAddrWidth r)) -> [(Int64, StackEntry (RegAddrWidth r))] -> AbsBlockState r
- joinAbsBlockState :: forall (r :: Type -> Type). RegisterInfo r => AbsBlockState r -> AbsBlockState r -> Maybe (AbsBlockState r)
- data StackEntry (w :: Nat) = StackEntry !(MemRepr tp) !(AbsValue w tp)
- type ArchAbsValue arch = AbsValue (ArchAddrWidth arch)
- data AbsValue (w :: Nat) (tp :: Type)
- = tp ~ BoolType => BoolConst !Bool
- | tp ~ BVType n => FinSet !(Set Integer)
- | tp ~ BVType w => CodePointers !(Set (MemSegmentOff w)) !Bool
- | tp ~ BVType w => StackOffsetAbsVal !(MemAddr w) !Int64
- | tp ~ BVType w => SomeStackOffset !(MemAddr w)
- | tp ~ BVType n => StridedInterval !(StridedInterval n)
- | ((n + 1) <= n', tp ~ BVType n') => SubValue !(NatRepr n) !(AbsValue w (BVType n))
- | TopV
- | tp ~ BVType w => ReturnAddr
- bvadd :: forall (w :: Natural) (u :: Nat). MemWidth w => NatRepr u -> AbsValue w (BVType u) -> AbsValue w (BVType u) -> AbsValue w (BVType u)
- emptyAbsValue :: forall (w :: Nat). AbsValue w (BVType w)
- concreteCodeAddr :: forall (w :: Nat). MemSegmentOff w -> AbsValue w (BVType w)
- joinAbsValue :: forall (w :: Natural) (tp :: Type). MemWidth w => AbsValue w tp -> AbsValue w tp -> Maybe (AbsValue w tp)
- ppAbsValue :: forall (w :: Natural) (tp :: Type) ann. MemWidth w => AbsValue w tp -> Maybe (Doc ann)
- absTrue :: forall (w :: Nat). AbsValue w BoolType
- absFalse :: forall (w :: Nat). AbsValue w BoolType
- subValue :: forall (n :: Natural) (n' :: Natural) (w :: Nat). (n + 1) <= n' => NatRepr n -> AbsValue w (BVType n) -> AbsValue w (BVType n')
- concretize :: forall (w :: Natural) (tp :: Type). MemWidth w => AbsValue w tp -> Maybe (Set Integer)
- asConcreteSingleton :: forall (w :: Natural) (tp :: Type). MemWidth w => AbsValue w tp -> Maybe Integer
- meet :: forall (w :: Natural) (tp :: Type). MemWidth w => AbsValue w tp -> AbsValue w tp -> AbsValue w tp
- absValueSize :: forall (w :: Nat) (tp :: Type). AbsValue w tp -> Maybe Integer
- codePointerSet :: forall (w :: Nat) (tp :: Type). AbsValue w tp -> Set (MemSegmentOff w)
- class Eq d => AbsDomain d where
- data AbsProcessorState (r :: Type -> Type) ids
- absMem :: AbsProcessorState r ids -> Memory (RegAddrWidth r)
- curAbsStack :: forall (r :: Type -> Type) ids f. Functor f => (AbsBlockStack (RegAddrWidth r) -> f (AbsBlockStack (RegAddrWidth r))) -> AbsProcessorState r ids -> f (AbsProcessorState r ids)
- absInitialRegs :: forall (r :: Type -> Type) ids f. Functor f => (RegState r (AbsValue (RegAddrWidth r)) -> f (RegState r (AbsValue (RegAddrWidth r)))) -> AbsProcessorState r ids -> f (AbsProcessorState r ids)
- initAbsProcessorState :: forall (r :: Type -> Type) ids. Memory (RegAddrWidth r) -> AbsBlockState r -> AbsProcessorState r ids
- absAssignments :: forall (r :: Type -> Type) ids f. Functor f => (MapF (AssignId ids) (AbsValue (RegAddrWidth r)) -> f (MapF (AssignId ids) (AbsValue (RegAddrWidth r)))) -> AbsProcessorState r ids -> f (AbsProcessorState r ids)
- assignLens :: forall ids (tp :: Type) (w :: Nat). AssignId ids tp -> Lens' (MapF (AssignId ids) (AbsValue w)) (AbsValue w tp)
- stridedInterval :: forall (n :: Nat) (w :: Nat). StridedInterval n -> AbsValue w (BVType n)
- finalAbsBlockState :: RegisterInfo (ArchReg a) => AbsProcessorState (ArchReg a) ids -> RegState (ArchReg a) (Value a ids) -> AbsBlockState (ArchReg a)
- addMemWrite :: forall arch ids (tp :: Type). (RegisterInfo (ArchReg arch), MemWidth (ArchAddrWidth arch), HasCallStack) => AbsProcessorState (ArchReg arch) ids -> Value arch ids (BVType (ArchAddrWidth arch)) -> MemRepr tp -> Value arch ids tp -> AbsProcessorState (ArchReg arch) ids
- addCondMemWrite :: forall (r :: Type -> Type) arch ids (tp :: Type). (RegisterInfo r, MemWidth (RegAddrWidth r), HasCallStack, r ~ ArchReg arch) => AbsProcessorState r ids -> Value arch ids BoolType -> Value arch ids (BVType (RegAddrWidth r)) -> MemRepr tp -> Value arch ids tp -> AbsProcessorState r ids
- transferValue :: forall a ids (tp :: Type). (RegisterInfo (ArchReg a), HasCallStack) => AbsProcessorState (ArchReg a) ids -> Value a ids tp -> ArchAbsValue a tp
- abstractULt :: forall (w :: Natural) (u :: Nat). MemWidth w => NatRepr u -> AbsValue w (BVType u) -> AbsValue w (BVType u) -> (AbsValue w (BVType u), AbsValue w (BVType u))
- abstractULeq :: forall (w :: Natural) (u :: Nat). MemWidth w => NatRepr u -> AbsValue w (BVType u) -> AbsValue w (BVType u) -> (AbsValue w (BVType u), AbsValue w (BVType u))
- isBottom :: forall (w :: Nat) (tp :: Type). AbsValue w tp -> Bool
- transferApp :: forall a ids (tp :: Type). (RegisterInfo (ArchReg a), HasCallStack) => AbsProcessorState (ArchReg a) ids -> App (Value a ids) tp -> ArchAbsValue a tp
- hasMaximum :: forall (w :: Nat) (p :: Nat). NatRepr w -> AbsValue p (BVType w) -> Maybe Integer
Documentation
data AbsBlockState (r :: Type -> Type) Source #
Processor/memory state after at beginning of a block.
Instances
(ShowF r, MemWidth (RegAddrWidth r)) => Show (AbsBlockState r) Source # | |
Defined in Data.Macaw.AbsDomain.AbsState Methods showsPrec :: Int -> AbsBlockState r -> ShowS # show :: AbsBlockState r -> String # showList :: [AbsBlockState r] -> ShowS # | |
(ShowF r, MemWidth (RegAddrWidth r)) => Pretty (AbsBlockState r) Source # | |
Defined in Data.Macaw.AbsDomain.AbsState |
Arguments
:: forall (r :: Type -> Type). RegisterInfo r | |
=> MemSegmentOff (RegAddrWidth r) | The address to set. |
-> AbsBlockState r | |
-> AbsBlockState r |
Update the block state to point to a specific IP address.
absRegState :: forall (r :: Type -> Type) f. Functor f => (RegState r (AbsValue (RegAddrWidth r)) -> f (RegState r (AbsValue (RegAddrWidth r)))) -> AbsBlockState r -> f (AbsBlockState r) Source #
absStackHasReturnAddr :: forall (r :: Type -> Type). AbsBlockState r -> Bool Source #
Returns true if return address is known to sit on stack.
data CallParams (r :: Type -> Type) Source #
Minimal information needed to update stack constraints after a call.
Constructors
CallParams | |
Fields
|
Arguments
:: RegisterInfo (ArchReg arch) | |
=> CallParams (ArchReg arch) | Configuration |
-> AbsProcessorState (ArchReg arch) ids | State before call |
-> RegState (ArchReg arch) (Value arch ids) | |
-> ArchSegmentOff arch | Address we are jumping to |
-> AbsBlockState (ArchReg arch) |
This updates the registers after a call has been performed.
type AbsBlockStack (w :: Nat) = Map Int64 (StackEntry w) Source #
The AbsBlockStack describes offsets of the stack. Values that are not in the map may denote any values.
The stack grows down, so negative keys are in the stack frame.
Arguments
:: forall (r :: Type -> Type). RegisterInfo r | |
=> MemSegmentOff (RegAddrWidth r) | Start address of the block |
-> MapF r (AbsValue (RegAddrWidth r)) | Values to explicitly assign to registers (overriding default IP and SP values) |
-> [(Int64, StackEntry (RegAddrWidth r))] | Stack entries to populate the abstract stack with (format: (offset, abstract stack entry)) |
-> AbsBlockState r |
This constructs the abstract state for the start of the function.
It populates the register state with abstract values from the provided map, along with defaults for the instruction pointer and stack pointer. The provided list provides abstract values to be placed on the stack.
NOTE: It does not place the return address as where that is stored is architecture-specific.
joinAbsBlockState :: forall (r :: Type -> Type). RegisterInfo r => AbsBlockState r -> AbsBlockState r -> Maybe (AbsBlockState r) Source #
data StackEntry (w :: Nat) Source #
Constructors
StackEntry !(MemRepr tp) !(AbsValue w tp) |
Instances
MemWidth w => Show (StackEntry w) Source # | |
Defined in Data.Macaw.AbsDomain.AbsState Methods showsPrec :: Int -> StackEntry w -> ShowS # show :: StackEntry w -> String # showList :: [StackEntry w] -> ShowS # | |
Eq (StackEntry w) Source # | |
Defined in Data.Macaw.AbsDomain.AbsState |
type ArchAbsValue arch = AbsValue (ArchAddrWidth arch) Source #
The type of abstract values associated with a given architecture.
This is only a function of the address width.
data AbsValue (w :: Nat) (tp :: Type) Source #
The abstract information that is associated with values of a given type.
The first parameter is the width of pointers on the value. It is expected to be at most 64 bits.
Constructors
tp ~ BoolType => BoolConst !Bool | A Boolean constant |
tp ~ BVType n => FinSet !(Set Integer) | Denotes that this value can take any one of the fixed set. |
tp ~ BVType w => CodePointers !(Set (MemSegmentOff w)) !Bool | Represents that all values point to a bounded set of addresses in an executable segment or the constant zero. The set contains the possible addresses, and the Boolean indicates whether this set contains the address 0. |
tp ~ BVType w => StackOffsetAbsVal !(MemAddr w) !Int64 | Offset of stack from the beginning of the block at the given address. To avoid conflating offsets that are relative to the begining of different blocks, we include the address of the block as the first argument. |
tp ~ BVType w => SomeStackOffset !(MemAddr w) | An offset to the stack at some offset. Note. We do nothing to guarantee that this is a legal stack offset. To avoid conflating offsets that are relative to the begining of different blocks, we include the address of the block as the first argument. |
tp ~ BVType n => StridedInterval !(StridedInterval n) | A strided interval |
((n + 1) <= n', tp ~ BVType n') => SubValue !(NatRepr n) !(AbsValue w (BVType n)) | A sub-value about which we know something about the low order bits. e.g., when tp = BVType 16, and n = 8, and the abs value argument is |
TopV | Any value |
tp ~ BVType w => ReturnAddr | Denotes a return address in the body of a function. |
Instances
(MemWidth w, ShowF r) => PrettyRegValue r (AbsValue w) Source # | Print a list of Docs vertically separated. |
EqF (AbsValue w :: Type -> Type) Source # | |
MemWidth w => Show (AbsValue w tp) Source # | |
Eq (AbsValue w tp) Source # | |
MemWidth w => AbsDomain (AbsValue w tp) Source # | |
MemWidth w => Pretty (AbsValue w tp) Source # | |
Defined in Data.Macaw.AbsDomain.AbsState |
bvadd :: forall (w :: Natural) (u :: Nat). MemWidth w => NatRepr u -> AbsValue w (BVType u) -> AbsValue w (BVType u) -> AbsValue w (BVType u) Source #
emptyAbsValue :: forall (w :: Nat). AbsValue w (BVType w) Source #
Denotes that we do not know of any value that could be in set.
concreteCodeAddr :: forall (w :: Nat). MemSegmentOff w -> AbsValue w (BVType w) Source #
Construct a abstract value for a pointer to a code address.
joinAbsValue :: forall (w :: Natural) (tp :: Type). MemWidth w => AbsValue w tp -> AbsValue w tp -> Maybe (AbsValue w tp) Source #
Join the old and new states and return the updated state iff the result is larger than the old state. This also returns any addresses that are discarded during joining.
ppAbsValue :: forall (w :: Natural) (tp :: Type) ann. MemWidth w => AbsValue w tp -> Maybe (Doc ann) Source #
subValue :: forall (n :: Natural) (n' :: Natural) (w :: Nat). (n + 1) <= n' => NatRepr n -> AbsValue w (BVType n) -> AbsValue w (BVType n') Source #
Smart constructor for sub-values. This ensures that the subvalues are sorted on size.
concretize :: forall (w :: Natural) (tp :: Type). MemWidth w => AbsValue w tp -> Maybe (Set Integer) Source #
Returns a set of concrete integers that this value may be. This function will neither return the complete set or an known under-approximation.
asConcreteSingleton :: forall (w :: Natural) (tp :: Type). MemWidth w => AbsValue w tp -> Maybe Integer Source #
Returns single value, if the abstract value can only take on one value.
meet :: forall (w :: Natural) (tp :: Type). MemWidth w => AbsValue w tp -> AbsValue w tp -> AbsValue w tp Source #
codePointerSet :: forall (w :: Nat) (tp :: Type). AbsValue w tp -> Set (MemSegmentOff w) Source #
class Eq d => AbsDomain d where Source #
This represents an lattice order.
Elements are comparable for equality, have a partial order, a top element, and the ability to join to elements.
Methods
The top element
leq :: d -> d -> Bool Source #
A partial ordering over d. forall x. x leq
top
Least upper bound (always defined, as we have top)
joinD :: d -> d -> Maybe d Source #
Join the old and new states and return the updated state iff the result is larger than the old state.
data AbsProcessorState (r :: Type -> Type) ids Source #
This stores the abstract state of the system which may be within a block.
Instances
(ShowF r, MemWidth (RegAddrWidth r)) => Show (AbsProcessorState r ids) Source # | |
Defined in Data.Macaw.AbsDomain.AbsState Methods showsPrec :: Int -> AbsProcessorState r ids -> ShowS # show :: AbsProcessorState r ids -> String # showList :: [AbsProcessorState r ids] -> ShowS # | |
(ShowF r, MemWidth (RegAddrWidth r)) => Pretty (AbsProcessorState r ids) Source # | |
Defined in Data.Macaw.AbsDomain.AbsState Methods pretty :: AbsProcessorState r ids -> Doc ann prettyList :: [AbsProcessorState r ids] -> Doc ann |
absMem :: AbsProcessorState r ids -> Memory (RegAddrWidth r) Source #
Recognizer for code addresses.
curAbsStack :: forall (r :: Type -> Type) ids f. Functor f => (AbsBlockStack (RegAddrWidth r) -> f (AbsBlockStack (RegAddrWidth r))) -> AbsProcessorState r ids -> f (AbsProcessorState r ids) Source #
absInitialRegs :: forall (r :: Type -> Type) ids f. Functor f => (RegState r (AbsValue (RegAddrWidth r)) -> f (RegState r (AbsValue (RegAddrWidth r)))) -> AbsProcessorState r ids -> f (AbsProcessorState r ids) Source #
initAbsProcessorState Source #
Arguments
:: forall (r :: Type -> Type) ids. Memory (RegAddrWidth r) | Current state of memory in the processor. Used for checking code segment status. |
-> AbsBlockState r | |
-> AbsProcessorState r ids |
Construct a abstate processor state for the start of block execution.
absAssignments :: forall (r :: Type -> Type) ids f. Functor f => (MapF (AssignId ids) (AbsValue (RegAddrWidth r)) -> f (MapF (AssignId ids) (AbsValue (RegAddrWidth r)))) -> AbsProcessorState r ids -> f (AbsProcessorState r ids) Source #
assignLens :: forall ids (tp :: Type) (w :: Nat). AssignId ids tp -> Lens' (MapF (AssignId ids) (AbsValue w)) (AbsValue w tp) Source #
A lens that allows one to lookup and update the value of an assignment in map from assignments to abstract values.
stridedInterval :: forall (n :: Nat) (w :: Nat). StridedInterval n -> AbsValue w (BVType n) Source #
Smart constructor for strided intervals which takes care of top
Arguments
:: RegisterInfo (ArchReg a) | |
=> AbsProcessorState (ArchReg a) ids | |
-> RegState (ArchReg a) (Value a ids) | Final values for abstract processor state |
-> AbsBlockState (ArchReg a) |
Return state for after value has run.
Arguments
:: forall arch ids (tp :: Type). (RegisterInfo (ArchReg arch), MemWidth (ArchAddrWidth arch), HasCallStack) | |
=> AbsProcessorState (ArchReg arch) ids | Current processor state. |
-> Value arch ids (BVType (ArchAddrWidth arch)) | Address that we are writing to. |
-> MemRepr tp | Information about how value should be represented in memory. |
-> Value arch ids tp | Value to write to memory |
-> AbsProcessorState (ArchReg arch) ids |
Update the processor state with a memory write.
Arguments
:: forall (r :: Type -> Type) arch ids (tp :: Type). (RegisterInfo r, MemWidth (RegAddrWidth r), HasCallStack, r ~ ArchReg arch) | |
=> AbsProcessorState r ids | Current processor state. |
-> Value arch ids BoolType | Condition that holds if write is performed. |
-> Value arch ids (BVType (RegAddrWidth r)) | Address that we are writing to. |
-> MemRepr tp | Information about how value should be represented in memory. |
-> Value arch ids tp | Value to write to memory |
-> AbsProcessorState r ids |
Update the processor state with a potential memory write.
transferValue :: forall a ids (tp :: Type). (RegisterInfo (ArchReg a), HasCallStack) => AbsProcessorState (ArchReg a) ids -> Value a ids tp -> ArchAbsValue a tp Source #
Compute abstract value from value and current registers.
abstractULt :: forall (w :: Natural) (u :: Nat). MemWidth w => NatRepr u -> AbsValue w (BVType u) -> AbsValue w (BVType u) -> (AbsValue w (BVType u), AbsValue w (BVType u)) Source #
abstractULt x y
refines x and y with the knowledge that x < y
is unsigned.
For example, given {2, 3} and {2, 3, 4}, we know (only) that
{2, 3} and {3, 4} because we may pick any element from either set.
abstractULeq :: forall (w :: Natural) (u :: Nat). MemWidth w => NatRepr u -> AbsValue w (BVType u) -> AbsValue w (BVType u) -> (AbsValue w (BVType u), AbsValue w (BVType u)) Source #
abstractULeq u v
returns a pair (u',v')
where for each x
in
u
, and y
in v
, such that x <= y
, we have that x in u'
and
y
in v'.
isBottom :: forall (w :: Nat) (tp :: Type). AbsValue w tp -> Bool Source #
Returns true if this value represents the empty set.
transferApp :: forall a ids (tp :: Type). (RegisterInfo (ArchReg a), HasCallStack) => AbsProcessorState (ArchReg a) ids -> App (Value a ids) tp -> ArchAbsValue a tp Source #