1
2
3FRAMA-C(1) General Commands Manual FRAMA-C(1)
4
5
6
8 frama-c[.byte] - a static analyzer for C programs
9
10 frama-c-gui[.byte] - the graphical interface of frama-c
11
13 frama-c [ options ] files
14
16 frama-c is a suite of tools dedicated to the analysis of source code
17 written in C. It gathers several analysis techniques in a single col‐
18 laborative framework. This framework can be extended by additional
19 plugins placed in the $FRAMAC_PLUGIN directory. The command
20
21 frama-c --plugins
22
23 will provide the full list of the plugins that are currently installed.
24
25 frama-c-gui is the graphical user interface of frama-c. It features
26 the same options as the command-line version.
27
28 frama-c.byte and frama-c-gui.byte are the OCaml bytecode versions of
29 the command-line and graphical user interface respectively.
30
31 By default, Frama-C recognizes .c files as C files needing pre-process‐
32 ing and .i files as C files having been already pre-processed. Some
33 plugins may extend the list of recognized files. Pre-processing can be
34 customized through the -cpp-command and -cpp-extra-args options.
35
37 Syntax
38 Options taking an additional parameter can also be written under the
39 form
40
41 -option=param
42
43 This form is mandatory when param starts with a dash (`-').
44
45 Most options that take no parameter have a corresponding
46
47 -no-option
48
49 option which has the opposite effect.
50
51 Help options
52 -help gives a short usage notice.
53
54 -kernel-help
55 prints the list of options recognized by Frama-C's kernel
56
57 -verbose n
58 sets verbosity level. Defaults to 1. Setting it to 0 will out‐
59 put less progress messages. This level can also be set on a
60 per-plugin basis, with option -plugin-verbose n. Verbosity
61 level of the kernel can be controlled with option -kernel-ver‐
62 bose n.
63
64 -debug n
65 sets debugging level. Defaults to 0, meaning no debugging mes‐
66 sages. This option has the same per-plugin (and kernel) spe‐
67 cializations as -verbose.
68
69 -quiet sets verbosity and debugging level to 0.
70
71 Options controlling Frama-C's kernel
72 -absolute-valid-range min-max
73 considers that all numerical addresses in the range min-max are
74 valid. Bounds are parsed as OCaml integer constants. By
75 default, all numerical addresses are considered invalid.
76
77 -add-path p1[,p2[...,pn]]
78 adds directories p1 through pn to the list of directories in
79 which plugins are searched.
80
81 [-no]-aggressive-merging
82 merges function definitions modulo renaming. Defaults to no.
83
84 [-no]-allow-duplication
85 allows duplication of small blocks during normalization of tests
86 and loops. Otherwise, normalization uses labels and gotos.
87 Bigger blocks and blocks with non-trivial control flow are never
88 duplicated. Defaults to yes.
89
90 [-no]-annot
91 reads ACSL annotations. This is the default. Annotations are
92 pre-processed by default. Use -no-pp-annot if you don't want to
93 expand macros in annotations.
94
95 -big-ints-hex max
96 integers larger than max are displayed in hexadecimal (by
97 default, all integers are displayed in decimal).
98
99 -check performs integrity checks on the internal AST (for developers
100 only).
101
102 [-no]-asm-contracts
103 generates contracts for assembly code written according to gcc's
104 extended syntax. Defaults to yes.
105
106 [-no]-asm-contracts-auto-validate
107 automatically marks contracts generated from asm as valid.
108 Defaults to no.
109
110 -c11 enables (partial) C11 compatibility, e.g. typedef redefinitions.
111 Defaults to no.
112
113 [-no]-collapse-call-cast
114 allows implicit cast between the value returned by a function
115 and the lvalue it is assigned to. Otherwise, a temporary vari‐
116 able is used and the cast is made explicit. Defaults to yes.
117
118 [-no]-constfold
119 folds all syntactically constant expressions in the code before
120 analyses. Defaults to no.
121
122 -const-readonly
123 variables with const qualifier must be actually constant.
124 Defaults to yes. The opposite option is -unsafe-writable.
125
126 [-no]-continue-annot-error
127 when analyzing an annotation, the default behavior (the -no ver‐
128 sion of this option) when a typechecking error occurs is to
129 reject the source file as is the case for typechecking errors
130 within the C code. With this option on, the typechecker will
131 only output a warning and discard the annotation but type‐check‐
132 ing will continue (errors in C code are still fatal, though).
133 Deprecated: use -kernel-warn-key annot-error instead.
134
135 -cpp-command cmd
136 uses cmd as the command to pre-process C files. Defaults to the
137 CPP environment variable or to
138
139 gcc -C -E -I.
140
141 if it is not set. If unset, the command is built as follows:
142
143 CPP -o
144
145 %1 and %2 can be used into the CPP string to mark the position of and
146 respectively. Note that this option is often better replaced by
147 -cpp-extra-args.
148
149 -cpp-extra-args args
150 gives additional arguments to the pre-processor. Pre-processing
151 annotations is done in two separate pre-processing stages. The
152 first one is a normal pass on the C code which retains macro
153 definitions. These are then used in the second pass during
154 which annotations are pre-processed. args are used only for the
155 first pass, so that arguments that should not be used twice
156 (such as additional include directives or macro definitions)
157 must thus go there instead of -cpp-command.
158
159 [-no]-cpp-frama-c-compliant
160 indicates that the chosen preprocessor complies to some Frama-C
161 requirements, such as accepting the same set of options as GNU
162 cpp, and accepting architecture-specific options such as
163 -m32/-m64. Default values depend on the installed preprocessor
164 at configure time. See also -pp-annot.
165
166 [-no]-autoload-plugins
167 when on, load all the dynamic plugins found in the search path
168 (see -print-plugin-path for more information on the default
169 search path). Otherwise, only plugins requested by -load-module
170 will be loaded. Defaults to on.
171
172 -enums repr
173 choose the way the representation of enumerated types is deter‐
174 mined. frama-c -enums help gives the list of available options.
175 Default is gcc-enums.
176
177 -float-digits n
178 when outputting floating-point numbers, display n digits.
179 Defaults to 12.
180
181 -float-flush-to-zero
182 floating point operations flush to zero.
183
184 -float-hex
185 display floats as hexadecimal.
186
187 -float-normal
188 display floats with the standard OCaml routine.
189
190 -float-relative
191 display float intervals as [ lower_bound++width ].
192
193 [-no]-frama-c-stdlib
194 adds -I$FRAMAC_SHARE/libc to the options given to the cpp com‐
195 mand. If -cpp-frama-c-compliant is not false, also adds -nostd‐
196 inc to prevent an inconsistent mix of system and Frama-C header
197 files. Defaults to yes.
198
199 -implicit-function-declaration action
200 warns or aborts when a function is called before it has been
201 declared. action can be one of ignore, warn, or error.
202 Defaults to warn.
203 Deprecated: use -kernel-warn-key typing:implicit-function-declaration
204 instead.
205
206 -initialized-padding-locals
207 implicit initialization of locals sets padding bits to 0. If
208 false, padding bits are left uninitialized. Defaults to yes.
209
210 -inline-calls f1,...,fn
211 syntactically inlines calls to functions f1,...,fn. Use @inline
212 to select all functions with attribute inline. Recursive func‐
213 tions are inlined only at the first level. Calls via function
214 pointers are not inlined.
215
216 -journal-disable
217 do not output a journal of the current session. See -jour‐
218 nal-enable.
219
220 -journal-enable
221 on by default, dumps a journal of all the actions performed dur‐
222 ing the current Frama-C session in the form of an OCaml script
223 that can be replayed with -load-script. The name of the script
224 can be set with the -journal-name option.
225
226 -journal-name name
227 sets the name of the journal file (without the .ml extension).
228 Defaults to frama_c_journal.
229
230 -json-compilation-database path
231 use path as a JSON compilation database (see
232 <https://clang.llvm.org/docs/JSONCompilationDatabase.html> for
233 more information): each file preprocessed by Frama-C will
234 include corresponding -I and -D flags according to the specifi‐
235 cations in path. If path is a directory, use <path>/com‐
236 pile_commands.json. Disabled by default.
237
238 [-no]-keep-comments
239 tries to preserve comments when pretty-printing the source code.
240 Defaults to no.
241
242 [-no]-keep-switch
243 when -simplify-cfg is set, keeps switch statements. Defaults to
244 no.
245
246 -keep-unused-specified-functions
247 see -remove-unused-specified-functions.
248
249 -kernel-log kind:file
250 copies log messages from the Frama-C's kernel to file. kind
251 specifies which kinds of messages to be copied (e.g. w for
252 warnings, e for errors, etc.). See -kernel-help for more
253 details. Can also be set on a per-plugin basis, with option
254 -<plugin>-log.
255
256 -kernel-msg-key k1,...,kn
257 controls the emission of messages based on categories. Use
258 -kernel-msg-key help to get a list of available categories, and
259 -kernel-msg-key=“*” to control all categories. To disable a
260 category, add a - before its name; to enable a category, simply
261 add its name, with an optional + before it. For instance, -ker‐
262 nel-msg-key=-k1,k2 will disable messages from category k1 and
263 enable those from category k2. Can also be set on a per-plugin
264 basis, with option -<plugin>-msg-key. Note that each plugin has
265 its own set of categories.
266
267 -kernel-warn-key k1=a1,...,kn=an
268 controls the emission of warnings based on categories: for each
269 warning category k, associate action a. Use -kernel-warn-key
270 help to get a list of available warning categories and their
271 currently associated actions. The following actions can be set
272 per category: active (warn), feedback, error, abort, once, feed‐
273 back-once, err-once. Omitting the action is equivalent to set‐
274 ting it to active. Warning categories can also be set on a
275 per-plugin basis, with option -<plugin>-warn-key.
276
277 [-no]-lib-entry
278 indicates that the entry point is called during program execu‐
279 tion. This implies in particular that global variables cannot
280 be assumed to have their initial values. The default is
281 -no-lib-entry: the entry point is also the starting point of the
282 program and globals have their initial value.
283
284 -load file
285 loads the (previously saved) state contained in file.
286
287 -load-module SPEC
288 dynamically load OCaml plug-ins, modules and scripts. Each SPEC
289 can be an OCaml source or object file, with or without exten‐
290 sion, or a Findlib package. Loading order is preserved and
291 additional dependencies can be listed in *.depend files.
292
293 -load-script SPEC
294 alias for option -load-module.
295
296 -machdep machine
297 uses machine as the current machine-dependent configuration
298 (size of the various integer types, endiandness, ...). The list
299 of currently supported machines is available through option
300 -machdep help. Default is x86_32.
301
302 -main f
303 sets f as the entry point of the analysis. Defaults to main.
304 By default, it is considered as the starting point of the pro‐
305 gram under analysis. Use -lib-entry if f is supposed to be
306 called in the middle of an execution.
307
308 -obfuscate
309 prints an obfuscated version of the code (where original identi‐
310 fiers are replaced by meaningless ones) and exits. The corre‐
311 spondence table between original and new symbols is kept at the
312 beginning of the result.
313
314 -ocode file
315 redirects pretty-printed code to file instead of standard out‐
316 put.
317
318 [-no]-orig-name
319 During the normalization phase, some variables may get renamed
320 when different variables with the same name can co-exist (e.g. a
321 global variable and a formal parameter). When this option is
322 on, a message is printed each time this occurs. Defaults to no.
323
324 [-no]-pp-annot
325 pre-processes annotations. This is currently only possible when
326 using gcc (or GNU cpp) pre-processor. The default is to
327 pre-process annotations when the default pre-processor is iden‐
328 tified as GNU or GNU-like. See also -cpp-frama-c-compliant.
329
330 [-no]-print
331 pretty-prints the source code as normalized by CIL. Defaults to
332 no.
333
334 [-no]-print-libc
335 expands #include directives in the pretty-printed CIL code for
336 files in the Frama-C standard library. Defaults to no.
337
338 -print-libpath
339 outputs the directory where the Frama-C kernel library is
340 installed.
341
342 -print-path
343 alias of -print-share-path.
344
345 -print-plugin-path
346 outputs the directory where Frama-C searches its plugins (can be
347 overridden by the FRAMAC_PLUGIN variable and the -add-path
348 option).
349
350 -print-share-path
351 outputs the directory where Frama-C stores its data (can be
352 overridden by the FRAMAC_SHARE variable).
353
354 [-no]-remove-exn
355 transforms throw and try/catch statements into normal C func‐
356 tions. Defaults to no, unless the input source language has an
357 exception mechanism.
358
359 -remove-inlined f1,...,fn
360 removes inlined functions f1,...,fn from the AST, which must
361 have been given to -inline-calls. Note: this option does not
362 check if the given functions were fully inlined.
363
364 -remove-projects p1,...,pn
365 removes the given projects p1,...,pn. @all_but_current removes
366 all projects but the current one.
367
368 -remove-unused-specified-functions
369 keeps function prototypes that have an ACSL specification but
370 are not used in the code. This is the default. Functions hav‐
371 ing the attribute FRAMAC_BUILTIN are always kept.
372
373 -safe-arrays
374 for multidimensional arrays or arrays that are fields inside
375 structs, assumes that all accesses must be in bound (set by
376 default). The opposite option is -unsafe-arrays.
377
378 -save file
379 saves Frama-C's state into file after analyses have taken place.
380
381 -session s
382 sets s as the directory in which session files are searched.
383
384 [-no]-set-project-as-default
385 the current project becomes the default one (and so future -then
386 sequences are applied on it). Defaults to no.
387
388 [-no]-simplify-cfg
389 removes break, continue and switch statements before analyses.
390 Defaults to no.
391
392 [-no]-simplify-trivial-loops
393 simplifies trivial loops such as do ... while (0) loops.
394 Defaults to yes.
395
396 -then allows one to compose analyses: a first run of Frama-C will
397 occur with the options before -then and a second run will be
398 done with the options after -then on the current project from
399 the first run.
400
401 -then-last
402 like -then, but the second group of actions is executed on the
403 last project created by a program transformer.
404
405 -then-on prj
406 similar to -then except that the second run is performed in
407 project prj. If no such project exists, Frama-C exits with an
408 error.
409
410 -then-replace
411 like -then-last, but also removes the previous current project.
412
413 -time file
414 appends user time and date in the given file when Frama-C exits.
415
416 -typecheck
417 forces typechecking of the source files. This option is only
418 relevant if no further analysis is requested (as typechecking
419 will implicitly occur before the analysis is launched).
420
421 -ulevel n
422 syntactically unroll loops n times before the analysis. This
423 can be quite costly and some plugins (e.g. Eva) provide more
424 efficient ways to perform the same thing. See their respective
425 manuals for more information. This can also be activated on a
426 per-loop basis via the loop pragma unroll directive. A nega‐
427 tive value for n will inhibit such pragmas.
428
429 [-no]-ulevel-force
430 ignores UNROLL loop pragmas disabling unrolling.
431
432 [-no]-unicode outputs ACSL formulas with UTF-8 characters. This is the
433 default. When given the -no-unicode option, Frama-C will use the ASCII
434 version instead. See the ACSL manual for the correspondence.
435
436 -unsafe-arrays
437 see -safe-arrays.
438
439 [-no]-unspecified-access
440 checks that read/write accesses occurring in an unspecified
441 order (according to the C standard's notion of sequence points)
442 are performed on separate locations. With -no-unspeci‐
443 fied-access, assumes that it is always the case (this is the
444 default).
445
446 -version
447 outputs the version string of Frama-C.
448
449 -warn-decimal-float freq
450 warns when a floating-point constant cannot be exactly repre‐
451 sented (e.g. 0.1). freq can be one of none, once, or all.
452 Deprecated: use -kernel-warn-key parser:decimal-float=once (and vari‐
453 ants) instead.
454
455 [-no]-warn-left-shift-negative
456 generate alarms for signed left shifts on negative values.
457 Defaults to yes.
458
459 [-no]-warn-right-shift-negative
460 generate alarms for signed right shifts on negative values.
461 Defaults to no.
462
463 [-no]-warn-signed-downcast
464 generates alarms when signed downcasts may exceed the destina‐
465 tion range. Defaults to no.
466
467 [-no]-warn-signed-overflow
468 generates alarms for signed operations that overflow. Defaults
469 to yes.
470
471 [-no]-warn-unsigned-downcast
472 generates alarms when unsigned downcasts may exceed the destina‐
473 tion range. Defaults to no.
474
475 [-no]-warn-unsigned-overflow
476 generates alarms for unsigned operations that overflow.
477 Defaults to no.
478
479 [-no]-warn-invalid-bool
480 generates alarms for reads of trap representations of _Bool
481 lvalues. Defaults to yes.
482
483 Plugin-specific options
484 For each plugin, the command
485
486 frama-c -plugin-help
487
488 will give the list of options that are specific to the plugin.
489
491 0 Successful execution
492
493 1 Invalid user input
494
495 2 User interruption (kill or equivalent)
496
497 3 Unimplemented feature
498
499 4 5 6 Internal error
500
501 125 Unknown error
502
503 Exit statuses greater than 2 can be considered as a bug (or a feature
504 request for the case of exit status 3) and may be reported on Frama-C's
505 BTS (see below).
506
508 It is possible to control the places where Frama-C looks for its files
509 through the following variables.
510
511 FRAMAC_LIB
512 The directory where kernel's compiled interfaces are installed.
513
514 FRAMAC_PLUGIN
515 The directory where Frama-C can find standard plugins. If you
516 wish to have plugins in several places, use -add-path instead.
517
518 FRAMAC_SHARE
519 The directory where Frama-C data (e.g. its version of the stan‐
520 dard library) is installed.
521
523 Frama-C user manual: http://frama-c.com/download/frama-c-user-man‐
524 ual.pdf
525
526 Frama-C homepage: http://frama-c.com
527
528 Frama-C BTS: http://bts.frama-c.com
529
530
531
532 2018-01-17 FRAMA-C(1)