-
Notifications
You must be signed in to change notification settings - Fork 77
/
Copy pathautoSoundConfig.ml
71 lines (60 loc) · 2.88 KB
/
autoSoundConfig.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
(** Automatically turning on analyses required to ensure soundness
based on a given specification (e.g., SV-COMP specification)
or programming idioms (e.g., longjmp) in the analyzed code,
but only when it is possible to do so automatically.
This does not fully exempt from the need for manual configuration.
*)
open GobConfig
open AutoTune
let enableSpecAnalyses spec analyses =
Logs.info "Specification: %s -> enabling soundness analyses \"%s\"" (Svcomp.Specification.to_string [spec]) (String.concat ", " analyses);
enableAnalyses analyses
let enableOptions options =
let enableOpt option =
Logs.info "Setting \"%s\" to true" option;
set_bool option true
in
List.iter enableOpt options
(** Selecting sound configurations based on SV-COMP specification.
Activating the analyses and enabling options that are
required for analyzing the property defined in the specification.
TODO: have only one function for matching all specifications and find a place where it can be called.
*)
let enableAnalysesForMemSafetySpecification (spec: Svcomp.Specification.t) =
match spec with
| ValidFree -> enableSpecAnalyses spec ["base"; "useAfterFree"];
| ValidDeref ->
enableSpecAnalyses spec ["base"; "memOutOfBounds"];
enableOptions ["ana.arrayoob"; "cil.addNestedScopeAttr"]
| ValidMemtrack
| ValidMemcleanup -> enableSpecAnalyses spec ["memLeak"];
| _ -> ()
let enableAnalysesForMemSafetySpecification () =
List.iter enableAnalysesForMemSafetySpecification (Svcomp.Specification.of_option ())
let enableAnalysesForTerminationSpecification (spec: Svcomp.Specification.t) =
match spec with
| Termination -> enableSpecAnalyses spec ["termination"];
| _ -> ()
let enableAnalysesForTerminationSpecification () =
List.iter enableAnalysesForTerminationSpecification (Svcomp.Specification.of_option ())
let enableAnalysesForSpecification (spec: Svcomp.Specification.t) =
match spec with
| UnreachCall s -> ()
| NoDataRace -> enableSpecAnalyses spec ["access"; "race"];
| NoOverflow -> enableOptions ["ana.int.interval"]
| _ -> ()
let enableAnalysesForSpecification () =
List.iter enableAnalysesForSpecification (Svcomp.Specification.of_option ())
(* This is run independent of the autotuner being enabled or not to be sound in the presence of setjmp/longjmp *)
(* It is done this way around to allow enabling some of these analyses also for programs without longjmp *)
let longjmpAnalyses = ["activeLongjmp"; "activeSetjmp"; "taintPartialContexts"; "modifiedSinceSetjmp"; "poisonVariables"; "expsplit"; "vla"]
let activateLongjmpAnalysesWhenRequired () =
let isLongjmp (desc: LibraryDesc.t) args =
match desc.special args with
| LibraryDesc.Longjmp _ -> true
| _ -> false
in
if hasFunction isLongjmp then (
Logs.info "longjmp -> enabling longjmp analyses \"%s\"" (String.concat ", " longjmpAnalyses);
enableAnalyses longjmpAnalyses;
)