Preparations for Arachne.
- roleInstanceDestroy is very much needed. - fixed bug in maxruns maintenance for incRuns. - Arachne does not use run knowledge.
This commit is contained in:
parent
028c3a03f2
commit
7fbd43986f
@ -329,6 +329,8 @@ main (int argc, char **argv)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
sys = systemInit ();
|
sys = systemInit ();
|
||||||
|
/* select default engine */
|
||||||
|
sys->engine = POR_ENGINE;
|
||||||
/* init compiler for this system */
|
/* init compiler for this system */
|
||||||
compilerInit (sys);
|
compilerInit (sys);
|
||||||
|
|
||||||
@ -791,6 +793,7 @@ MC_incRuns (const System sys)
|
|||||||
runs++;
|
runs++;
|
||||||
}
|
}
|
||||||
while (flag && runs <= maxruns);
|
while (flag && runs <= maxruns);
|
||||||
|
sys->maxruns = maxruns;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Analyse the model by incremental trace lengths.
|
//! Analyse the model by incremental trace lengths.
|
||||||
|
62
src/system.c
62
src/system.c
@ -191,8 +191,10 @@ systemDone (const System sys)
|
|||||||
memFree (sys->traceNode, s * sizeof (states_t));
|
memFree (sys->traceNode, s * sizeof (states_t));
|
||||||
|
|
||||||
/* clear roledefs */
|
/* clear roledefs */
|
||||||
for (run = 0; run < sys->maxruns; run++)
|
while (sys->maxruns > 0)
|
||||||
roledefDestroy (runPointerGet (sys, run));
|
{
|
||||||
|
roleInstanceDestroy (sys);
|
||||||
|
}
|
||||||
|
|
||||||
/* clear substructures */
|
/* clear substructures */
|
||||||
termlistDestroy (sys->secrets);
|
termlistDestroy (sys->secrets);
|
||||||
@ -479,6 +481,7 @@ roleInstance (const System sys, const Protocol protocol, const Role role,
|
|||||||
Termlist scanfrom, scanto;
|
Termlist scanfrom, scanto;
|
||||||
Termlist fromlist = NULL;
|
Termlist fromlist = NULL;
|
||||||
Termlist tolist = NULL;
|
Termlist tolist = NULL;
|
||||||
|
Termlist artefacts = NULL;
|
||||||
Term extterm = NULL;
|
Term extterm = NULL;
|
||||||
Term newvar;
|
Term newvar;
|
||||||
|
|
||||||
@ -503,6 +506,7 @@ roleInstance (const System sys, const Protocol protocol, const Role role,
|
|||||||
/* There is a TYPE constant in the parameter list.
|
/* There is a TYPE constant in the parameter list.
|
||||||
* Generate a new local variable for this run, with this type */
|
* Generate a new local variable for this run, with this type */
|
||||||
newvar = makeTermType (VARIABLE, scanfrom->term->left.symb, rid);
|
newvar = makeTermType (VARIABLE, scanfrom->term->left.symb, rid);
|
||||||
|
artefacts = termlistAdd (artefacts, newvar);
|
||||||
sys->variables = termlistAdd (sys->variables, newvar);
|
sys->variables = termlistAdd (sys->variables, newvar);
|
||||||
newvar->stype = termlistAdd (NULL, scanto->term);
|
newvar->stype = termlistAdd (NULL, scanto->term);
|
||||||
tolist = termlistAdd (tolist, newvar);
|
tolist = termlistAdd (tolist, newvar);
|
||||||
@ -518,6 +522,7 @@ roleInstance (const System sys, const Protocol protocol, const Role role,
|
|||||||
* this will do for now. I.e. occurring
|
* this will do for now. I.e. occurring
|
||||||
* first in a read will do */
|
* first in a read will do */
|
||||||
extterm = makeTermTuple (newvar, extterm);
|
extterm = makeTermTuple (newvar, extterm);
|
||||||
|
artefacts = termlistAdd (artefacts, extterm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -565,6 +570,7 @@ roleInstance (const System sys, const Protocol protocol, const Role role,
|
|||||||
if (realTermLeaf (t))
|
if (realTermLeaf (t))
|
||||||
{
|
{
|
||||||
Term newt = makeTermType (t->type, t->left.symb, rid);
|
Term newt = makeTermType (t->type, t->left.symb, rid);
|
||||||
|
artefacts = termlistAdd (artefacts, newt);
|
||||||
if (realTermVariable (newt))
|
if (realTermVariable (newt))
|
||||||
{
|
{
|
||||||
sys->variables = termlistAdd (sys->variables, newt);
|
sys->variables = termlistAdd (sys->variables, newt);
|
||||||
@ -579,7 +585,14 @@ roleInstance (const System sys, const Protocol protocol, const Role role,
|
|||||||
|
|
||||||
/* TODO this is not what we want yet, also local knowledge. The local
|
/* TODO this is not what we want yet, also local knowledge. The local
|
||||||
* knowledge (list?) also needs to be substituted on invocation. */
|
* knowledge (list?) also needs to be substituted on invocation. */
|
||||||
|
if (sys->engine == ARACHNE_ENGINE)
|
||||||
|
{
|
||||||
|
runs[rid].know = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
runs[rid].know = knowledgeDuplicate (sys->know);
|
runs[rid].know = knowledgeDuplicate (sys->know);
|
||||||
|
}
|
||||||
|
|
||||||
/* now adjust the local run copy */
|
/* now adjust the local run copy */
|
||||||
|
|
||||||
@ -594,6 +607,7 @@ roleInstance (const System sys, const Protocol protocol, const Role role,
|
|||||||
}
|
}
|
||||||
termlistDelete (fromlist);
|
termlistDelete (fromlist);
|
||||||
runs[rid].locals = tolist;
|
runs[rid].locals = tolist;
|
||||||
|
runs[rid].artefacts = artefacts;
|
||||||
|
|
||||||
/* Determine symmetric run */
|
/* Determine symmetric run */
|
||||||
runs[rid].prevSymmRun = staticRunSymmetry (sys, rid); // symmetry reduction static analysis
|
runs[rid].prevSymmRun = staticRunSymmetry (sys, rid); // symmetry reduction static analysis
|
||||||
@ -603,6 +617,50 @@ roleInstance (const System sys, const Protocol protocol, const Role role,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! Destroy roleInstance
|
||||||
|
/**
|
||||||
|
* Destroys the run with the highest index number
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
roleInstanceDestroy (const System sys)
|
||||||
|
{
|
||||||
|
int runid;
|
||||||
|
|
||||||
|
runid = sys->maxruns - 1;
|
||||||
|
if (runid >= 0)
|
||||||
|
{
|
||||||
|
struct run myrun;
|
||||||
|
Termlist artefacts;
|
||||||
|
|
||||||
|
myrun = sys->runs[runid];
|
||||||
|
|
||||||
|
// Destroy roledef
|
||||||
|
roledefDestroy (myrun.start);
|
||||||
|
// Destroy artefacts
|
||||||
|
termlistDelete (myrun.artefacts);
|
||||||
|
termlistDelete (myrun.locals);
|
||||||
|
termlistDelete (myrun.agents);
|
||||||
|
/*
|
||||||
|
* Arachne does real-time reduction of memory, POR does not
|
||||||
|
* Artefact removal can only be done if knowledge sets are empty, as with Arachne
|
||||||
|
*/
|
||||||
|
if (sys->engine == ARACHNE_ENGINE)
|
||||||
|
{
|
||||||
|
// Remove artefacts
|
||||||
|
artefacts = myrun.artefacts;
|
||||||
|
while (artefacts != NULL)
|
||||||
|
{
|
||||||
|
memFree(artefacts->term, sizeof (struct term));
|
||||||
|
artefacts = artefacts->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Destroy run struct allocation in array using realloc
|
||||||
|
sys->runs = (Run) memRealloc (sys->runs, sizeof (struct run) * (runid));
|
||||||
|
// Reduce run count
|
||||||
|
sys->maxruns = runid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//! Initialise the second system phase.
|
//! Initialise the second system phase.
|
||||||
/**
|
/**
|
||||||
* Allocates memory for traces.
|
* Allocates memory for traces.
|
||||||
|
@ -15,6 +15,9 @@
|
|||||||
enum outputs
|
enum outputs
|
||||||
{ EMPTY, ATTACK, STATESPACE, SCENARIOS, SUMMARY };
|
{ EMPTY, ATTACK, STATESPACE, SCENARIOS, SUMMARY };
|
||||||
|
|
||||||
|
enum engines
|
||||||
|
{ POR_ENGINE, ARACHNE_ENGINE };
|
||||||
|
|
||||||
//! Protocol definition.
|
//! Protocol definition.
|
||||||
struct protocol
|
struct protocol
|
||||||
{
|
{
|
||||||
@ -44,6 +47,7 @@ struct run
|
|||||||
Roledef start; //!< Head of the run definition.
|
Roledef start; //!< Head of the run definition.
|
||||||
Knowledge know; //!< Current knowledge of the run.
|
Knowledge know; //!< Current knowledge of the run.
|
||||||
Termlist locals; //!< Locals of the run.
|
Termlist locals; //!< Locals of the run.
|
||||||
|
Termlist artefacts; //!< Stuff created especially for this run.
|
||||||
int prevSymmRun; //!< Used for symmetry reduction. Either -1, or the previous run with the same role def and at least a single parameter.
|
int prevSymmRun; //!< Used for symmetry reduction. Either -1, or the previous run with the same role def and at least a single parameter.
|
||||||
int firstNonAgentRead; //!< Used for symmetry reductions for equal agents runs; -1 if there is no candidate.
|
int firstNonAgentRead; //!< Used for symmetry reductions for equal agents runs; -1 if there is no candidate.
|
||||||
int firstReal; //!< 1 if a choose was inserted, otherwise 0
|
int firstReal; //!< 1 if a choose was inserted, otherwise 0
|
||||||
@ -97,6 +101,7 @@ struct tracebuf
|
|||||||
//! The main state structure.
|
//! The main state structure.
|
||||||
struct system
|
struct system
|
||||||
{
|
{
|
||||||
|
int engine; //!< Engine type (POR_ENGINE,ARACHNE_ENGINE)
|
||||||
int step; //!< Step in trace during exploration. Can be managed globally
|
int step; //!< Step in trace during exploration. Can be managed globally
|
||||||
Knowledge know; //!< Knowledge in currect step of system.
|
Knowledge know; //!< Knowledge in currect step of system.
|
||||||
struct parameters *parameters; // misc
|
struct parameters *parameters; // misc
|
||||||
@ -205,6 +210,7 @@ Term agentOfRunRole (const System sys, const int run, const Term role);
|
|||||||
Term agentOfRun (const System sys, const int run);
|
Term agentOfRun (const System sys, const int run);
|
||||||
void roleInstance (const System sys, const Protocol protocol, const Role role,
|
void roleInstance (const System sys, const Protocol protocol, const Role role,
|
||||||
const Termlist tolist);
|
const Termlist tolist);
|
||||||
|
void roleInstanceDestroy (const System sys);
|
||||||
void systemStart (const System sys);
|
void systemStart (const System sys);
|
||||||
void indentActivate ();
|
void indentActivate ();
|
||||||
void indentSet (int i);
|
void indentSet (int i);
|
||||||
|
Loading…
Reference in New Issue
Block a user