66 ui_message_handler(cmdline,
"JBMC " CBMC_VERSION),
67 path_strategy_chooser()
74 const std::string &extra_options):
77 ui_message_handler(cmdline,
"JBMC " CBMC_VERSION),
78 path_strategy_chooser()
128 "localize-faults-method",
155 "self-loops-to-assumptions",
163 options.
set_option(
"java-unwind-enum-static",
true);
183 options.
set_option(
"unwinding-assertions",
false);
187 "unwinding-assertions",
199 error() <<
"--partial-loops and --unwinding-assertions " 200 <<
"must not be given together" <<
eom;
234 options.
set_option(
"refine-arithmetic",
true);
241 options.
set_option(
"refine-arithmetic",
true);
255 "max-node-refinement",
259 bool version_set=
false;
279 bool solver_set=
false;
283 options.
set_option(
"boolector",
true), solver_set=
true;
285 options.
set_option(
"smt2",
true), version_set=
true;
290 options.
set_option(
"mathsat",
true), solver_set=
true;
292 options.
set_option(
"smt2",
true), version_set=
true;
297 options.
set_option(
"cvc3",
true), solver_set=
true;
299 options.
set_option(
"smt1",
true), version_set=
true;
304 options.
set_option(
"cvc4",
true), solver_set=
true;
306 options.
set_option(
"smt2",
true), version_set=
true;
311 options.
set_option(
"yices",
true), solver_set=
true;
313 options.
set_option(
"smt2",
true), version_set=
true;
318 options.
set_option(
"z3",
true), solver_set=
true;
320 options.
set_option(
"smt2",
true), version_set=
true;
325 options.
set_option(
"opensmt",
true), solver_set=
true;
327 options.
set_option(
"smt1",
true), version_set=
true;
330 if(version_set && !solver_set)
335 options.
set_option(
"generic",
true), solver_set=
true;
341 options.
set_option(
"boolector",
true), solver_set=
true;
346 options.
set_option(
"z3",
true), solver_set=
true;
352 INVARIANT(version_set==solver_set,
"solver and version set");
358 options.
set_option(
"sat-preprocessor",
false);
378 "symex-coverage-report",
385 options.
set_option(
"symex-driven-lazy-loading",
true);
386 for(
const char *opt :
390 "reachability-slice",
391 "reachability-slice-fb" })
395 throw std::string(
"Option ") + opt +
396 " can't be used with --symex-driven-lazy-loading";
407 options.
set_option(
"allow-pointer-unsoundness",
true);
415 std::cout << CBMC_VERSION <<
'\n';
429 catch(
const char *error_msg)
435 catch(
const std::string &error_msg)
447 status() <<
"JBMC version " CBMC_VERSION
" " 448 <<
sizeof(
void *)*8 <<
"-bit " 459 error() <<
"Please give exactly one source file" <<
eom;
466 std::ifstream infile(
widen(filename));
468 std::ifstream infile(filename);
473 error() <<
"failed to open input file `" 474 << filename <<
"'" <<
eom;
478 std::unique_ptr<languaget> language=
481 if(language==
nullptr)
483 error() <<
"failed to figure out type of file `" 484 << filename <<
"'" <<
eom;
491 status() <<
"Parsing " << filename <<
eom;
493 if(language->
parse(infile, filename))
503 std::function<void(bmct &, const symbol_tablet &)> configure_bmc =
nullptr;
510 unsigned loop_number,
512 unsigned &max_unwind) {
540 std::unique_ptr<goto_modelt> goto_model_ptr;
542 if(get_goto_program_ret!=-1)
543 return get_goto_program_ret;
579 error() <<
"the program has no entry point";
597 auto callback_after_symex = [
this, &lazy_goto_model]() {
611 callback_after_symex);
629 catch(
const std::string &e)
644 std::unique_ptr<goto_modelt> &goto_model,
649 error() <<
"Please provide a program to verify" <<
eom;
688 std::move(lazy_goto_model));
689 if(goto_model ==
nullptr)
721 catch(
const std::string &e)
732 catch(
const std::bad_alloc &)
746 journalling_symbol_tablet &symbol_table =
function.get_symbol_table();
750 bool using_symex_driven_loading =
760 if(using_symex_driven_loading)
773 auto function_is_stub = [&symbol_table, &model](
const irep_idt &id) {
774 return symbol_table.lookup_ref(
id).value.is_nil() &&
790 goto_check(ns, options, ID_java,
function.get_goto_function());
800 journalling_symbol_tablet::changesett new_symbols =
801 symbol_table.get_inserted();
802 for(
const irep_idt &new_symbol_name : new_symbols)
805 symbol_table.lookup_ref(new_symbol_name),
813 if(using_symex_driven_loading)
819 cover_config !=
nullptr,
"cover config should have been parsed");
826 goto_function.body.update();
827 function.compute_location_numbers();
828 goto_function.body.compute_loop_numbers();
832 function.update_instructions_function();
841 catch(
const std::string &e)
847 catch(
const std::bad_alloc &)
904 status() <<
"Running GOTO functions transformation passes" <<
eom;
906 bool using_symex_driven_loading =
911 if(using_symex_driven_loading)
926 status() <<
"Adding nondeterministic initialization " 927 "of static/global variables" <<
eom;
937 status() <<
"Removing unused functions" <<
eom;
964 error() <<
"--reachability-slice and --reachability-slice-fb " 965 <<
"must not be given together" <<
eom;
969 status() <<
"Performing a forwards-backwards reachability slice" <<
eom;
978 status() <<
"Performing a reachability slice" <<
eom;
988 status() <<
"Performing a full slice" <<
eom;
1005 catch(
const std::string &e)
1016 catch(
const std::bad_alloc &)
1036 bool body_available)
1071 std::cout <<
'\n' <<
banner_string(
"JBMC", CBMC_VERSION) <<
'\n' 1073 "* * Copyright (C) 2001-2018 * *\n" 1074 "* * Daniel Kroening, Edmund Clarke * *\n" 1075 "* * Carnegie Mellon University, Computer Science Department * *\n" 1076 "* * kroening@kroening.com * *\n" 1080 " jbmc [-?] [-h] [--help] show help\n" 1081 " jbmc class name of class to be checked\n" 1083 "Analysis options:\n" 1085 " --symex-coverage-report f generate a Cobertura XML coverage report in f\n" 1086 " --property id only check one specific property\n" 1087 " --stop-on-fail stop analysis once a failed property is detected\n" 1088 " --trace give a counterexample trace for failed properties\n" 1092 "Program representations:\n" 1093 " --show-parse-tree show parse tree\n" 1094 " --show-symbol-table show loaded symbol table\n" 1096 " --drop-unused-functions drop functions trivially unreachable from main function\n" 1099 "Program instrumentation options:\n" 1101 " --no-assertions ignore user assertions\n" 1102 " --no-assumptions ignore user assumptions\n" 1103 " --error-label label check that label is unreachable\n" 1104 " --cover CC create test-suite with coverage criterion CC\n" 1105 " --mm MM memory consistency model for concurrent programs\n" 1107 " --full-slice run full slicer (experimental)\n" 1109 "Java Bytecode frontend options:\n" 1110 " --classpath dir/jar set the classpath\n" 1111 " --main-class class-name set the name of the main class\n" 1115 " --java-threading enable experimental support for java multi-threading\n" 1116 " --java-unwind-enum-static try to unwind loops in static initialization of enums\n" 1118 " --symex-driven-lazy-loading only load functions when first entered by symbolic execution\n" 1119 " Note --show-symbol-table/goto-functions/properties output\n" 1120 " will be restricted to loaded methods in this case, and only\n" 1121 " output after the symex phase\n" 1126 "Backend options:\n" 1127 " --object-bits n number of bits used for object addresses\n" 1128 " --dimacs generate CNF in DIMACS format\n" 1129 " --beautify beautify the counterexample (greedy heuristic)\n" 1130 " --localize-faults localize faults (experimental)\n" 1131 " --smt1 use default SMT1 solver (obsolete)\n" 1132 " --smt2 use default SMT2 solver (Z3)\n" 1133 " --boolector use Boolector\n" 1134 " --mathsat use MathSAT\n" 1135 " --cvc4 use CVC4\n" 1136 " --yices use Yices\n" 1138 " --refine use refinement procedure (experimental)\n" 1139 " --refine-strings use string refinement (experimental)\n" 1140 " --string-printable add constraint that strings are printable (experimental)\n" 1141 " --string-max-length add constraint on the length of strings\n" 1142 " --string-max-input-length add constraint on the length of input strings\n" 1143 " --outfile filename output formula to given file\n" 1144 " --arrays-uf-never never turn arrays into uninterpreted functions\n" 1145 " --arrays-uf-always always turn arrays into uninterpreted functions\n" 1148 " --version show version and exit\n" 1149 " --xml-ui use XML-formatted output\n" 1150 " --json-ui use JSON-formatted output\n" 1153 " --verbosity # verbosity level\n" Remove Java New Operators.
const std::list< std::string > & get_values(const std::string &option) const
bool process_goto_functions(goto_modelt &goto_model, const optionst &options)
void show_loop_ids(ui_message_handlert::uit ui, const goto_modelt &goto_model)
jbmc_parse_optionst(int argc, const char **argv)
void reachability_slicer(goto_modelt &goto_model, const bool include_forward_reachability)
Perform reachability slicing on goto_model, with respect to the criterion given by all properties...
#define HELP_REACHABILITY_SLICER
Abstract interface to eager or lazy GOTO models.
const symbolt & lookup_ref(const irep_idt &name) const
Find a symbol in the symbol table for read-only access.
Remove function exceptional returns.
void instrument_preconditions(const goto_modelt &goto_model, goto_programt &goto_program)
Remove Instance-of Operators.
std::wstring widen(const char *s)
Remove Virtual Function (Method) Calls.
irep_idt mode
Language mode.
virtual void get_language_options(const cmdlinet &)
std::string object_bits_info()
static lazy_goto_modelt from_handler_object(THandler &handler, const optionst &options, message_handlert &message_handler)
Create a lazy_goto_modelt from a object that defines function/module pass handlers.
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...
#define HELP_SHOW_CLASS_HIERARCHY
Java simple opaque stub generation.
std::string get_value(char option) const
void java_generate_simple_method_stub(const irep_idt &function_name, symbol_table_baset &symbol_table, bool assume_non_null, const object_factory_parameterst &object_factory_parameters, message_handlert &message_handler)
object_factory_parameterst object_factory_params
void remove_unused_functions(goto_modelt &goto_model, message_handlert &message_handler)
virtual const goto_functionst & get_goto_functions() const =0
Accessor to get a raw goto_functionst.
void convert_function(const irep_idt &identifier, goto_functionst::goto_functiont &result)
std::unique_ptr< languaget > get_language_from_filename(const std::string &filename)
Get the language corresponding to the registered file name extensions.
JBMC Command Line Option Processing.
void process_goto_function(goto_model_functiont &function, const abstract_goto_modelt &, const optionst &)
Model that holds partially loaded map of functions.
static mstreamt & eom(mstreamt &m)
void show_goto_functions(const namespacet &ns, message_handlert &message_handler, ui_message_handlert::uit ui, const goto_functionst &goto_functions, bool list_only)
std::unique_ptr< cover_configt > cover_config
Remove 'asm' statements by compiling into suitable standard code.
void remove_virtual_functions(const symbol_table_baset &symbol_table, goto_functionst &goto_functions)
void add_failed_symbol_if_needed(const symbolt &symbol, symbol_table_baset &symbol_table)
Create a failed-dereference symbol for the given base symbol if it is pointer-typed, an lvalue, and doesn't already have one.
#define CPROVER_EXIT_SUCCESS
Success indicates the required analysis has been performed without error.
#define INVARIANT(CONDITION, REASON)
static int do_language_agnostic_bmc(const path_strategy_choosert &path_strategy_chooser, const optionst &opts, abstract_goto_modelt &goto_model, const ui_message_handlert::uit &ui, messaget &message, std::function< void(bmct &, const symbol_tablet &)> driver_configure_bmc=nullptr, std::function< bool(void)> callback_after_symex=nullptr)
Perform core BMC, using an abstract model to supply GOTO function bodies (perhaps created on demand)...
path_strategy_choosert path_strategy_chooser
void parse_cover_options(const cmdlinet &cmdline, optionst &options)
Parses coverage-related command line options.
Set the properties to check.
bool generate_function_body(const irep_idt &function_name, symbol_table_baset &symbol_table, goto_functiont &function, bool body_available)
#define PARSE_OPTIONS_GOTO_TRACE(cmdline, options)
bool set(const cmdlinet &cmdline)
void add_loop_unwind_handler(symex_bmct::loop_unwind_handlert handler)
void remove_instanceof(goto_programt::targett target, goto_programt &goto_program, symbol_table_baset &symbol_table)
Replace an instanceof in the expression or guard of the passed instruction of the given function body...
void show_symbol_table(const symbol_tablet &symbol_table, ui_message_handlert::uit ui)
std::string show_strategies() const
suitable for displaying as a front-end help message
virtual bool isset(char option) const
void set_path_strategy_options(const cmdlinet &, optionst &, messaget &) const
add paths and exploration-strategy option, suitable to be invoked from front-ends.
bool can_generate_function_body(const irep_idt &name)
size_t max_nondet_tree_depth
Maximum depth for object hierarchy on input.
#define HELP_SHOW_PROPERTIES
#define MAX_NONDET_ARRAY_LENGTH_DEFAULT
void remove_exceptions(symbol_table_baset &symbol_table, goto_functionst &goto_functions, remove_exceptions_typest type)
removes throws/CATCH-POP/CATCH-PUSH
#define INITIALIZE_FUNCTION
Nondeterministic initialization of certain global scope variables.
void initialize(const cmdlinet &cmdline)
bool get_bool_option(const std::string &option) const
tvt java_enum_static_init_unwind_handler(const irep_idt &function_id, unsigned loop_number, unsigned unwind_count, unsigned &unwind_max, const symbol_tablet &symbol_table)
Unwind handler that special-cases the clinit (static initializer) functions of enumeration classes...
static std::unique_ptr< goto_modelt > process_whole_model_and_freeze(lazy_goto_modelt &&model)
The model returned here has access to the functions we've already loaded but is frozen in the sense t...
::goto_functiont goto_functiont
virtual const symbol_tablet & get_symbol_table() const =0
Accessor to get the symbol table.
Abstract interface to support a programming language.
Convert side_effect_expr_nondett expressions.
std::unique_ptr< languaget > new_java_bytecode_language()
virtual void set_message_handler(message_handlert &_message_handler)
void full_slicer(goto_functionst &goto_functions, const namespacet &ns, slicing_criteriont &criterion)
virtual bool can_produce_function(const irep_idt &id) const =0
Determines if this model can produce a body for the given function.
void property_slicer(goto_functionst &goto_functions, const namespacet &ns, const std::list< std::string > &properties)
void adjust_float_expressions(exprt &expr, const namespacet &ns)
This adds the rounding mode to floating-point operations, including those in vectors and complex numb...
virtual int doit() override
invoke main modules
Replace Java Nondet expressions.
std::string banner_string(const std::string &front_end, const std::string &version)
void instrument_cover_goals(goto_programt &goto_program, const cover_instrumenterst &instrumenters, const irep_idt &mode, message_handlert &message_handler)
Applies instrumenters to given goto program.
bool has_symbol(const irep_idt &name) const
Check whether a symbol exists in the symbol table.
#define PARSE_OPTIONS_GOTO_CHECK(cmdline, options)
void remove_returns(symbol_table_baset &symbol_table, goto_functionst &goto_functions)
removes returns
void goto_check(const namespacet &ns, const optionst &options, const irep_idt &mode, goto_functionst::goto_functiont &goto_function)
virtual void help() override
display command line help
void load_all_functions() const
Eagerly loads all functions from the symbol table.
int get_goto_program(std::unique_ptr< goto_modelt > &goto_model, const optionst &)
virtual void show_parse(std::ostream &out)=0
bool show_loaded_functions(const abstract_goto_modelt &goto_model)
static irep_idt this_operating_system()
message_handlert & get_message_handler()
void convert_nondet(goto_programt &goto_program, symbol_table_baset &symbol_table, message_handlert &message_handler, const object_factory_parameterst &object_factory_parameters, const irep_idt &mode)
For each instruction in the goto program, checks if it is an assignment from nondet and replaces it w...
bool stub_objects_are_not_null
size_t max_nondet_array_length
Maximum value for the non-deterministically-chosen length of an array.
Goto Programs with Functions.
static irep_idt entry_point()
Document and give macros for the exit codes of CPROVER binaries.
mstreamt & status() const
bool set_properties(goto_modelt &goto_model)
#define JAVA_BYTECODE_LANGUAGE_OPTIONS_HELP
#define HELP_SHOW_GOTO_FUNCTIONS
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...
size_t max_nondet_string_length
Maximum value for the non-deterministically-chosen length of a string.
The symbol table base class interface.
void remove_skip(goto_programt &goto_program, goto_programt::targett begin, goto_programt::targett end)
remove unnecessary skip statements
void show_class_hierarchy(const class_hierarchyt &hierarchy, message_handlert &message_handler, ui_message_handlert::uit ui, bool children_only)
Output the class hierarchy.
void remove_java_new(goto_programt::targett target, goto_programt &goto_program, symbol_table_baset &symbol_table, message_handlert &message_handler)
Replace every java_new or java_new_array by a malloc side-effect and zero initialization.
symbol_tablet & symbol_table
Reference to symbol_table in the internal goto_model.
std::unique_ptr< languaget > new_ansi_c_language()
Bounded model checking or path exploration for goto-programs.
Unwind loops in static initializers.
ui_message_handlert ui_message_handler
void get_command_line_options(optionst &)
virtual void usage_error()
void register_language(language_factoryt factory)
Register a language Note: registering a language is required for using the functions in language_util...
static void replace_java_nondet(goto_programt &goto_program)
Checks each instruction in the goto program to see whether it is a method returning nondet...
void set_option(const std::string &option, const bool value)
#define MAX_NONDET_TREE_DEPTH
virtual bool parse(std::istream &instream, const std::string &path)=0
#define MAX_NONDET_STRING_LENGTH
void label_properties(goto_modelt &goto_model)
goto_functionst goto_functions
GOTO functions.
std::unique_ptr< 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.
static irep_idt this_architecture()
void nondet_static(const namespacet &ns, goto_functionst &goto_functions, const irep_idt &fct_name)
Interface providing access to a single function in a GOTO model, plus its associated symbol table...
void show_properties(const namespacet &ns, const irep_idt &identifier, message_handlert &message_handler, ui_message_handlert::uit ui, const goto_programt &goto_program)