81 const std::string &extra_options)
95 options.
set_option(
"built-in-assertions",
true);
99 options.
set_option(
"show-goto-symex-steps",
false);
100 options.
set_option(
"show-points-to-sets",
false);
101 options.
set_option(
"show-array-constraints",
false);
115 options.
set_option(
"pointer-primitive-check", enabled);
116 options.
set_option(
"div-by-zero-check", enabled);
117 options.
set_option(
"signed-overflow-check", enabled);
118 options.
set_option(
"undefined-shift-check", enabled);
124 if(!options.
is_set(
"unwinding-assertions"))
126 options.
set_option(
"unwinding-assertions", enabled);
131 config.ansi_c.malloc_may_fail =
true;
132 config.ansi_c.malloc_failure_mode =
137 config.ansi_c.malloc_may_fail =
false;
138 config.ansi_c.malloc_failure_mode =
148 options, !
cmdline.isset(
"no-standard-checks"));
162 if(
cmdline.isset(
"cover") &&
cmdline.isset(
"unwinding-assertions"))
165 <<
"--cover and --unwinding-assertions must not be given together"
174 !
cmdline.isset(
"no-unwinding-assertions"))
176 log.warning() <<
"--cover is incompatible with --unwinding-assertions, so "
177 "unwinding-assertions will be defaulted to false"
188 if(
cmdline.isset(
"unwinding-assertions"))
190 options.
set_option(
"unwinding-assertions",
true);
191 options.
set_option(
"paths-symex-explore-all",
true);
193 else if(
cmdline.isset(
"no-unwinding-assertions"))
195 options.
set_option(
"unwinding-assertions",
false);
196 options.
set_option(
"paths-symex-explore-all",
false);
199 if(
cmdline.isset(
"max-field-sensitivity-array-size"))
202 "max-field-sensitivity-array-size",
203 cmdline.get_value(
"max-field-sensitivity-array-size"));
206 if(
cmdline.isset(
"no-array-field-sensitivity"))
208 if(
cmdline.isset(
"max-field-sensitivity-array-size"))
211 <<
"--no-array-field-sensitivity and --max-field-sensitivity-array-size"
215 options.
set_option(
"no-array-field-sensitivity",
true);
218 if(
cmdline.isset(
"reachability-slice") &&
219 cmdline.isset(
"reachability-slice-fb"))
222 <<
"--reachability-slice and --reachability-slice-fb must not be "
227 if(
cmdline.isset(
"full-slice"))
230 if(
cmdline.isset(
"show-symex-strategies"))
238 if(
cmdline.isset(
"program-only"))
241 if(
cmdline.isset(
"show-byte-ops"))
253 options.
set_option(
"unwinding-assertions",
false);
259 if(
cmdline.isset(
"symex-complexity-limit"))
262 "symex-complexity-limit",
cmdline.get_value(
"symex-complexity-limit"));
263 log.warning() <<
"**** WARNING: Complexity-limited analysis may yield "
264 "unsound verification results"
268 if(
cmdline.isset(
"symex-complexity-failed-child-loops-limit"))
271 "symex-complexity-failed-child-loops-limit",
272 cmdline.get_value(
"symex-complexity-failed-child-loops-limit"));
273 if(!
cmdline.isset(
"symex-complexity-limit"))
275 log.warning() <<
"**** WARNING: Complexity-limited analysis may yield "
276 "unsound verification results"
284 if(
cmdline.isset(
"drop-unused-functions"))
285 options.
set_option(
"drop-unused-functions",
true);
287 if(
cmdline.isset(
"string-abstraction"))
288 options.
set_option(
"string-abstraction",
true);
290 if(
cmdline.isset(
"reachability-slice-fb"))
291 options.
set_option(
"reachability-slice-fb",
true);
293 if(
cmdline.isset(
"reachability-slice"))
294 options.
set_option(
"reachability-slice",
true);
296 if(
cmdline.isset(
"nondet-static"))
299 if(
cmdline.isset(
"no-simplify"))
302 if(
cmdline.isset(
"stop-on-fail") ||
316 if(
cmdline.isset(
"export-symex-ready-goto"))
319 "export-symex-ready-goto",
cmdline.get_value(
"export-symex-ready-goto"));
320 if(options.
get_option(
"export-symex-ready-goto").empty())
323 <<
"ERROR: Please provide a filename to write the goto-binary to."
329 if(
cmdline.isset(
"localize-faults"))
337 !
cmdline.isset(
"unwinding-assertions"))
339 log.warning() <<
"**** WARNING: Use --unwinding-assertions to obtain "
340 "sound verification results"
349 <<
"**** WARNING: Depth-bounded analysis may yield unsound verification "
354 if(
cmdline.isset(
"slice-by-trace"))
363 "unwindset",
cmdline.get_comma_separated_values(
"unwindset"));
366 !
cmdline.isset(
"unwinding-assertions"))
368 log.warning() <<
"**** WARNING: Use --unwinding-assertions to obtain "
369 "sound verification results"
375 if(
cmdline.isset(
"no-propagation"))
380 "self-loops-to-assumptions",
381 !
cmdline.isset(
"no-self-loops-to-assumptions"));
386 if(
cmdline.isset(
"partial-loops"))
390 <<
"**** WARNING: --partial-loops may yield unsound verification results"
395 if(
cmdline.isset(
"slice-formula"))
398 if(
cmdline.isset(
"arrays-uf-always"))
400 else if(
cmdline.isset(
"arrays-uf-never"))
403 if(
cmdline.isset(
"show-array-constraints"))
404 options.
set_option(
"show-array-constraints",
true);
406 if(
cmdline.isset(
"refine-strings"))
413 "symex-cache-dereferences",
cmdline.isset(
"symex-cache-dereferences"));
415 if(
cmdline.isset(
"incremental-loop"))
418 "incremental-loop",
cmdline.get_value(
"incremental-loop"));
422 if(
cmdline.isset(
"unwind-min"))
425 if(
cmdline.isset(
"unwind-max"))
428 if(
cmdline.isset(
"ignore-properties-before-unwind-min"))
429 options.
set_option(
"ignore-properties-before-unwind-min",
true);
433 log.error() <<
"--paths not supported with --incremental-loop"
439 if(
cmdline.isset(
"graphml-witness"))
446 if(
cmdline.isset(
"symex-coverage-report"))
449 "symex-coverage-report",
450 cmdline.get_value(
"symex-coverage-report"));
451 options.
set_option(
"paths-symex-explore-all",
true);
454 if(
cmdline.isset(
"validate-ssa-equation"))
456 options.
set_option(
"validate-ssa-equation",
true);
459 if(
cmdline.isset(
"validate-goto-model"))
461 options.
set_option(
"validate-goto-model",
true);
464 if(
cmdline.isset(
"show-goto-symex-steps"))
465 options.
set_option(
"show-goto-symex-steps",
true);
467 if(
cmdline.isset(
"show-points-to-sets"))
468 options.
set_option(
"show-points-to-sets",
true);
511 cmdline.isset(
"gen-interface"))
513 log.error() <<
"This version of CBMC has no support for "
514 " hardware modules. Please use hw-cbmc."
519 if(
cmdline.isset(
"show-points-to-sets"))
523 log.error() <<
"--show-points-to-sets supports only"
524 " json output. Use --json-ui."
530 if(
cmdline.isset(
"show-array-constraints"))
534 log.error() <<
"--show-array-constraints supports only"
535 " json output. Use --json-ui."
547 gcc_version.
get(
"gcc");
551 if(
cmdline.isset(
"test-preprocessor"))
556 if(
cmdline.isset(
"preprocess"))
562 if(
cmdline.isset(
"show-parse-tree"))
572 std::string filename=
cmdline.args[0];
578 log.error() <<
"failed to open input file '" << filename <<
"'"
583 std::unique_ptr<languaget> language=
586 if(language==
nullptr)
588 log.error() <<
"failed to figure out type of file '" << filename <<
"'"
607 int get_goto_program_ret =
610 if(get_goto_program_ret!=-1)
611 return get_goto_program_ret;
613 if(
cmdline.isset(
"show-claims") ||
614 cmdline.isset(
"show-properties"))
626 if(options.
is_set(
"export-symex-ready-goto"))
628 auto symex_ready_goto_filename =
629 options.
get_option(
"export-symex-ready-goto");
636 log.error() <<
"ERROR: Unable to export goto-program in file "
642 log.status() <<
"Exported goto-program in symex-ready-goto form at "
688 if(options.
is_set(
"cover"))
704 std::unique_ptr<goto_verifiert> verifier =
nullptr;
706 if(options.
is_set(
"incremental-loop"))
710 verifier = std::make_unique<
725 std::make_unique<stop_on_fail_verifiert<single_path_symex_checkert>>(
741 std::make_unique<stop_on_fail_verifiert<multi_path_symex_checkert>>(
749 verifier = std::make_unique<
765 verifier = std::make_unique<
775 const resultt result = (*verifier)();
809 if(
cmdline.isset(
"show-symbol-table"))
818 if(
cmdline.isset(
"validate-goto-model"))
824 if(
cmdline.isset(
"show-loops"))
832 cmdline.isset(
"show-goto-functions") ||
833 cmdline.isset(
"list-goto-functions"))
853 std::string filename =
cmdline.args[0];
855 std::ifstream infile(filename);
865 if(language ==
nullptr)
887 log.status() <<
"Adding CPROVER library (" <<
config.ansi_c.arch <<
")"
911 log.status() <<
"Adding nondeterministic initialization "
912 "of static/global variables"
926 if(options.
is_set(
"cover"))
929 options,
goto_model.symbol_table,
log.get_message_handler());
945 log.status() <<
"Performing a forwards-backwards reachability slice"
947 if(options.
is_set(
"property"))
953 log.get_message_handler());
962 if(options.
is_set(
"property"))
967 log.get_message_handler());
976 log.warning() <<
"**** WARNING: Experimental option --full-slice, "
977 <<
"analysis results may be unsound. See "
978 <<
"https://github.com/diffblue/cbmc/issues/260"
981 if(options.
is_set(
"property"))
985 log.get_message_handler());
1009 "Usage: \tPurpose:\n"
1011 " {bcbmc} [{y-?}] [{y-h}] [{y--help}] \t show this help\n"
1012 " {bcbmc} {y--version} \t show version and exit\n"
1013 " {bcbmc} [options] {ufile.c} {u...} \t perform bounded model checking\n"
1015 "Analysis options:\n"
1017 " {y--symex-coverage-report} {uf} \t generate a Cobertura XML coverage"
1019 " {y--property} {uid} \t only check one specific property\n"
1020 " {y--trace} \t give a counterexample trace for failed properties\n"
1021 " {y--stop-on-fail} \t stop analysis once a failed property is detected"
1022 " (implies {y--trace})\n"
1023 " {y--localize-faults} \t localize faults (experimental)\n"
1025 "C/C++ frontend options:\n"
1026 " {y--preprocess} \t stop after preprocessing\n"
1027 " {y--test-preprocessor} \t stop after preprocessing, discard output\n"
1032 "Platform options:\n"
1035 "Program representations:\n"
1036 " {y--show-parse-tree} \t show parse tree\n"
1037 " {y--show-symbol-table} \t show loaded symbol table\n"
1040 " {y--export-symex-ready-goto} {uf} \t "
1041 "serialise goto-program in symex-ready-goto form in {uf}\n"
1043 "Program instrumentation options:\n"
1046 " {y--mm} {uMM} \t memory consistency model for concurrent programs"
1047 " (default: {ysc})\n"
1050 " {y--full-slice} \t run full slicer (experimental)\n"
1051 " {y--drop-unused-functions} \t drop functions trivially unreachable from"
1054 "Semantic transformations:\n"
1055 " {y--nondet-static} \t add nondeterministic initialization of variables"
1056 " with static lifetime\n"
1061 "Backend options:\n"
1065 " {y--arrays-uf-never} \t never turn arrays into uninterpreted functions\n"
1066 " {y--arrays-uf-always} \t always turn arrays into uninterpreted"
1068 " {y--show-array-constraints} \t show array theory constraints added"
1069 " during post processing. Requires {y--json-ui}.\n"
1071 "User-interface options:\n"
1076 " {y--verbosity} {u#} \t verbosity level (default 6)\n"
void add_failed_symbols(symbol_table_baset &symbol_table)
Create a failed-dereference symbol for all symbols in the given table that need one (i....
Goto Verifier for Verifying all Properties.
Goto verifier for verifying all properties that stores traces and localizes faults.
Goto verifier for verifying all properties that stores traces.
void cprover_c_library_factory(const std::set< irep_idt > &functions, const symbol_table_baset &symbol_table, symbol_table_baset &dest_symbol_table, message_handlert &message_handler)
#define HELP_ANSI_C_LANGUAGE
Bounded Model Checking Utilities.
void parse_c_object_factory_options(const cmdlinet &cmdline, optionst &options)
Parse the c object factory parameters from a given command line.
bool test_c_preprocessor(message_handlert &message_handler)
CBMC Command Line Option Processing.
Requires an incremental goto checker that is a goto_trace_providert and fault_localization_providert.
virtual int doit() override
invoke main modules
static bool process_goto_program(goto_modelt &, const optionst &, messaget &)
static void set_default_options(optionst &)
Set the options that have default values.
static int get_goto_program(goto_modelt &, const optionst &, const cmdlinet &, ui_message_handlert &)
void get_command_line_options(optionst &)
void register_languages() override
void preprocessing(const optionst &)
static void set_default_analysis_flags(optionst &, const bool enabled)
Setup default analysis flags.
virtual void help() override
display command line help
cbmc_parse_optionst(int argc, const char **argv)
void report() override
Report results.
const goto_trace_storaget & get_traces() const
void get(const std::string &executable)
Class that provides messages with a built-in verbosity 'level'.
static unsigned eval_verbosity(const std::string &user_input, const message_levelt default_verbosity, message_handlert &dest)
Parse a (user-)provided string as a verbosity level and set it as the verbosity of dest.
Performs a multi-path symbolic execution using goto-symex and calls a SAT/SMT solver to check the sta...
bool is_set(const std::string &option) const
N.B. opts.is_set("foo") does not imply opts.get_bool_option("foo").
bool get_bool_option(const std::string &option) const
void set_option(const std::string &option, const bool value)
const std::string get_option(const std::string &option) const
const value_listt & get_list_option(const std::string &option) const
virtual void usage_error()
parse_options_baset(const std::string &optstring, int argc, const char **argv, const std::string &program)
void log_version_and_architecture(const std::string &front_end)
Write version and system architecture to log.status().
ui_message_handlert ui_message_handler
Performs a multi-path symbolic execution using goto-symex that incrementally unwinds a given loop and...
Stops when the first failing property is found and localizes the fault Requires an incremental goto c...
Stops when the first failing property is found.
#define HELP_CONFIG_LIBRARY
#define HELP_CONFIG_PLATFORM
#define HELP_CONFIG_C_CPP
#define HELP_CONFIG_BACKEND
static void instrument_cover_goals(const irep_idt &function_id, goto_programt &goto_program, const cover_instrumenterst &instrumenters, const irep_idt &mode, message_handlert &message_handler, const cover_instrumenter_baset::assertion_factoryt &make_assertion)
Applies instrumenters to given goto program.
cover_configt get_cover_config(const optionst &options, const symbol_tablet &symbol_table, message_handlert &message_handler)
Build data structures controlling coverage from command-line options.
void parse_cover_options(const cmdlinet &cmdline, optionst &options)
Parses coverage-related command line options.
Coverage Instrumentation.
Goto verifier for covering goals that stores traces.
void cprover_cpp_library_factory(const std::set< irep_idt > &functions, const symbol_table_baset &symbol_table, symbol_table_baset &dest_symbol_table, message_handlert &message_handler)
static void show_goto_functions(const goto_modelt &goto_model)
Document and give macros for the exit codes of CPROVER binaries.
#define CPROVER_EXIT_INTERNAL_ERROR
An error has been encountered during processing the requested analysis.
#define CPROVER_EXIT_INCORRECT_TASK
The command line is correctly structured but cannot be carried out due to missing files,...
#define CPROVER_EXIT_USAGE_ERROR
A usage error is returned when the command line is invalid or conflicting.
#define CPROVER_EXIT_SUCCESS
Success indicates the required analysis has been performed without error.
#define CPROVER_EXIT_SET_PROPERTIES_FAILED
Failure to identify the properties to verify.
#define CPROVER_EXIT_PREPROCESSOR_TEST_FAILED
Failure of the test-preprocessor method.
void property_slicer(goto_functionst &goto_functions, const namespacet &ns, const std::list< std::string > &properties, message_handlert &message_handler)
void full_slicer(goto_functionst &goto_functions, const namespacet &ns, const slicing_criteriont &criterion, message_handlert &message_handler)
void configure_gcc(const gcc_versiont &gcc_version)
#define PARSE_OPTIONS_GOTO_CHECK(cmdline, options)
#define PARSE_OPTIONS_GOTO_TRACE(cmdline, options)
goto_modelt initialize_goto_model(const std::vector< std::string > &files, message_handlert &message_handler, const optionst &options)
void update_max_malloc_size(goto_modelt &goto_model, message_handlert &message_handler)
Update the initial value of __CPROVER_max_malloc_size in case the number of object bits has changed.
Initialize a Goto Program.
void json_interface(cmdlinet &cmdline, message_handlert &message_handler)
Parses the JSON-formatted command line from stdin.
#define HELP_JSON_INTERFACE
Abstract interface to support a programming language.
void link_to_library(goto_modelt &goto_model, message_handlert &message_handler, const std::function< void(const std::set< irep_idt > &, const symbol_tablet &, symbol_tablet &, message_handlert &)> &library)
Complete missing function definitions using the library.
void show_loop_ids(ui_message_handlert::uit ui, const goto_modelt &goto_model)
std::unique_ptr< languaget > get_language_from_filename(const std::string &filename)
Get the language corresponding to the registered file name extensions.
Goto Checker using Multi-Path Symbolic Execution.
Goto Checker using Multi-Path Symbolic Execution only (no SAT solving).
static void nondet_static(const namespacet &ns, goto_modelt &goto_model, const irep_idt &fct_name)
Nondeterministically initializes global scope variables in a goto-function.
Nondeterministically initializes global scope variables, except for constants (such as string literal...
std::string align_center_with_border(const std::string &text)
Utility for displaying help centered messages borderered by "* *".
std::string banner_string(const std::string &front_end, const std::string &version)
void parse_path_strategy_options(const cmdlinet &cmdline, optionst &options, message_handlert &message_handler)
add paths and exploration-strategy option, suitable to be invoked from front-ends.
std::string show_path_strategies()
suitable for displaying as a front-end help message
Storage of symbolic execution paths to resume.
int result_to_exit_code(resultt result)
resultt
The result of goto verifying.
void reachability_slicer(goto_modelt &goto_model, const bool include_forward_reachability, message_handlert &message_handler)
Perform reachability slicing on goto_model, with respect to the criterion given by all properties.
#define HELP_REACHABILITY_SLICER
bool is_goto_binary(const std::string &filename, message_handlert &message_handler)
void remove_asm(goto_functionst &goto_functions, symbol_tablet &symbol_table, message_handlert &message_handler)
Replaces inline assembly instructions in the goto program (i.e., instructions of kind OTHER with a co...
bool has_asm(const goto_functionst &goto_functions)
returns true iff the given goto functions use asm instructions
Remove 'asm' statements by compiling them into suitable standard goto program instructions.
void remove_skip(goto_programt &goto_program, goto_programt::targett begin, goto_programt::targett end)
remove unnecessary skip statements
void label_properties(goto_modelt &goto_model)
Set the properties to check.
#define HELP_SHOW_GOTO_FUNCTIONS
void show_properties(const namespacet &ns, const irep_idt &identifier, message_handlert &message_handler, ui_message_handlert::uit ui, const goto_programt &goto_program)
#define HELP_SHOW_PROPERTIES
void show_symbol_table(const symbol_table_baset &symbol_table, ui_message_handlert &ui)
Goto Checker using multi-path symbolic execution with incremental unwinding of a specified loop.
Goto Checker using Single Path Symbolic Execution.
Goto Checker using Single Path Symbolic Execution only.
void parse_solver_options(const cmdlinet &cmdline, optionst &options)
Parse solver-related command-line parameters in cmdline and set corresponding values in options.
#define UNREACHABLE
This should be used to mark dead code.
Goto Verifier for stopping at the first failing property.
Goto Verifier for stopping at the first failing property and localizing the fault.
#define HELP_STRING_REFINEMENT_CBMC
@ malloc_failure_mode_return_null
@ malloc_failure_mode_none
#define widen_if_needed(s)
const char * CBMC_VERSION
static void write_goto_binary(std::ostream &out, const symbol_table_baset &symbol_table, const goto_functionst &goto_functions, irep_serializationt &irepconverter)
Writes a goto program to disc, using goto binary format.
void xml_interface(cmdlinet &cmdline, message_handlert &message_handler)
Parse XML-formatted commandline options from stdin.
#define HELP_XML_INTERFACE