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
Update PPInfo while exporting
  • Loading branch information
glguy committed Aug 23, 2021
commit 51665d7d4ccf84ac9b09a81491889ac1f0fc802f
12 changes: 10 additions & 2 deletions heapster-saw/src/Verifier/SAW/Heapster/GenMonad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ module Verifier.SAW.Heapster.GenMonad (
-- * Core definitions
GenStateContT(..), (>>>=), (>>>),
-- * Continuation operations
gcaptureCC, gmapRet, gabortM, gparallel, gopenBinding,
gcaptureCC, gmapRet, gabortM, gparallel, startBinding, gopenBinding,
-- * State operations
gmodify,
-- * Transformations
addReader,
) where

import Data.Binding.Hobbits ( nuMultiWithElim1, Mb, Name, RAssign )
import Data.Binding.Hobbits ( nuMulti, nuMultiWithElim1, Mb, Name, RAssign )
import Control.Monad.State ( ap, MonadState(get, put) )
import Control.Monad.Trans.Class ( MonadTrans(lift) )
import Control.Monad.Trans.Reader
import Data.Proxy

-- | The generalized state-continuation monad
newtype GenStateContT s1 r1 s2 r2 m a = GenStateContT {
Expand Down Expand Up @@ -107,6 +108,13 @@ gopenBinding f_ret mb_a =
f_ret $ flip nuMultiWithElim1 mb_a $ \names a ->
k (names, a)

-- | Name-binding in the generalized continuation monad (FIXME: explain)
startBinding ::
RAssign Proxy ctx ->
(Mb ctx (m r1) -> m r2) ->
GenStateContT s r1 s r2 m (RAssign Name ctx)
startBinding tps f_ret = gcaptureCC (f_ret . nuMulti tps)

addReader :: GenStateContT s1 r1 s2 r2 m a -> GenStateContT s1 r1 s2 r2 (ReaderT e m) a
addReader (GenStateContT m) =
GenStateContT \s2 k ->
Expand Down
37 changes: 23 additions & 14 deletions heapster-saw/src/Verifier/SAW/Heapster/IDESupport.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ import Control.Monad.Reader
( MonadReader (ask, local),
ReaderT (..),
)
import Control.Monad.Writer
( MonadWriter (tell),
Writer,
execWriter,
)
import Data.Aeson (ToJSON, Value, encodeFile)
import Data.Binding.Hobbits
( Liftable (..),
Expand All @@ -33,6 +28,7 @@ import Data.Binding.Hobbits
nuMP,
nuMultiWithElim1,
unsafeMbTypeRepr,
Name,
)
import Data.Maybe (catMaybes, listToMaybe, mapMaybe)
import Data.Parameterized.Some (Some (..))
Expand All @@ -52,10 +48,11 @@ import Verifier.SAW.Heapster.Implication
import Verifier.SAW.Heapster.Permissions
import Verifier.SAW.Heapster.TypedCrucible
import Verifier.SAW.Heapster.JSONExport(ppToJson)
import Data.Aeson (Value)
import Data.Type.RList (mapRAssign)
import Data.Functor.Constant
import Control.Monad.Writer
import Data.Binding.Hobbits.NameMap (NameMap)
import qualified Data.Binding.Hobbits.NameMap as NameMap

-- | The entry point for dumping a Heapster environment to a file for IDE
-- consumption.
Expand Down Expand Up @@ -140,12 +137,24 @@ instance (PermCheckExtC ext)
let callers = callerIDs $ typedEntryCallers te
(ppi, _, fname) <- ask
let loc' = snd (ppLoc loc)
let f ::
(Pair (Constant String) ValuePerm) x ->
Constant (String, String, Value) x
f (Pair (Constant name) vp) = Constant (name, permPrettyString ppi vp, ppToJson ppi vp)
let inputs = mbLift
$ fmap (RL.toList . mapRAssign f . zipRAssign (typedEntryNames te)) (typedEntryPermsIn te)

let insertNames ::
RL.RAssign Name (x :: RList CrucibleType) ->
RL.RAssign (Constant String) x ->
NameMap (StringF :: CrucibleType -> *)->
NameMap (StringF :: CrucibleType -> *)
insertNames RL.MNil RL.MNil m = m
insertNames (ns RL.:>: n) (xs RL.:>: Constant name) m =
insertNames ns xs (NameMap.insert n (StringF name) m)
inputs = mbLift
$ flip nuMultiWithElim1 (typedEntryPermsIn te)
$ \ns body ->
let ppi' = ppi { ppExprNames = insertNames ns (typedEntryNames te) (ppExprNames ppi) }
f ::
(Pair (Constant String) ValuePerm) x ->
Constant (String, String, Value) x
f (Pair (Constant name) vp) = Constant (name, permPrettyString ppi' vp, ppToJson ppi' vp)
in RL.toList (mapRAssign f (zipRAssign (typedEntryNames te) body))
tell [LogEntry loc' entryId callers fname inputs]

mkLogEntryID :: TypedEntryID blocks args -> LogEntryID
Expand Down Expand Up @@ -212,8 +221,8 @@ mbExtractLogEntries
mbExtractLogEntries mb_a =
ReaderT $ \(ppi, loc, fname) ->
tell $ mbLift $ flip nuMultiWithElim1 mb_a $ \ns x ->
execWriter $ runReaderT (extractLogEntries x)
(ppInfoAddExprNames "x" ns ppi, loc, fname)
let ppi' = ppInfoAddExprNames "x" ns ppi in
execWriter $ runReaderT (extractLogEntries x) (ppi', loc, fname)

typedStmtOutCtx :: TypedStmt ext rets ps_in ps_next -> CruCtx rets
typedStmtOutCtx = error "FIXME: write typedStmtOutCtx"
Expand Down
5 changes: 2 additions & 3 deletions heapster-saw/src/Verifier/SAW/Heapster/TypedCrucible.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2532,9 +2532,8 @@ emitStmt ::
StmtPermCheckM ext cblocks blocks tops ret ps_out ps_in
(RAssign Name rets)
emitStmt tps names loc stmt =
gopenBinding
((TypedConsStmt loc stmt (cruCtxProxies tps) <$>) . strongMbM)
(mbPure (cruCtxProxies tps) ()) >>>= \(ns, ()) ->
let pxys = cruCtxProxies tps in
startBinding pxys (fmap (TypedConsStmt loc stmt pxys) . strongMbM) >>>= \ns ->
setVarTypes Nothing names ns tps >>>
gmodify (modifySTCurPerms (applyTypedStmt stmt ns)) >>>
pure ns
Expand Down