コード例 #1
0
ファイル: c2goto.cpp プロジェクト: huangshiyou/esbmc
  int doit() {
    goto_functionst goto_functions;

    config.set(cmdline);

    // Depends on command line options and config
    init_expr_constants();

    if (!cmdline.isset("output")) {
      std::cerr << "Must set output file" << std::endl;
      return 1;
    }

    if (parse()) return 1;
    if (typecheck()) return 1;

    std::ofstream out(cmdline.getval("output"), std::ios::out | std::ios::binary);

    if (write_goto_binary(out, context, goto_functions)) {
      std::cerr << "Failed to write C library to binary obj" << std::endl;
      return 1;
    }

    return 0;
  }
コード例 #2
0
ファイル: termination_base.cpp プロジェクト: olivo/BP
bool termination_baset::cegar(
  concrete_modelt &model,
  goto_tracet &goto_trace,
  fine_timet &modelchecker_time,
  fine_timet &unsafe_time,
  fine_timet &safe_time)
{
  goto_trace.clear();

  #if 0
  std::ofstream out("model");
  model.goto_functions.output(ns, out);
  out.close();
  #endif

  null_message_handlert nmh;
  message_handlert &mh = (verbosity >= 8) ? get_message_handler() : nmh;
  
  loop_componentt::argst args(mh, model);
  
  std::auto_ptr<refinert> refiner(select_refiner(options, args));
  std::auto_ptr<abstractort> abstractor(select_abstractor(options, args));
  std::auto_ptr<modelcheckert> modelchecker(select_modelchecker(options, args));
  std::auto_ptr<simulatort> simulator(select_simulator(options, args, shadow_context));

  unsigned this_verb=get_verbosity()-2;

  // set their verbosity -- all the same for now
  refiner->set_verbosity(this_verb);
  abstractor->set_verbosity(this_verb);
  modelchecker->set_verbosity(this_verb);
  simulator->set_verbosity(this_verb);

  try
  {
    satabs_safety_checker_baset safety_checker(ns, *abstractor, *refiner, *modelchecker, *simulator);
    safety_checker.set_message_handler(mh);
    safety_checker.set_verbosity(this_verb);

    fine_timet before=current_time();
    safety_checkert::resultt result=safety_checker(model.goto_functions);
    fine_timet diff=current_time()-before;
    modelchecker_time+=diff;

    switch(result)
    {
    case safety_checkert::ERROR:
      unsafe_time+=diff;
      throw "CEGAR Error";

    case safety_checkert::UNSAFE:
      goto_trace.clear();
      goto_trace.swap(safety_checker.error_trace);

      unsafe_time+=diff;
      return false; // not safe

    case safety_checkert::SAFE:
      safe_time+=diff;
      return true; // safe

    default:
      unsafe_time+=diff;
      throw std::string("CEGAR Result: ") + i2string(result);
    }
  }
  catch(const std::bad_alloc &s)
  {
    status(std::string("CEGAR Loop Exception: Memory exhausted"));
  }
  catch(const std::string &s)
  {
    status(std::string("CEGAR Loop Exception: ") + s);
  }
  catch(const char *s)
  {
    status(std::string("CEGAR Loop Exception: ") + s);
    if(std::string(s)=="refinement failure")
    {
      status("Dumping failure.o");
      write_goto_binary("failure.o", ns.get_context(), model.goto_functions, mh);
    }
  }
  catch(unsigned u)
  {
    status(std::string("CEGAR Loop Exception: ") + i2string(u));
  }
  catch(...)
  {
    status("UNKNOWN EXCEPTION CAUGHT");
  }

  return false;
}
コード例 #3
0
int goto_fence_inserter_parse_optionst::doit()
{
  if(cmdline.isset("version"))
  {
    std::cout << MUSKETEER_VERSION << std::endl;
    return 0;
  }

  if(cmdline.args.size()!=1 && cmdline.args.size()!=2)
  {
    help();
    return 0;
  }

  set_verbosity();

  try
  {
    register_languages();

    goto_functionst goto_functions;

    get_goto_program(goto_functions);

    instrument_goto_program(goto_functions);

    // write new binary?
    if(cmdline.args.size()==2)
    {
      status() << "Writing GOTO program to " << cmdline.args[1] << eom;

      if(write_goto_binary(
        cmdline.args[1], symbol_table, goto_functions, get_message_handler()))
        return 1;
      else
        return 0;
    }

    // help();
    return 0;
  }

  catch(const char *e)
  {
    error() << e << eom;
    return 11;
  }

  catch(const std::string e)
  {
    error() << e << eom;
    return 11;
  }

  catch(int)
  {
    return 11;
  }

  catch(std::bad_alloc)
  {
    error() << "Out of memory" << eom;
    return 11;
  }
}