Example #1
0
static void top(void)
{
	xenstat_domain **domains;
	unsigned int i, num_domains = 0;

	/* Now get the node information */
	if (prev_node != NULL)
		xenstat_free_node(prev_node);
	prev_node = cur_node;
	cur_node = xenstat_get_node(xhandle, XENSTAT_ALL);
	if (cur_node == NULL)
		fail("Failed to retrieve statistics from libxenstat\n");

	/* dump summary top information */
	if (!batch)
		do_summary();

	/* Count the number of domains for which to report data */
	num_domains = xenstat_node_num_domains(cur_node);

	domains = calloc(num_domains, sizeof(xenstat_domain *));
	if(domains == NULL)
		fail("Failed to allocate memory\n");

	for (i=0; i < num_domains; i++)
		domains[i] = xenstat_node_domain_by_index(cur_node, i);

	/* Sort */
	qsort(domains, num_domains, sizeof(xenstat_domain *),
	      (int(*)(const void *, const void *))compare_domains);

	if(first_domain_index >= num_domains)
		first_domain_index = num_domains-1;

	for (i = first_domain_index; i < num_domains; i++) {
		if(!batch && current_row() == lines()-1)
			break;
		if (i == first_domain_index || repeat_header)
			do_header();
		do_domain(domains[i]);
		if (show_vcpus)
			do_vcpu(domains[i]);
		if (show_networks)
			do_network(domains[i]);
		if (show_vbds)
			do_vbd(domains[i]);
		if (show_tmem)
			do_tmem(domains[i]);
	}

	if (!batch)
		do_bottom_line();

	free(domains);
}
Example #2
0
void summarizer_fwt::compute_summary_rec(const function_namet &function_name,
				      const exprt &precondition,
				      bool context_sensitive)
{
  local_SSAt &SSA = ssa_db.get(function_name); //TODO: make const
  
  // recursively compute summaries for function calls
  inline_summaries(function_name,SSA,precondition,context_sensitive); 

  status() << "Analyzing function "  << function_name << eom;

#if 0
  {
    std::ostringstream out;
    out << "Function body for " << function_name << 
      " to be analyzed: " << std::endl;
    for(local_SSAt::nodest::iterator n = SSA.nodes.begin(); 
        n!=SSA.nodes.end(); n++)
    {
      if(!n->empty()) n->output(out,SSA.ns);
    }
    out << "(enable) " << from_expr(SSA.ns, "", SSA.get_enabling_exprs()) 
	<< "\n";
    debug() << out.str() << eom;
  }
#endif

  // create summary
  summaryt summary;
  summary.params = SSA.params;
  summary.globals_in = SSA.globals_in;
  summary.globals_out = SSA.globals_out;
  summary.fw_precondition = precondition;

  if(!options.get_bool_option("havoc"))
  {
    do_summary(function_name,SSA,summary,true_exprt(),context_sensitive);
  }

  if(!options.get_bool_option("competition-mode"))
  {
    std::ostringstream out;
    out << std::endl << "Summary for function " << function_name << std::endl;
    summary.output(out,SSA.ns);   
    status() << out.str() << eom;
  }

  // store summary in db
  summary_db.put(function_name,summary);
}
Example #3
0
int main(int argc, char** argv) {
  llvm::cl::ParseCommandLineOptions(argc, argv);
  graph.structureFromFile(inputfilename);
  
  for (unsigned i = 0; i != statModeList.size(); ++i) {
    switch (statModeList[i]) {
      case summary: do_summary(); break;
      case degrees: do_degrees(); break;
      default: abort(); break;
    }
  }

  return 0;
}
Example #4
0
void summarizer_bwt::compute_summary_rec(const function_namet &function_name,
				      const exprt &postcondition,
				      bool context_sensitive)
{
  local_SSAt &SSA = ssa_db.get(function_name); 
  
  const summaryt &old_summary = summary_db.get(function_name);

  // recursively compute summaries for function calls
  inline_summaries(function_name,SSA,old_summary,
		   postcondition,context_sensitive,
		   options.get_bool_option("sufficient")); 

  status() << "Analyzing function "  << function_name << eom;

  // create summary
  summaryt summary;
  summary.params = SSA.params;
  summary.globals_in = SSA.globals_in;
  summary.globals_out = SSA.globals_out;
  summary.bw_postcondition = postcondition;

  if(!options.get_bool_option("havoc"))
  {
    do_summary(function_name,SSA,old_summary,summary,context_sensitive);
  }

  // store summary in db
  summary_db.put(function_name,summary);

  {
    std::ostringstream out;
    out << std::endl << "Summary for function " << function_name << std::endl;
    summary_db.get(function_name).output(out,SSA.ns);   
    status() << out.str() << eom;
  }

}
Example #5
0
void summarizer_fw_termt::compute_summary_rec(
  const function_namet &function_name,
  const exprt &precondition,
  bool context_sensitive)
{
  if(options.get_bool_option("competition-mode") &&
     summary_db.exists(ID__start) &&
     summary_db.get(ID__start).terminates==NO)
  {
    return;
  }

  local_SSAt &SSA=ssa_db.get(function_name);

  // recursively compute summaries for function calls
  threevalt calls_terminate=YES;
  bool has_function_calls=false;
  inline_summaries(
    function_name,
    SSA,
    precondition,
    context_sensitive,
    calls_terminate,
    has_function_calls);

  status() << "Analyzing function "  << function_name << eom;

  {
    std::ostringstream out;
    out << "Function body for " << function_name <<
      " to be analyzed: " << std::endl;
    for(local_SSAt::nodest::iterator n=SSA.nodes.begin();
        n!=SSA.nodes.end(); n++)
    {
      if(!n->empty())
        n->output(out, SSA.ns);
    }
    out << "(enable) " << from_expr(SSA.ns, "", SSA.get_enabling_exprs())
        << "\n";
    debug() << out.str() << eom;
  }

  bool has_loops=false;
  for(local_SSAt::nodest::iterator n_it=SSA.nodes.begin();
      n_it!=SSA.nodes.end(); n_it++)
  {
    if(n_it->loophead!=SSA.nodes.end())
    {
      has_loops=true;
      break;
    }
  }

  debug() << "function "
          << (has_function_calls ? "has" : "does not have") << " function calls"
          << eom;
  debug() << "function calls terminate: "
          << threeval2string(calls_terminate) << eom;
  debug() << "function "
          << (has_loops ? "has loops" : "does not have loops") << eom;

  // create summary
  summaryt summary;
  summary.params=SSA.params;
  summary.globals_in=SSA.globals_in;
  summary.globals_out=SSA.globals_out;
  summary.fw_precondition=precondition;
  summary.terminates=UNKNOWN;

  // compute summary
  if(!options.get_bool_option("havoc"))
  {
    // We are not allowed to assume the assertions here,
    //  otherwise we might cut off all terminating executions
    //  and classify the program as non-terminating.
    do_summary(function_name, SSA, summary, true_exprt(), context_sensitive);
  }

  // check termination
  status() << "Computing termination argument for " << function_name << eom;
  // check non-termination if we haven't analyzed this function yet,
  // otherwise the termination status is UNKNOWN anyways
  if(!summary_db.exists(function_name))
  {
    do_nontermination(function_name, SSA, summary);
  }
  if(summary.terminates==UNKNOWN)
  {
    bool has_terminating_function_calls=
      has_function_calls && calls_terminate==YES;

    if(!has_loops && !has_function_calls)
    {
      status() << "Function trivially terminates" << eom;
      summary.terminates=YES;
    }
    else if(!has_loops && has_function_calls && calls_terminate==YES)
    {
      status() << "Function terminates" << eom;
      summary.terminates=YES;
    }
    else if(has_function_calls && calls_terminate!=YES)
    {
      summary.terminates=calls_terminate;
    }
    else if(has_loops &&
            (!has_function_calls || has_terminating_function_calls))
    {
      do_termination(function_name, SSA, summary);
    }
  }
  {
    std::ostringstream out;
    out << std::endl << "Summary for function " << function_name << std::endl;
    summary.output(out, SSA.ns);
    status() << out.str() << eom;
  }

  // store summary in db
  summary_db.put(function_name, summary);
}
Example #6
0
int
main (int argc, char **argv)
{
	MsOle *ole;
	int lp, exit = 0, interact = 0;
	char *buffer = g_new (char, 1024) ;

	if (argc<2)
		syntax_error(0);

	if (!g_strcasecmp (argv [1], "regression")) {
		do_regression_tests ();
		return 0;
	}

	printf ("Ole file '%s'\n", argv[1]);
	if (ms_ole_open_vfs (&ole, argv[1], TRUE, NULL)
	    != MS_OLE_ERR_OK) {
		printf ("Creating new file '%s'\n", argv[1]);
		if (ms_ole_create_vfs (&ole, argv[1], TRUE, NULL)
		    != MS_OLE_ERR_OK)
			syntax_error ("Can't open file or create new one");
	}

	if (argc<=2)
		syntax_error ("Need command or -i");

	if (argc>2 && argv[argc-1][0]=='-'
	    && argv[argc-1][1]=='i') 
		interact=1;
	else {
		char *str=g_strdup(argv[2]) ;
		for (lp=3;lp<argc;lp++)
			str = g_strconcat(str," ",argv[lp],NULL); /* FIXME Mega leak :-) */
		buffer = str; /* and again */
	}

	cur_dir = g_strdup ("/");

	do
	{
		char *ptr;

		if (interact) {
			fprintf (stdout,"> ");
			fflush (stdout);
			fgets (buffer, 1023, stdin);
		}

		arg_data = g_strsplit (g_strchomp (buffer), delim, -1);
		arg_cur  = 0;
		if (!arg_data && interact) continue;
		if (!interact)
			printf ("Command : '%s'\n", arg_data[0]);
		ptr = arg_data[arg_cur++];
		if (!ptr)
			continue;

		if (g_strcasecmp (ptr, "ls") == 0)
			list_files (ole);
		else if (g_strcasecmp (ptr, "cd") == 0)
			enter_dir (ole);
		else if (g_strcasecmp (ptr, "dump") == 0)
			do_dump (ole);
		else if (g_strcasecmp (ptr, "biff") == 0)
			do_biff (ole);
		else if (g_strcasecmp (ptr, "biffraw") == 0)
			do_biff_raw (ole);
		else if (g_strcasecmp (ptr, "get") == 0)
			do_get (ole);
		else if (g_strcasecmp (ptr, "put") == 0)
			do_put (ole);
		else if (g_strcasecmp (ptr, "copyin") == 0)
			do_copyin (ole);
		else if (g_strcasecmp (ptr, "copyout") == 0)
			do_copyout (ole);
		else if (g_strcasecmp (ptr, "summary") == 0)
			do_summary (ole);
		else if (g_strcasecmp (ptr, "docsummary") == 0)
			do_docsummary (ole);
		else if (g_strcasecmp (ptr, "debug") == 0)
			ms_ole_debug (ole, 1);
		else if (g_strcasecmp (ptr, "tree") == 0)
			ms_ole_debug (ole, 2);
		else if (g_strcasecmp (ptr, "vba") == 0)
			dump_vba (ole);
		else if (g_strcasecmp (ptr, "help") == 0 ||
			 g_strcasecmp (ptr, "?") == 0 ||
			 g_strcasecmp (ptr, "info") == 0 ||
			 g_strcasecmp (ptr, "man") == 0)
			list_commands ();
		else if (g_strcasecmp (ptr, "exit") == 0 ||
			 g_strcasecmp (ptr, "quit") == 0 ||
			 g_strcasecmp (ptr, "q") == 0 ||
			 g_strcasecmp (ptr, "bye") == 0)
			exit = 1;
	}
	while (!exit && interact);

	ms_ole_destroy (&ole);
	return 0;
}
Example #7
0
void summarizer_bw_termt::compute_summary_rec(
  const function_namet &function_name,
  const exprt &postcondition,
  bool context_sensitive)
{
  local_SSAt &SSA=ssa_db.get(function_name);

  const summaryt &old_summary=summary_db.get(function_name);

  // recursively compute summaries for function calls
  inline_summaries(
    function_name, SSA, old_summary, postcondition, context_sensitive, false);

  status() << "Analyzing function "  << function_name << eom;

  bool has_loops=false;
  for(local_SSAt::nodest::iterator n_it=SSA.nodes.begin();
      n_it!=SSA.nodes.end(); n_it++)
  {
    if(n_it->loophead!=SSA.nodes.end())
    {
      has_loops=true;
      break;
    }
  }

  debug() << "function " <<
    (has_loops ? "has loops" : "does not have loops") << eom;

  // create summary
  summaryt summary;
  summary.params=SSA.params;
  summary.globals_in=SSA.globals_in;
  summary.globals_out=SSA.globals_out;
  summary.bw_postcondition=postcondition;

  do_nontermination(function_name, SSA, old_summary, summary);
  if(!options.get_bool_option("havoc") &&
     summary.terminates!=NO)
  {
    if(!has_loops)
    {
      do_summary(function_name, SSA, old_summary, summary, context_sensitive);
    }
    else
    {
      do_summary_term(
        function_name, SSA, old_summary, summary, context_sensitive);
    }
  }

  // store summary in db
  summary_db.put(function_name, summary);

  {
    std::ostringstream out;
    out << std::endl << "Summary for function " << function_name << std::endl;
    summary_db.get(function_name).output(out, SSA.ns);
    status() << out.str() << eom;
  }
}