- Implemented --claim=ns3,I switch to filter certain claims.

This commit is contained in:
ccremers 2006-08-08 12:30:29 +00:00
parent a6933806f9
commit ec3be3d55b
5 changed files with 186 additions and 125 deletions

View File

@ -2237,9 +2237,6 @@ arachneClaim (Claimlist cl)
{
// Skip the dummy claims
if (!isTermEqual (cl->type, CLAIM_Empty))
{
// Any other claims might be filterered
if (switches.filterClaim == NULL || switches.filterClaim == cl->type)
{
// Some claims are always true!
if (!cl->alwaystrue)
@ -2362,7 +2359,6 @@ arachneClaim (Claimlist cl)
eprintf ("Proof complete for this claim.\n");
}
}
}
claimStatusReport (sys, cl);
if (switches.xml)
{

View File

@ -1,6 +1,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include <string.h>
#include "tac.h"
#include "term.h"
#include "termlist.h"
@ -431,11 +432,31 @@ claimCreate (const System sys, const Protocol protocol, const Role role,
Claimlist cl;
Term labeltuple;
/* check for ignored claim types */
if (switches.filterClaim != NULL && switches.filterClaim != claim)
if (switches.filterProtocol != NULL)
{
/* abort the construction of the node */
return;
// only this protocol
if (strcmp
(switches.filterProtocol, TermSymb (protocol->nameterm)->text) != 0)
{
// not this protocol; return
return NULL;
}
// and maybe also a specific label?
if (switches.filterLabel != NULL)
{
Term t;
t = label;
while (isTermTuple (t))
{
t = TermOp2 (t);
}
if (strcmp (switches.filterLabel, TermSymb (t)->text) != 0)
{
// not this label; return
return NULL;
}
}
}
/* generate full unique label */
@ -556,16 +577,15 @@ commEvent (int event, Tac tc)
/* effectively, labels are bound to the protocol */
level--;
/* leaves a garbage tuple. dunnoh what to do with it */
label =
makeTermTuple (thisProtocol->nameterm, levelConst (tc->t1.sym));
label = levelConst (tc->t1.sym);
level++;
}
else
{
/* leaves a garbage tuple. dunnoh what to do with it */
}
}
label = makeTermTuple (thisProtocol->nameterm, label);
}
}
/**
* Parse the specific event type
@ -1017,7 +1037,17 @@ protocolCompile (Symbol prots, Tac tc, Tac tcroles)
Protocol pr;
Term t;
if (levelFind (prots, level) != NULL)
/* make new (empty) current protocol with name */
pr = protocolCreate (levelConst (prots));
thisProtocol = pr;
{
// check for double name declarations
Protocol prold;
prold = sys->protocols;
while (prold != NULL)
{
if (isTermEqual (pr->nameterm, prold->nameterm))
{
globalError++;
eprintf ("error: Double declaration of protocol ");
@ -1025,9 +1055,10 @@ protocolCompile (Symbol prots, Tac tc, Tac tcroles)
eprintf (" ");
errorTac (tc->lineno);
}
/* make new (empty) current protocol with name */
pr = protocolCreate (levelConst (prots));
thisProtocol = pr;
prold = prold->next;
}
}
/* add protocol to list */
pr->next = sys->protocols;
sys->protocols = pr;

View File

@ -53,7 +53,8 @@ switchesInit (int argc, char **argv)
switches.maxproofdepth = INT_MAX;
switches.maxtracelength = INT_MAX;
switches.runs = 5; // default is 5 for usability, but -r 0 or --maxruns=0 will set it back to INT_MAX
switches.filterClaim = NULL; // default check all claims
switches.filterProtocol = NULL; // default check all claims
switches.filterLabel = NULL; // default check all claims
switches.maxAttacks = 0; // no maximum default
// Arachne
@ -299,6 +300,20 @@ switcher (const int process, int index, int commandline)
arg_pointer = argv[index];
}
//! Retrieve a (string) argument
char *string_argument (void)
{
char *result;
if (arg_pointer == NULL)
{
error ("Argument expected.");
}
result = arg_pointer;
arg_next ();
return result;
}
//! Parse an argument into an integer
int integer_argument (void)
{
@ -480,6 +495,30 @@ switcher (const int process, int index, int commandline)
}
}
if (detect (' ', "claim", 1))
{
if (!process)
{
helptext ("--claim=<protocol>[,<label>]",
"check only a certain claim");
}
else
{
char *second;
switches.filterProtocol = string_argument ();
second = strchr (switches.filterProtocol, ',');
if (second != NULL)
{
// Cut off first part (turn ',' into '\0'; string is disposable) and proceed to next character.
second[0] = '\0';
second++;
switches.filterLabel = second;
}
return index;
}
}
if (detect (' ', "remove-claims", 0))
{
if (!process)

View File

@ -23,7 +23,8 @@ struct switchdata
int maxproofdepth; //!< Maximum proof depth
int maxtracelength; //!< Maximum trace length allowed
int runs; //!< The number of runs as in the switch
Term filterClaim; //!< Which claim should be checked?
char *filterProtocol; //!< Which claim should be checked?
char *filterLabel; //!< Which claim should be checked?
int maxAttacks; //!< When not 0, maximum number of attacks
// Arachne

View File

@ -1,9 +1,3 @@
- Add --filter-claim and --filter-label switches; parse as symbols, and
turn into (global?) terms, add to switches termlists. Later check them
using two new term functions:
const char *termSymbolString(Term t);
int termSymbolEqual(Term t1, Term t2);
Iteration through the termlist should be done by hand.
- --check is slightly f***ed up because there is no good semantics for
the --disable intruder check. As a result, it is now too strict can
cause correct protocols to fail. Fix.