Skip to content

Commit

Permalink
crucible-cli: Library for sharing code between Crucible CLI frontends (
Browse files Browse the repository at this point in the history
…#1123)

* crucible-cli: Library for sharing code between Crucible CLI frontends

Previously, `crucible-syntax` had some code for setting up and executing the
Crucible symbolic simulator. This functionality is very useful for testing and
interactive experimentation via a CLI, but is not necessary for most library
clients of `crucible-syntax`. Furthermore, creating additional CLI frontends
entailed copy-pasting a lot of `optparse-applicative`-related code from
`crucible-syntax`'s' `crucibler` executable. Now, both these issues are
addressed by factoring this code into a separate `crucible-cli` package.

* crucible-llvm-cli: CLI for executing crucible-llvm CFGs

* crucible-{,llvm-}cli: Fix hlint lints, trailing whitespace

* ci: Fix executable name

* crucible-cli: Haddocks

* crucible-llvm-cli: Haddocks

* crucible-llvm-cli: Fix build on GHC 8.10.7 by enabling GADTs
  • Loading branch information
langston-barrett authored Nov 8, 2023
1 parent 00f7d8c commit 0d26e4a
Show file tree
Hide file tree
Showing 135 changed files with 1,278 additions and 729 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/crux-llvm-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ jobs:
setup_bin() { echo setup.${{ matrix.ghc }}; }
with_ghc() { $NS -c ${@}; }
(cd crucible; with_ghc ghc -o $(setup_bin) $(setup_src) && ./$(setup_bin) clean)
(cd crucible-cli; with_ghc ghc -o $(setup_bin) $(setup_src) && ./$(setup_bin) clean)
(cd crucible-llvm; with_ghc ghc -o $(setup_bin) $(setup_src) && ./$(setup_bin) clean)
(cd crucible-llvm-cli; with_ghc ghc -o $(setup_bin) $(setup_src) && ./$(setup_bin) clean)
(cd crucible-llvm-syntax; with_ghc ghc -o $(setup_bin) $(setup_src) && ./$(setup_bin) clean)
(cd crux; with_ghc ghc -o $(setup_bin) $(setup_src) && ./$(setup_bin) clean)
(cd crux-llvm; with_ghc ghc -o $(setup_bin) $(setup_src) && ./$(setup_bin) clean)
Expand All @@ -163,7 +165,9 @@ jobs:

- shell: bash
run: |
.github/ci.sh build exe:crucible
.github/ci.sh build lib:crucible-llvm-syntax
.github/ci.sh build exe:crucible-llvm
.github/ci.sh build exe:crux-llvm
.github/ci.sh build exe:crux-llvm-for-ide
.github/ci.sh build exe:crux-llvm-svcomp
Expand All @@ -177,6 +181,10 @@ jobs:
name: Test crucible
run: .github/ci.sh test crucible

- shell: bash
name: Test crucible-cli
run: .github/ci.sh test crucible-cli

- shell: bash
name: Test crucible-symio (Linux)
run: cabal test pkg:crucible-symio
Expand All @@ -196,6 +204,11 @@ jobs:
run: .github/ci.sh test crucible-llvm-syntax
if: runner.os == 'Linux'

- shell: bash
name: Test crucible-llvm-cli (Linux)
run: .github/ci.sh test crucible-llvm-cli
if: runner.os == 'Linux'

- shell: bash
name: Test crux-llvm (Linux)
run: .github/ci.sh test crux-llvm
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/uc-crux-llvm-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:
https://github.com/ndmitchell/hlint/releases/download/v3.3/hlint-3.3-x86_64-linux.tar.gz
tar xvf hlint.tar.gz
(cd crucible-cli/; ../hlint-3.3/hlint app src test)
(cd crucible-llvm-cli/; ../hlint-3.3/hlint app src test)
(cd crucible-llvm-syntax/; ../hlint-3.3/hlint src test)
cd uc-crux-llvm/
Expand Down
23 changes: 17 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ Currently, the repository consists of the following Haskell packages:
executing JVM bytecode programs in the Crucible symbolic simulator.
* **`crucible-saw`** provides functionality for generating
SAW Core terms from Crucible Control-Flow-Graphs.
* **`crucible-syntax`** provides a native S-Expression based concrete
syntax for crucible programs. It is useful for being able to
directly interact with the core Crucible simulator without bringing
in issues related to the translation of other front-ends (e.g. the
LLVM translation). It is primarily intended for the purpose of
writing test cases.
* **`crux`** provides common support libraries for running the
crucible simulator in a basic "all-at-once" use mode for simulation
and verification. This includes most of the setup steps required
Expand Down Expand Up @@ -69,6 +63,23 @@ In addition, there are the following library/executable packages:
false positives and is less useful for full verification than `crux-llvm`.
See [the README](./uc-crux-llvm/README.md) for details.

Finally, the following packages are intended primarily for use by Crucible
developers:

* **`crucible-cli`** provides a CLI for interacting with the Crucible
simulator, via programs written in `crucible-syntax`.

* **`crucible-llvm-cli`** provides a CLI for interacting with the Crucible
simulator, via programs written in `crucible-syntax` with the extensions
provided by `crucible-llvm{,-syntax}`.

* **`crucible-syntax`** provides a native S-Expression based concrete
syntax for crucible programs. It is useful for being able to
directly interact with the core Crucible simulator without bringing
in issues related to the translation of other front-ends (e.g. the
LLVM translation). It is primarily intended for the purpose of
writing test cases.

The development of major features and additions to `crucible` is done
in separate branches of the repository, all of which are based off
`master` and merge back into it when completed. Minor features and bug
Expand Down
2 changes: 2 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@

packages:
crucible/
crucible-cli/
crucible-go/
crucible-jvm/
crucible-llvm/
crucible-llvm-cli/
crucible-llvm-syntax/
crucible-mir/
crucible-wasm/
Expand Down
13 changes: 13 additions & 0 deletions crucible-cli/.hlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# HLint's default suggestions are opinionated, so we disable all of them by
# default and enable just a small subset we can agree on.

- ignore: {} # ignore all
- error: { name: "Fix pragma markup" }
- error: { name: "Redundant as-pattern" }
- error: { name: "Redundant do" }
- error: { name: "Unused LANGUAGE pragma" }
- error: { name: "Used otherwise as a pattern" }
- error: { name: "Use explicit module export list" }
- error: { name: "Use pragma syntax" }
- error: { name: "Use unless" }
- error: { name: "Use when" }
30 changes: 30 additions & 0 deletions crucible-cli/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Copyright (c) 2023 Galois Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.

* Neither the name of Galois, Inc. nor the names of its contributors
may be used to endorse or promote products derived from this
software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21 changes: 21 additions & 0 deletions crucible-cli/app/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{-# LANGUAGE ImplicitParams #-}

module Main (main) where

import Lang.Crucible.Simulator.ExecutionTree (emptyExtensionImpl)

import Lang.Crucible.Syntax.Concrete (defaultParserHooks)
import Lang.Crucible.Syntax.Overrides (setupOverrides)

import Lang.Crucible.CLI (SimulateProgramHooks(..), defaultSimulateProgramHooks)
import qualified Lang.Crucible.CLI.Options as Opts

main :: IO ()
main =
do let ?parserHooks = defaultParserHooks
Opts.main "crucible" (\_ -> emptyExtensionImpl) simulationHooks
where
simulationHooks =
defaultSimulateProgramHooks
{ setupOverridesHook = setupOverrides
}
145 changes: 145 additions & 0 deletions crucible-cli/crucible-cli.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
Cabal-version: 2.2
Name: crucible-cli
Version: 0.1
Author: Galois Inc.
Maintainer: [email protected]
Build-type: Simple
License: BSD-3-Clause
License-file: LICENSE
Category: Language
Synopsis: A library for sharing code between Crucible CLI frontends
-- Description:

extra-doc-files: README.md
extra-source-files:
test-data/**/*.cbl
test-data/**/*.out.good

common shared
-- Specifying -Wall and -Werror can cause the project to fail to build on
-- newer versions of GHC simply due to new warnings being added to -Wall. To
-- prevent this from happening we manually list which warnings should be
-- considered errors. We also list some warnings that are not in -Wall, though
-- try to avoid "opinionated" warnings (though this judgement is clearly
-- subjective).
--
-- Warnings are grouped by the GHC version that introduced them, and then
-- alphabetically.
--
-- A list of warnings and the GHC version in which they were introduced is
-- available here:
-- https://ghc.gitlab.haskell.org/ghc/doc/users_guide/using-warnings.html

-- Since GHC 8.10 or earlier:
ghc-options:
-Wall
-Werror=compat-unqualified-imports
-Werror=deferred-type-errors
-Werror=deprecated-flags
-Werror=deprecations
-Werror=deriving-defaults
-Werror=dodgy-foreign-imports
-Werror=duplicate-exports
-Werror=empty-enumerations
-Werror=identities
-Werror=inaccessible-code
-Werror=incomplete-patterns
-Werror=incomplete-record-updates
-Werror=incomplete-uni-patterns
-Werror=inline-rule-shadowing
-Werror=missed-extra-shared-lib
-Werror=missing-exported-signatures
-Werror=missing-fields
-Werror=missing-home-modules
-Werror=missing-methods
-Werror=overflowed-literals
-Werror=overlapping-patterns
-Werror=partial-fields
-Werror=partial-type-signatures
-Werror=simplifiable-class-constraints
-Werror=star-binder
-Werror=star-is-type
-Werror=tabs
-Werror=typed-holes
-Werror=unrecognised-pragmas
-Werror=unrecognised-warning-flags
-Werror=unsupported-calling-conventions
-Werror=unsupported-llvm-version
-Werror=unticked-promoted-constructors
-Werror=unused-imports
-Werror=warnings-deprecations
-Werror=wrong-do-bind

if impl(ghc >= 9.2)
ghc-options:
-Werror=ambiguous-fields
-Werror=operator-whitespace
-Werror=operator-whitespace-ext-conflict
-Werror=redundant-bang-patterns

if impl(ghc >= 9.4)
ghc-options:
-Werror=forall-identifier
-Werror=misplaced-pragmas
-Werror=redundant-strictness-flags
-Werror=type-equality-out-of-scope
-Werror=type-equality-requires-operators

ghc-prof-options: -O2 -fprof-auto-top
default-language: Haskell2010

library
import: shared

build-depends:
base >= 4.13,
containers,
crucible >= 0.1,
crucible-syntax,
lens,
megaparsec >= 7.0 && < 9.7,
mtl,
optparse-applicative,
parameterized-utils >= 0.1.7,
prettyprinter,
text,
what4,

hs-source-dirs: src

exposed-modules:
Lang.Crucible.CLI
Lang.Crucible.CLI.Options

test-suite crucible-cli-tests
import: shared
type: exitcode-stdio-1.0
main-is: Test.hs
hs-source-dirs: test
other-modules:
Overrides
build-depends:
base,
containers,
crucible >= 0.1,
crucible-cli,
crucible-syntax,
directory,
filepath,
lens,
parameterized-utils >= 0.1.7,
tasty,
tasty-hunit,
tasty-golden,
text,
what4,

executable crucible
import: shared
hs-source-dirs: app
main-is: Main.hs
build-depends:
base >= 4.13,
crucible,
crucible-cli,
crucible-syntax,
Loading

0 comments on commit 0d26e4a

Please sign in to comment.