| Copyright | (c) Galois Inc 2015-2016 |
|---|---|
| License | BSD3 |
| Maintainer | Rob Dockins <rdockins@galois.com> |
| Stability | provisional |
| Safe Haskell | None |
| Language | Haskell2010 |
Lang.Crucible.LLVM.MemModel.Pointer
Description
Synopsis
- type HasPtrWidth (w :: Natural) = (1 <= w, 16 <= w, ?ptrWidth :: NatRepr w)
- pattern PtrWidth :: forall (w :: Natural) w'. HasPtrWidth w => w ~ w' => NatRepr w'
- withPtrWidth :: forall (w :: Natural) a. 16 <= w => NatRepr w -> (HasPtrWidth w => a) -> a
- type LLVMPointerType (w :: Nat) = IntrinsicType "LLVM_pointer" ((EmptyCtx :: Ctx CrucibleType) ::> BVType w)
- type LLVMPtr sym (w :: Nat) = RegValue sym (LLVMPointerType w)
- data SomePointer sym = 1 <= w => SomePointer !(LLVMPtr sym w)
- pattern LLVMPointerRepr :: forall ty (w :: Natural). () => (1 <= w, ty ~ LLVMPointerType w) => NatRepr w -> TypeRepr ty
- pattern PtrRepr :: forall (wptr :: Natural) ty. HasPtrWidth wptr => ty ~ LLVMPointerType wptr => TypeRepr ty
- pattern SizeT :: forall (wptr :: Natural) ty. HasPtrWidth wptr => ty ~ BVType wptr => TypeRepr ty
- pattern LLVMPointer :: SymNat sym -> SymBV sym w -> LLVMPointer sym w
- ptrWidth :: forall sym (w :: Nat). IsExprBuilder sym => LLVMPtr sym w -> NatRepr w
- llvmPointerView :: forall sym (w :: Nat). LLVMPtr sym w -> (SymNat sym, SymBV sym w)
- llvmPointerBlock :: forall sym (w :: Nat). LLVMPtr sym w -> SymNat sym
- llvmPointerOffset :: forall sym (w :: Nat). LLVMPtr sym w -> SymBV sym w
- llvmPointerType :: forall sym (w :: Nat). IsExpr (SymExpr sym) => LLVMPtr sym w -> TypeRepr (LLVMPointerType w)
- muxLLVMPtr :: forall (w :: Natural) sym. (1 <= w, IsSymInterface sym) => sym -> Pred sym -> LLVMPtr sym w -> LLVMPtr sym w -> IO (LLVMPtr sym w)
- llvmPointer_bv :: forall sym (w :: Nat). IsSymInterface sym => sym -> SymBV sym w -> IO (LLVMPtr sym w)
- mkNullPointer :: forall (w :: Natural) sym. (1 <= w, IsSymInterface sym) => sym -> NatRepr w -> IO (LLVMPtr sym w)
- data ConcLLVMPtr (w :: Nat) = ConcLLVMPtr {}
- concLLVMPtr :: forall sym (w :: Nat). IsExprBuilder sym => (forall (tp :: BaseType). SymExpr sym tp -> IO (GroundValue tp)) -> RegValue sym (LLVMPointerType w) -> IO (ConcLLVMPtr w)
- concLLVMPtrToSymbolic :: forall sym (w :: Natural). (IsExprBuilder sym, 1 <= w) => sym -> ConcLLVMPtr w -> IO (RegValue sym (LLVMPointerType w))
- concBV :: forall sym (w :: Natural). (IsExprBuilder sym, 1 <= w) => sym -> (forall (tp :: BaseType). SymExpr sym tp -> IO (GroundValue tp)) -> SymBV sym w -> IO (SymBV sym w)
- concPtr :: forall sym (w :: Natural). (IsExprBuilder sym, 1 <= w) => sym -> (forall (tp :: BaseType). SymExpr sym tp -> IO (GroundValue tp)) -> RegValue sym (LLVMPointerType w) -> IO (RegValue sym (LLVMPointerType w))
- concPtr' :: forall sym (w :: Natural). (IsExprBuilder sym, 1 <= w) => sym -> (forall (tp :: BaseType). SymExpr sym tp -> IO (GroundValue tp)) -> RegValue' sym (LLVMPointerType w) -> IO (RegValue' sym (LLVMPointerType w))
- concPtrFn :: IntrinsicConcFn t "LLVM_pointer"
- concPtrFnMap :: MapF SymbolRepr (IntrinsicConcFn t)
- concToSymPtrFn :: IntrinsicConcToSymFn "LLVM_pointer"
- concToSymPtrFnMap :: MapF SymbolRepr IntrinsicConcToSymFn
- constOffset :: forall (w :: Natural) sym. (1 <= w, IsExprBuilder sym) => sym -> NatRepr w -> Addr -> IO (SymBV sym w)
- ptrSameAlloc :: forall (w :: Natural) sym. (1 <= w, IsSymInterface sym) => sym -> LLVMPtr sym w -> LLVMPtr sym w -> IO (Pred sym)
- ptrEq :: forall (w :: Natural) sym. (1 <= w, IsSymInterface sym) => sym -> NatRepr w -> LLVMPtr sym w -> LLVMPtr sym w -> IO (Pred sym)
- ptrLe :: forall (w :: Natural) sym. (1 <= w, IsSymInterface sym, ?memOpts :: MemOptions) => sym -> NatRepr w -> LLVMPtr sym w -> LLVMPtr sym w -> IO (Pred sym, Pred sym)
- ptrAdd :: forall (w :: Natural) sym. (1 <= w, IsExprBuilder sym) => sym -> NatRepr w -> LLVMPtr sym w -> SymBV sym w -> IO (LLVMPtr sym w)
- ptrDiff :: forall (w :: Natural) sym. (1 <= w, IsSymInterface sym) => sym -> NatRepr w -> LLVMPtr sym w -> LLVMPtr sym w -> IO (SymBV sym w, Pred sym)
- ptrSub :: forall (w :: Natural) sym. (1 <= w, IsSymInterface sym) => sym -> NatRepr w -> LLVMPtr sym w -> SymBV sym w -> IO (LLVMPtr sym w)
- ptrIsBv :: forall sym (w :: Nat). IsSymInterface sym => sym -> LLVMPtr sym w -> IO (Pred sym)
- ptrIsNull :: forall (w :: Natural) sym. (1 <= w, IsSymInterface sym) => sym -> NatRepr w -> LLVMPtr sym w -> IO (Pred sym)
- isGlobalPointer :: forall sym (w :: Nat). IsSymInterface sym => Map Natural Symbol -> LLVMPtr sym w -> Maybe Symbol
- isGlobalPointer' :: forall sym (w :: Nat). IsSymInterface sym => Map Natural Symbol -> LLVMPtr sym w -> Maybe Symbol
- ppPtr :: forall sym (wptr :: Nat) ann. IsExpr (SymExpr sym) => LLVMPtr sym wptr -> Doc ann
- annotatePointerBlock :: forall sym (w :: Nat). IsSymInterface sym => sym -> LLVMPtr sym w -> IO (SymAnnotation sym BaseIntegerType, LLVMPointer sym w)
- annotatePointerOffset :: forall sym (w :: Nat). IsSymInterface sym => sym -> LLVMPtr sym w -> IO (SymAnnotation sym (BaseBVType w), LLVMPointer sym w)
Pointer bitwidth
type HasPtrWidth (w :: Natural) = (1 <= w, 16 <= w, ?ptrWidth :: NatRepr w) Source #
This constraint captures the idea that there is a distinguished
pointer width in scope which is appropriate according to the C
notion of pointer, and object size. In particular, it must be at
least 16-bits wide (as required for the size_t type).
withPtrWidth :: forall (w :: Natural) a. 16 <= w => NatRepr w -> (HasPtrWidth w => a) -> a Source #
Crucible pointer representation
type LLVMPointerType (w :: Nat) = IntrinsicType "LLVM_pointer" ((EmptyCtx :: Ctx CrucibleType) ::> BVType w) Source #
Crucible type of pointers/bitvector values of width w.
type LLVMPtr sym (w :: Nat) = RegValue sym (LLVMPointerType w) Source #
Symbolic LLVM pointer or bitvector values of width w.
data SomePointer sym Source #
A pointer with an existentially-quantified width
Constructors
| 1 <= w => SomePointer !(LLVMPtr sym w) |
pattern LLVMPointerRepr :: forall ty (w :: Natural). () => (1 <= w, ty ~ LLVMPointerType w) => NatRepr w -> TypeRepr ty Source #
This pattern synonym makes it easy to build and destruct runtime
representatives of .LLVMPointerType w
pattern PtrRepr :: forall (wptr :: Natural) ty. HasPtrWidth wptr => ty ~ LLVMPointerType wptr => TypeRepr ty Source #
This pattern creates/matches against the TypeRepr for LLVM pointer values that are of the distinguished pointer width.
pattern SizeT :: forall (wptr :: Natural) ty. HasPtrWidth wptr => ty ~ BVType wptr => TypeRepr ty Source #
This pattern creates/matches against the TypeRepr for raw bitvector values that are of the distinguished pointer width.
pattern LLVMPointer :: SymNat sym -> SymBV sym w -> LLVMPointer sym w Source #
A pointer is a base point offset.
ptrWidth :: forall sym (w :: Nat). IsExprBuilder sym => LLVMPtr sym w -> NatRepr w Source #
Compute the width of a pointer value.
llvmPointerView :: forall sym (w :: Nat). LLVMPtr sym w -> (SymNat sym, SymBV sym w) Source #
Alternative to the LLVMPointer pattern synonym, this function can be used as a view
constructor instead to silence incomplete pattern warnings.
llvmPointerBlock :: forall sym (w :: Nat). LLVMPtr sym w -> SymNat sym Source #
Retrieve this pointer's block number.
Use of this function is discouraged, as it is abstraction-breaking.
llvmPointerOffset :: forall sym (w :: Nat). LLVMPtr sym w -> SymBV sym w Source #
Retrieve this pointer's offset.
Use of this function is discouraged, as it is abstraction-breaking.
llvmPointerType :: forall sym (w :: Nat). IsExpr (SymExpr sym) => LLVMPtr sym w -> TypeRepr (LLVMPointerType w) Source #
muxLLVMPtr :: forall (w :: Natural) sym. (1 <= w, IsSymInterface sym) => sym -> Pred sym -> LLVMPtr sym w -> LLVMPtr sym w -> IO (LLVMPtr sym w) Source #
Mux function specialized to LLVM pointer values.
llvmPointer_bv :: forall sym (w :: Nat). IsSymInterface sym => sym -> SymBV sym w -> IO (LLVMPtr sym w) Source #
Convert a raw bitvector value into an LLVM pointer value.
mkNullPointer :: forall (w :: Natural) sym. (1 <= w, IsSymInterface sym) => sym -> NatRepr w -> IO (LLVMPtr sym w) Source #
Produce the distinguished null pointer value.
Concretization
Arguments
| :: forall sym (w :: Nat). IsExprBuilder sym | |
| => (forall (tp :: BaseType). SymExpr sym tp -> IO (GroundValue tp)) | Model from SMT solver |
| -> RegValue sym (LLVMPointerType w) | |
| -> IO (ConcLLVMPtr w) |
Concretize a symbolic pointer to a particular ConcLLVMPtr that is
feasible in a model.
concLLVMPtrToSymbolic :: forall sym (w :: Natural). (IsExprBuilder sym, 1 <= w) => sym -> ConcLLVMPtr w -> IO (RegValue sym (LLVMPointerType w)) Source #
Create a symbolic pointer from a concrete one
concBV :: forall sym (w :: Natural). (IsExprBuilder sym, 1 <= w) => sym -> (forall (tp :: BaseType). SymExpr sym tp -> IO (GroundValue tp)) -> SymBV sym w -> IO (SymBV sym w) Source #
concPtr :: forall sym (w :: Natural). (IsExprBuilder sym, 1 <= w) => sym -> (forall (tp :: BaseType). SymExpr sym tp -> IO (GroundValue tp)) -> RegValue sym (LLVMPointerType w) -> IO (RegValue sym (LLVMPointerType w)) Source #
concPtr' :: forall sym (w :: Natural). (IsExprBuilder sym, 1 <= w) => sym -> (forall (tp :: BaseType). SymExpr sym tp -> IO (GroundValue tp)) -> RegValue' sym (LLVMPointerType w) -> IO (RegValue' sym (LLVMPointerType w)) Source #
concPtrFn :: IntrinsicConcFn t "LLVM_pointer" Source #
An IntrinsicConcFn for LLVM pointers
concPtrFnMap :: MapF SymbolRepr (IntrinsicConcFn t) Source #
A singleton map suitable for use in a ConcCtx if LLVM pointers are
the only intrinsic type in use
concToSymPtrFn :: IntrinsicConcToSymFn "LLVM_pointer" Source #
A IntrinsicConcToSymFn for LLVM pointers
concToSymPtrFnMap :: MapF SymbolRepr IntrinsicConcToSymFn Source #
A singleton map suitable for use in concToSym if LLVM
pointers are the only intrinsic type in use
Operations on valid pointers
constOffset :: forall (w :: Natural) sym. (1 <= w, IsExprBuilder sym) => sym -> NatRepr w -> Addr -> IO (SymBV sym w) Source #
Generate a concrete offset value from an Addr value.
ptrSameAlloc :: forall (w :: Natural) sym. (1 <= w, IsSymInterface sym) => sym -> LLVMPtr sym w -> LLVMPtr sym w -> IO (Pred sym) Source #
Test whether two pointers point to the same allocation (i.e., have the same block number).
Using this function is preferred to pattern matching on LLVMPointer or
llvmPointerBlock, because it operates at a higher level of abstraction
(i.e., if the representation of pointers were changed, it could continue to
work as intended).
ptrEq :: forall (w :: Natural) sym. (1 <= w, IsSymInterface sym) => sym -> NatRepr w -> LLVMPtr sym w -> LLVMPtr sym w -> IO (Pred sym) Source #
Test whether two pointers are equal.
ptrLe :: forall (w :: Natural) sym. (1 <= w, IsSymInterface sym, ?memOpts :: MemOptions) => sym -> NatRepr w -> LLVMPtr sym w -> LLVMPtr sym w -> IO (Pred sym, Pred sym) Source #
Test whether one pointer is less than or equal to the other.
The returned predicates assert (in this order): * the first pointer is less than or equal to the second * the comparison is valid: the pointers are to the same allocation
ptrAdd :: forall (w :: Natural) sym. (1 <= w, IsExprBuilder sym) => sym -> NatRepr w -> LLVMPtr sym w -> SymBV sym w -> IO (LLVMPtr sym w) Source #
Add an offset to a pointer.
ptrDiff :: forall (w :: Natural) sym. (1 <= w, IsSymInterface sym) => sym -> NatRepr w -> LLVMPtr sym w -> LLVMPtr sym w -> IO (SymBV sym w, Pred sym) Source #
Compute the difference between two pointers. The returned predicate asserts that the pointers point into the same allocation block.
ptrSub :: forall (w :: Natural) sym. (1 <= w, IsSymInterface sym) => sym -> NatRepr w -> LLVMPtr sym w -> SymBV sym w -> IO (LLVMPtr sym w) Source #
Subtract an offset from a pointer.
ptrIsBv :: forall sym (w :: Nat). IsSymInterface sym => sym -> LLVMPtr sym w -> IO (Pred sym) Source #
Test if a pointer value is a bitvector (i.e., has a block number of 0)
Using this function is preferred to pattern matching on LLVMPointer or
llvmPointerBlock, because it operates at a higher level of abstraction
(i.e., if the representation of pointers were changed, it could continue to
work as intended).
ptrIsNull :: forall (w :: Natural) sym. (1 <= w, IsSymInterface sym) => sym -> NatRepr w -> LLVMPtr sym w -> IO (Pred sym) Source #
Test if a pointer value is the null pointer.
Arguments
| :: forall sym (w :: Nat). IsSymInterface sym | |
| => Map Natural Symbol | c.f. |
| -> LLVMPtr sym w | |
| -> Maybe Symbol |
Look up a pointer in the memImplGlobalMap to see if it's a global.
This is best-effort and will only work if the pointer is fully concrete and matches the address of the global on the nose. It is used in SAWscript for friendly error messages.
Arguments
| :: forall sym (w :: Nat). IsSymInterface sym | |
| => Map Natural Symbol | c.f. |
| -> LLVMPtr sym w | |
| -> Maybe Symbol |
For when you don't know 1 <= w
Pretty printing
Annotation
annotatePointerBlock :: forall sym (w :: Nat). IsSymInterface sym => sym -> LLVMPtr sym w -> IO (SymAnnotation sym BaseIntegerType, LLVMPointer sym w) Source #
annotatePointerOffset :: forall sym (w :: Nat). IsSymInterface sym => sym -> LLVMPtr sym w -> IO (SymAnnotation sym (BaseBVType w), LLVMPointer sym w) Source #
Orphan instances
| IsSymInterface sym => IntrinsicClass sym "LLVM_pointer" Source # | |
Methods pushBranchIntrinsic :: forall (ctx :: Ctx CrucibleType). sym -> IntrinsicTypes sym -> SymbolRepr "LLVM_pointer" -> CtxRepr ctx -> Intrinsic sym "LLVM_pointer" ctx -> IO (Intrinsic sym "LLVM_pointer" ctx) # abortBranchIntrinsic :: forall (ctx :: Ctx CrucibleType). sym -> IntrinsicTypes sym -> SymbolRepr "LLVM_pointer" -> CtxRepr ctx -> Intrinsic sym "LLVM_pointer" ctx -> IO (Intrinsic sym "LLVM_pointer" ctx) # muxIntrinsic :: forall (ctx :: Ctx CrucibleType). sym -> IntrinsicTypes sym -> SymbolRepr "LLVM_pointer" -> CtxRepr ctx -> Pred sym -> Intrinsic sym "LLVM_pointer" ctx -> Intrinsic sym "LLVM_pointer" ctx -> IO (Intrinsic sym "LLVM_pointer" ctx) # | |