X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/32dda1d6e208496b7ce85e5f5b677fb295e82277..c0b8222b84f1084085608ef4d3da724f7f3710e8:/src/mc/mc_global.cpp diff --git a/src/mc/mc_global.cpp b/src/mc/mc_global.cpp index d47939e795..9f231b9675 100644 --- a/src/mc/mc_global.cpp +++ b/src/mc/mc_global.cpp @@ -21,9 +21,6 @@ #include #endif -#include -#include - #include "src/simix/smx_process_private.h" #if HAVE_MC @@ -42,8 +39,7 @@ #include "src/mc/mc_protocol.h" #include "src/mc/Client.hpp" -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_global, mc, - "Logging specific to MC (global)"); +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_global, mc, "Logging specific to MC (global)"); e_mc_mode_t mc_mode; @@ -78,29 +74,13 @@ xbt_automaton_t property_automaton = nullptr; /* Dot output */ FILE *dot_output = nullptr; -const char *colors[13]; /******************************* Initialisation of MC *******************************/ /*********************************************************************************/ void MC_init_dot_output() -{ /* FIXME : more colors */ - - colors[0] = "blue"; - colors[1] = "red"; - colors[2] = "green3"; - colors[3] = "goldenrod"; - colors[4] = "brown"; - colors[5] = "purple"; - colors[6] = "magenta"; - colors[7] = "turquoise4"; - colors[8] = "gray25"; - colors[9] = "forestgreen"; - colors[10] = "hotpink"; - colors[11] = "lightblue"; - colors[12] = "tan"; - +{ dot_output = fopen(_sg_mc_dot_output_file, "w"); if (dot_output == nullptr) { @@ -113,77 +93,19 @@ void MC_init_dot_output() } -#if HAVE_MC -void MC_init() -{ - simgrid::mc::processes_time.resize(simix_process_maxpid); - - if (_sg_mc_visited > 0 || _sg_mc_liveness || _sg_mc_termination || mc_mode == MC_MODE_SERVER) { - /* Those requests are handled on the client side and propagated by message - * to the server: */ - - MC_ignore_heap(simgrid::mc::processes_time.data(), - simix_process_maxpid * sizeof(double)); - - smx_process_t process; - xbt_swag_foreach(process, simix_global->process_list) - MC_ignore_heap(&(process->process_hookup), sizeof(process->process_hookup)); - } -} - -#endif - /******************************* Core of MC *******************************/ /**************************************************************************/ void MC_run() { - mc_mode = MC_MODE_CLIENT; - MC_init(); - simgrid::mc::Client::get()->mainLoop(); -} - -void MC_exit(void) -{ - simgrid::mc::processes_time.clear(); - MC_memory_exit(); - //xbt_abort(); -} - -#if HAVE_MC -int MC_deadlock_check() -{ - if (mc_mode == MC_MODE_SERVER) { - int res; - if ((res = mc_model_checker->process().getChannel().send(MC_MESSAGE_DEADLOCK_CHECK))) - xbt_die("Could not check deadlock state"); - s_mc_int_message_t message; - ssize_t s = mc_model_checker->process().getChannel().receive(message); - if (s == -1) - xbt_die("Could not receive message"); - if (s != sizeof(message) || message.type != MC_MESSAGE_DEADLOCK_CHECK_REPLY) - xbt_die("%s received unexpected message %s (%i, size=%i) " - "expected MC_MESSAGE_DEADLOCK_CHECK_REPLY (%i, size=%i)", - MC_mode_name(mc_mode), - MC_message_type_name(message.type), (int) message.type, (int) s, - (int) MC_MESSAGE_DEADLOCK_CHECK_REPLY, (int) sizeof(message) - ); - return message.value; - } - - bool deadlock = false; + simgrid::mc::processes_time.resize(simix_process_maxpid); + MC_ignore_heap(simgrid::mc::processes_time.data(), + simgrid::mc::processes_time.size() * sizeof(simgrid::mc::processes_time[0])); smx_process_t process; - if (xbt_swag_size(simix_global->process_list)) { - deadlock = true; - xbt_swag_foreach(process, simix_global->process_list) - if (simgrid::mc::process_is_enabled(process)) { - deadlock = false; - break; - } - } - return deadlock; + xbt_swag_foreach(process, simix_global->process_list) + MC_ignore_heap(&(process->process_hookup), sizeof(process->process_hookup)); + simgrid::mc::Client::get()->mainLoop(); } -#endif /** * \brief Re-executes from the state at position start all the transitions indicated by @@ -278,73 +200,6 @@ void MC_replay(xbt_fifo_t stack) XBT_DEBUG("**** End Replay ****"); } -void MC_replay_liveness(xbt_fifo_t stack) -{ - xbt_fifo_item_t item; - simgrid::mc::Pair* pair = nullptr; - mc_state_t state = nullptr; - smx_simcall_t req = nullptr, saved_req = NULL; - int value, depth = 1; - char *req_str; - - XBT_DEBUG("**** Begin Replay ****"); - - /* Intermediate backtracking */ - if(_sg_mc_checkpoint > 0) { - item = xbt_fifo_get_first_item(stack); - pair = (simgrid::mc::Pair*) xbt_fifo_get_item_content(item); - if(pair->graph_state->system_state){ - simgrid::mc::restore_snapshot(pair->graph_state->system_state); - return; - } - } - - /* Restore the initial state */ - simgrid::mc::restore_snapshot(initial_global_state->snapshot); - - /* Traverse the stack from the initial state and re-execute the transitions */ - for (item = xbt_fifo_get_last_item(stack); - item != xbt_fifo_get_first_item(stack); - item = xbt_fifo_get_prev_item(item)) { - - pair = (simgrid::mc::Pair*) xbt_fifo_get_item_content(item); - - state = (mc_state_t) pair->graph_state; - - if (pair->exploration_started) { - - saved_req = MC_state_get_executed_request(state, &value); - - if (saved_req != nullptr) { - /* because we got a copy of the executed request, we have to fetch the - real one, pointed by the request field of the issuer process */ - const smx_process_t issuer = MC_smx_simcall_get_issuer(saved_req); - req = &issuer->simcall; - - /* Debug information */ - if (XBT_LOG_ISENABLED(mc_global, xbt_log_priority_debug)) { - req_str = simgrid::mc::request_to_string(req, value, simgrid::mc::RequestType::simix); - XBT_DEBUG("Replay (depth = %d) : %s (%p)", depth, req_str, state); - xbt_free(req_str); - } - - } - - simgrid::mc::handle_simcall(req, value); - mc_model_checker->wait_for_requests(); - } - - /* Update statistics */ - mc_stats->visited_pairs++; - mc_stats->executed_transitions++; - - depth++; - - } - - XBT_DEBUG("**** End Replay ****"); -} - /** * \brief Dumps the contents of a model-checker's stack and shows the actual * execution trace @@ -405,39 +260,6 @@ void MC_show_non_termination(void){ MC_print_statistics(mc_stats); } -namespace simgrid { -namespace mc { - -void show_stack_liveness(xbt_fifo_t stack) -{ - int value; - simgrid::mc::Pair* pair; - xbt_fifo_item_t item; - smx_simcall_t req; - char *req_str = nullptr; - - for (item = xbt_fifo_get_last_item(stack); - item; item = xbt_fifo_get_prev_item(item)) { - pair = (simgrid::mc::Pair*) xbt_fifo_get_item_content(item); - req = MC_state_get_executed_request(pair->graph_state, &value); - if (req && req->call != SIMCALL_NONE) { - req_str = simgrid::mc::request_to_string(req, value, simgrid::mc::RequestType::executed); - XBT_INFO("%s", req_str); - xbt_free(req_str); - } - } -} - -void dump_stack_liveness(xbt_fifo_t stack) -{ - simgrid::mc::Pair* pair; - while ((pair = (simgrid::mc::Pair*) xbt_fifo_pop(stack)) != nullptr) - delete pair; -} - -} -} - void MC_print_statistics(mc_stats_t stats) { if(_sg_mc_comms_determinism) {