Beispiel #1
0
Scml_Orig_IP::~Scml_Orig_IP() {
  std::cout << std::endl << std::endl;
  std::cout << "Destructor "<<name()<<std::endl;
  show_properties();
  std::cout << std::endl << std::endl;
  std::cout << std::endl << std::endl;
}
Beispiel #2
0
void show_properties(
  const goto_modelt &goto_model,
  ui_message_handlert::uit ui)
{
  const namespacet ns(goto_model.symbol_table);
  if(ui == ui_message_handlert::uit::JSON_UI)
    show_properties_json(ns, goto_model.goto_functions);
  else
    show_properties(ns, ui, goto_model.goto_functions);
}
Beispiel #3
0
void show_properties(
  const namespacet &ns,
  ui_message_handlert::uit ui,
  const goto_functionst &goto_functions)
{
  if(ui == ui_message_handlert::uit::JSON_UI)
    show_properties_json(ns, goto_functions);
  else
    for(const auto &fct : goto_functions.function_map)
      if(!fct.second.is_inlined())
        show_properties(ns, fct.first, ui, fct.second.body);
}
Beispiel #4
0
void Scml_Orig_IP::main_action() {
  wait(sc_core::SC_ZERO_TIME); // let the ScmlTe  stIP set the values in case of gc scml_properties
  show_properties();

  std::cout << std::endl << std::endl;
  SHOW_W_TIME("m_int_prop += 100" << std::endl);
  m_int_prop = m_int_prop + 100;
  SHOW_W_TIME("m_double_prop *= 2" << std::endl);
  m_double_prop *= 2;
  show_properties();
  
  wait(1, sc_core::SC_PS);
  show_properties();

  std::cout << std::endl << std::endl;
  SHOW_W_TIME("m_string_prop = \"value set by model\"" << std::endl);
  m_string_prop = "value set by model";
  SHOW_W_TIME("m_bool_prop = false" << std::endl);
  m_bool_prop = false;
  show_properties();
}
Beispiel #5
0
void show_properties(
  const indext &index,
  const optionst &options,
  std::ostream &out,
  message_handlert &message_handler)
{
  for(indext::file_to_functiont::const_iterator
      file_it=index.file_to_function.begin();
      file_it!=index.file_to_function.end();
      file_it++)
  {
    // read the file
    goto_modelt model;
    read_goto_binary(index.full_path(file_it->first), model, message_handler);
    
    // add the properties
    goto_check(options, model);
    model.goto_functions.update();
    label_properties(model.goto_functions);
    
    show_properties(model, ui_message_handlert::PLAIN);
  }
  
}
Beispiel #6
0
int symex_parseoptionst::doit()
{
  if(cmdline.isset("version"))
  {
    std::cout << CBMC_VERSION << std::endl;
    return 0;
  }

  register_language(new_ansi_c_language);
  register_language(new_cpp_language);

  //
  // command line options
  //

  optionst options;
  get_command_line_options(options);

  eval_verbosity();

  goto_functionst goto_functions;

  if(get_goto_program(options, goto_functions))
    return 6;

  label_properties(goto_functions);

  if(cmdline.isset("show-properties"))
  {
    const namespacet ns(symbol_table);
    show_properties(ns, get_ui(), goto_functions);
    return 0;
  }

  if(set_properties(goto_functions))
    return 7;

  if(cmdline.isset("show-locs"))
  {
    const namespacet ns(symbol_table);
    locst locs(ns);
    locs.build(goto_functions);
    locs.output(std::cout);
    return 0;
  }

  // do actual Symex

  try
  {
    const namespacet ns(symbol_table);
    path_searcht path_search(ns);

    path_search.set_message_handler(get_message_handler());
    path_search.set_verbosity(get_verbosity());

    if(cmdline.isset("depth"))
      path_search.depth_limit=unsafe_string2unsigned(cmdline.getval("depth"));

    if(cmdline.isset("context-bound"))
      path_search.context_bound=unsafe_string2unsigned(cmdline.getval("context-bound"));

    if(cmdline.isset("unwind"))
      path_search.unwind_limit=unsafe_string2unsigned(cmdline.getval("unwind"));

    if(cmdline.isset("show-vcc"))
    {
      path_search.show_vcc=true;
      path_search(goto_functions);
      return 0;
    }

    // do actual symex
    switch(path_search(goto_functions))
    {
    case safety_checkert::SAFE:
      report_properties(path_search.property_map);
      report_success();
      return 0;

    case safety_checkert::UNSAFE:
      report_properties(path_search.property_map);
      report_failure();
      return 10;

    default:
      return 8;
    }
  }

  catch(const std::string error_msg)
  {
    error() << error_msg << messaget::eom;
    return 8;
  }

  catch(const char *error_msg)
  {
    error() << error_msg << messaget::eom;
    return 8;
  }

  #if 0
  // let's log some more statistics
  debug() << "Memory consumption:" << messaget::endl;
  memory_info(debug());
  debug() << eom;
  #endif
}
Beispiel #7
0
int symex_parse_optionst::doit()
{
  if(cmdline.isset("version"))
  {
    std::cout << CBMC_VERSION << std::endl;
    return 0;
  }

  register_language(new_ansi_c_language);
  register_language(new_cpp_language);
  register_language(new_java_bytecode_language);

  //
  // command line options
  //

  optionst options;
  get_command_line_options(options);

  eval_verbosity();

  goto_model.set_message_handler(get_message_handler());

  if(goto_model(cmdline.args))
    return 6;

  if(process_goto_program(options))
    return 6;

  label_properties(goto_model);

  if(cmdline.isset("show-properties"))
  {
    show_properties(goto_model, get_ui());
    return 0;
  }

  if(set_properties())
    return 7;

  if(cmdline.isset("show-locs"))
  {
    const namespacet ns(goto_model.symbol_table);
    locst locs(ns);
    locs.build(goto_model.goto_functions);
    locs.output(std::cout);
    return 0;
  }

  // do actual Symex

  try
  {
    const namespacet ns(goto_model.symbol_table);
    path_searcht path_search(ns);

    path_search.set_message_handler(get_message_handler());

    if(cmdline.isset("depth"))
      path_search.set_depth_limit(unsafe_string2unsigned(cmdline.get_value("depth")));

    if(cmdline.isset("context-bound"))
      path_search.set_context_bound(unsafe_string2unsigned(cmdline.get_value("context-bound")));

    if(cmdline.isset("branch-bound"))
      path_search.set_branch_bound(unsafe_string2unsigned(cmdline.get_value("branch-bound")));

    if(cmdline.isset("unwind"))
      path_search.set_unwind_limit(unsafe_string2unsigned(cmdline.get_value("unwind")));

    if(cmdline.isset("dfs"))
      path_search.set_dfs();

    if(cmdline.isset("bfs"))
      path_search.set_bfs();

    if(cmdline.isset("locs"))
      path_search.set_locs();

    if(cmdline.isset("show-vcc"))
    {
      path_search.show_vcc=true;
      path_search(goto_model.goto_functions);
      return 0;
    }

    path_search.eager_infeasibility=
      cmdline.isset("eager-infeasibility");

    if(cmdline.isset("cover"))
    {
      // test-suite generation
      path_search(goto_model.goto_functions);
      report_cover(path_search.property_map);
      return 0;
    }
    else
    {
      // do actual symex, for assertion checking
      switch(path_search(goto_model.goto_functions))
      {
      case safety_checkert::SAFE:
        report_properties(path_search.property_map);
        report_success();
        return 0;

      case safety_checkert::UNSAFE:
        report_properties(path_search.property_map);
        report_failure();
        return 10;

      default:
        return 8;
      }
    }
  }

  catch(const std::string error_msg)
  {
    error() << error_msg << messaget::eom;
    return 8;
  }

  catch(const char *error_msg)
  {
    error() << error_msg << messaget::eom;
    return 8;
  }

  #if 0
  // let's log some more statistics
  debug() << "Memory consumption:" << messaget::endl;
  memory_info(debug());
  debug() << eom;
  #endif
}
Upscale_property_dialog::Upscale_property_dialog(QWidget *parent)
  : QDialog(parent)
{
  this->setWindowTitle("Block upscaling of properties");

  QVBoxLayout* main_layout = new QVBoxLayout(this);
  this->setLayout(main_layout);

  QHBoxLayout* source_layout = new QHBoxLayout(this);
  source_layout->addWidget(new QLabel("Source Grid",this));
  source_grid_selector_ = new GridSelector(this);
  source_layout->addWidget(source_grid_selector_);
  main_layout->addLayout(source_layout);

  QHBoxLayout* target_layout = new QHBoxLayout(this);
  target_layout->addWidget(new QLabel("Target Grid",this));
  target_grid_selector_ = new GridSelector(this);
  target_layout->addWidget(target_grid_selector_);
  main_layout->addLayout(target_layout);


  QButtonGroup* button_group = new QButtonGroup(this);
  use_group_ = new QRadioButton("From group",this);
  use_properties_ = new QRadioButton("From selected properties",this);
  use_group_->setChecked(true);
  use_properties_->setChecked(false);
  button_group->addButton(use_group_);
  button_group->addButton(use_properties_);
  button_group->setExclusive(true);

  QHBoxLayout* group_button_layout = new QHBoxLayout( this);
  group_button_layout->addWidget(use_group_);
  group_button_layout->addWidget(use_properties_);
  main_layout->addLayout(group_button_layout);

  QGroupBox* group_box = new QGroupBox("Select a group to upscale",this);
  group_selector_ = new SinglePropertyGroupSelector(this);
  group_box->setLayout(new QVBoxLayout());
  group_box->layout()->addWidget(group_selector_);
  main_layout->addWidget(group_box);

  QGroupBox* properties_box = new QGroupBox("Select properties to upscale",this);
  prop_selector_ = new OrderedPropertySelector(this);
  properties_box->setLayout(new QVBoxLayout());
  properties_box->layout()->addWidget(prop_selector_);
  main_layout->addWidget(properties_box);
  properties_box->setVisible(false);

  compute_variance_ = new QCheckBox("Compute block variance for continuous attribute ",this);
  main_layout->addWidget(compute_variance_);

  main_layout->addStretch();

 
  QHBoxLayout* bottom_layout = new QHBoxLayout( this);
  bottom_layout->setSpacing(9);
  QPushButton* close = new QPushButton( "Create and Close", this);
  QPushButton* ok = new QPushButton( "Create", this);
  QPushButton* cancel = new QPushButton( "Exit", this);
  bottom_layout->addStretch();
  bottom_layout->addWidget( ok ); 
//  bottom_layout->addStretch();
  bottom_layout->addWidget( close ); 
//  bottom_layout->addStretch();
  bottom_layout->addWidget( cancel ); 
//  bottom_layout->addStretch();

  main_layout->addLayout(bottom_layout);

  QObject::connect( use_group_, SIGNAL( toggled(bool) ),
                    group_box, SLOT( setVisible(bool) ) );
  QObject::connect( use_group_, SIGNAL( toggled(bool) ),
                    properties_box, SLOT( setHidden(bool) ) );

  QObject::connect( source_grid_selector_, SIGNAL( activated(QString) ),
                    group_selector_, SLOT( show_property_groups(QString) ) );
  QObject::connect( source_grid_selector_, SIGNAL( activated(QString) ),
                    prop_selector_, SLOT( show_properties(QString) ) );

  QObject::connect( ok, SIGNAL( clicked() ),
                    this, SLOT( create() ) );
  QObject::connect( close, SIGNAL( clicked() ),
                    this, SLOT( create_and_close() ) );
  QObject::connect( cancel, SIGNAL( clicked() ),
                    this, SLOT( reject() ) );

}
Beispiel #9
0
int clobber_parse_optionst::doit()
{
  if(cmdline.isset("version"))
  {
    std::cout << CBMC_VERSION << std::endl;
    return 0;
  }

  register_language(new_ansi_c_language);
  register_language(new_cpp_language);

  //
  // command line options
  //

  optionst options;
  get_command_line_options(options);

  eval_verbosity();

  goto_functionst goto_functions;

  if(get_goto_program(options, goto_functions))
    return 6;
    
  label_properties(goto_functions);

  if(cmdline.isset("show-properties"))
  {
    const namespacet ns(symbol_table);
    show_properties(ns, get_ui(), goto_functions);
    return 0;
  }

  if(set_properties(goto_functions))
    return 7;
    
  // do instrumentation

  try
  {
    const namespacet ns(symbol_table);
    
    std::ofstream out("simulator.c");
    
    if(!out)
      throw std::string("failed to create file simulator.c");
    
    dump_c(goto_functions, true, ns, out);
    
    status() << "instrumentation complete; compile and execute simulator.c" << eom;
    
    return 0;
  }
  
  catch(const std::string error_msg)
  {
    error() << error_msg << messaget::eom;
    return 8;
  }

  catch(const char *error_msg)
  {
    error() << error_msg << messaget::eom;
    return 8;
  }

  #if 0                                         
  // let's log some more statistics
  debug() << "Memory consumption:" << messaget::endl;
  memory_info(debug());
  debug() << eom;
  #endif
}
Beispiel #10
0
int cbmc_parse_optionst::doit()
{
  if(cmdline.isset("version"))
  {
    std::cout << CBMC_VERSION << std::endl;
    return 0;
  }
  
  //
  // command line options
  //

  optionst options;
  get_command_line_options(options);
  eval_verbosity();

  //
  // Print a banner
  //
  status() << "CBMC version " CBMC_VERSION " "
           << sizeof(void *)*8 << "-bit "
           << config.this_architecture() << " "
           << config.this_operating_system() << eom;

  //
  // Unwinding of transition systems is done by hw-cbmc.
  //

  if(cmdline.isset("module") ||
     cmdline.isset("gen-interface"))

  {
    error() << "This version of CBMC has no support for "
               " hardware modules. Please use hw-cbmc." << eom;
    return 1;
  }
  
  register_languages();
  
  if(cmdline.isset("test-preprocessor"))
    return test_c_preprocessor(ui_message_handler)?8:0;
  
  if(cmdline.isset("preprocess"))
  {
    preprocessing();
    return 0;
  }

  goto_functionst goto_functions;

  // get solver
  cbmc_solverst cbmc_solvers(options, symbol_table, ui_message_handler);
  cbmc_solvers.set_ui(get_ui());

  std::unique_ptr<cbmc_solverst::solvert> cbmc_solver;
  
  try
  {
    cbmc_solver=cbmc_solvers.get_solver();
  }
  
  catch(const char *error_msg)
  {
    error() << error_msg << eom;
    return 1;
  }

  prop_convt &prop_conv=cbmc_solver->prop_conv();

  bmct bmc(options, symbol_table, ui_message_handler, prop_conv);

  int get_goto_program_ret=
    get_goto_program(options, bmc, goto_functions);

  if(get_goto_program_ret!=-1)
    return get_goto_program_ret;

  label_properties(goto_functions);

  if(cmdline.isset("show-claims") || // will go away
     cmdline.isset("show-properties")) // use this one
  {
    const namespacet ns(symbol_table);
    show_properties(ns, get_ui(), goto_functions);
    return 0;
  }

  if(cmdline.isset("show-reachable-properties")) // may replace --show-properties
  {
    const namespacet ns(symbol_table);
    
    // Entry point will have been set before and function pointers removed
    status() << "Removing Unused Functions" << eom;
    remove_unused_functions(goto_functions, ui_message_handler);
    
    show_properties(ns, get_ui(), goto_functions);
    return 0;
  }

  if(set_properties(goto_functions))
    return 7;

  if(cmdline.isset("danger"))
    return run_danger(options, result(), symbol_table, goto_functions);
  if(cmdline.isset("safety"))
    return run_safety(options, result(), symbol_table, goto_functions);

  // do actual BMC
  return do_bmc(bmc, goto_functions);
}