-/* Copyright (c) 2011-2021. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2011-2022. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "src/mc/checker/LivenessChecker.hpp"
+#include "src/mc/Session.hpp"
#include "src/mc/mc_config.hpp"
#include "src/mc/mc_exit.hpp"
#include "src/mc/mc_private.hpp"
&& evaluate_label(l->u.or_and.right_exp, values);
case xbt_automaton_exp_label::AUT_NOT:
return not evaluate_label(l->u.exp_not, values);
- case xbt_automaton_exp_label::AUT_PREDICAT:{
- auto cursor = api::get().compare_automaton_exp_label(l);
- if(cursor >= 0)
- return values[cursor] != 0;
- xbt_die("Missing predicate");
- break;
- }
+ case xbt_automaton_exp_label::AUT_PREDICAT:
+ return values.at(api::get().compare_automaton_exp_label(l)) != 0;
case xbt_automaton_exp_label::AUT_ONE:
return true;
default:
std::shared_ptr<const std::vector<int>> LivenessChecker::get_proposition_values() const
{
- auto values = api::get().automaton_propositional_symbol_evaluate();
+ auto values = api::get().automaton_propositional_symbol_evaluate();
return std::make_shared<const std::vector<int>>(std::move(values));
}
}
}
- /* Restore the initial state */
- api::get().restore_initial_state();
+ get_session().restore_initial_state();
/* Traverse the stack from the initial state and re-execute the transitions */
int depth = 1;
next_pair->depth = current_pair->depth + 1;
else
next_pair->depth = 1;
- /* Get enabled actors and insert them in the interleave set of the next graph_state */
- auto actors = api::get().get_actors();
- for (auto& actor : actors)
- if (api::get().actor_is_enabled(actor.copy.get_buffer()->get_pid()))
- next_pair->graph_state->mark_todo(actor.copy.get_buffer());
+ /* Add all enabled actors to the interleave set of the initial state */
+ for (auto& act : api::get().get_actors()) {
+ auto actor = act.copy.get_buffer();
+ if (get_session().actor_is_enabled(actor->get_pid()))
+ next_pair->graph_state->mark_todo(actor);
+ }
+
next_pair->requests = next_pair->graph_state->count_todo();
/* FIXME : get search_cycle value for each accepting state */
if (next_pair->automaton_state->type == 1 || (current_pair && current_pair->search_cycle))
api::get().automaton_load(_sg_mc_property_file.get().c_str());
XBT_DEBUG("Starting the liveness algorithm");
- api::get().session_initialize();
+ get_session().take_initial_snapshot();
/* Initialize */
this->previous_pair_ = 0;
// (application_state, automaton_state) pair to the exploration stack:
for (int i = api::get().get_dynar_length(current_pair->automaton_state->out) - 1; i >= 0; i--) {
auto transition_succ_label = api::get().get_automaton_transition_label(current_pair->automaton_state->out, i);
- auto transition_succ_dst = api::get().get_automaton_transition_dst(current_pair->automaton_state->out, i);
+ auto transition_succ_dst = api::get().get_automaton_transition_dst(current_pair->automaton_state->out, i);
if (evaluate_label(transition_succ_label, *prop_values))
exploration_stack_.push_back(this->create_pair(current_pair.get(), transition_succ_dst, prop_values));
}
api::get().log_state();
}
-Checker* createLivenessChecker(Session* session)
+Checker* create_liveness_checker(Session* session)
{
return new LivenessChecker(session);
}