-
Notifications
You must be signed in to change notification settings - Fork 88
Add YAML witness output #744
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
Merged
Merged
Changes from 11 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
df336a3
Add yaml dependency
sim642 e3311fd
Add yaml witness prototype
sim642 b25d33b
Add options for yaml witnesses
sim642 9e1da44
Add uuidm dependency
sim642 81cee80
Add more yaml witness fields
sim642 f0ca5ff
Add SHA256 caching to yaml witness
sim642 45ac462
Add join over all contexts to yaml witness
sim642 a558f0f
Only emit yaml entries for Statement nodes
sim642 ed66dac
Add commented out dumping of conf to yaml witness
sim642 310bedd
Add command_line to yaml witness
sim642 44141c5
Add architecture and specification to yaml witness
sim642 4fbd0ef
Move trans.assert options to witness.invariant for unification
sim642 87473da
Refactor witness.invariant options
sim642 24b7789
Extract invariant node logic from GraphML witness generation
sim642 d3935a3
Handle after-lock in WitnessUtil.Invariant
sim642 175775b
Use witness.invariant options for yaml witness
sim642 ad9dde7
Split conjunctions in yaml witness output to work around misparsing
sim642 0efac22
Add option witness.invariant.split-conjunction
sim642 e9fc8bd
Fix YamlWitness indentation
sim642 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| open Analyses | ||
|
|
||
| let uuid_random_state = Random.State.make_self_init () | ||
|
|
||
| module Make | ||
| (Spec : Spec) | ||
| (EQSys : GlobConstrSys with module LVar = VarF (Spec.C) | ||
| and module GVar = GVarF (Spec.V) | ||
| and module D = Spec.D | ||
| and module G = Spec.G) | ||
| (LHT : BatHashtbl.S with type key = EQSys.LVar.t) | ||
| (GHT : BatHashtbl.S with type key = EQSys.GVar.t) = | ||
| struct | ||
|
|
||
| module NH = BatHashtbl.Make (Node) | ||
|
|
||
| (* copied from Constraints.CompareNode *) | ||
| let join_contexts (lh: Spec.D.t LHT.t): Spec.D.t NH.t = | ||
| let nh = NH.create 113 in | ||
| LHT.iter (fun (n, _) d -> | ||
| let d' = try Spec.D.join (NH.find nh n) d with Not_found -> d in | ||
| NH.replace nh n d' | ||
| ) lh; | ||
| nh | ||
|
|
||
| let write lh gh = | ||
| (* yaml_conf is too verbose *) | ||
| (* let yaml_conf: Yaml.value = Json_repr.convert (module Json_repr.Yojson) (module Json_repr.Ezjsonm) (!GobConfig.json_conf) in *) | ||
| let yaml_creation_time = `String (TimeUtil.iso8601_now ()) in | ||
| let yaml_producer = `O [ | ||
| ("name", `String "Goblint"); | ||
| ("version", `String Version.goblint); | ||
| (* TODO: configuration *) | ||
| (* ("configuration", yaml_conf); *) (* yaml_conf is too verbose *) | ||
| ("command_line", `String Goblintutil.command_line); | ||
| (* TODO: description *) | ||
| ] | ||
| in | ||
| let files = GobConfig.get_string_list "files" in | ||
| let sha256_file f = Sha256.(to_hex (file f)) in | ||
| let sha256_file_cache = BatCache.make_ht ~gen:sha256_file ~init_size:5 in | ||
| let sha256_file = sha256_file_cache.get in | ||
| let yaml_task = `O ([ | ||
| ("input_files", `A (List.map Yaml.Util.string files)); | ||
| ("input_file_hashes", `O (List.map (fun file -> | ||
| (file, `String (sha256_file file)) | ||
| ) files)); | ||
| ("data_model", `String (match GobConfig.get_string "exp.architecture" with | ||
| | "64bit" -> "LP64" | ||
| | "32bit" -> "ILP32" | ||
| | _ -> failwith "invalid architecture")); | ||
| ("language", `String "C"); | ||
| ] @ match !Svcomp.task with | ||
| | Some (module Task) -> [ | ||
| ("specification", `String (Svcomp.Specification.to_string Task.specification)) | ||
| ] | ||
| | None -> | ||
| [] | ||
| ) | ||
| in | ||
|
|
||
| let nh = join_contexts lh in | ||
|
|
||
| let yaml_entries = NH.fold (fun n local acc -> | ||
| match n with | ||
| | Statement _ -> | ||
| let context: Invariant.context = { | ||
| scope=Node.find_fundec n; | ||
| i = -1; | ||
| lval=None; | ||
| offset=Cil.NoOffset; | ||
| deref_invariant=(fun _ _ _ -> Invariant.none) (* TODO: should throw instead? *) | ||
| } | ||
| in | ||
| begin match Spec.D.invariant context local with | ||
| | Some inv -> | ||
| let inv = InvariantCil.exp_replace_original_name inv in | ||
| let loc = Node.location n in | ||
| let uuid = Uuidm.v4_gen uuid_random_state () in | ||
| let entry = `O [ | ||
| ("entry_type", `String "loop_invariant"); | ||
| ("metadata", `O [ | ||
| ("format_version", `String "0.1"); | ||
| ("uuid", `String (Uuidm.to_string uuid)); | ||
| ("creation_time", yaml_creation_time); | ||
| ("producer", yaml_producer); | ||
| ("task", yaml_task); | ||
| ]); | ||
| ("location", `O [ | ||
| ("file_name", `String loc.file); | ||
| ("file_hash", `String (sha256_file loc.file)); | ||
| ("line", `Float (float_of_int loc.line)); | ||
| ("column", `Float (float_of_int (loc.column - 1))); | ||
| ("function", `String (Node.find_fundec n).svar.vname); | ||
| ]); | ||
| ("loop_invariant", `O [ | ||
| ("string", `String (CilType.Exp.show inv)); | ||
| ("type", `String "assertion"); | ||
| ("format", `String "C"); | ||
| ]); | ||
| ] | ||
| in | ||
| entry :: acc | ||
| | None -> | ||
| acc | ||
| end | ||
| | _ -> (* avoid FunctionEntry/Function because their locations are not inside the function where assert could be inserted *) | ||
| acc | ||
| ) nh [] | ||
| in | ||
|
|
||
| let yaml = `A yaml_entries in | ||
| Yaml_unix.to_file_exn (Fpath.v (GobConfig.get_string "witness.yaml.path")) yaml | ||
| end | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.