int goto_instrument_parse_optionst::doit() { if(cmdline.isset("version")) { std::cout << CBMC_VERSION << std::endl; return 0; } if(cmdline.args.size()!=1 && cmdline.args.size()!=2) { help(); return 0; } eval_verbosity(); try { register_languages(); get_goto_program(); instrument_goto_program(); if(cmdline.isset("show-value-sets")) { do_function_pointer_removal(); do_partial_inlining(); // recalculate numbers, etc. goto_functions.update(); status() << "Pointer Analysis" << eom; namespacet ns(symbol_table); value_set_analysist value_set_analysis(ns); value_set_analysis(goto_functions); show_value_sets(get_ui(), goto_functions, value_set_analysis); return 0; } if(cmdline.isset("show-global-may-alias")) { do_function_pointer_removal(); do_partial_inlining(); do_remove_returns(); parameter_assignments(symbol_table, goto_functions); // recalculate numbers, etc. goto_functions.update(); namespacet ns(symbol_table); global_may_alias_analysist global_may_alias_analysis; global_may_alias_analysis(goto_functions, ns); global_may_alias_analysis.output(ns, goto_functions, std::cout); return 0; } if(cmdline.isset("show-local-bitvector-analysis")) { do_function_pointer_removal(); do_partial_inlining(); parameter_assignments(symbol_table, goto_functions); // recalculate numbers, etc. goto_functions.update(); namespacet ns(symbol_table); forall_goto_functions(it, goto_functions) { local_bitvector_analysist local_bitvector_analysis(it->second); std::cout << ">>>>" << std::endl; std::cout << ">>>> " << it->first << std::endl; std::cout << ">>>>" << std::endl; local_bitvector_analysis.output(std::cout, it->second, ns); std::cout << std::endl; } return 0; }
int preparet::get_async_modules() { if(goto_functions.function_map.empty()) { // see if we have a "main" if(context.symbols.find("main")==context.symbols.end()) { error("failed to find entry point -- please provide a model"); return 1; } status("Generating GOTO Program"); goto_convert( context, options, goto_functions, get_message_handler()); } if(cmdline.isset("show-goto-functions")) { goto_functions.output(ns, std::cout); return 0; } unsigned functions=goto_functions.function_map.size(); unsigned instructions=0; forall_goto_functions(it, goto_functions) instructions+=it->second.body.instructions.size(); status(i2string(functions)+" functions, "+ i2string(instructions)+" instructions."); if(cmdline.isset("string-abstraction")) string_instrumentation( context, get_message_handler(), goto_functions); status("Removing function pointers"); remove_function_pointers(ns, goto_functions); status("Removing unused functions"); remove_unused_functions( goto_functions, get_message_handler()); if(cmdline.isset("full-inlining")) { status("Full inlining"); satabs_inline( goto_functions, ns, get_message_handler()); } else { // partially inline functions status("Partial inlining"); satabs_partial_inline( goto_functions, ns, get_message_handler()); // we do this again, to remove all the functions that are inlined now remove_unused_functions( goto_functions, get_message_handler()); status("Adjusting functions"); prepare_functions( context, goto_functions, get_message_handler()); // show it? if(cmdline.isset("show-adjusted-functions")) { goto_functions.output(ns, std::cout); return 0; } } // add loop ids goto_functions.compute_loop_numbers(); // show it? if(cmdline.isset("show-loops")) { show_loop_numbers(get_ui(), goto_functions); return 0; } add_failed_symbols(context); // add generic checks goto_check(ns, options, goto_functions); if(cmdline.isset("string-abstraction")) { status("String Abstraction"); string_abstraction( context, get_message_handler(), goto_functions); } goto_functions.compute_location_numbers(); if(cmdline.isset("pointer-check") || cmdline.isset("show-value-sets") || cmdline.isset("data-race-check")) { status("Pointer Analysis"); value_set_analysist value_set_analysis(ns); value_set_analysis(goto_functions); // show it? if(cmdline.isset("show-value-sets")) { show_value_sets(get_ui(), goto_functions, value_set_analysis); return 0; } if(cmdline.isset("pointer-check")) { status("Adding Pointer Checks"); // add pointer checks pointer_checks( goto_functions, context, options, value_set_analysis); } if(cmdline.isset("data-race-check")) { status("Adding Data Race Checks"); add_race_assertions( value_set_analysis, context, goto_functions); value_set_analysis. update(goto_functions); } } goto_functions.compute_location_numbers(); #if 0 // do invariant propagation if(!cmdline.isset("no-invariant-sets")) { status("Invariant Propagation"); invariant_propagation( goto_functions); } else invariant_propagation.initialize( goto_functions); if(cmdline.isset("show-invariant-sets")) { invariant_propagation.output( goto_functions, std::cout); return 0; } // simplify if(!cmdline.isset("no-invariant-sets")) invariant_propagation.simplify( goto_functions); #endif // set claim if(cmdline.isset("claim")) set_claims( goto_functions, cmdline.get_values("claim")); // slice if(!cmdline.isset("no-slicing")) slicer(goto_functions); // show it? if(cmdline.isset("show-final-program")) { goto_functions.output(ns, std::cout); return 0; } return -1; // proceed! }
int preparet::get_async_modules() { if(goto_functions.function_map.empty()) { // see if we have a "main" if(context.symbols.find("main")==context.symbols.end()) { error("failed to find entry point -- please provide a model"); return 1; } status("Generating GOTO Program"); goto_convert( context, goto_functions, get_message_handler()); } // we no longer need any parse trees or language files clear_parse(); // finally add the library status("Adding CPROVER library"); link_to_library( context, goto_functions, get_message_handler()); if(cmdline.isset("show-goto-functions")) { goto_functions.output(ns, std::cout); return 0; } unsigned functions=goto_functions.function_map.size(); unsigned instructions=0; forall_goto_functions(it, goto_functions) instructions+=it->second.body.instructions.size(); status(i2string(functions)+" functions, "+ i2string(instructions)+" instructions."); if(cmdline.isset("string-abstraction")) string_instrumentation( context, get_message_handler(), goto_functions); status("Removing function pointers"); remove_function_pointers(ns, goto_functions, cmdline.isset("pointer-check")); status("Removing unused functions"); remove_unused_functions( goto_functions, get_message_handler()); // Boom requies full inlining. bool boom= !cmdline.isset("modelchecker") || std::string(cmdline.getval("modelchecker"))=="boom"; // OSWALDO if(cmdline.isset("full-inlining") || boom) { status("Full inlining"); satabs_inline( goto_functions, ns, get_message_handler()); } else { // partially inline functions status("Partial inlining"); satabs_partial_inline( goto_functions, ns, get_message_handler()); // we do this again, to remove all the functions that are inlined now remove_unused_functions( goto_functions, get_message_handler()); status("Adjusting functions"); prepare_functions( context, goto_functions, get_message_handler()); // show it? if(cmdline.isset("show-adjusted-functions")) { goto_functions.output(ns, std::cout); return 0; } } // add loop ids goto_functions.compute_loop_numbers(); add_failed_symbols(context); // add generic checks goto_check(ns, options, goto_functions); if(cmdline.isset("string-abstraction")) { status("String Abstraction"); string_abstraction( context, get_message_handler(), goto_functions); } goto_functions.compute_location_numbers(); #if 0 // obsoleted by goto_check if(cmdline.isset("pointer-check") || cmdline.isset("show-value-sets")) { status("Pointer Analysis"); value_set_analysist value_set_analysis(ns); value_set_analysis(goto_functions); // show it? if(cmdline.isset("show-value-sets")) { show_value_sets(get_ui(), goto_functions, value_set_analysis); return 0; } if(cmdline.isset("pointer-check")) { status("Adding Pointer Checks"); // add pointer checks pointer_checks( goto_functions, context, options, value_set_analysis); } } #endif goto_functions.compute_location_numbers(); // label claims label_claims(goto_functions); // set claim if(cmdline.isset("claim")) set_claims( goto_functions, cmdline.get_values("claim")); // reachability slice? if(!cmdline.isset("no-slicing")) reachability_slicer(goto_functions); // show it? if(cmdline.isset("show-final-program")) { goto_functions.output(ns, std::cout); return 0; } return -1; // proceed! }
bool cbmc_parseoptionst::process_goto_program( const optionst &options, goto_functionst &goto_functions) { try { namespacet ns(context); if(cmdline.isset("string-abstraction")) string_instrumentation( context, get_message_handler(), goto_functions); status("Function Pointer Removal"); remove_function_pointers(ns, goto_functions, cmdline.isset("pointer-check")); status("Partial Inlining"); // do partial inlining goto_partial_inline(goto_functions, ns, ui_message_handler); status("Generic Property Instrumentation"); // add generic checks goto_check(ns, options, goto_functions); if(cmdline.isset("string-abstraction")) { status("String Abstraction"); string_abstraction(context, get_message_handler(), goto_functions); } // add failed symbols // needs to be done before pointer analysis add_failed_symbols(context); if(cmdline.isset("pointer-check") || cmdline.isset("show-value-sets")) { status("Pointer Analysis"); value_set_analysist value_set_analysis(ns); value_set_analysis(goto_functions); // show it? if(cmdline.isset("show-value-sets")) { show_value_sets(get_ui(), goto_functions, value_set_analysis); return true; } status("Adding Pointer Checks"); // add pointer checks pointer_checks( goto_functions, context, options, value_set_analysis); } // recalculate numbers, etc. goto_functions.update(); // add loop ids goto_functions.compute_loop_numbers(); // if we aim to cover, replace // all assertions by false to prevent simplification if(cmdline.isset("cover-assertions")) make_assertions_false(goto_functions); // show it? if(cmdline.isset("show-loops")) { show_loop_numbers(get_ui(), goto_functions); return true; } // show it? if(cmdline.isset("show-goto-functions")) { goto_functions.output(ns, std::cout); return true; } } catch(const char *e) { error(e); return true; } catch(const std::string e) { error(e); return true; } catch(int) { return true; } catch(std::bad_alloc) { error("Out of memory"); return true; } return false; }