- Implemented output method selector, sys->output.
- Changed disable-report switch into --empty. - --scenario=-1 now displays a list of scenarios. Use wc -l to count them.
This commit is contained in:
		
							parent
							
								
									d5db3ca0e2
								
							
						
					
					
						commit
						dda2907492
					
				
							
								
								
									
										78
									
								
								src/main.c
									
									
									
									
									
								
							
							
						
						
									
										78
									
								
								src/main.c
									
									
									
									
									
								
							@ -102,8 +102,8 @@ main (int argc, char **argv)
 | 
				
			|||||||
  struct arg_lit *switch_incremental_runs = arg_lit0 (NULL, "increment-runs",
 | 
					  struct arg_lit *switch_incremental_runs = arg_lit0 (NULL, "increment-runs",
 | 
				
			||||||
				      "incremental search using the number of runs");
 | 
									      "incremental search using the number of runs");
 | 
				
			||||||
  struct arg_lit *switch_latex_output = arg_lit0 (NULL, "latex", "output in LaTeX format");
 | 
					  struct arg_lit *switch_latex_output = arg_lit0 (NULL, "latex", "output in LaTeX format");
 | 
				
			||||||
  struct arg_lit *switch_disable_violations_report =
 | 
					  struct arg_lit *switch_empty =
 | 
				
			||||||
    arg_lit0 ("d", "disable-report", "don't report violations");
 | 
					    arg_lit0 ("e", "empty", "do not generate output");
 | 
				
			||||||
  struct arg_lit *switch_no_progress_bar = arg_lit0 (NULL, "no-progress", "suppress progress bar");
 | 
					  struct arg_lit *switch_no_progress_bar = arg_lit0 (NULL, "no-progress", "suppress progress bar");
 | 
				
			||||||
  struct arg_lit *switch_state_space_graph = arg_lit0 (NULL, "state-space", "output state space graph");
 | 
					  struct arg_lit *switch_state_space_graph = arg_lit0 (NULL, "state-space", "output state space graph");
 | 
				
			||||||
  struct arg_lit *switch_implicit_choose = arg_lit0 (NULL, "implicit-choose", "allow implicit choose events (useful for few runs)");
 | 
					  struct arg_lit *switch_implicit_choose = arg_lit0 (NULL, "implicit-choose", "allow implicit choose events (useful for few runs)");
 | 
				
			||||||
@ -135,7 +135,7 @@ main (int argc, char **argv)
 | 
				
			|||||||
    switch_prune_trace_length, switch_incremental_trace_length,
 | 
					    switch_prune_trace_length, switch_incremental_trace_length,
 | 
				
			||||||
    switch_maximum_runs, switch_incremental_runs,
 | 
					    switch_maximum_runs, switch_incremental_runs,
 | 
				
			||||||
    switch_latex_output,
 | 
					    switch_latex_output,
 | 
				
			||||||
    switch_disable_violations_report,
 | 
					    switch_empty,
 | 
				
			||||||
    switch_no_progress_bar, 
 | 
					    switch_no_progress_bar, 
 | 
				
			||||||
    switch_state_space_graph,
 | 
					    switch_state_space_graph,
 | 
				
			||||||
    switch_implicit_choose,
 | 
					    switch_implicit_choose,
 | 
				
			||||||
@ -327,6 +327,10 @@ main (int argc, char **argv)
 | 
				
			|||||||
   * any scenario traversing selects chooses first.
 | 
					   * any scenario traversing selects chooses first.
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  sys->switchScenario = switch_scenario->ival[0];	/* scenario selector */
 | 
					  sys->switchScenario = switch_scenario->ival[0];	/* scenario selector */
 | 
				
			||||||
 | 
					  if (sys->switchScenario < 0)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      sys->output = SCENARIOS;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
  if (sys->switchScenario != 0)
 | 
					  if (sys->switchScenario != 0)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
#ifdef DEBUG
 | 
					#ifdef DEBUG
 | 
				
			||||||
@ -396,15 +400,12 @@ main (int argc, char **argv)
 | 
				
			|||||||
  if (switch_state_space_graph->count > 0)
 | 
					  if (switch_state_space_graph->count > 0)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      /* enable state space graph output */
 | 
					      /* enable state space graph output */
 | 
				
			||||||
      sys->switchStatespace = 1;
 | 
					      sys->output = STATESPACE;		//!< New method
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  /* TODO for now, warning for -m2 and non-clp */
 | 
					 | 
				
			||||||
  if (sys->match == 2 && !sys->clp)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
      printf
 | 
					 | 
				
			||||||
	("Warning: -m2 is only supported for constraint logic programming.\n");
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					  if (switch_empty->count > 0)
 | 
				
			||||||
 | 
					    sys->output = EMPTY;
 | 
				
			||||||
 | 
					  if (switch_prune_trace_length->ival[0] >= 0)
 | 
				
			||||||
 | 
					    sys->switch_maxtracelength = switch_prune_trace_length->ival[0];
 | 
				
			||||||
#ifdef DEBUG
 | 
					#ifdef DEBUG
 | 
				
			||||||
  /* in debugging mode, some extra switches */
 | 
					  /* in debugging mode, some extra switches */
 | 
				
			||||||
  if (switch_debug_indent->count > 0)
 | 
					  if (switch_debug_indent->count > 0)
 | 
				
			||||||
@ -415,10 +416,42 @@ main (int argc, char **argv)
 | 
				
			|||||||
  /* non-debug defaults */
 | 
					  /* non-debug defaults */
 | 
				
			||||||
  sys->switchM = 0;
 | 
					  sys->switchM = 0;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
  if (switch_disable_violations_report->count > 0)
 | 
					
 | 
				
			||||||
    sys->report = 0;
 | 
					  /*
 | 
				
			||||||
  if (switch_prune_trace_length->ival[0] >= 0)
 | 
					   * ---------------------------------------
 | 
				
			||||||
    sys->switch_maxtracelength = switch_prune_trace_length->ival[0];
 | 
					   *  Switches consistency checking.
 | 
				
			||||||
 | 
					   * ---------------------------------------
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /* Latex only makes sense for attacks */
 | 
				
			||||||
 | 
					  if (sys->latex && sys->output != ATTACK)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      error ("Scyther can only generate LaTeX output for attacks.");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  /* Incremental stuff only works for attack locating */
 | 
				
			||||||
 | 
					  if (switch_incremental_runs->count > 0 ||
 | 
				
			||||||
 | 
					      switch_incremental_trace_length->count > 0)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      if (sys->output != ATTACK &&
 | 
				
			||||||
 | 
						  sys->output != EMPTY)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
						  error ("Incremental traversal only for empty or attack output.");
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  /* TODO for now, warning for -m2 and non-clp */
 | 
				
			||||||
 | 
					  if (sys->match == 2 && !sys->clp)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      warning ("-m2 is only supported for constraint logic programming.");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef DEBUG
 | 
				
			||||||
 | 
					  warning ("Selected output method is %i", sys->output);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					  /*
 | 
				
			||||||
 | 
					   * ---------------------------------------
 | 
				
			||||||
 | 
					   *  Start real stuff
 | 
				
			||||||
 | 
					   * ---------------------------------------
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* latex header? */
 | 
					  /* latex header? */
 | 
				
			||||||
  if (sys->latex)
 | 
					  if (sys->latex)
 | 
				
			||||||
@ -427,7 +460,7 @@ main (int argc, char **argv)
 | 
				
			|||||||
  /* model check system */
 | 
					  /* model check system */
 | 
				
			||||||
#ifdef DEBUG
 | 
					#ifdef DEBUG
 | 
				
			||||||
  if (DEBUGL (1))
 | 
					  if (DEBUGL (1))
 | 
				
			||||||
    printf ("Start modelchecking system.\n");
 | 
					    warning ("Start modelchecking system.");
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
  if (switch_incremental_runs->count > 0)
 | 
					  if (switch_incremental_runs->count > 0)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@ -448,8 +481,11 @@ main (int argc, char **argv)
 | 
				
			|||||||
  /* Display shortest attack, if any */
 | 
					  /* Display shortest attack, if any */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (sys->attack != NULL && sys->attack->length != 0)
 | 
					  if (sys->attack != NULL && sys->attack->length != 0)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      if (sys->output == ATTACK)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
      	  attackDisplay(sys);
 | 
					      	  attackDisplay(sys);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
      /* mark exit code */
 | 
					      /* mark exit code */
 | 
				
			||||||
      exitcode = 3;
 | 
					      exitcode = 3;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -563,12 +599,6 @@ timersPrint (const System sys)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  fprintf (stderr, "\n");
 | 
					  fprintf (stderr, "\n");
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  /* if scenario counting, display */
 | 
					 | 
				
			||||||
  if (sys->switchScenario < 0)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
      fprintf (stderr, "Number of scenarios found: %i\n", sys->countScenario);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//! Analyse the model by incremental runs.
 | 
					//! Analyse the model by incremental runs.
 | 
				
			||||||
@ -697,7 +727,7 @@ MC_single (const System sys)
 | 
				
			|||||||
int
 | 
					int
 | 
				
			||||||
modelCheck (const System sys)
 | 
					modelCheck (const System sys)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  if (sys->switchStatespace)
 | 
					  if (sys->output == STATESPACE)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      graphInit (sys);
 | 
					      graphInit (sys);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -713,7 +743,7 @@ modelCheck (const System sys)
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  timersPrint (sys);
 | 
					  timersPrint (sys);
 | 
				
			||||||
  if (sys->switchStatespace)
 | 
					  if (sys->output == STATESPACE)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      graphDone (sys);
 | 
					      graphDone (sys);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -218,7 +218,7 @@ executeStep (const System sys, const int run)
 | 
				
			|||||||
  /* store new node numbder */
 | 
					  /* store new node numbder */
 | 
				
			||||||
  sys->traceNode[sys->step] = sys->states;
 | 
					  sys->traceNode[sys->step] = sys->states;
 | 
				
			||||||
  /* the construction below always assumes MAX_GRAPH_STATES to be smaller than the unsigned long it, which seems realistic. */
 | 
					  /* the construction below always assumes MAX_GRAPH_STATES to be smaller than the unsigned long it, which seems realistic. */
 | 
				
			||||||
  if (sys->switchStatespace && statesSmallerThan (sys->states, MAX_GRAPH_STATES))
 | 
					  if (sys->output == STATESPACE && statesSmallerThan (sys->states, MAX_GRAPH_STATES))
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      /* display graph */
 | 
					      /* display graph */
 | 
				
			||||||
      graphNode (sys);
 | 
					      graphNode (sys);
 | 
				
			||||||
@ -566,21 +566,19 @@ explorify (const System sys, const int run)
 | 
				
			|||||||
		{
 | 
							{
 | 
				
			||||||
      	          sys->countScenario++;
 | 
					      	          sys->countScenario++;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
#ifdef DEBUG
 | 
						      /* If we are displaying scenarios, print it */
 | 
				
			||||||
	      /* If we are counting and debug, print it */
 | 
						      if (sys->output == SCENARIOS)
 | 
				
			||||||
	      if (sys->switchScenario < 0)
 | 
					 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		  printf ("// Scenario %i: ", sys->countScenario);
 | 
							  printf ("%i\t", sys->countScenario);
 | 
				
			||||||
		  scenarioPrint (sys);
 | 
							  scenarioPrint (sys);
 | 
				
			||||||
		  printf ("\n");
 | 
							  printf ("\n");
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
	      /* If it is not the selected one, abort */
 | 
						      /* If it is not the selected one, abort */
 | 
				
			||||||
	      if (sys->switchScenario != sys->countScenario)
 | 
						      if (sys->switchScenario != sys->countScenario)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
		  /* this branch is not interesting */
 | 
							  /* this branch is not interesting */
 | 
				
			||||||
		  /* unfortunately, it is also not drawn in the state graph because of this */
 | 
							  /* unfortunately, it is also not drawn in the state graph because of this */
 | 
				
			||||||
		  if (sys->switchStatespace)
 | 
							  if (sys->output == STATESPACE)
 | 
				
			||||||
		    {
 | 
							    {
 | 
				
			||||||
		      graphScenario (sys, run, rd);
 | 
							      graphScenario (sys, run, rd);
 | 
				
			||||||
		    }
 | 
							    }
 | 
				
			||||||
@ -1188,7 +1186,7 @@ violateClaim (const System sys, int length, int claimev, Termlist reqt)
 | 
				
			|||||||
  sys->failed = statesIncrease (sys->failed);
 | 
					  sys->failed = statesIncrease (sys->failed);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* mark the path in the state graph? */
 | 
					  /* mark the path in the state graph? */
 | 
				
			||||||
  if (sys->switchStatespace)
 | 
					  if (sys->output == STATESPACE)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      graphPath (sys, length);
 | 
					      graphPath (sys, length);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -481,9 +481,6 @@ attackDisplayAscii (const System sys)
 | 
				
			|||||||
void
 | 
					void
 | 
				
			||||||
attackDisplay (const System sys)
 | 
					attackDisplay (const System sys)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  if (!sys->report || sys->switchStatespace)
 | 
					 | 
				
			||||||
      return;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  if (sys->latex)
 | 
					  if (sys->latex)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      attackDisplayLatex (sys);
 | 
					      attackDisplayLatex (sys);
 | 
				
			||||||
 | 
				
			|||||||
@ -58,7 +58,7 @@ reportEnd (const System sys)
 | 
				
			|||||||
void
 | 
					void
 | 
				
			||||||
reportSecrecy (const System sys, Term t)
 | 
					reportSecrecy (const System sys, Term t)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  if (!sys->report)
 | 
					  if (sys->output != ATTACK)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      reportQuit (sys);
 | 
					      reportQuit (sys);
 | 
				
			||||||
      return;
 | 
					      return;
 | 
				
			||||||
 | 
				
			|||||||
@ -54,10 +54,10 @@ systemInit ()
 | 
				
			|||||||
  sys->attack = tracebufInit();
 | 
					  sys->attack = tracebufInit();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* switches */
 | 
					  /* switches */
 | 
				
			||||||
 | 
					  sys->output = ATTACK;		// default is to show the attacks
 | 
				
			||||||
  sys->porparam = 0;		// multi-purpose parameter
 | 
					  sys->porparam = 0;		// multi-purpose parameter
 | 
				
			||||||
  sys->latex = 0;		// latex output?
 | 
					  sys->latex = 0;		// latex output?
 | 
				
			||||||
  sys->switchScenario = 0;
 | 
					  sys->switchScenario = 0;
 | 
				
			||||||
  sys->switchStatespace = 0;
 | 
					 | 
				
			||||||
  sys->switchForceChoose = 1;	// force explicit chooses by default
 | 
					  sys->switchForceChoose = 1;	// force explicit chooses by default
 | 
				
			||||||
  sys->switchChooseFirst = 0;	// no priority to chooses by default
 | 
					  sys->switchChooseFirst = 0;	// no priority to chooses by default
 | 
				
			||||||
  sys->switchReadSymm = 0;	// don't force read symmetries by default
 | 
					  sys->switchReadSymm = 0;	// don't force read symmetries by default
 | 
				
			||||||
@ -69,7 +69,6 @@ systemInit ()
 | 
				
			|||||||
  /* set illegal traversal by default, to make sure it is set
 | 
					  /* set illegal traversal by default, to make sure it is set
 | 
				
			||||||
     later */
 | 
					     later */
 | 
				
			||||||
  sys->traverse = 0;
 | 
					  sys->traverse = 0;
 | 
				
			||||||
  sys->report = 1;
 | 
					 | 
				
			||||||
  sys->switch_maxtracelength = INT_MAX;
 | 
					  sys->switch_maxtracelength = INT_MAX;
 | 
				
			||||||
  sys->maxtracelength = INT_MAX;
 | 
					  sys->maxtracelength = INT_MAX;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -91,6 +91,8 @@ struct tracebuf
 | 
				
			|||||||
  Varbuf	variables;
 | 
					  Varbuf	variables;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					enum outputs { EMPTY, ATTACK, STATESPACE, SCENARIOS };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//! The main state structure.
 | 
					//! The main state structure.
 | 
				
			||||||
struct system
 | 
					struct system
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -109,6 +111,7 @@ struct system
 | 
				
			|||||||
  int shortestattack;		//!< Length of shortest attack trace.
 | 
					  int shortestattack;		//!< Length of shortest attack trace.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /* switches */
 | 
					  /* switches */
 | 
				
			||||||
 | 
					  int output;			//!< From enum outputs: what should be produced. Default ATTACK.
 | 
				
			||||||
  int report;
 | 
					  int report;
 | 
				
			||||||
  int prune;			//!< Type of pruning.
 | 
					  int prune;			//!< Type of pruning.
 | 
				
			||||||
  int switch_maxtracelength;	//!< Helps to remember the length of the last trace.
 | 
					  int switch_maxtracelength;	//!< Helps to remember the length of the last trace.
 | 
				
			||||||
@ -118,7 +121,6 @@ struct system
 | 
				
			|||||||
  int switchS;			//!< Progress display switch. (traversed states)
 | 
					  int switchS;			//!< Progress display switch. (traversed states)
 | 
				
			||||||
  int porparam;			//!< A multi-purpose integer parameter, passed to the partial order reduction method selected.
 | 
					  int porparam;			//!< A multi-purpose integer parameter, passed to the partial order reduction method selected.
 | 
				
			||||||
  int switchScenario;		//!< -1 to count, 0 for disable, 1-n to select the choose scenario
 | 
					  int switchScenario;		//!< -1 to count, 0 for disable, 1-n to select the choose scenario
 | 
				
			||||||
  int switchStatespace;		//!< Output statespace for dot package
 | 
					 | 
				
			||||||
  int switchForceChoose;	//!< Force chooses for each run, even if involved in first read
 | 
					  int switchForceChoose;	//!< Force chooses for each run, even if involved in first read
 | 
				
			||||||
  int switchChooseFirst;	//!< Priority to chooses, implicit and explicit
 | 
					  int switchChooseFirst;	//!< Priority to chooses, implicit and explicit
 | 
				
			||||||
  int switchReadSymm;		//!< Enable read symmetry reduction
 | 
					  int switchReadSymm;		//!< Enable read symmetry reduction
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user