Commit 21e0e9bc authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

* src/tgbaalgos/replayrun.hh,

src/tgbaalgos/replayrun.cc (replay_tgba_run): Take a `debug'
option to decide whether the output should look like that of
print_tgba_run() or a complete debug trace.
* src/tgbatest/ltl2tgba.cc (main): Call replay_tgba_run() with
debug=true.
parent a67e2d0b
2004-11-10 Alexandre Duret-Lutz <adl@src.lip6.fr> 2004-11-10 Alexandre Duret-Lutz <adl@src.lip6.fr>
* src/tgbaalgos/replayrun.hh,
src/tgbaalgos/replayrun.cc (replay_tgba_run): Take a `debug'
option to decide whether the output should look like that of
print_tgba_run() or a complete debug trace.
* src/tgbatest/ltl2tgba.cc (main): Call replay_tgba_run() with
debug=true.
* iface/gspn/ltlgspn.cc (main): Adjust to recent changes to * iface/gspn/ltlgspn.cc (main): Adjust to recent changes to
src/tgbaalgos/magic.cc, call explicit_magic_search() instead of src/tgbaalgos/magic.cc, call explicit_magic_search() instead of
building a spot::magic_search. building a spot::magic_search.
......
...@@ -41,7 +41,8 @@ namespace spot ...@@ -41,7 +41,8 @@ namespace spot
} }
bool bool
replay_tgba_run(std::ostream& os, const tgba* a, const tgba_run* run) replay_tgba_run(std::ostream& os, const tgba* a, const tgba_run* run,
bool debug)
{ {
const state* s = a->get_init_state(); const state* s = a->get_init_state();
int serial = 1; int serial = 1;
...@@ -58,47 +59,58 @@ namespace spot ...@@ -58,47 +59,58 @@ namespace spot
{ {
l = &run->cycle; l = &run->cycle;
in = "cycle"; in = "cycle";
if (!debug)
os << "No prefix.\nCycle:" << std::endl;
} }
else else
{ {
l = &run->prefix; l = &run->prefix;
in = "prefix"; in = "prefix";
if (!debug)
os << "Prefix:" << std::endl;
} }
tgba_run::steps::const_iterator i = l->begin(); tgba_run::steps::const_iterator i = l->begin();
if (s->compare(i->s)) if (s->compare(i->s))
{ {
os << "ERROR: First state of run (in " << in << "): " if (debug)
<< a->format_state(i->s) << std::endl os << "ERROR: First state of run (in " << in << "): "
<< "does not match initial state of automata: " << a->format_state(i->s) << std::endl
<< a->format_state(s) << std::endl; << "does not match initial state of automata: "
<< a->format_state(s) << std::endl;
delete s; delete s;
return false; return false;
} }
for (; i != l->end(); ++serial) for (; i != l->end(); ++serial)
{ {
// Keep track of the serial associated to each state so we if (debug)
// can note duplicate states and make the replay easier to read.
state_map::iterator o = seen.find(s);
std::ostringstream msg;
if (o != seen.end())
{ {
std::set<int>::const_iterator d; // Keep track of the serial associated to each state so we
for (d = o->second.begin(); d != o->second.end(); ++d) // can note duplicate states and make the replay easier to read.
msg << " == " << *d; state_map::iterator o = seen.find(s);
o->second.insert(serial); std::ostringstream msg;
delete s; if (o != seen.end())
s = o->first; {
std::set<int>::const_iterator d;
for (d = o->second.begin(); d != o->second.end(); ++d)
msg << " == " << *d;
o->second.insert(serial);
delete s;
s = o->first;
}
else
{
seen[s].insert(serial);
}
os << "state " << serial << " in " << in << msg.str() << ": ";
} }
else else
{ {
seen[s].insert(serial); os << " ";
} }
os << a->format_state(s) << std::endl;
os << "state " << serial << " in " << in << msg.str() << ": "
<< a->format_state(s) << std::endl;
// expected outgoing transition // expected outgoing transition
bdd label = i->label; bdd label = i->label;
...@@ -118,6 +130,8 @@ namespace spot ...@@ -118,6 +130,8 @@ namespace spot
l = &run->cycle; l = &run->cycle;
in = "cycle"; in = "cycle";
i = l->begin(); i = l->begin();
if (!debug)
std::cout << "Cycle:" << std::endl;
} }
next = l->begin()->s; next = l->begin()->s;
} }
...@@ -144,37 +158,53 @@ namespace spot ...@@ -144,37 +158,53 @@ namespace spot
} }
if (j->done()) if (j->done())
{ {
os << "ERROR: no transition with label=" if (debug)
<< bdd_format_formula(a->get_dict(), label)
<< " and acc=" << bdd_format_accset(a->get_dict(), acc)
<< " leaving state " << serial
<< " for state " << a->format_state(next)
<< std::endl
<< "The following transitions leave state " << serial
<< ":" << std::endl;
for (j->first(); !j->done(); j->next())
{ {
const state* s2 = j->current_state(); os << "ERROR: no transition with label="
os << " *"; << bdd_format_formula(a->get_dict(), label)
print_annotation(os, a, j); << " and acc=" << bdd_format_accset(a->get_dict(), acc)
os << " label=" << bdd_format_formula(a->get_dict(), << " leaving state " << serial
j->current_condition()) << " for state " << a->format_state(next)
<< " and acc=" << std::endl
<< bdd_format_accset(a->get_dict(), << "The following transitions leave state " << serial
j->current_acceptance_conditions()) << ":" << std::endl;
<< " going to " << a->format_state(s2) << std::endl; for (j->first(); !j->done(); j->next())
delete s2; {
const state* s2 = j->current_state();
os << " *";
print_annotation(os, a, j);
os << " label="
<< bdd_format_formula(a->get_dict(),
j->current_condition())
<< " and acc="
<< bdd_format_accset(a->get_dict(),
j->current_acceptance_conditions())
<< " going to " << a->format_state(s2) << std::endl;
delete s2;
}
} }
delete j; delete j;
delete s; delete s;
return false; return false;
} }
os << "transition"; if (debug)
print_annotation(os, a, j); {
os << " with label=" os << "transition";
<< bdd_format_formula(a->get_dict(), label) print_annotation(os, a, j);
<< " and acc=" << bdd_format_accset(a->get_dict(), acc) os << " with label="
<< std::endl; << bdd_format_formula(a->get_dict(), label)
<< " and acc=" << bdd_format_accset(a->get_dict(), acc)
<< std::endl;
}
else
{
os << " | ";
print_annotation(os, a, j);
bdd_print_formula(os, a->get_dict(), label);
os << "\t";
bdd_print_accset(os, a->get_dict(), acc);
os << std::endl;
}
delete j; delete j;
// Sum acceptance conditions. // Sum acceptance conditions.
...@@ -184,22 +214,24 @@ namespace spot ...@@ -184,22 +214,24 @@ namespace spot
if (!all_acc_seen && all_acc == expected_all_acc) if (!all_acc_seen && all_acc == expected_all_acc)
{ {
all_acc_seen = true; all_acc_seen = true;
os << "all acceptance conditions (" if (debug)
<< bdd_format_accset(a->get_dict(), all_acc) os << "all acceptance conditions ("
<< ") have been seen" << bdd_format_accset(a->get_dict(), all_acc)
<< std::endl; << ") have been seen"
<< std::endl;
} }
} }
} }
delete s; delete s;
if (all_acc != expected_all_acc) if (all_acc != expected_all_acc)
{ {
os << "ERROR: The cycle's acceptance conditions (" if (debug)
<< bdd_format_accset(a->get_dict(), all_acc) << ") do not" os << "ERROR: The cycle's acceptance conditions ("
<< std::endl << bdd_format_accset(a->get_dict(), all_acc) << ") do not"
<< "match those of the automata (" << std::endl
<< bdd_format_accset(a->get_dict(), expected_all_acc) << "match those of the automata ("
<< std::endl; << bdd_format_accset(a->get_dict(), expected_all_acc)
<< std::endl;
return false; return false;
} }
......
...@@ -31,11 +31,20 @@ namespace spot ...@@ -31,11 +31,20 @@ namespace spot
/// \brief Replay a tgba_run on a tgba. /// \brief Replay a tgba_run on a tgba.
/// ///
/// This is similar to print_tgba_run(), except that the run is
/// actually replayed on the automaton while it is printed. Doing
/// so makes it possible to display transition annotations (returned
/// by spot::tgba::transition_annotation()). The output will stop
/// if the run cannot be completed.
///
/// \param run the run to replay /// \param run the run to replay
/// \param a the automata on which to replay that run /// \param a the automata on which to replay that run
/// \param os the stream on which the replay should be traced /// \param os the stream on which the replay should be traced
/// \param debug if set the output will be more verbose and extra
/// debugging informations will be output on failure
/// \return true iff the run could be completed /// \return true iff the run could be completed
bool replay_tgba_run(std::ostream& os, const tgba* a, const tgba_run* run); bool replay_tgba_run(std::ostream& os, const tgba* a, const tgba_run* run,
bool debug = false);
} }
#endif // SPOT_TGBAALGOS_REPLAYRUN_HH #endif // SPOT_TGBAALGOS_REPLAYRUN_HH
...@@ -619,7 +619,8 @@ main(int argc, char** argv) ...@@ -619,7 +619,8 @@ main(int argc, char** argv)
else else
{ {
spot::print_tgba_run(std::cout, ec_a, run); spot::print_tgba_run(std::cout, ec_a, run);
if (!spot::replay_tgba_run(std::cout, ec_a, run)) if (!spot::replay_tgba_run(std::cout, ec_a, run,
true))
exit_code = 1; exit_code = 1;
} }
delete run; delete run;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment