- Improved debugging output by adhering to the level setup.

This commit is contained in:
ccremers 2004-08-14 16:12:32 +00:00
parent 53cb869426
commit 1b3ef9e4ac

View File

@ -16,6 +16,7 @@
#include "arachne.h" #include "arachne.h"
#include "error.h" #include "error.h"
#include "claim.h" #include "claim.h"
#include "debug.h"
static System sys; static System sys;
Protocol INTRUDER; // Pointers, to be set by the Init Protocol INTRUDER; // Pointers, to be set by the Init
@ -245,8 +246,11 @@ create_intruder_goal (Term t)
sys->runs[run].length = 1; sys->runs[run].length = 1;
rd->message = termDuplicate (t); rd->message = termDuplicate (t);
#ifdef DEBUG #ifdef DEBUG
if (DEBUGL (3))
{
explanation = "Adding intruder goal for message "; explanation = "Adding intruder goal for message ";
e_term1 = t; e_term1 = t;
}
#endif #endif
return run; return run;
} }
@ -284,6 +288,8 @@ bind_existing_run (const Goal goal, const Protocol p, const Role r,
int run, flag; int run, flag;
#ifdef DEBUG #ifdef DEBUG
if (DEBUGL (4))
{
indentPrint (); indentPrint ();
eprintf ("Trying to bind "); eprintf ("Trying to bind ");
termPrint (goal.rd->message); termPrint (goal.rd->message);
@ -292,6 +298,7 @@ bind_existing_run (const Goal goal, const Protocol p, const Role r,
eprintf (", "); eprintf (", ");
termPrint (r->nameterm); termPrint (r->nameterm);
eprintf ("\n"); eprintf ("\n");
}
#endif #endif
flag = 1; flag = 1;
goal.rd->bind_index = index; goal.rd->bind_index = index;
@ -312,9 +319,12 @@ bind_existing_run (const Goal goal, const Protocol p, const Role r,
if (index >= old_length) if (index >= old_length)
sys->runs[run].length = index + 1; sys->runs[run].length = index + 1;
#ifdef DEBUG #ifdef DEBUG
if (DEBUGL (3))
{
explanation = "Bind existing run"; explanation = "Bind existing run";
e_run = run; e_run = run;
e_term1 = goal.rd->message; e_term1 = goal.rd->message;
}
#endif #endif
goal.rd->bind_run = run; goal.rd->bind_run = run;
@ -348,11 +358,14 @@ bind_new_run (const Goal goal, const Protocol p, const Role r,
goal.rd->bind_run = run; goal.rd->bind_run = run;
goal.rd->bind_index = index; goal.rd->bind_index = index;
#ifdef DEBUG #ifdef DEBUG
if (DEBUGL (3))
{
explanation = "Bind new run"; explanation = "Bind new run";
e_run = run; e_run = run;
e_term1 = r->nameterm; e_term1 = r->nameterm;
rd = roledef_shift (sys->runs[run].start, index); rd = roledef_shift (sys->runs[run].start, index);
e_term2 = rd->message; e_term2 = rd->message;
}
#endif #endif
flag = iterate (); flag = iterate ();
@ -460,12 +473,15 @@ bind_goal_regular (const Goal goal)
if (run == -1) if (run == -1)
return 1; return 1;
#ifdef DEBUG #ifdef DEBUG
if (DEBUGL (5))
{
indentPrint (); indentPrint ();
eprintf ("Term "); eprintf ("Term ");
termPrint (goal.rd->message); termPrint (goal.rd->message);
eprintf (" can possibly be bound by role "); eprintf (" can possibly be bound by role ");
termPrint (r->nameterm); termPrint (r->nameterm);
eprintf (", index %i, forced_run %i\n", index, run); eprintf (", index %i, forced_run %i\n", index, run);
}
#endif #endif
/** /**
* Two options; as this, it is from an existing run, * Two options; as this, it is from an existing run,
@ -488,6 +504,8 @@ bind_goal_regular (const Goal goal)
{ {
// Test for interm unification // Test for interm unification
#ifdef DEBUG #ifdef DEBUG
if (DEBUGL (5))
{
indentPrint (); indentPrint ();
eprintf ("Checking send candidate with message "); eprintf ("Checking send candidate with message ");
termPrint (rd->message); termPrint (rd->message);
@ -496,6 +514,7 @@ bind_goal_regular (const Goal goal)
eprintf (", "); eprintf (", ");
termPrint (r->nameterm); termPrint (r->nameterm);
eprintf (", index %i\n", index); eprintf (", index %i\n", index);
}
#endif #endif
return termMguInTerm (goal.rd->message, rd->message, return termMguInTerm (goal.rd->message, rd->message,
bind_this_unification); bind_this_unification);
@ -504,13 +523,19 @@ bind_goal_regular (const Goal goal)
// Bind to all possible sends or intruder node; // Bind to all possible sends or intruder node;
#ifdef DEBUG #ifdef DEBUG
if (DEBUGL (5))
{
indentPrint (); indentPrint ();
eprintf ("Try regular role send.\n"); eprintf ("Try regular role send.\n");
}
#endif #endif
flag = iterate_role_sends (bind_this_role_send); flag = iterate_role_sends (bind_this_role_send);
#ifdef DEBUG #ifdef DEBUG
if (DEBUGL (5))
{
indentPrint (); indentPrint ();
eprintf ("Try intruder send.\n"); eprintf ("Try intruder send.\n");
}
#endif #endif
return (flag && add_intruder_goal_iterate (goal)); return (flag && add_intruder_goal_iterate (goal));
} }
@ -667,8 +692,11 @@ prune ()
{ {
// Hardcoded limit on iterations // Hardcoded limit on iterations
#ifdef DEBUG #ifdef DEBUG
if (DEBUGL (3))
{
indentPrint (); indentPrint ();
eprintf ("Pruned because too many iteration levels.\n"); eprintf ("Pruned because too many iteration levels.\n");
}
#endif #endif
return 1; return 1;
} }
@ -676,8 +704,11 @@ prune ()
{ {
// Hardcoded limit on runs // Hardcoded limit on runs
#ifdef DEBUG #ifdef DEBUG
if (DEBUGL (3))
{
indentPrint (); indentPrint ();
eprintf ("Pruned because too many runs.\n"); eprintf ("Pruned because too many runs.\n");
}
#endif #endif
return 1; return 1;
} }
@ -705,7 +736,7 @@ iterate ()
sys->states = statesIncrease (sys->states); sys->states = statesIncrease (sys->states);
#ifdef DEBUG #ifdef DEBUG
if (explanation != NULL) if (DEBUGL (3) && explanation != NULL)
{ {
indentPrint (); indentPrint ();
eprintf ("%s ", explanation); eprintf ("%s ", explanation);
@ -742,16 +773,24 @@ iterate ()
* all goals bound, check for property * all goals bound, check for property
*/ */
sys->claims = statesIncrease (sys->claims); sys->claims = statesIncrease (sys->claims);
#ifdef DEBUG
if (DEBUGL (3))
{
printSemiState (); printSemiState ();
}
#endif
//!@todo Property check in Arachne. //!@todo Property check in Arachne.
} }
else else
{ {
#ifdef DEBUG #ifdef DEBUG
if (DEBUGL (4))
{
indentPrint (); indentPrint ();
eprintf ("Trying to bind goal "); eprintf ("Trying to bind goal ");
termPrint (goal.rd->message); termPrint (goal.rd->message);
eprintf (" from run %i, index %i.\n", goal.run, goal.index); eprintf (" from run %i, index %i.\n", goal.run, goal.index);
}
#endif #endif
/* /*
* bind this goal in all possible ways and iterate * bind this goal in all possible ways and iterate
@ -800,7 +839,12 @@ arachne ()
eprintf ("\n"); eprintf ("\n");
} }
#ifdef DEBUG
if (DEBUGL (1))
{
iterate_role_sends (print_send); iterate_role_sends (print_send);
}
#endif
indentDepth = 0; indentDepth = 0;
cl = sys->claimlist; cl = sys->claimlist;
@ -817,6 +861,9 @@ arachne ()
p = (Protocol) cl->protocol; p = (Protocol) cl->protocol;
r = (Role) cl->role; r = (Role) cl->role;
#ifdef DEBUG
if (DEBUGL (2))
{
indentPrint (); indentPrint ();
eprintf ("Testing Claim "); eprintf ("Testing Claim ");
termPrint (cl->type); termPrint (cl->type);
@ -825,13 +872,18 @@ arachne ()
eprintf (", role "); eprintf (", role ");
termPrint (r->nameterm); termPrint (r->nameterm);
eprintf (" at index %i.\n", cl->ev); eprintf (" at index %i.\n", cl->ev);
}
#endif
indentDepth++; indentDepth++;
roleInstance (sys, p, r, NULL); roleInstance (sys, p, r, NULL);
sys->runs[0].length = cl->ev + 1; sys->runs[0].length = cl->ev + 1;
#ifdef DEBUG #ifdef DEBUG
if (DEBUGL (5))
{
printSemiState (); printSemiState ();
}
#endif #endif
/* /*