Example #1
0
void string_instrumentation(
  contextt &context,
  message_handlert &message_handler,
  goto_functionst &dest)
{
  string_instrumentationt string_instrumentation(context, message_handler);
  string_instrumentation(dest);
}
Example #2
0
void string_instrumentation(
  symbol_tablet &symbol_table,
  message_handlert &message_handler,
  goto_functionst &dest)
{
  string_instrumentationt string_instrumentation(symbol_table, message_handler);
  string_instrumentation(dest);
}
Example #3
0
bool tan_parseoptionst::prepare()
{
  message_handlert &mh=get_message_handler();
  
  if(cmdline.isset("show-model"))
  {
    goto_functions.output(ns, std::cout);
    return true;
  }
  
  if(cmdline.isset("string-abstraction"))
    string_instrumentation(context, mh, goto_functions);
  
  status("Removing function pointers");
  remove_function_pointers(ns, goto_functions, false);

  status("Removing unused functions");
  remove_unused_functions(goto_functions, mh);

  status("Transforming loops");
  transform_loops(goto_functions, context, mh);
  
  status("Partial inlining");
  goto_partial_inline(goto_functions, ns, mh);
  
  // we do this again, to remove all the functions that are inlined now
  remove_unused_functions(goto_functions, mh);

  status("Adjusting functions");
  prepare_functions(context, goto_functions, mh);
  
  if(cmdline.isset("string-abstraction"))
  {
    status("String Abstraction");
    string_abstraction(context, mh, goto_functions);
  }
    
  goto_functions.compute_location_numbers();

  #if 0
  status("Natural loops:");

  forall_goto_functions(it, goto_functions)
  {
    natural_loopst nl;
    nl(it->second.body);		
    nl.output(std::cout);
  }
Example #4
0
File: prepare.cpp Project: olivo/BP
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!
}
Example #5
0
File: prepare.cpp Project: olivo/BP
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!
}
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;
}
Example #7
0
bool cbmc_parse_optionst::process_goto_program(
  const optionst &options,
  goto_functionst &goto_functions)
{
  try
  {
    namespacet ns(symbol_table);
    
    // Remove inline assembler; this needs to happen before
    // adding the library.
    remove_asm(symbol_table, goto_functions);

    // add the library
    status() << "Adding CPROVER library (" 
             << config.ansi_c.arch << ")" << eom;
    link_to_library(symbol_table, goto_functions, ui_message_handler);

    if(cmdline.isset("string-abstraction"))
      string_instrumentation(
        symbol_table, get_message_handler(), goto_functions);

    // remove function pointers
    status() << "Function Pointer Removal" << eom;
    remove_function_pointers(symbol_table, goto_functions,
      cmdline.isset("pointer-check"));

    // full slice?
    if(cmdline.isset("full-slice"))
    {
      status() << "Performing a full slice" << eom;
      full_slicer(goto_functions, ns);
    }
  
    // do partial inlining
    status() << "Partial Inlining" << eom;
    goto_partial_inline(goto_functions, ns, ui_message_handler);
    
    // remove returns, gcc vectors, complex
    remove_returns(symbol_table, goto_functions);
    remove_vector(symbol_table, goto_functions);
    remove_complex(symbol_table, goto_functions);
    
    // add generic checks
    status() << "Generic Property Instrumentation" << eom;
    goto_check(ns, options, goto_functions);
    
    if(cmdline.isset("string-abstraction"))
    {
      status() << "String Abstraction" << eom;
      string_abstraction(symbol_table,
        get_message_handler(), goto_functions);
    }

    // add failed symbols
    // needs to be done before pointer analysis
    add_failed_symbols(symbol_table);
    
    // recalculate numbers, etc.
    goto_functions.update();

    // add loop ids
    goto_functions.compute_loop_numbers();
    
    // if we aim to cover assertions, replace
    // all assertions by false to prevent simplification
    
    if(cmdline.isset("cover") &&
       cmdline.get_value("cover")=="assertions")
      make_assertions_false(goto_functions);

    // show it?
    if(cmdline.isset("show-loops"))
    {
      show_loop_ids(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 << eom;
    return true;
  }

  catch(const std::string e)
  {
    error() << e << eom;
    return true;
  }
  
  catch(int)
  {
    return true;
  }
  
  catch(std::bad_alloc)
  {
    error() << "Out of memory" << eom;
    return true;
  }
  
  return false;
}