-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathoptions.ml
196 lines (171 loc) · 5.59 KB
/
options.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
(**************************************************************************)
(* *)
(* ldrgen, a generator of random C programs *)
(* Copyright (C) 2017-2024, Gergö Barany <[email protected]> *)
(* *)
(* This program is free software: you can redistribute it and/or modify *)
(* it under the terms of the GNU General Public License as published by *)
(* the Free Software Foundation, either version 3 of the License, or *)
(* (at your option) any later version. *)
(* *)
(* This program is distributed in the hope that it will be useful, *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
(* GNU General Public License for more details. *)
(* *)
(* You should have received a copy of the GNU General Public License *)
(* along with this program. If not, see <http://www.gnu.org/licenses/>. *)
(* *)
(**************************************************************************)
include Plugin.Register
(struct
let name = "Ldrgen"
let shortname = "ldrgen"
let help = "generate a random C program"
end)
module Run = False
(struct
let option_name = "-ldrgen"
let help = "generate a random C function"
end)
module CheckAst = True
(struct
let option_name = "-ldrgen-check-ast"
let help = "perform sanity checks on the generated ast"
end)
module Seed = Zero
(struct
let option_name = "-ldrgen-seed"
let arg_name = "s"
let help = "set random seed"
end)
module ExprDepth = Int
(struct
let option_name = "-ldrgen-expr-depth"
let arg_name = "d"
let default = 5
let help = "set maximal expression depth"
end)
module StmtDepth = Int
(struct
let option_name = "-ldrgen-stmt-depth"
let arg_name = "d"
let default = 3
let help = "set maximal statement nesting depth"
end)
module BlockLength = Int
(struct
let option_name = "-ldrgen-block-length"
let arg_name = "n"
let default = 5
let help = "set maximal number of instructions per block"
end)
module MaxLive = Int
(struct
let option_name = "-ldrgen-max-live"
let arg_name = "l"
let default = 32
let help = "set maximal number of concurrently live variables"
end)
module MaxArgs = Int
(struct
let option_name = "-ldrgen-max-args"
let arg_name = "a"
let default = 8
let help = "set maximal number of function arguments"
end)
module Arrays = True
(struct
let option_name = "-ldrgen-arrays"
let help = "allow generation of arrays"
end)
module MaxArrayDim = Int
(struct
let option_name = "-ldrgen-max-array-dim"
let arg_name = "n"
let default = 3
let help = "set maximal number of array dimensions"
end)
module MaxArrayLengthPerDim = Int
(struct
let option_name = "-ldrgen-max-array-length-per-dim"
let arg_name = "n"
let default = 5
let help = "set maximal number of array elements per dimension"
end)
module FloatingPoint = True
(struct
let option_name = "-ldrgen-fp"
let help = "allow generation of floating-point arithmetic"
end)
module Float = True
(struct
let option_name = "-ldrgen-float"
let help = "allow generation of the float type if -ldrgen-fp is set"
end)
module FloatingPointOnly = False
(struct
let option_name = "-ldrgen-fp-only"
let help = "allow *only* generation of floating-point arithmetic but \
no integer arithmetic"
end)
module IntOnly = False
(struct
let option_name = "-ldrgen-int-only"
let help = "allow *only* generation of int and unsigned int types"
end)
module LongLong = True
(struct
let option_name = "-ldrgen-long-long"
let help = "allow generation of long long arithmetic"
end)
module PointerArgs = True
(struct
let option_name = "-ldrgen-pointer-args"
let help = "allow generation of pointer arguments"
end)
module DivMod = True
(struct
let option_name = "-ldrgen-div-mod"
let help = "allow generation of division and modulo operations"
end)
module Mod = True
(struct
let option_name = "-ldrgen-mod"
let help = "allow generation of modulo operations if -ldrgen-divmod \
is set"
end)
module Bitwise = True
(struct
let option_name = "-ldrgen-bitwise"
let help = "allow generation of bitwise operations"
end)
module Loops = True
(struct
let option_name = "-ldrgen-loops"
let help = "allow generation of loops"
end)
module WhileLoops = True
(struct
let option_name = "-ldrgen-while-loops"
let help = "allow generation of while loops"
end)
module ForLoops = True
(struct
let option_name = "-ldrgen-for-loops"
let help = "allow generation of for loops"
end)
let initialize () =
(* Fake some command line settings to keep Frama-C from complaining about
missing input files, and about problems preprocessing [/dev/null]. *)
Kernel.Verbose.set 0;
Kernel.Files.set [Datatype.Filepath.of_string "/dev/null"];
Kernel.CppCommand.set "/bin/true";
Kernel.CppGnuLike.set false;
(* Initialize the random number generator. *)
if Seed.is_default () then begin
Random.self_init ();
let s = Random.bits () in
Seed.set s
end;
Random.init (Seed.get ())