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

crucible{,-llvm}-syntax: Evaluating programs with syntax extensions #1121

Merged
merged 5 commits into from
Nov 8, 2023

Conversation

langston-barrett
Copy link
Contributor

Fixes #1115.

  • Changes the type of SimulateProgramHooks to bind an ext variable, so hooks can be extension-specific
  • Adds a simulation hook that can run an arbitrary override action before simulation (necessary for initializing LLVM memory global variable)
  • Adds a exec-crucible-llvm executable based on crucibler - has lots of shared code with crucibler, but is also substantially different, so not sure if more sharing is feasible
  • Adds a test for simulating Crucible-LLVM extension statements

Copy link
Contributor

@RyanGlScott RyanGlScott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adds a exec-crucible-llvm executable based on crucibler - has lots of shared code with crucibler, but is also substantially different, so not sure if more sharing is feasible

I might be missing something, but the code in exec-crucible-llvm doesn't seem that different to me. At a glance, the big differences that stand out are:

  1. exec-crucible-llvm uses a different ExtensionImpl
  2. exec-crucible-llvm uses a different setupHook
  3. exec-curcible-llvm uses a different ParserHooks

Am I missing something? If that's it, I could definitely imagine factoring out a large chunk of the functionality that is shared in common between crucibler and exec-crucible-llvm, including the three things above as arguments to the function.

(As a side note, I've never understand why it's named crucibler in the first place. I was going to suggest naming the other tool something like crucibler-llvm, but I'm not sure if it's a convention worth keeping.)

crucible-llvm-syntax/app/Main.hs Show resolved Hide resolved
@langston-barrett
Copy link
Contributor Author

Am I missing something? If that's it, I could definitely imagine factoring out a large chunk of the functionality that is shared in common between crucibler and exec-crucible-llvm, including the three things above as arguments to the function.

No, you're right - I guess the real question is: Where should that shared code go, given that it mostly consists of optparse-applicative setup? I would say probably not in crucible-syntax itself, as there's no reason for library clients to need to build optparse-applicative and that module. Do we want to make a new package (crucible-exec?) for sharing code between crucible-syntax frontends?

@RyanGlScott
Copy link
Contributor

I was thinking of moving most of this functionality to Lang.Crucible.Syntax.Prog. We could have a function of (roughly) this type:

Command -> ExtensionImpl -> ParserHooks -> SimulatorHooks -> IO ()

Where Command is the data type that encodes which of the crucibler/exec-crucible-llvm subcommands you want to run. Then, each executable can instantiate this function as needed and define the necessary optparse-applicative logic to parse command-line arguments into a Command.

@langston-barrett
Copy link
Contributor Author

langston-barrett commented Nov 8, 2023

I was thinking of moving most of this functionality to Lang.Crucible.Syntax.Prog.

Done.

I don't love this solution, as library clients still need to build code they don't need (Prog.hs), and the CLIs still need to copy-paste code (optparse-applicative setup). But I think it's better than it was before, so thank you for the suggestion!

In the future, it might be nice to create a crucible-cli package or similar that provides the functionality of Prog.hs, in addition to the optparse-applicative bits, and then have crucible-cli, crucible-llvm-cli, etc. executables that are all thin wrappers over the crucible-cli library that instantiate it with the proper syntax extension. In addition to the current functionality (check/simulate/repl), we could also expose reading and then pretty-printing CFGs from actual code (e.g., LLVM bitcode modules), and perhaps add some debugging-oriented execution features that could be used with simulate.

Copy link
Contributor

@RyanGlScott RyanGlScott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm broadly aligned with the goal of factoring out the CLI-related bits, although we certainly don't have to hold up this PR on that.

Everything else looks great!

@langston-barrett langston-barrett merged commit 00f7d8c into master Nov 8, 2023
31 checks passed
@langston-barrett langston-barrett deleted the lb/syntax-eval branch November 8, 2023 13:02
RyanGlScott added a commit that referenced this pull request Feb 1, 2024
RyanGlScott added a commit that referenced this pull request Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

crucible-syntax: Allow simulating CFGs with syntax extensions
2 participants