Skip to content

Commit

Permalink
Update saw-script and submodules to use prettyprinter package.
Browse files Browse the repository at this point in the history
This commit includes the following submodule PRs:
- GaloisInc/what4#77
- GaloisInc/crucible#586
- GaloisInc/macaw#178
- GaloisInc/elf-edit#20
  • Loading branch information
Brian Huffman committed Dec 3, 2020
1 parent 14bab8f commit f1ae175
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 33 deletions.
2 changes: 1 addition & 1 deletion deps/crucible
Submodule crucible updated 122 files
2 changes: 1 addition & 1 deletion deps/macaw
Submodule macaw updated 47 files
+1 −1 base/macaw-base.cabal
+44 −33 base/src/Data/Macaw/AbsDomain/AbsState.hs
+9 −8 base/src/Data/Macaw/AbsDomain/JumpBounds.hs
+31 −30 base/src/Data/Macaw/AbsDomain/StackAnalysis.hs
+8 −7 base/src/Data/Macaw/AbsDomain/StridedInterval.hs
+23 −21 base/src/Data/Macaw/Analysis/RegisterUse.hs
+9 −9 base/src/Data/Macaw/CFG/App.hs
+6 −5 base/src/Data/Macaw/CFG/AssignRhs.hs
+13 −9 base/src/Data/Macaw/CFG/Block.hs
+59 −60 base/src/Data/Macaw/CFG/Core.hs
+8 −5 base/src/Data/Macaw/DebugLogging.hs
+1 −1 base/src/Data/Macaw/Discovery.hs
+51 −38 base/src/Data/Macaw/Discovery/State.hs
+43 −41 base/src/Data/Macaw/Dwarf.hs
+11 −10 base/src/Data/Macaw/Memory.hs
+8 −7 base/src/Data/Macaw/Types.hs
+6 −6 base/src/Data/Macaw/Utils/Pretty.hs
+2 −2 cabal.project.dist.ghc-8.10.2.freeze
+2 −2 cabal.project.dist.ghc-8.6.5.freeze
+2 −3 cabal.project.dist.ghc-8.8.4.freeze
+1 −1 deps/asl-translator
+1 −1 deps/crucible
+1 −1 deps/elf-edit
+1 −1 deps/macaw-loader
+1 −1 deps/what4
+2 −2 macaw-aarch32/macaw-aarch32.cabal
+2 −2 macaw-aarch32/src/Data/Macaw/ARM/ARMReg.hs
+11 −10 macaw-aarch32/src/Data/Macaw/ARM/Arch.hs
+3 −3 macaw-aarch32/src/Data/Macaw/ARM/BinaryFormat/ELF.hs
+2 −2 macaw-aarch32/tests/ARMTests.hs
+1 −1 macaw-ppc/macaw-ppc.cabal
+40 −39 macaw-ppc/src/Data/Macaw/PPC/Arch.hs
+1 −1 macaw-ppc/src/Data/Macaw/PPC/Eval.hs
+2 −2 macaw-ppc/src/Data/Macaw/PPC/PPCReg.hs
+0 −1 macaw-semmc/macaw-semmc.cabal
+0 −2 refinement/macaw-refinement.cabal
+2 −3 refinement/src/Data/Macaw/Refinement/Path.hs
+1 −1 symbolic/macaw-symbolic.cabal
+14 −14 symbolic/src/Data/Macaw/Symbolic/CrucGen.hs
+1 −1 x86/macaw-x86.cabal
+2 −2 x86/src/Data/Macaw/X86.hs
+16 −15 x86/src/Data/Macaw/X86/ArchTypes.hs
+2 −2 x86/src/Data/Macaw/X86/Generator.hs
+7 −6 x86/src/Data/Macaw/X86/Monad.hs
+2 −2 x86/src/Data/Macaw/X86/X86Reg.hs
+1 −1 x86_symbolic/macaw-x86-symbolic.cabal
+1 −1 x86_symbolic/src/Data/Macaw/X86/Crucible.hs
25 changes: 14 additions & 11 deletions src/SAWScript/Crucible/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,33 @@ import qualified What4.ProgramLoc as W4 (plSourceLoc)

import System.Directory (createDirectoryIfMissing)
import System.FilePath ((</>))
import qualified Text.PrettyPrint.ANSI.Leijen as PP hiding ((<$>), (<>))
import qualified Prettyprinter as PP

-- | The symbolic backend we use for SAW verification
type Sym = SAWCoreBackend Nonce.GlobalNonceGenerator Yices.Connection (W4.Flags W4.FloatReal)

ppAbortedResult :: (forall l args. GlobalPair Sym (SimFrame Sym ext l args) -> PP.Doc)
ppAbortedResult :: (forall l args. GlobalPair Sym (SimFrame Sym ext l args) -> PP.Doc ann)
-> AbortedResult Sym ext
-> PP.Doc
-> PP.Doc ann
ppAbortedResult _ (AbortedExec InfeasibleBranch _) =
PP.text "Infeasible branch"
PP.pretty "Infeasible branch"
ppAbortedResult ppGP (AbortedExec abt gp) = do
ppAbortExecReason abt PP.<$$> ppGP gp
PP.vcat
[ ppAbortExecReason abt
, ppGP gp
]
ppAbortedResult ppGP (AbortedBranch loc _predicate trueBranch falseBranch) =
PP.vcat
[ PP.text "Both branches aborted after a symbolic branch."
, PP.text "Location of control-flow branching:"
, PP.indent 2 (PP.text (show (W4.plSourceLoc loc)))
, PP.text "Message from the true branch:"
[ PP.pretty "Both branches aborted after a symbolic branch."
, PP.pretty "Location of control-flow branching:"
, PP.indent 2 (PP.pretty (W4.plSourceLoc loc))
, PP.pretty "Message from the true branch:"
, PP.indent 2 (ppAbortedResult ppGP trueBranch)
, PP.text "Message from the false branch:"
, PP.pretty "Message from the false branch:"
, PP.indent 2 (ppAbortedResult ppGP falseBranch)
]
ppAbortedResult _ (AbortedExit ec) =
PP.text "Branch exited:" PP.<+> PP.text (show ec)
PP.pretty "Branch exited:" PP.<+> PP.viaShow ec

setupProfiling ::
IsSymInterface sym =>
Expand Down
5 changes: 2 additions & 3 deletions src/SAWScript/Crucible/JVM/Builtins.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ import qualified Data.Set as Set
import qualified Data.Sequence as Seq
import qualified Data.Vector as V
import Data.Void (absurd)
import Prettyprinter
import System.IO

import Text.PrettyPrint.ANSI.Leijen hiding ((<$>), (<>))

-- jvm-verifier
-- TODO: transition to Lang.JVM.Codebase from crucible-jvm
import qualified Verifier.Java.Codebase as CB
Expand Down Expand Up @@ -130,7 +129,7 @@ type SetupCondition = MS.SetupCondition CJ.JVM
-- TODO: something useful with the global pair?
ppAbortedResult :: JVMCrucibleContext
-> Crucible.AbortedResult Sym a
-> Doc
-> Doc ann
ppAbortedResult _cc = Common.ppAbortedResult (\_gp -> mempty)

-- FIXME: We need a better way to identify a set of class names to
Expand Down
11 changes: 5 additions & 6 deletions src/SAWScript/Crucible/LLVM/Builtins.hs
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,10 @@ import Data.Sequence (Seq)
import qualified Data.Sequence as Seq
import qualified Data.Text as Text
import qualified Data.Vector as V
import Prettyprinter
import System.IO
import qualified Text.LLVM.AST as L
import qualified Text.LLVM.PP as L (ppType, ppSymbol)
import Text.PrettyPrint.ANSI.Leijen hiding ((<$>), (<>))
import qualified Text.PrettyPrint.ANSI.Leijen as PP
import Text.URI
import qualified Control.Monad.Trans.Maybe as MaybeT

Expand Down Expand Up @@ -917,17 +916,17 @@ doAlloc cc i (LLVMAllocSpec mut _memTy alignment sz loc fresh)

ppAbortedResult :: LLVMCrucibleContext arch
-> Crucible.AbortedResult Sym a
-> Doc
-> Doc ann
ppAbortedResult cc = Common.ppAbortedResult (ppGlobalPair cc)

ppGlobalPair :: LLVMCrucibleContext arch
-> Crucible.GlobalPair Sym a
-> Doc
-> Doc ann
ppGlobalPair cc gp =
let mvar = Crucible.llvmMemVar (ccLLVMContext cc)
globals = gp ^. Crucible.gpGlobals in
case Crucible.lookupGlobal mvar globals of
Nothing -> text "LLVM Memory global variable not initialized"
Nothing -> "LLVM Memory global variable not initialized"
Just mem -> Crucible.ppMem (Crucible.memImplHeap mem)


Expand Down Expand Up @@ -1263,7 +1262,7 @@ setupLLVMCrucibleContext bic opts pathSat lm action =
[ W4.opt
enableSMTArrayMemoryModel
(W4.ConcreteBool smt_array_memory_model_enabled)
(PP.text "Enable SMT array memory model")
("Enable SMT array memory model" :: Text.Text)
]
cfg

Expand Down
4 changes: 0 additions & 4 deletions src/SAWScript/Crucible/LLVM/MethodSpecIR.hs
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,6 @@ type instance MS.HasGhostState (CL.LLVM _) = 'True
type instance MS.TypeName (CL.LLVM arch) = CL.Ident
type instance MS.ExtType (CL.LLVM arch) = CL.MemType

-- TODO: remove when crucible switches to prettyprinter
instance PPL.Pretty CL.MemType where
pretty = PPL.viaShow . CL.ppMemType

--------------------------------------------------------------------------------
-- *** LLVMMethodId

Expand Down
7 changes: 2 additions & 5 deletions src/SAWScript/Crucible/LLVM/Override.hs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ import Data.Text (Text, pack)
import qualified Data.Vector as V
import GHC.Generics (Generic)
import Numeric.Natural
import qualified Text.PrettyPrint.ANSI.Leijen as PPWL
import qualified Prettyprinter as PP

import qualified Text.LLVM.AST as L
Expand Down Expand Up @@ -186,8 +185,7 @@ mkStructuralMismatch _opts cc _sc spec llvmval setupval memTy =
nameEnv = MS.csTypeNames spec
maybeTy = typeOfSetupValue cc tyEnv nameEnv setupval
in pure $ StructuralMismatch
-- TODO: remove 'viaShow' when crucible switches to prettyprinter
(PP.viaShow (PPWL.pretty llvmval))
(PP.pretty llvmval)
(MS.ppSetupValue setupval)
maybeTy
memTy
Expand All @@ -209,8 +207,7 @@ ppPointsToAsLLVMVal opts cc sc spec (LLVMPointsTo loc cond ptr val) = do
, "Pointee:" PP.<+> pretty2
, maybe PP.emptyDoc (\tt -> "Condition:" PP.<+> MS.ppTypedTerm tt) cond
, "Assertion made at:" PP.<+>
-- TODO: replace 'viaShow' with 'pretty' when what4 switches to prettyprinter
PP.viaShow (W4.plSourceLoc loc)
PP.pretty (W4.plSourceLoc loc)
]

-- | Create an error stating that the 'LLVMVal' was not equal to the 'SetupValue'
Expand Down

0 comments on commit f1ae175

Please sign in to comment.