Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

heapster-saw: Export block entry-point and implication error information for IDE ingestion #1442

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
3a9c13b
add basic IDE logging, start error cleanup
Jun 28, 2021
bfd0566
clean up additional implication errors
Jun 28, 2021
49f72e4
add structure to stmt fail in line with impl fail
Jun 29, 2021
716a2e1
redesign error message types, pipe through to log
Jul 7, 2021
9283f0e
fix default heapster environments missing ioref
Jul 8, 2021
1e427a4
carry more information through on most common implication error
Jul 9, 2021
059ab7b
Merge branch 'heapster-ide-info' of github.com:GaloisInc/saw-script i…
Jul 9, 2021
6fef67a
remove Some from error constructor
Jul 9, 2021
f3b76bb
Merge branch 'master' into heapster-ide-info
glguy Jul 26, 2021
e2c9cd6
Export valueperms in full json detail
glguy Jul 28, 2021
b59adb9
Avoid generating orphan ToJSON instances and using Given
glguy Jul 28, 2021
65ae7dd
refine jsonexport instances
glguy Jul 28, 2021
931d802
Document JSONExport
glguy Jul 28, 2021
2ad2225
Remove need for passing undefined
glguy Jul 30, 2021
ce3313b
JSONExport support for PermImpls
glguy Jul 30, 2021
df114c1
export entrypoint and caller ID information
Aug 12, 2021
8875708
cleanup imports, 80 char columns
Aug 12, 2021
5f12cc4
heapster: export function name for IDE
Aug 12, 2021
cb7c57c
heapster-saw: LogEntry with names and structure
glguy Aug 19, 2021
e768f1f
Incorporate names from bindings in JsonExport
glguy Aug 20, 2021
f60affd
Merge remote-tracking branch 'origin/master' into heapster-ide-info
glguy Aug 20, 2021
51665d7
Update PPInfo while exporting
glguy Aug 23, 2021
dc70b93
checkpoint
glguy Aug 27, 2021
f0c7747
Use types to generate names for pretty permissions where possible
glguy Aug 27, 2021
e634949
Checkpoint
glguy Aug 28, 2021
b284fc4
Checkpoint
glguy Aug 28, 2021
491c38f
Update cabal file
glguy Aug 30, 2021
4454faf
Merge branch 'master' into glguy/heapster-ide-info
Aug 30, 2021
3d0ae00
user the error prefix when logging errors for IDE
Aug 31, 2021
4e4cc4b
revert commented error prefix code
Aug 31, 2021
f60e26b
Change Mb' to NMb
glguy Aug 31, 2021
f34cabb
Merge branch 'glguy/heapster-ide-info' of github.com:GaloisInc/saw-sc…
glguy Aug 31, 2021
24d7122
Comments and more consistent naming
glguy Aug 31, 2021
2ac547b
Merge branch 'master' of github.com:GaloisInc/saw-script into heapste…
glguy Aug 31, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add structure to stmt fail in line with impl fail
  • Loading branch information
Karl Smeltzer committed Jun 29, 2021
commit 49f72e4b9063316a658b03e6186d7632b78533c8
114 changes: 57 additions & 57 deletions heapster-saw/src/Verifier/SAW/Heapster/Implication.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2714,7 +2714,7 @@ partialSubstForceM mb_e caller =
case partialSubst psubst mb_e of
Just e -> pure e
Nothing ->
implFailM' $ PartialSubstitutionError caller mb_e
implFailM $ PartialSubstitutionError caller mb_e

-- | Modify the current partial substitution
modifyPSubst :: (PartialSubst vars -> PartialSubst vars) ->
Expand Down Expand Up @@ -2780,7 +2780,7 @@ implRecFlagCaseM m1 m2 =
implSetRecRecurseRightM :: NuMatchingAny1 r => ImplM vars s r ps ps ()
implSetRecRecurseRightM =
use implStateRecRecurseFlag >>= \case
RecLeft -> implFailM' MuUnfoldError
RecLeft -> implFailM MuUnfoldError
_ -> implStateRecRecurseFlag .= RecRight

-- | Set the recursive recursion flag to indicate recursion on the left, or fail
Expand All @@ -2789,7 +2789,7 @@ implSetRecRecurseLeftM :: NuMatchingAny1 r => ImplM vars s r ps ps ()
implSetRecRecurseLeftM =
use implStateRecRecurseFlag >>= \case
RecRight ->
implFailM' MuUnfoldError
implFailM MuUnfoldError
_ -> implStateRecRecurseFlag .= RecLeft

-- | Look up the 'NamedPerm' structure for a named permssion
Expand Down Expand Up @@ -3208,7 +3208,7 @@ implElimLLVMBlockToEq x bp =
pure y

-- | Try to prove a proposition about bitvectors dynamically, failing as in
-- 'implFailM' if the proposition does not hold
-- 'implFailM if the proposition does not hold
implTryProveBVProp :: (1 <= w, KnownNat w, NuMatchingAny1 r) =>
ExprVar (LLVMPointerType w) -> BVProp w ->
ImplM vars s r (ps :> LLVMPointerType w) ps ()
Expand Down Expand Up @@ -3663,7 +3663,7 @@ implEndLifetimeM :: NuMatchingAny1 r => Proxy ps -> ExprVar LifetimeType ->
implEndLifetimeM ps l ps_in ps_out@(lownedPermsToDistPerms -> Just dps_out) =
implSimplM ps (SImpl_EndLifetime l ps_in ps_out) >>>
recombinePermsPartial ps dps_out
implEndLifetimeM _ _ _ _ = implFailM' $ LifetimeError EndLifetimeError
implEndLifetimeM _ _ _ _ = implFailM $ LifetimeError EndLifetimeError


-- | Save a permission for later by splitting it into part that is in the
Expand Down Expand Up @@ -3959,7 +3959,7 @@ implElimLLVMBlock x bp@(LLVMBlockPerm { llvmBlockShape =
PExpr_ExShape _mb_sh }) =
implSimplM Proxy (SImpl_ElimLLVMBlockEx x bp)
implElimLLVMBlock _ bp =
implFailM' $ MemBlockError bp
implFailM $ MemBlockError bp

-- | Eliminate a @memblock@ permission on the top of the stack and recombine it,
-- if this is possible; otherwise fail
Expand Down Expand Up @@ -3988,7 +3988,7 @@ getLifetimeCurrentPerms (PExpr_Var l) =
case some_cur_perms of
Some cur_perms -> pure $ Some $ CurrentTransPerms cur_perms l
_ ->
implFailM' $ LifetimeError (LifetimeCurrentError l)
implFailM $ LifetimeError (LifetimeCurrentError l)

-- | Prove the permissions represented by a 'LifetimeCurrentPerms'
proveLifetimeCurrent :: NuMatchingAny1 r => LifetimeCurrentPerms ps_l ->
Expand Down Expand Up @@ -4234,7 +4234,7 @@ instance ProveEq (LLVMFramePerm w) where
do eqp1 <- proveEq e mb_e
eqp2 <- proveEq fperms mb_fperms
pure (liftA2 (\x y -> (x,i):y) eqp1 eqp2)
proveEq perms mb = implFailM' $ EqualityProofError perms mb
proveEq perms mb = implFailM $ EqualityProofError perms mb

instance ProveEq (LLVMBlockPerm w) where
proveEq bp mb_bp =
Expand Down Expand Up @@ -4308,15 +4308,15 @@ proveEqH psubst e mb_e = case (e, mbMatch mb_e) of
Just _ -> proveEqH psubst e mb_e
Nothing -> getVarEqPerm y >>= \case
Just _ -> proveEqH psubst e mb_e
Nothing -> implFailM' $ EqualityProofError e mb_e
Nothing -> implFailM $ EqualityProofError e mb_e

-- To prove x=e, try to see if x:eq(e') and proceed by transitivity
(PExpr_Var x, _) ->
getVarEqPerm x >>= \case
Just e' ->
proveEq e' mb_e >>= \eqp2 ->
pure (someEqProofTrans (someEqProofPerm x e' True) eqp2)
Nothing -> implFailM' $ EqualityProofError e mb_e
Nothing -> implFailM $ EqualityProofError e mb_e

-- To prove e=x, try to see if x:eq(e') and proceed by transitivity
(_, [nuMP| PExpr_Var z |])
Expand All @@ -4325,7 +4325,7 @@ proveEqH psubst e mb_e = case (e, mbMatch mb_e) of
Just e' ->
proveEq e (fmap (const e') mb_e) >>= \eqp ->
pure (someEqProofTrans eqp (someEqProofPerm x e' False))
Nothing -> implFailM' $ EqualityProofError e mb_e
Nothing -> implFailM $ EqualityProofError e mb_e

-- FIXME: if proving word(e1)=word(e2) for ground e2, we could add an assertion
-- that e1=e2 using a BVProp_Eq
Expand All @@ -4345,7 +4345,7 @@ proveEqH psubst e mb_e = case (e, mbMatch mb_e) of
-- FIXME: add cases to prove struct(es1)=struct(es2)

-- Otherwise give up!
_ -> implFailM' $ EqualityProofError e mb_e
_ -> implFailM $ EqualityProofError e mb_e


-- | Build a proof on the top of the stack that @x:eq(e)@. Assume that all @x@
Expand Down Expand Up @@ -5005,7 +5005,7 @@ proveVarLLVMArray_ArrayStep x ps ap i ap_lhs

-- Otherwise we don't know what to do so we fail
proveVarLLVMArray_ArrayStep _x _ps _ap _i _ap_lhs =
implFailM' ArrayStepError
implFailM ArrayStepError


----------------------------------------------------------------------
Expand Down Expand Up @@ -5950,7 +5950,7 @@ proveVarAtomicImpl x ps mb_p = case mbMatch mb_p of
lownedPermsToDistPerms ps_inR', lownedPermsToDistPerms ps_outR') of
(Just dps_inL, Just dps_outL, Just dps_inR, Just dps_outR) ->
pure (dps_inL, dps_outL, dps_inR, dps_outR)
_ -> implFailM' $ LifetimeError ImplicationLifetimeError)
_ -> implFailM $ LifetimeError ImplicationLifetimeError)
>>>= \(dps_inL, dps_outL, dps_inR, dps_outR) ->
localProveVars (RL.append ps1 dps_inR) dps_inL >>>= \impl_in ->
localProveVars (RL.append ps2 dps_outL) dps_outR >>>= \impl_out ->
Expand Down Expand Up @@ -6083,7 +6083,7 @@ proveVarConjImpl x ps mb_ps =
mb_ps' mb_p) "proveVarConjImpl") >>>= \(ps',p) ->
implInsertConjM x p ps' i
Nothing ->
implFailM' $ InsufficientVariablesError (fmap ValPerm_Conj mb_ps)
implFailM $ InsufficientVariablesError (fmap ValPerm_Conj mb_ps)


----------------------------------------------------------------------
Expand Down Expand Up @@ -6403,11 +6403,11 @@ proveExVarImpl _ mb_x mb_p@(mbMatch -> [nuMP| ValPerm_Conj [Perm_LLVMFrame _] |]
getVarVarM memb >>>= \n' ->
proveVarImplInt n' mb_p >>> pure n'
Nothing ->
implFailM' NoFrameInScopeError
implFailM NoFrameInScopeError

-- Otherwise we fail
proveExVarImpl _ mb_x mb_p =
implFailM' $ ExistentialError mb_x mb_p
implFailM $ ExistentialError mb_x mb_p


----------------------------------------------------------------------
Expand Down Expand Up @@ -6561,7 +6561,7 @@ proveVarsImplAppendInt ps =
proveVarsImplAppendInt (mbMap2 appendDistPerms ps1 ps2) >>>
implMoveUpM cur_perms (mbDistPermsToProxies ps1) x (mbDistPermsToProxies ps2)
_ ->
implFailM' $ InsufficientVariablesError ps
implFailM $ InsufficientVariablesError ps

-- | Prove a list of existentially-quantified distinguished permissions and put
-- those proofs onto the stack. This is the same as 'proveVarsImplAppendInt'
Expand Down Expand Up @@ -6682,57 +6682,57 @@ data LifetimeErrorType where
LifetimeCurrentError :: PermPretty p => p -> LifetimeErrorType

class ErrorPretty a where
ppErrorFn :: a -> PPInfo -> String
ppError :: a -> PPInfo -> String

instance ErrorPretty ImplError where
ppErrorFn (FatalError f) pp = renderDoc $ f pp
ppErrorFn NoFrameInScopeError _ = "No LLVM frame in scope"
ppErrorFn ArrayStepError _ = "Error proving array permissions"
ppErrorFn MuUnfoldError _ =
"Tried to unfold a mu on the left after unfolding on the right"
ppErrorFn FunctionPermissionError _ =
"Could not find function permission"
ppErrorFn (PartialSubstitutionError caller mb_e) pp = renderDoc $
sep [pretty ("Incomplete susbtitution in " ++ caller ++ " for: "),
permPretty pp mb_e]
ppErrorFn (LifetimeError EndLifetimeError) _ =
"implEndLifetimeM: lownedPermsToDistPerms"
ppErrorFn (LifetimeError ImplicationLifetimeError) _ =
"proveVarAtomicImpl: lownedPermsToDistPerms"
ppErrorFn (LifetimeError (LifetimeCurrentError l)) pp = renderDoc $
pretty "Could not prove lifetime is current:" <+>
permPretty pp l
ppErrorFn (MemBlockError bp) pp = renderDoc $
pretty "Could not eliminate permission" <+>
permPretty pp (Perm_LLVMBlock bp)
ppErrorFn (EqualityProofError e mb_e) pp = renderDoc $
sep [pretty "proveEq" <> colon <+> pretty "Could not prove",
sep [permPretty pp e <+>
pretty "=" <+> permPretty pp mb_e]]
ppErrorFn (InsufficientVariablesError ps) pp = renderDoc $
sep [PP.fillSep [PP.pretty
"Could not determine enough variables to prove permissions:",
permPretty pp ps]]
ppErrorFn (ExistentialError mb_x mb_p) pp = renderDoc $
pretty "proveExVarImpl: existential variable" <+>
permPretty pp mb_x <+>
pretty "not resolved when trying to prove:" <> softline <>
permPretty pp mb_p
ppErrorFn (ImplVariableError f) pp = renderDoc $ f pp
ppError (FatalError f) pp = renderDoc $ f pp
ppError NoFrameInScopeError _ = "No LLVM frame in scope"
ppError ArrayStepError _ = "Error proving array permissions"
ppError MuUnfoldError _ =
"Tried to unfold a mu on the left after unfolding on the right"
ppError FunctionPermissionError _ =
"Could not find function permission"
ppError (PartialSubstitutionError caller mb_e) pp = renderDoc $
sep [pretty ("Incomplete susbtitution in " ++ caller ++ " for: "),
permPretty pp mb_e]
ppError (LifetimeError EndLifetimeError) _ =
"implEndLifetimeM: lownedPermsToDistPerms"
ppError (LifetimeError ImplicationLifetimeError) _ =
"proveVarAtomicImpl: lownedPermsToDistPerms"
ppError (LifetimeError (LifetimeCurrentError l)) pp = renderDoc $
pretty "Could not prove lifetime is current:" <+>
permPretty pp l
ppError (MemBlockError bp) pp = renderDoc $
pretty "Could not eliminate permission" <+>
permPretty pp (Perm_LLVMBlock bp)
ppError (EqualityProofError e mb_e) pp = renderDoc $
sep [pretty "proveEq" <> colon <+> pretty "Could not prove",
sep [permPretty pp e <+>
pretty "=" <+> permPretty pp mb_e]]
ppError (InsufficientVariablesError ps) pp = renderDoc $
sep [PP.fillSep [PP.pretty
"Could not determine enough variables to prove permissions:",
permPretty pp ps]]
ppError (ExistentialError mb_x mb_p) pp = renderDoc $
pretty "proveExVarImpl: existential variable" <+>
permPretty pp mb_x <+>
pretty "not resolved when trying to prove:" <> softline <>
permPretty pp mb_p
ppError (ImplVariableError f) pp = renderDoc $ f pp

-- | Terminate the current proof branch with a failure
implFailM' :: NuMatchingAny1 r => ImplError -> ImplM vars s r ps_any ps a
implFailM' err =
implFailM :: NuMatchingAny1 r => ImplError -> ImplM vars s r ps_any ps a
implFailM err =
use implStateFailPrefix >>>= \prefix ->
uses implStatePPInfo (ppErrorFn err) >>>= \doc ->
uses implStatePPInfo (ppError err) >>>= \doc ->
let msg = prefix <> doc
in implTraceM (const $ pretty msg) >>> implApplyImpl1 (Impl1_Fail msg) MNil

-- | Terminate the current proof branch with a failure proving @x:p -o mb_p@
implFailVarM :: NuMatchingAny1 r => String -> ExprVar tp -> ValuePerm tp ->
Mb vars (ValuePerm tp) -> ImplM vars s r ps_any ps a
implFailVarM f x p mb_p =
implFailM' $ ImplVariableError (\i ->
implFailM $ ImplVariableError (\i ->
sep [pretty f <> colon <+> pretty "Could not prove",
ppImpl i x p mb_p])

Expand Down
Loading