Copyright | (c) Galois Inc 2014-2018 |
---|---|
License | BSD3 |
Maintainer | Joe Hendrix <jhendrix@galois.com> |
Stability | provisional |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Lang.Crucible.Simulator.ExecutionTree
Description
Execution trees record the state of the simulator as it explores execution paths through a program. This module defines the collection of datatypes that record the state of a running simulator and basic lenses and accessors for these types. See Lang.Crucible.Simulator.Operations for the definitions of operations that manipulate these datastructures to drive them through the simulator state machine.
Synopsis
- data GlobalPair sym (v :: Type) = GlobalPair {
- _gpValue :: !v
- _gpGlobals :: !(SymGlobalState sym)
- gpValue :: Lens (GlobalPair sym u) (GlobalPair sym v) u v
- gpGlobals :: Simple Lens (GlobalPair sym u) (SymGlobalState sym)
- type TopFrame sym ext f a = GlobalPair sym (SimFrame sym ext f a)
- crucibleTopFrame :: Lens (TopFrame sym ext (CrucibleLang blocks r) ('Just args)) (TopFrame sym ext (CrucibleLang blocks r) ('Just args')) (CallFrame sym ext blocks r args) (CallFrame sym ext blocks r args')
- overrideTopFrame :: Lens (TopFrame sym ext (OverrideLang r) ('Just args)) (TopFrame sym ext (OverrideLang r') ('Just args')) (OverrideFrame sym r args) (OverrideFrame sym r' args')
- data CrucibleBranchTarget f (args :: Maybe (Ctx CrucibleType)) where
- BlockTarget :: !(BlockID blocks args) -> CrucibleBranchTarget (CrucibleLang blocks r) ('Just args)
- ReturnTarget :: CrucibleBranchTarget f 'Nothing
- ppBranchTarget :: CrucibleBranchTarget f args -> String
- data AbortedResult sym ext where
- AbortedExec :: !AbortExecReason -> !(GlobalPair sym (SimFrame sym ext l args)) -> AbortedResult sym ext
- AbortedExit :: !ExitCode -> AbortedResult sym ext
- AbortedBranch :: !ProgramLoc -> !(Pred sym) -> !(AbortedResult sym ext) -> !(AbortedResult sym ext) -> AbortedResult sym ext
- data SomeFrame (f :: fk -> argk -> Type) = forall l a. SomeFrame !(f l a)
- filterCrucibleFrames :: SomeFrame (SimFrame sym ext) -> Maybe ProgramLoc
- arFrames :: Simple Traversal (AbortedResult sym ext) (SomeFrame (SimFrame sym ext))
- ppExceptionContext :: [SomeFrame (SimFrame sym ext)] -> Doc ann
- data PartialResult sym ext (v :: Type)
- = TotalRes !(GlobalPair sym v)
- | PartialRes !ProgramLoc !(Pred sym) !(GlobalPair sym v) !(AbortedResult sym ext)
- type PartialResultFrame sym ext f args = PartialResult sym ext (SimFrame sym ext f args)
- partialValue :: Lens (PartialResult sym ext u) (PartialResult sym ext v) (GlobalPair sym u) (GlobalPair sym v)
- data ExecResult p sym ext (r :: Type)
- = FinishedResult !(SimContext p sym ext) !(PartialResult sym ext r)
- | AbortedResult !(SimContext p sym ext) !(AbortedResult sym ext)
- | TimeoutResult !(ExecState p sym ext r)
- data ExecState p sym ext (rtp :: Type)
- = ResultState !(ExecResult p sym ext rtp)
- | forall f a. AbortState !AbortExecReason !(SimState p sym ext rtp f a)
- | forall f a r. UnwindCallState !(ValueFromValue p sym ext rtp r) !(AbortedResult sym ext) !(SimState p sym ext rtp f a)
- | forall f a ret. CallState !(ReturnHandler ret p sym ext rtp f a) !(ResolvedCall p sym ext ret) !(SimState p sym ext rtp f a)
- | forall f a ret. TailCallState !(ValueFromValue p sym ext rtp ret) !(ResolvedCall p sym ext ret) !(SimState p sym ext rtp f a)
- | forall f a ret. ReturnState !FunctionName !(ValueFromValue p sym ext rtp ret) !(RegEntry sym ret) !(SimState p sym ext rtp f a)
- | forall blocks r args. RunningState !(RunningStateInfo blocks args) !(SimState p sym ext rtp (CrucibleLang blocks r) ('Just args))
- | forall f args postdom_args. SymbolicBranchState !(Pred sym) !(PausedFrame p sym ext rtp f) !(PausedFrame p sym ext rtp f) !(CrucibleBranchTarget f postdom_args) !(SimState p sym ext rtp f ('Just args))
- | forall f a. ControlTransferState !(ControlResumption p sym ext rtp f) !(SimState p sym ext rtp f ('Just a))
- | forall args ret. OverrideState !(Override p sym ext args ret) !(SimState p sym ext rtp (OverrideLang ret) ('Just args))
- | forall f args. BranchMergeState !(CrucibleBranchTarget f args) !(SimState p sym ext rtp f args)
- | forall ret.rtp ~ RegEntry sym ret => InitialState !(SimContext p sym ext) !(SymGlobalState sym) !(AbortHandler p sym ext (RegEntry sym ret)) !(TypeRepr ret) !(ExecCont p sym ext (RegEntry sym ret) (OverrideLang ret) ('Just EmptyCtx))
- type ExecCont p sym ext r f a = ReaderT (SimState p sym ext r f a) IO (ExecState p sym ext r)
- data RunningStateInfo blocks args
- = RunBlockStart !(BlockID blocks args)
- | RunBlockEnd !(Some (BlockID blocks))
- | RunReturnFrom !FunctionName
- | RunPostBranchMerge !(BlockID blocks args)
- data ResolvedCall p sym ext ret where
- OverrideCall :: !(Override p sym ext args ret) -> !(OverrideFrame sym ret args) -> ResolvedCall p sym ext ret
- CrucibleCall :: !(BlockID blocks args) -> !(CallFrame sym ext blocks ret args) -> ResolvedCall p sym ext ret
- resolvedCallHandle :: ResolvedCall p sym ext ret -> SomeHandle
- execResultContext :: ExecResult p sym ext r -> SimContext p sym ext
- execStateContext :: ExecState p sym ext r -> SimContext p sym ext
- execStateSimState :: ExecState p sym ext r -> Maybe (SomeSimState p sym ext r)
- data ValueFromValue p sym ext (ret :: Type) (top_return :: CrucibleType)
- = forall args caller. VFVCall !(ValueFromFrame p sym ext ret caller) !(SimFrame sym ext caller args) !(ReturnHandler top_return p sym ext ret caller args)
- | VFVPartial !(ValueFromValue p sym ext ret top_return) !ProgramLoc !(Pred sym) !(AbortedResult sym ext)
- | ret ~ RegEntry sym top_return => VFVEnd
- data ValueFromFrame p sym ext (ret :: Type) (f :: Type)
- = forall args. VFFBranch !(ValueFromFrame p sym ext ret f) !FrameIdentifier !ProgramLoc !(Pred sym) !(VFFOtherPath p sym ext ret f args) !(CrucibleBranchTarget f args)
- | VFFPartial !(ValueFromFrame p sym ext ret f) !ProgramLoc !(Pred sym) !(AbortedResult sym ext) !PendingPartialMerges
- | VFFEnd !(ValueFromValue p sym ext ret (FrameRetType f))
- data PendingPartialMerges
- data ResolvedJump sym blocks = forall args. ResolvedJump !(BlockID blocks args) !(RegMap sym args)
- data ControlResumption p sym ext rtp f where
- ContinueResumption :: !(ResolvedJump sym blocks) -> ControlResumption p sym ext rtp (CrucibleLang blocks r)
- CheckMergeResumption :: !(ResolvedJump sym blocks) -> ControlResumption p sym ext rtp (CrucibleLang blocks r)
- SwitchResumption :: ![(Pred sym, ResolvedJump sym blocks)] -> ControlResumption p sym ext rtp (CrucibleLang blocks r)
- OverrideResumption :: ExecCont p sym ext rtp (OverrideLang r) ('Just args) -> !(RegMap sym args) -> ControlResumption p sym ext rtp (OverrideLang r)
- data PausedFrame p sym ext rtp f = forall old_args.PausedFrame {
- pausedFrame :: !(PartialResultFrame sym ext f ('Just old_args))
- resume :: !(ControlResumption p sym ext rtp f)
- pausedLoc :: !(Maybe ProgramLoc)
- data VFFOtherPath p sym ext ret f args
- = VFFActivePath !(PausedFrame p sym ext ret f)
- | VFFCompletePath !(Assumptions sym) !(PartialResultFrame sym ext f args)
- type family FrameRetType (f :: Type) :: CrucibleType where ...
- data ReturnHandler (ret :: CrucibleType) p sym ext root f args where
- ReturnToOverride :: (RegEntry sym ret -> SimState p sym ext root (OverrideLang r) ('Just args) -> IO (ExecState p sym ext root)) -> ReturnHandler ret p sym ext root (OverrideLang r) ('Just args)
- ReturnToCrucible :: TypeRepr ret -> StmtSeq ext blocks r (ctx ::> ret) -> ReturnHandler ret p sym ext root (CrucibleLang blocks r) ('Just ctx)
- TailReturnToCrucible :: ret ~ r => ReturnHandler ret p sym ext root (CrucibleLang blocks r) ctx
- data ActiveTree p sym ext root (f :: Type) args = ActiveTree {
- _actContext :: !(ValueFromFrame p sym ext root f)
- _actResult :: !(PartialResultFrame sym ext f args)
- singletonTree :: TopFrame sym ext f args -> ActiveTree p sym ext (RegEntry sym (FrameRetType f)) f args
- activeFrames :: ActiveTree ctx sym ext root a args -> [SomeFrame (SimFrame sym ext)]
- actContext :: Lens (ActiveTree p sym ext root f args) (ActiveTree p sym ext root f args) (ValueFromFrame p sym ext root f) (ValueFromFrame p sym ext root f)
- actFrame :: Lens (ActiveTree p sym ext root f args) (ActiveTree p sym ext root f args') (TopFrame sym ext f args) (TopFrame sym ext f args')
- data Override p sym ext (args :: Ctx CrucibleType) ret = Override {
- overrideName :: FunctionName
- overrideHandler :: forall r. ExecCont p sym ext r (OverrideLang ret) ('Just args)
- data FnState p sym ext (args :: Ctx CrucibleType) (ret :: CrucibleType)
- = UseOverride !(Override p sym ext args ret)
- | forall blocks. UseCFG !(CFG ext blocks args ret) !(CFGPostdom blocks)
- newtype FunctionBindings p sym ext = FnBindings {
- fnBindings :: FnHandleMap (FnState p sym ext)
- data ExtensionImpl p sym ext = ExtensionImpl {
- extensionEval :: forall bak rtp blocks r ctx. IsSymBackend sym bak => bak -> IntrinsicTypes sym -> (Int -> String -> IO ()) -> CrucibleState p sym ext rtp blocks r ctx -> EvalAppFunc sym (ExprExtension ext)
- extensionExec :: EvalStmtFunc p sym ext
- type EvalStmtFunc p sym ext = forall rtp blocks r ctx tp'. StmtExtension ext (RegEntry sym) tp' -> CrucibleState p sym ext rtp blocks r ctx -> IO (RegValue sym tp', CrucibleState p sym ext rtp blocks r ctx)
- emptyExtensionImpl :: ExtensionImpl p sym ()
- type IsSymInterfaceProof sym a = (IsSymInterface sym => a) -> a
- data SimContext (personality :: Type) (sym :: Type) (ext :: Type) = SimContext {
- _ctxBackend :: !(SomeBackend sym)
- ctxSolverProof :: !(forall a. IsSymInterfaceProof sym a)
- ctxIntrinsicTypes :: !(IntrinsicTypes sym)
- simHandleAllocator :: !HandleAllocator
- printHandle :: !Handle
- extensionImpl :: ExtensionImpl personality sym ext
- _functionBindings :: !(FunctionBindings personality sym ext)
- _cruciblePersonality :: !personality
- _profilingMetrics :: !(Map Text (Metric personality sym ext))
- newtype Metric p sym ext = Metric {}
- initSimContext :: IsSymBackend sym bak => bak -> IntrinsicTypes sym -> HandleAllocator -> Handle -> FunctionBindings personality sym ext -> ExtensionImpl personality sym ext -> personality -> SimContext personality sym ext
- withBackend :: SimContext personality sym ext -> (forall bak. IsSymBackend sym bak => bak -> a) -> a
- ctxSymInterface :: Getter (SimContext p sym ext) sym
- functionBindings :: Lens' (SimContext p sym ext) (FunctionBindings p sym ext)
- cruciblePersonality :: Lens' (SimContext p sym ext) p
- profilingMetrics :: Lens' (SimContext p sym ext) (Map Text (Metric p sym ext))
- data SimState p sym ext rtp f (args :: Maybe (Ctx CrucibleType)) = SimState {
- _stateContext :: !(SimContext p sym ext)
- _abortHandler :: !(AbortHandler p sym ext rtp)
- _stateTree :: !(ActiveTree p sym ext rtp f args)
- data SomeSimState p sym ext rtp = forall f args. SomeSimState !(SimState p sym ext rtp f args)
- initSimState :: SimContext p sym ext -> SymGlobalState sym -> AbortHandler p sym ext (RegEntry sym ret) -> TypeRepr ret -> IO (SimState p sym ext (RegEntry sym ret) (OverrideLang ret) ('Just EmptyCtx))
- stateLocation :: Getter (SimState p sym ext r f a) (Maybe ProgramLoc)
- newtype AbortHandler p sym ext rtp = AH {
- runAH :: forall (l :: Type) args. AbortExecReason -> ExecCont p sym ext rtp l args
- type CrucibleState p sym ext rtp blocks ret args = SimState p sym ext rtp (CrucibleLang blocks ret) ('Just args)
- stateTree :: Lens (SimState p sym ext rtp f a) (SimState p sym ext rtp g b) (ActiveTree p sym ext rtp f a) (ActiveTree p sym ext rtp g b)
- abortHandler :: Simple Lens (SimState p sym ext r f a) (AbortHandler p sym ext r)
- stateContext :: Simple Lens (SimState p sym ext r f a) (SimContext p sym ext)
- stateCrucibleFrame :: Lens (SimState p sym ext rtp (CrucibleLang blocks r) ('Just a)) (SimState p sym ext rtp (CrucibleLang blocks r) ('Just a')) (CallFrame sym ext blocks r a) (CallFrame sym ext blocks r a')
- stateSymInterface :: Getter (SimState p sym ext r f a) sym
- stateSolverProof :: SimState p sym ext r f args -> forall a. IsSymInterfaceProof sym a
- stateIntrinsicTypes :: Getter (SimState p sym ext r f args) (IntrinsicTypes sym)
- stateOverrideFrame :: Lens (SimState p sym ext q (OverrideLang r) ('Just a)) (SimState p sym ext q (OverrideLang r) ('Just a')) (OverrideFrame sym r a) (OverrideFrame sym r a')
- stateGlobals :: Simple Lens (SimState p sym ext q f args) (SymGlobalState sym)
- stateConfiguration :: Getter (SimState p sym ext r f args) Config
GlobalPair
data GlobalPair sym (v :: Type) Source #
A value of some type v
together with a global state.
Constructors
GlobalPair | |
Fields
|
gpValue :: Lens (GlobalPair sym u) (GlobalPair sym v) u v Source #
Access the value stored in the global pair.
gpGlobals :: Simple Lens (GlobalPair sym u) (SymGlobalState sym) Source #
Access the globals stored in the global pair.
TopFrame
type TopFrame sym ext f a = GlobalPair sym (SimFrame sym ext f a) Source #
The currently-executing frame plus the global state associated with it.
crucibleTopFrame :: Lens (TopFrame sym ext (CrucibleLang blocks r) ('Just args)) (TopFrame sym ext (CrucibleLang blocks r) ('Just args')) (CallFrame sym ext blocks r args) (CallFrame sym ext blocks r args') Source #
Access the Crucible call frame inside a TopFrame
.
overrideTopFrame :: Lens (TopFrame sym ext (OverrideLang r) ('Just args)) (TopFrame sym ext (OverrideLang r') ('Just args')) (OverrideFrame sym r args) (OverrideFrame sym r' args') Source #
CrucibleBranchTarget
data CrucibleBranchTarget f (args :: Maybe (Ctx CrucibleType)) where Source #
A CrucibleBranchTarget
identifies a program location that is a
potential join point. Each label is a merge point, and there is
an additional implicit join point at function returns.
Constructors
BlockTarget :: !(BlockID blocks args) -> CrucibleBranchTarget (CrucibleLang blocks r) ('Just args) | |
ReturnTarget :: CrucibleBranchTarget f 'Nothing |
Instances
TestEquality (CrucibleBranchTarget f :: Maybe (Ctx CrucibleType) -> Type) Source # | |
Defined in Lang.Crucible.Simulator.CallFrame Methods testEquality :: forall (a :: k) (b :: k). CrucibleBranchTarget f a -> CrucibleBranchTarget f b -> Maybe (a :~: b) # |
ppBranchTarget :: CrucibleBranchTarget f args -> String Source #
AbortedResult
data AbortedResult sym ext where Source #
An execution path that was prematurely aborted. Note, an abort does not necessarily indicate an error condition. An execution path might abort because it became infeasible (inconsistent path conditions), because the program called an exit primitive, or because of a true error condition (e.g., a failed assertion).
Constructors
AbortedExec :: !AbortExecReason -> !(GlobalPair sym (SimFrame sym ext l args)) -> AbortedResult sym ext | A single aborted execution with the execution state at time of the abort and the reason. |
AbortedExit :: !ExitCode -> AbortedResult sym ext | An aborted execution that was ended by a call to |
AbortedBranch :: !ProgramLoc -> !(Pred sym) -> !(AbortedResult sym ext) -> !(AbortedResult sym ext) -> AbortedResult sym ext | Two separate threads of execution aborted after a symbolic branch, possibly for different reasons. |
data SomeFrame (f :: fk -> argk -> Type) Source #
This represents an execution frame where its frame type and arguments have been hidden.
Constructors
forall l a. SomeFrame !(f l a) |
filterCrucibleFrames :: SomeFrame (SimFrame sym ext) -> Maybe ProgramLoc Source #
Return the program locations of all the Crucible frames.
arFrames :: Simple Traversal (AbortedResult sym ext) (SomeFrame (SimFrame sym ext)) Source #
Iterate over frames in the result.
Partial result
data PartialResult sym ext (v :: Type) Source #
A PartialResult
represents the result of a computation that
might be only partially defined. If the result is a TotalResult
,
the the result is fully defined; however if it is a
PartialResult
, then some of the computation paths that led to
this result aborted for some reason, and the resulting value is
only defined if the associated condition is true.
Constructors
TotalRes !(GlobalPair sym v) | A |
PartialRes !ProgramLoc !(Pred sym) !(GlobalPair sym v) !(AbortedResult sym ext) |
|
type PartialResultFrame sym ext f args = PartialResult sym ext (SimFrame sym ext f args) Source #
partialValue :: Lens (PartialResult sym ext u) (PartialResult sym ext v) (GlobalPair sym u) (GlobalPair sym v) Source #
Access the value stored in the partial result.
Execution states
data ExecResult p sym ext (r :: Type) Source #
Executions that have completed either due to (partial or total) successful completion or by some abort condition.
Constructors
FinishedResult !(SimContext p sym ext) !(PartialResult sym ext r) | At least one execution path resulted in some return result. |
AbortedResult !(SimContext p sym ext) !(AbortedResult sym ext) | All execution paths resulted in an abort condition, and there is no result to return. |
TimeoutResult !(ExecState p sym ext r) | An execution stopped somewhere in the middle of a run because a timeout condition occurred. |
data ExecState p sym ext (rtp :: Type) Source #
An ExecState
represents an intermediate state of executing a
Crucible program. The Crucible simulator executes by transitioning
between these different states until it results in a ResultState
,
indicating the program has completed.
Constructors
ResultState !(ExecResult p sym ext rtp) | The |
forall f a. AbortState !AbortExecReason !(SimState p sym ext rtp f a) | An abort state indicates that the included |
forall f a r. UnwindCallState !(ValueFromValue p sym ext rtp r) !(AbortedResult sym ext) !(SimState p sym ext rtp f a) | An unwind call state occurs when we are about to leave the context of a
function call because of an abort. The included |
forall f a ret. CallState !(ReturnHandler ret p sym ext rtp f a) !(ResolvedCall p sym ext ret) !(SimState p sym ext rtp f a) | A call state is entered when we are about to make a function call to the included call frame, which has already resolved the implementation and arguments to the function. |
forall f a ret. TailCallState !(ValueFromValue p sym ext rtp ret) !(ResolvedCall p sym ext ret) !(SimState p sym ext rtp f a) | A tail-call state is entered when we are about to make a function call to the included call frame, and this is the last action we need to take in the current caller. Note, we can only enter a tail-call state if there are no pending merge points in the caller. This means that sometimes calls that appear to be in tail-call position may nonetheless have to be treated as ordinary calls. |
forall f a ret. ReturnState !FunctionName !(ValueFromValue p sym ext rtp ret) !(RegEntry sym ret) !(SimState p sym ext rtp f a) | A return state is entered after the final return value of a function is computed, and just before we resolve injecting the return value back into the caller's context. |
forall blocks r args. RunningState !(RunningStateInfo blocks args) !(SimState p sym ext rtp (CrucibleLang blocks r) ('Just args)) | A running state indicates the included |
forall f args postdom_args. SymbolicBranchState !(Pred sym) !(PausedFrame p sym ext rtp f) !(PausedFrame p sym ext rtp f) !(CrucibleBranchTarget f postdom_args) !(SimState p sym ext rtp f ('Just args)) | A symbolic branch state indicates that the execution needs to
branch on a non-trivial symbolic condition. The included |
forall f a. ControlTransferState !(ControlResumption p sym ext rtp f) !(SimState p sym ext rtp f ('Just a)) | A control transfer state is entered just prior to invoking a control resumption. Control resumptions are responsible for transitioning from the end of one basic block to another, although there are also some intermediate states related to resolving switch statements. |
forall args ret. OverrideState !(Override p sym ext args ret) !(SimState p sym ext rtp (OverrideLang ret) ('Just args)) | An override state indicates the included |
forall f args. BranchMergeState !(CrucibleBranchTarget f args) !(SimState p sym ext rtp f args) | A branch merge state occurs when the included |
forall ret.rtp ~ RegEntry sym ret => InitialState !(SimContext p sym ext) !(SymGlobalState sym) !(AbortHandler p sym ext (RegEntry sym ret)) !(TypeRepr ret) !(ExecCont p sym ext (RegEntry sym ret) (OverrideLang ret) ('Just EmptyCtx)) | An initial state indicates the state of a simulator just before execution begins.
It specifies all the initial data necessary to begin simulating. The given
|
type ExecCont p sym ext r f a = ReaderT (SimState p sym ext r f a) IO (ExecState p sym ext r) Source #
data RunningStateInfo blocks args Source #
Some additional information attached to a RunningState
that indicates how we got to this running state.
Constructors
RunBlockStart !(BlockID blocks args) | This indicates that we are now in a |
RunBlockEnd !(Some (BlockID blocks)) | This indicates that we are in a |
RunReturnFrom !FunctionName | This indicates that we are in a |
RunPostBranchMerge !(BlockID blocks args) | This indicates that we are now in a |
data ResolvedCall p sym ext ret where Source #
The result of resolving a function call.
Constructors
OverrideCall :: !(Override p sym ext args ret) -> !(OverrideFrame sym ret args) -> ResolvedCall p sym ext ret | A resolved function call to an override. |
CrucibleCall :: !(BlockID blocks args) -> !(CallFrame sym ext blocks ret args) -> ResolvedCall p sym ext ret | A resolved function call to a Crucible function. |
resolvedCallHandle :: ResolvedCall p sym ext ret -> SomeHandle Source #
execResultContext :: ExecResult p sym ext r -> SimContext p sym ext Source #
execStateContext :: ExecState p sym ext r -> SimContext p sym ext Source #
execStateSimState :: ExecState p sym ext r -> Maybe (SomeSimState p sym ext r) Source #
Simulator context trees
Main context data structures
data ValueFromValue p sym ext (ret :: Type) (top_return :: CrucibleType) Source #
This type contains information about the current state of the exploration
of the branching structure of a program. The ValueFromValue
states correspond
to stack call frames in a more traditional simulator environment.
The type parameters have the following meanings:
p
is the personality of the simulator (i.e., custom user state).sym
is the simulator backend being used.ext
specifies what extensions to the Crucible language are enabledret
is the global return type of the entire computationtop_return
is the return type of the top-most call on the stack.
Constructors
forall args caller. VFVCall !(ValueFromFrame p sym ext ret caller) !(SimFrame sym ext caller args) !(ReturnHandler top_return p sym ext ret caller args) |
|
VFVPartial !(ValueFromValue p sym ext ret top_return) !ProgramLoc !(Pred sym) !(AbortedResult sym ext) | A partial value. The predicate indicates what needs to hold to avoid the partiality. The AbortedResult describes what could go wrong if the predicate does not hold. |
ret ~ RegEntry sym top_return => VFVEnd | The top return value, indicating the program termination point. |
Instances
Pretty (ValueFromValue p ext sym root rp) Source # | |
Defined in Lang.Crucible.Simulator.ExecutionTree Methods pretty :: ValueFromValue p ext sym root rp -> Doc ann # prettyList :: [ValueFromValue p ext sym root rp] -> Doc ann # |
data ValueFromFrame p sym ext (ret :: Type) (f :: Type) Source #
This type contains information about the current state of the exploration
of the branching structure of a program. The ValueFromFrame
states correspond
to the structure of symbolic branching that occurs within a single function call.
The type parameters have the following meanings:
p
is the personality of the simulator (i.e., custom user state).sym
is the simulator backend being used.ext
specifies what extensions to the Crucible language are enabledret
is the global return type of the entire execution.f
is the type of the top frame.
Constructors
forall args. VFFBranch !(ValueFromFrame p sym ext ret f) !FrameIdentifier !ProgramLoc !(Pred sym) !(VFFOtherPath p sym ext ret f args) !(CrucibleBranchTarget f args) | We are working on a branch; this could be the first or the second
of both branches (see the |
VFFPartial !(ValueFromFrame p sym ext ret f) !ProgramLoc !(Pred sym) !(AbortedResult sym ext) !PendingPartialMerges | We are on a branch where the other branch was aborted before getting to the merge point. |
VFFEnd !(ValueFromValue p sym ext ret (FrameRetType f)) | When we are finished with this branch we should return from the function. |
Instances
Pretty (ValueFromFrame p ext sym ret f) Source # | |
Defined in Lang.Crucible.Simulator.ExecutionTree Methods pretty :: ValueFromFrame p ext sym ret f -> Doc ann # prettyList :: [ValueFromFrame p ext sym ret f] -> Doc ann # |
data PendingPartialMerges Source #
Data about whether the surrounding context is expecting a merge to occur or not. If the context sill expects a merge, we need to take some actions to indicate that the merge will not occur; otherwise there is no special work to be done.
Constructors
NoNeedToAbort | Don't indicate an abort condition in the context |
NeedsToBeAborted | Indicate an abort condition in the context when we get there again. |
Paused Frames
data ResolvedJump sym blocks Source #
A ResolvedJump
is a block label together with a collection of
actual arguments that are expected by that block. These data
are sufficient to actually transfer control to the named label.
Constructors
forall args. ResolvedJump !(BlockID blocks args) !(RegMap sym args) |
data ControlResumption p sym ext rtp f where Source #
When a path of execution is paused by the symbolic simulator
(while it first explores other paths), a ControlResumption
indicates what actions must later be taken in order to resume
execution of that path.
Constructors
ContinueResumption :: !(ResolvedJump sym blocks) -> ControlResumption p sym ext rtp (CrucibleLang blocks r) | When resuming a paused frame with a |
CheckMergeResumption :: !(ResolvedJump sym blocks) -> ControlResumption p sym ext rtp (CrucibleLang blocks r) | When resuming with a |
SwitchResumption :: ![(Pred sym, ResolvedJump sym blocks)] -> ControlResumption p sym ext rtp (CrucibleLang blocks r) | When resuming a paused frame with a |
OverrideResumption :: ExecCont p sym ext rtp (OverrideLang r) ('Just args) -> !(RegMap sym args) -> ControlResumption p sym ext rtp (OverrideLang r) | When resuming a paused frame with an |
data PausedFrame p sym ext rtp f Source #
A PausedFrame
represents a path of execution that has been postponed
while other paths are explored. It consists of a (potentially partial)
SimFrame
together with some information about how to resume execution
of that frame.
Constructors
forall old_args. PausedFrame | |
Fields
|
Sibling paths
data VFFOtherPath p sym ext ret f args Source #
This describes the state of the sibling path at a symbolic branch point.
A symbolic branch point starts with the sibling in the VFFActivePath
state, which indicates that the sibling path still needs to be executed.
After the first path to be explored has reached the merge point, the
places of the two paths are exchanged, and the completed path is
stored in the VFFCompletePath
state until the second path also
reaches its merge point. The two paths will then be merged,
and execution will continue beyond the merge point.
Constructors
VFFActivePath !(PausedFrame p sym ext ret f) | This corresponds the a path that still needs to be analyzed. |
VFFCompletePath !(Assumptions sym) !(PartialResultFrame sym ext f args) | This is a completed execution path. |
Instances
Pretty (VFFOtherPath ctx sym ext r f a) Source # | |
Defined in Lang.Crucible.Simulator.ExecutionTree Methods pretty :: VFFOtherPath ctx sym ext r f a -> Doc ann # prettyList :: [VFFOtherPath ctx sym ext r f a] -> Doc ann # |
type family FrameRetType (f :: Type) :: CrucibleType where ... Source #
Equations
FrameRetType (CrucibleLang b r) = r | |
FrameRetType (OverrideLang r) = r |
ReturnHandler
data ReturnHandler (ret :: CrucibleType) p sym ext root f args where Source #
A ReturnHandler
indicates what actions to take to resume
executing in a caller's context once a function call has completed and
the return value is available.
The type parameters have the following meanings:
ret
is the type of the return value that is expected.p
is the personality of the simulator (i.e., custom user state).sym
is the simulator backend being used.ext
specifies what extensions to the Crucible language are enabled.root
is the global return type of the entire computation.f
is the stack type of the caller.args
is the type of the local variables in scope prior to the call.
Constructors
ReturnToOverride :: (RegEntry sym ret -> SimState p sym ext root (OverrideLang r) ('Just args) -> IO (ExecState p sym ext root)) -> ReturnHandler ret p sym ext root (OverrideLang r) ('Just args) | The |
ReturnToCrucible :: TypeRepr ret -> StmtSeq ext blocks r (ctx ::> ret) -> ReturnHandler ret p sym ext root (CrucibleLang blocks r) ('Just ctx) | The |
TailReturnToCrucible :: ret ~ r => ReturnHandler ret p sym ext root (CrucibleLang blocks r) ctx | The |
ActiveTree
data ActiveTree p sym ext root (f :: Type) args Source #
An active execution tree contains at least one active execution. The data structure is organized so that the current execution can be accessed rapidly.
Constructors
ActiveTree | |
Fields
|
singletonTree :: TopFrame sym ext f args -> ActiveTree p sym ext (RegEntry sym (FrameRetType f)) f args Source #
Create a tree with a single top frame.
activeFrames :: ActiveTree ctx sym ext root a args -> [SomeFrame (SimFrame sym ext)] Source #
Return the call stack of all active frames, in reverse activation order (i.e., with callees appearing before callers).
actContext :: Lens (ActiveTree p sym ext root f args) (ActiveTree p sym ext root f args) (ValueFromFrame p sym ext root f) (ValueFromFrame p sym ext root f) Source #
Access the calling context of the currently-active frame
actFrame :: Lens (ActiveTree p sym ext root f args) (ActiveTree p sym ext root f args') (TopFrame sym ext f args) (TopFrame sym ext f args') Source #
Access the currently-active frame
Simulator context
Function bindings
data Override p sym ext (args :: Ctx CrucibleType) ret Source #
A definition of a function's semantics, given as a Haskell action.
Constructors
Override | |
Fields
|
data FnState p sym ext (args :: Ctx CrucibleType) (ret :: CrucibleType) Source #
State used to indicate what to do when function is called. A function
may either be defined by writing a Haskell Override
or by giving
a Crucible control-flow graph representation.
Constructors
UseOverride !(Override p sym ext args ret) | |
forall blocks. UseCFG !(CFG ext blocks args ret) !(CFGPostdom blocks) |
newtype FunctionBindings p sym ext Source #
A map from function handles to their semantics.
Constructors
FnBindings | |
Fields
|
Extensions
data ExtensionImpl p sym ext Source #
In order to start executing a simulator, one must provide an implementation of the extension syntax. This includes an evaluator for the added expression forms, and an evaluator for the added statement forms.
Constructors
ExtensionImpl | |
Fields
|
type EvalStmtFunc p sym ext = forall rtp blocks r ctx tp'. StmtExtension ext (RegEntry sym) tp' -> CrucibleState p sym ext rtp blocks r ctx -> IO (RegValue sym tp', CrucibleState p sym ext rtp blocks r ctx) Source #
The type of functions that interpret extension statements. These have access to the main simulator state, and can make fairly arbitrary changes to it.
emptyExtensionImpl :: ExtensionImpl p sym () Source #
Trivial implementation for the "empty" extension, which adds no additional syntactic forms.
SimContext record
type IsSymInterfaceProof sym a = (IsSymInterface sym => a) -> a Source #
data SimContext (personality :: Type) (sym :: Type) (ext :: Type) Source #
Top-level state record for the simulator. The state contained in this record remains persistent across all symbolic simulator actions. In particular, it is not rolled back when the simulator returns previous program points to explore additional paths, etc.
Constructors
SimContext | |
Fields
|
Arguments
:: IsSymBackend sym bak | |
=> bak | Symbolic backend |
-> IntrinsicTypes sym | Implementations of intrinsic types |
-> HandleAllocator | Handle allocator for creating new function handles |
-> Handle | Handle to write output to |
-> FunctionBindings personality sym ext | Initial bindings for function handles |
-> ExtensionImpl personality sym ext | Semantics for extension syntax |
-> personality | Initial value for custom user state |
-> SimContext personality sym ext |
Create a new SimContext
with the given bindings.
withBackend :: SimContext personality sym ext -> (forall bak. IsSymBackend sym bak => bak -> a) -> a Source #
ctxSymInterface :: Getter (SimContext p sym ext) sym Source #
Access the symbolic backend inside a SimContext
.
functionBindings :: Lens' (SimContext p sym ext) (FunctionBindings p sym ext) Source #
A map from function handles to their semantics.
cruciblePersonality :: Lens' (SimContext p sym ext) p Source #
Access the custom user-state inside the SimContext
.
profilingMetrics :: Lens' (SimContext p sym ext) (Map Text (Metric p sym ext)) Source #
SimState
data SimState p sym ext rtp f (args :: Maybe (Ctx CrucibleType)) Source #
A SimState contains the execution context, an error handler, and the current execution tree. It captures the entire state of the symbolic simulator.
Constructors
SimState | |
Fields
|
Instances
MonadState (SimState p sym ext rtp (OverrideLang ret) ('Just args)) (OverrideSim p sym ext rtp args ret) Source # | |
Defined in Lang.Crucible.Simulator.OverrideSim Methods get :: OverrideSim p sym ext rtp args ret (SimState p sym ext rtp (OverrideLang ret) ('Just args)) # put :: SimState p sym ext rtp (OverrideLang ret) ('Just args) -> OverrideSim p sym ext rtp args ret () # state :: (SimState p sym ext rtp (OverrideLang ret) ('Just args) -> (a, SimState p sym ext rtp (OverrideLang ret) ('Just args))) -> OverrideSim p sym ext rtp args ret a # |
data SomeSimState p sym ext rtp Source #
Constructors
forall f args. SomeSimState !(SimState p sym ext rtp f args) |
Arguments
:: SimContext p sym ext | initial |
-> SymGlobalState sym | state of Crucible global variables |
-> AbortHandler p sym ext (RegEntry sym ret) | initial abort handler |
-> TypeRepr ret | |
-> IO (SimState p sym ext (RegEntry sym ret) (OverrideLang ret) ('Just EmptyCtx)) |
Create an initial SimState
stateLocation :: Getter (SimState p sym ext r f a) (Maybe ProgramLoc) Source #
newtype AbortHandler p sym ext rtp Source #
An abort handler indicates to the simulator what actions to take
when an abort occurs. Usually, one should simply use the
defaultAbortHandler
from Lang.Crucible.Simulator, which
unwinds the tree context to the nearest branch point and
correctly resumes simulation. However, for some use cases, it
may be desirable to take additional or alternate actions on abort
events; in which case, the library user may replace the default
abort handler with their own.
Constructors
AH | |
Fields
|
type CrucibleState p sym ext rtp blocks ret args = SimState p sym ext rtp (CrucibleLang blocks ret) ('Just args) Source #
A simulator state that is currently executing Crucible instructions.
Lenses and accessors
stateTree :: Lens (SimState p sym ext rtp f a) (SimState p sym ext rtp g b) (ActiveTree p sym ext rtp f a) (ActiveTree p sym ext rtp g b) Source #
Access the active tree associated with a state.
abortHandler :: Simple Lens (SimState p sym ext r f a) (AbortHandler p sym ext r) Source #
Access the current abort handler of a state.
stateContext :: Simple Lens (SimState p sym ext r f a) (SimContext p sym ext) Source #
Access the SimContext
inside a SimState
stateCrucibleFrame :: Lens (SimState p sym ext rtp (CrucibleLang blocks r) ('Just a)) (SimState p sym ext rtp (CrucibleLang blocks r) ('Just a')) (CallFrame sym ext blocks r a) (CallFrame sym ext blocks r a') Source #
Access the Crucible call frame inside a SimState
stateSymInterface :: Getter (SimState p sym ext r f a) sym Source #
Get the symbolic interface out of a SimState
stateSolverProof :: SimState p sym ext r f args -> forall a. IsSymInterfaceProof sym a Source #
Provide the IsSymInterface
typeclass dictionary from a SimState
stateIntrinsicTypes :: Getter (SimState p sym ext r f args) (IntrinsicTypes sym) Source #
Get the intrinsic type map out of a SimState
stateOverrideFrame :: Lens (SimState p sym ext q (OverrideLang r) ('Just a)) (SimState p sym ext q (OverrideLang r) ('Just a')) (OverrideFrame sym r a) (OverrideFrame sym r a') Source #
Access the override frame inside a SimState
stateGlobals :: Simple Lens (SimState p sym ext q f args) (SymGlobalState sym) Source #
Access the globals inside a SimState