X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/f05224ef57c30ee1e71be443a160a236f7fe121a..39657d7de68ca06c1c3064d52c025aacdd8a9add:/src/mc/LivenessChecker.cpp diff --git a/src/mc/LivenessChecker.cpp b/src/mc/LivenessChecker.cpp index e41d3f54fd..15a0a731e3 100644 --- a/src/mc/LivenessChecker.cpp +++ b/src/mc/LivenessChecker.cpp @@ -29,6 +29,8 @@ #include "src/mc/mc_replay.h" #include "src/mc/mc_safety.h" #include "src/mc/mc_exit.h" +#include "src/mc/Transition.hpp" +#include "src/mc/Session.hpp" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_liveness, mc, "Logging specific to algorithms for liveness properties verification"); @@ -138,7 +140,7 @@ std::shared_ptr LivenessChecker::insertAcceptancePair(simgrid::mc:: if (dot_output != nullptr) fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", initial_global_state->prev_pair, pair_test->num, - initial_global_state->prev_req); + initial_global_state->prev_req.c_str()); return nullptr; } @@ -157,7 +159,6 @@ void LivenessChecker::removeAcceptancePair(int pair_num) void LivenessChecker::prepare(void) { - mc_model_checker->wait_for_requests(); initial_global_state->snapshot = simgrid::mc::take_snapshot(0); initial_global_state->prev_pair = 0; @@ -199,8 +200,8 @@ void LivenessChecker::replay() if (pair->exploration_started) { - int value; - smx_simcall_t saved_req = MC_state_get_executed_request(state.get(), &value); + int req_num = state->transition.argument; + smx_simcall_t saved_req = &state->executed_req; smx_simcall_t req = nullptr; @@ -211,16 +212,14 @@ void LivenessChecker::replay() req = &issuer->simcall; /* Debug information */ - if (XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)) { - char* req_str = simgrid::mc::request_to_string(req, value, simgrid::mc::RequestType::simix); - XBT_DEBUG("Replay (depth = %d) : %s (%p)", depth, req_str, state.get()); - xbt_free(req_str); - } - + XBT_DEBUG("Replay (depth = %d) : %s (%p)", + depth, + simgrid::mc::request_to_string( + req, req_num, simgrid::mc::RequestType::simix).c_str(), + state.get()); } - simgrid::mc::handle_simcall(req, value); - mc_model_checker->wait_for_requests(); + this->getSession().execute(state->transition); } /* Update statistics */ @@ -297,18 +296,19 @@ LivenessChecker::~LivenessChecker() RecordTrace LivenessChecker::getRecordTrace() // override { RecordTrace res; - for (std::shared_ptr const& pair : explorationStack_) { - int value; - smx_simcall_t req = MC_state_get_executed_request(pair->graph_state.get(), &value); - if (req && req->call != SIMCALL_NONE) { - smx_process_t issuer = MC_smx_simcall_get_issuer(req); - const int pid = issuer->pid; - res.push_back(RecordTraceElement(pid, value)); - } - } + for (std::shared_ptr const& pair : explorationStack_) + res.push_back(pair->graph_state->getTransition()); return res; } +void LivenessChecker::logState() // override +{ + Checker::logState(); + XBT_INFO("Expanded pairs = %lu", mc_stats->expanded_pairs); + XBT_INFO("Visited pairs = %lu", mc_stats->visited_pairs); + XBT_INFO("Executed transitions = %lu", mc_stats->executed_transitions); +} + void LivenessChecker::showAcceptanceCycle(std::size_t depth) { XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*"); @@ -318,7 +318,7 @@ void LivenessChecker::showAcceptanceCycle(std::size_t depth) simgrid::mc::dumpRecordPath(); for (auto& s : this->getTextualTrace()) XBT_INFO("%s", s.c_str()); - MC_print_statistics(mc_stats); + simgrid::mc::session->logState(); XBT_INFO("Counter-example depth : %zd", depth); } @@ -326,13 +326,11 @@ std::vector LivenessChecker::getTextualTrace() // override { std::vector trace; for (std::shared_ptr const& pair : explorationStack_) { - int value; - smx_simcall_t req = MC_state_get_executed_request(pair->graph_state.get(), &value); - if (req && req->call != SIMCALL_NONE) { - char* req_str = simgrid::mc::request_to_string(req, value, simgrid::mc::RequestType::executed); - trace.push_back(std::string(req_str)); - xbt_free(req_str); - } + int req_num = pair->graph_state->transition.argument; + smx_simcall_t req = &pair->graph_state->executed_req; + if (req && req->call != SIMCALL_NONE) + trace.push_back(simgrid::mc::request_to_string( + req, req_num, simgrid::mc::RequestType::executed)); } return trace; } @@ -345,9 +343,10 @@ int LivenessChecker::main(void) /* Update current state in buchi automaton */ simgrid::mc::property_automaton->current_state = current_pair->automaton_state; - XBT_DEBUG("********************* ( Depth = %d, search_cycle = %d, interleave size = %d, pair_num = %d, requests = %d)", + XBT_DEBUG("********************* ( Depth = %d, search_cycle = %d, interleave size = %zd, pair_num = %d, requests = %d)", current_pair->depth, current_pair->search_cycle, - MC_state_interleave_size(current_pair->graph_state.get()), current_pair->num, + current_pair->graph_state->interleaveSize(), + current_pair->num, current_pair->requests); if (current_pair->requests == 0) { @@ -368,7 +367,9 @@ int LivenessChecker::main(void) && (visited_num = this->insertVisitedPair( reached_pair, current_pair.get())) != -1) { if (dot_output != nullptr){ - fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", initial_global_state->prev_pair, visited_num, initial_global_state->prev_req); + fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", + initial_global_state->prev_pair, visited_num, + initial_global_state->prev_req.c_str()); fflush(dot_output); } XBT_DEBUG("Pair already visited (equal to pair %d), exploration on the current path stopped.", visited_num); @@ -377,27 +378,26 @@ int LivenessChecker::main(void) continue; } - int value; - smx_simcall_t req = MC_state_get_request(current_pair->graph_state.get(), &value); + smx_simcall_t req = MC_state_get_request(current_pair->graph_state.get()); + int req_num = current_pair->graph_state->transition.argument; if (dot_output != nullptr) { if (initial_global_state->prev_pair != 0 && initial_global_state->prev_pair != current_pair->num) { - fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", initial_global_state->prev_pair, current_pair->num, initial_global_state->prev_req); - xbt_free(initial_global_state->prev_req); + fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", + initial_global_state->prev_pair, current_pair->num, + initial_global_state->prev_req.c_str()); + initial_global_state->prev_req.clear(); } initial_global_state->prev_pair = current_pair->num; - initial_global_state->prev_req = simgrid::mc::request_get_dot_output(req, value); + initial_global_state->prev_req = simgrid::mc::request_get_dot_output(req, req_num); if (current_pair->search_cycle) fprintf(dot_output, "%d [shape=doublecircle];\n", current_pair->num); fflush(dot_output); } - char* req_str = simgrid::mc::request_to_string(req, value, simgrid::mc::RequestType::simix); - XBT_DEBUG("Execute: %s", req_str); - xbt_free(req_str); - - /* Set request as executed */ - MC_state_set_executed_request(current_pair->graph_state.get(), req, value); + XBT_DEBUG("Execute: %s", + simgrid::mc::request_to_string( + req, req_num, simgrid::mc::RequestType::simix).c_str()); /* Update mc_stats */ mc_stats->executed_transitions++; @@ -405,7 +405,7 @@ int LivenessChecker::main(void) mc_stats->visited_pairs++; /* Answer the request */ - simgrid::mc::handle_simcall(req, value); + mc_model_checker->handle_simcall(current_pair->graph_state->transition); /* Wait for requests (schedules processes) */ mc_model_checker->wait_for_requests(); @@ -430,7 +430,7 @@ int LivenessChecker::main(void) } XBT_INFO("No property violation found."); - MC_print_statistics(mc_stats); + simgrid::mc::session->logState(); return SIMGRID_MC_EXIT_SUCCESS; } @@ -447,8 +447,8 @@ std::shared_ptr LivenessChecker::newPair(Pair* current_pair, xbt_automaton /* Get enabled processes and insert them in the interleave set of the next graph_state */ for (auto& p : mc_model_checker->process().simix_processes()) if (simgrid::mc::process_is_enabled(&p.copy)) - MC_state_interleave_process(next_pair->graph_state.get(), &p.copy); - next_pair->requests = MC_state_interleave_size(next_pair->graph_state.get()); + next_pair->graph_state->interleave(&p.copy); + next_pair->requests = next_pair->graph_state->interleaveSize(); /* FIXME : get search_cycle value for each acceptant state */ if (next_pair->automaton_state->type == 1 || (current_pair && current_pair->search_cycle))