1 /* Copyright (c) 2008-2014. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
14 #include "simgrid/sg_config.h"
15 #include "../surf/surf_private.h"
16 #include "../simix/smx_private.h"
17 #include "../xbt/mmalloc/mmprivate.h"
19 #include "mc_private.h"
20 #include "xbt/automaton.h"
23 XBT_LOG_NEW_CATEGORY(mc, "All MC categories");
24 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_global, mc,
25 "Logging specific to MC (global)");
27 /* Configuration support */
28 e_mc_reduce_t mc_reduce_kind = e_mc_reduce_unset;
30 int _sg_do_model_check = 0;
31 int _sg_mc_checkpoint = 0;
32 int _sg_mc_sparse_checkpoint = 0;
33 char *_sg_mc_property_file = NULL;
34 int _sg_mc_timeout = 0;
36 int _sg_mc_max_depth = 1000;
37 int _sg_mc_visited = 0;
38 char *_sg_mc_dot_output_file = NULL;
39 int _sg_mc_comms_determinism = 0;
40 int _sg_mc_send_determinism = 0;
41 int _sg_mc_safety = 0;
42 int _sg_mc_liveness = 0;
44 int user_max_depth_reached = 0;
46 void _mc_cfg_cb_reduce(const char *name, int pos)
48 if (_sg_cfg_init_status && !_sg_do_model_check) {
50 ("You are specifying a reduction strategy after the initialization (through MSG_config?), but model-checking was not activated at config time (through --cfg=model-check:1). This won't work, sorry.");
52 char *val = xbt_cfg_get_string(_sg_cfg_set, name);
53 if (!strcasecmp(val, "none")) {
54 mc_reduce_kind = e_mc_reduce_none;
55 } else if (!strcasecmp(val, "dpor")) {
56 mc_reduce_kind = e_mc_reduce_dpor;
58 xbt_die("configuration option %s can only take 'none' or 'dpor' as a value",
63 void _mc_cfg_cb_checkpoint(const char *name, int pos)
65 if (_sg_cfg_init_status && !_sg_do_model_check) {
67 ("You are specifying a checkpointing value after the initialization (through MSG_config?), but model-checking was not activated at config time (through --cfg=model-check:1). This won't work, sorry.");
69 _sg_mc_checkpoint = xbt_cfg_get_int(_sg_cfg_set, name);
72 void _mc_cfg_cb_sparse_checkpoint(const char *name, int pos) {
73 if (_sg_cfg_init_status && !_sg_do_model_check) {
74 xbt_die("You are specifying a checkpointing value after the initialization (through MSG_config?), but model-checking was not activated at config time (through --cfg=model-check:1). This won't work, sorry.");
76 _sg_mc_sparse_checkpoint = xbt_cfg_get_int(_sg_cfg_set, name);
79 void _mc_cfg_cb_property(const char *name, int pos)
81 if (_sg_cfg_init_status && !_sg_do_model_check) {
83 ("You are specifying a property after the initialization (through MSG_config?), but model-checking was not activated at config time (through --cfg=model-check:1). This won't work, sorry.");
85 _sg_mc_property_file = xbt_cfg_get_string(_sg_cfg_set, name);
88 void _mc_cfg_cb_timeout(const char *name, int pos)
90 if (_sg_cfg_init_status && !_sg_do_model_check) {
92 ("You are specifying a value to enable/disable timeout for wait requests after the initialization (through MSG_config?), but model-checking was not activated at config time (through --cfg=model-check:1). This won't work, sorry.");
94 _sg_mc_timeout = xbt_cfg_get_boolean(_sg_cfg_set, name);
97 void _mc_cfg_cb_hash(const char *name, int pos)
99 if (_sg_cfg_init_status && !_sg_do_model_check) {
101 ("You are specifying a value to enable/disable the use of global hash to speedup state comparaison, but model-checking was not activated at config time (through --cfg=model-check:1). This won't work, sorry.");
103 _sg_mc_hash = xbt_cfg_get_boolean(_sg_cfg_set, name);
106 void _mc_cfg_cb_max_depth(const char *name, int pos)
108 if (_sg_cfg_init_status && !_sg_do_model_check) {
110 ("You are specifying a max depth value after the initialization (through MSG_config?), but model-checking was not activated at config time (through --cfg=model-check:1). This won't work, sorry.");
112 _sg_mc_max_depth = xbt_cfg_get_int(_sg_cfg_set, name);
115 void _mc_cfg_cb_visited(const char *name, int pos)
117 if (_sg_cfg_init_status && !_sg_do_model_check) {
119 ("You are specifying a number of stored visited states after the initialization (through MSG_config?), but model-checking was not activated at config time (through --cfg=model-check:1). This won't work, sorry.");
121 _sg_mc_visited = xbt_cfg_get_int(_sg_cfg_set, name);
124 void _mc_cfg_cb_dot_output(const char *name, int pos)
126 if (_sg_cfg_init_status && !_sg_do_model_check) {
128 ("You are specifying a file name for a dot output of graph state after the initialization (through MSG_config?), but model-checking was not activated at config time (through --cfg=model-check:1). This won't work, sorry.");
130 _sg_mc_dot_output_file = xbt_cfg_get_string(_sg_cfg_set, name);
133 void _mc_cfg_cb_comms_determinism(const char *name, int pos)
135 if (_sg_cfg_init_status && !_sg_do_model_check) {
137 ("You are specifying a value to enable/disable the detection of determinism in the communications schemes after the initialization (through MSG_config?), but model-checking was not activated at config time (through --cfg=model-check:1). This won't work, sorry.");
139 _sg_mc_comms_determinism = xbt_cfg_get_boolean(_sg_cfg_set, name);
142 void _mc_cfg_cb_send_determinism(const char *name, int pos)
144 if (_sg_cfg_init_status && !_sg_do_model_check) {
146 ("You are specifying a value to enable/disable the detection of send-determinism in the communications schemes after the initialization (through MSG_config?), but model-checking was not activated at config time (through --cfg=model-check:1). This won't work, sorry.");
148 _sg_mc_send_determinism = xbt_cfg_get_boolean(_sg_cfg_set, name);
151 /* MC global data structures */
152 mc_state_t mc_current_state = NULL;
153 char mc_replay_mode = FALSE;
154 double *mc_time = NULL;
155 __thread mc_comparison_times_t mc_comp_times = NULL;
156 __thread double mc_snapshot_comparison_time;
157 mc_stats_t mc_stats = NULL;
158 mc_global_t initial_global_state = NULL;
159 xbt_fifo_t mc_stack = NULL;
162 xbt_automaton_t _mc_property_automaton = NULL;
165 mc_object_info_t mc_libsimgrid_info = NULL;
166 mc_object_info_t mc_binary_info = NULL;
168 mc_object_info_t mc_object_infos[2] = { NULL, NULL };
170 size_t mc_object_infos_size = 2;
173 FILE *dot_output = NULL;
174 const char *colors[13];
177 /******************************* Initialisation of MC *******************************/
178 /*********************************************************************************/
180 static void MC_init_dot_output()
181 { /* FIXME : more colors */
185 colors[2] = "green3";
186 colors[3] = "goldenrod";
188 colors[5] = "purple";
189 colors[6] = "magenta";
190 colors[7] = "turquoise4";
191 colors[8] = "gray25";
192 colors[9] = "forestgreen";
193 colors[10] = "hotpink";
194 colors[11] = "lightblue";
197 dot_output = fopen(_sg_mc_dot_output_file, "w");
199 if (dot_output == NULL) {
200 perror("Error open dot output file");
205 "digraph graphname{\n fixedsize=true; rankdir=TB; ranksep=.25; edge [fontsize=12]; node [fontsize=10, shape=circle,width=.5 ]; graph [resolution=20, fontsize=10];\n");
209 static void MC_init_debug_info(void)
211 XBT_INFO("Get debug information ...");
213 memory_map_t maps = MC_get_memory_map();
215 /* Get local variables for state equality detection */
216 mc_binary_info = MC_find_object_info(maps, xbt_binary_name, 1);
217 mc_object_infos[0] = mc_binary_info;
219 mc_libsimgrid_info = MC_find_object_info(maps, libsimgrid_path, 0);
220 mc_object_infos[1] = mc_libsimgrid_info;
222 // Use information of the other objects:
223 MC_post_process_object_info(mc_binary_info);
224 MC_post_process_object_info(mc_libsimgrid_info);
226 MC_free_memory_map(maps);
227 XBT_INFO("Get debug information done !");
231 mc_model_checker_t mc_model_checker = NULL;
235 int raw_mem_set = (mmalloc_get_current_heap() == mc_heap);
237 mc_time = xbt_new0(double, simix_process_maxpid);
239 /* Initialize the data structures that must be persistent across every
240 iteration of the model-checker (in RAW memory) */
244 mc_model_checker = xbt_new0(s_mc_model_checker_t, 1);
245 mc_model_checker->pages = mc_pages_store_new();
246 mc_model_checker->fd_clear_refs = -1;
247 mc_model_checker->fd_pagemap = -1;
249 mc_comp_times = xbt_new0(s_mc_comparison_times_t, 1);
251 /* Initialize statistics */
252 mc_stats = xbt_new0(s_mc_stats_t, 1);
253 mc_stats->state_size = 1;
255 MC_init_memory_map_info();
256 MC_init_debug_info(); /* FIXME : get debug information only if liveness verification or visited state reduction */
258 if ((_sg_mc_dot_output_file != NULL) && (_sg_mc_dot_output_file[0] != '\0'))
259 MC_init_dot_output();
262 //parmap = xbt_parmap_mc_new(xbt_os_get_numcores(), XBT_PARMAP_DEFAULT);
266 if (_sg_mc_visited > 0 || _sg_mc_liveness) {
267 /* Ignore some variables from xbt/ex.h used by exception e for stacks comparison */
268 MC_ignore_local_variable("e", "*");
269 MC_ignore_local_variable("__ex_cleanup", "*");
270 MC_ignore_local_variable("__ex_mctx_en", "*");
271 MC_ignore_local_variable("__ex_mctx_me", "*");
272 MC_ignore_local_variable("__xbt_ex_ctx_ptr", "*");
273 MC_ignore_local_variable("_log_ev", "*");
274 MC_ignore_local_variable("_throw_ctx", "*");
275 MC_ignore_local_variable("ctx", "*");
277 MC_ignore_local_variable("self", "simcall_BODY_mc_snapshot");
278 MC_ignore_local_variable("next_cont"
279 "ext", "smx_ctx_sysv_suspend_serial");
280 MC_ignore_local_variable("i", "smx_ctx_sysv_suspend_serial");
282 /* Ignore local variable about time used for tracing */
283 MC_ignore_local_variable("start_time", "*");
285 MC_ignore_global_variable("mc_model_checker");
287 // Mot of those things could be moved into mc_model_checker:
288 MC_ignore_global_variable("compared_pointers");
289 MC_ignore_global_variable("mc_comp_times");
290 MC_ignore_global_variable("mc_snapshot_comparison_time");
291 MC_ignore_global_variable("mc_time");
292 MC_ignore_global_variable("smpi_current_rank");
293 MC_ignore_global_variable("counter"); /* Static variable used for tracing */
294 MC_ignore_global_variable("maestro_stack_start");
295 MC_ignore_global_variable("maestro_stack_end");
296 MC_ignore_global_variable("smx_total_comms");
299 MC_ignore_heap(mc_time, simix_process_maxpid * sizeof(double));
301 smx_process_t process;
302 xbt_swag_foreach(process, simix_global->process_list) {
303 MC_ignore_heap(&(process->process_hookup),
304 sizeof(process->process_hookup));
313 /******************************* Core of MC *******************************/
314 /**************************************************************************/
316 static void MC_modelcheck_comm_determinism_init(void)
319 int mc_mem_set = (mmalloc_get_current_heap() == mc_heap);
326 /* Create exploration stack */
327 mc_stack = xbt_fifo_new();
331 MC_pre_modelcheck_comm_determinism();
334 initial_global_state = xbt_new0(s_mc_global_t, 1);
335 initial_global_state->snapshot = MC_take_snapshot(0);
336 initial_global_state->initial_communications_pattern_done = 0;
337 initial_global_state->comm_deterministic = 1;
338 initial_global_state->send_deterministic = 1;
341 MC_modelcheck_comm_determinism();
348 static void MC_modelcheck_safety_init(void)
350 int mc_mem_set = (mmalloc_get_current_heap() == mc_heap);
359 /* Create exploration stack */
360 mc_stack = xbt_fifo_new();
364 MC_pre_modelcheck_safety();
367 /* Save the initial state */
368 initial_global_state = xbt_new0(s_mc_global_t, 1);
369 initial_global_state->snapshot = MC_take_snapshot(0);
372 MC_modelcheck_safety();
381 static void MC_modelcheck_liveness_init()
384 int mc_mem_set = (mmalloc_get_current_heap() == mc_heap);
393 /* Create exploration stack */
394 mc_stack = xbt_fifo_new();
396 /* Create the initial state */
397 initial_global_state = xbt_new0(s_mc_global_t, 1);
401 MC_pre_modelcheck_liveness();
404 MC_print_statistics(mc_stats);
412 void MC_do_the_modelcheck_for_real()
415 if (_sg_mc_comms_determinism || _sg_mc_send_determinism) {
416 XBT_INFO("Check communication determinism");
417 MC_modelcheck_comm_determinism_init();
418 } else if (!_sg_mc_property_file || _sg_mc_property_file[0] == '\0') {
419 if (mc_reduce_kind == e_mc_reduce_unset)
420 mc_reduce_kind = e_mc_reduce_dpor;
421 XBT_INFO("Check a safety property");
422 MC_modelcheck_safety_init();
424 if (mc_reduce_kind == e_mc_reduce_unset)
425 mc_reduce_kind = e_mc_reduce_none;
426 XBT_INFO("Check the liveness property %s", _sg_mc_property_file);
427 MC_automaton_load(_sg_mc_property_file);
428 MC_modelcheck_liveness_init();
441 int SIMIX_pre_mc_random(smx_simcall_t simcall, int min, int max)
444 return simcall->mc_value;
448 int MC_random(int min, int max)
450 /*FIXME: return mc_current_state->executed_transition->random.value; */
451 return simcall_mc_random(min, max);
455 * \brief Schedules all the process that are ready to run
457 void MC_wait_for_requests(void)
459 smx_process_t process;
463 while (!xbt_dynar_is_empty(simix_global->process_to_run)) {
464 SIMIX_process_runall();
465 xbt_dynar_foreach(simix_global->process_that_ran, iter, process) {
466 req = &process->simcall;
467 if (req->call != SIMCALL_NONE && !MC_request_is_visible(req))
468 SIMIX_simcall_pre(req, 0);
473 int MC_deadlock_check()
475 int deadlock = FALSE;
476 smx_process_t process;
477 if (xbt_swag_size(simix_global->process_list)) {
479 xbt_swag_foreach(process, simix_global->process_list) {
480 if (process->simcall.call != SIMCALL_NONE
481 && MC_request_is_enabled(&process->simcall)) {
491 * \brief Re-executes from the state at position start all the transitions indicated by
492 * a given model-checker stack.
493 * \param stack The stack with the transitions to execute.
494 * \param start Start index to begin the re-execution.
496 void MC_replay(xbt_fifo_t stack, int start)
498 int raw_mem = (mmalloc_get_current_heap() == mc_heap);
500 int value, i = 1, count = 1;
502 smx_simcall_t req = NULL, saved_req = NULL;
503 xbt_fifo_item_t item, start_item;
505 smx_process_t process = NULL;
506 int comm_pattern = 0;
507 smx_action_t current_comm;
509 XBT_DEBUG("**** Begin Replay ****");
512 /* Restore the initial state */
513 MC_restore_snapshot(initial_global_state->snapshot);
514 /* At the moment of taking the snapshot the raw heap was set, so restoring
515 * it will set it back again, we have to unset it to continue */
519 start_item = xbt_fifo_get_last_item(stack);
522 start_item = xbt_fifo_get_prev_item(start_item);
529 if ((mc_reduce_kind == e_mc_reduce_dpor) && !_sg_mc_comms_determinism && !_sg_mc_send_determinism) {
530 xbt_dict_reset(first_enabled_state);
531 xbt_swag_foreach(process, simix_global->process_list) {
532 if (MC_process_is_enabled(process)) {
533 char *key = bprintf("%lu", process->pid);
534 char *data = bprintf("%d", count);
535 xbt_dict_set(first_enabled_state, key, data, NULL);
541 if (_sg_mc_comms_determinism || _sg_mc_send_determinism) {
542 xbt_dynar_reset(communications_pattern);
543 xbt_dynar_reset(incomplete_communications_pattern);
549 /* Traverse the stack from the state at position start and re-execute the transitions */
550 for (item = start_item;
551 item != xbt_fifo_get_first_item(stack);
552 item = xbt_fifo_get_prev_item(item)) {
554 state = (mc_state_t) xbt_fifo_get_item_content(item);
555 saved_req = MC_state_get_executed_request(state, &value);
557 if ((mc_reduce_kind == e_mc_reduce_dpor) && !_sg_mc_comms_determinism && !_sg_mc_send_determinism) {
559 char *key = bprintf("%lu", saved_req->issuer->pid);
560 xbt_dict_remove(first_enabled_state, key);
566 /* because we got a copy of the executed request, we have to fetch the
567 real one, pointed by the request field of the issuer process */
568 req = &saved_req->issuer->simcall;
570 /* Debug information */
571 if (XBT_LOG_ISENABLED(mc_global, xbt_log_priority_debug)) {
572 req_str = MC_request_to_string(req, value);
573 XBT_DEBUG("Replay: %s (%p)", req_str, state);
577 /* TODO : handle test and testany simcalls */
578 if (_sg_mc_comms_determinism || _sg_mc_send_determinism) {
579 if (req->call == SIMCALL_COMM_ISEND)
581 else if (req->call == SIMCALL_COMM_IRECV)
583 else if (req->call == SIMCALL_COMM_WAIT)
585 else if (req->call == SIMCALL_COMM_WAITANY)
589 SIMIX_simcall_pre(req, value);
591 if (_sg_mc_comms_determinism || _sg_mc_send_determinism) {
593 if (comm_pattern == 1 || comm_pattern == 2) {
594 get_comm_pattern(communications_pattern, req, comm_pattern);
595 } else if (comm_pattern == 3 /* || comm_pattern == 4 */ ) {
596 current_comm = simcall_comm_wait__get__comm(req);
597 if (current_comm->comm.refcount == 1) { /* First wait only must be considered */
598 complete_comm_pattern(communications_pattern, current_comm);
600 } else if (comm_pattern == 4 /* || comm_pattern == 4 */ ) {
602 xbt_dynar_get_as(simcall_comm_waitany__get__comms(req), value,
604 if (current_comm->comm.refcount == 1) { /* First wait only must be considered */
605 complete_comm_pattern(communications_pattern, current_comm);
613 MC_wait_for_requests();
617 if ((mc_reduce_kind == e_mc_reduce_dpor) && !_sg_mc_comms_determinism && !_sg_mc_send_determinism) {
619 /* Insert in dict all enabled processes */
620 xbt_swag_foreach(process, simix_global->process_list) {
621 if (MC_process_is_enabled(process) ) {
622 char *key = bprintf("%lu", process->pid);
623 if (xbt_dict_get_or_null(first_enabled_state, key) == NULL) {
624 char *data = bprintf("%d", count);
625 xbt_dict_set(first_enabled_state, key, data, NULL);
634 /* Update statistics */
635 mc_stats->visited_states++;
636 mc_stats->executed_transitions++;
640 XBT_DEBUG("**** End Replay ****");
650 void MC_replay_liveness(xbt_fifo_t stack, int all_stack)
653 initial_global_state->raw_mem_set = (mmalloc_get_current_heap() == mc_heap);
657 smx_simcall_t req = NULL, saved_req = NULL;
658 xbt_fifo_item_t item;
663 XBT_DEBUG("**** Begin Replay ****");
665 /* Restore the initial state */
666 MC_restore_snapshot(initial_global_state->snapshot);
668 /* At the moment of taking the snapshot the raw heap was set, so restoring
669 * it will set it back again, we have to unset it to continue */
670 if (!initial_global_state->raw_mem_set)
675 item = xbt_fifo_get_last_item(stack);
677 while (depth <= xbt_fifo_size(stack)) {
679 pair = (mc_pair_t) xbt_fifo_get_item_content(item);
680 state = (mc_state_t) pair->graph_state;
682 if (pair->requests > 0) {
684 saved_req = MC_state_get_executed_request(state, &value);
685 //XBT_DEBUG("SavedReq->call %u", saved_req->call);
687 if (saved_req != NULL) {
688 /* because we got a copy of the executed request, we have to fetch the
689 real one, pointed by the request field of the issuer process */
690 req = &saved_req->issuer->simcall;
691 //XBT_DEBUG("Req->call %u", req->call);
693 /* Debug information */
694 if (XBT_LOG_ISENABLED(mc_global, xbt_log_priority_debug)) {
695 req_str = MC_request_to_string(req, value);
696 XBT_DEBUG("Replay (depth = %d) : %s (%p)", depth, req_str, state);
702 SIMIX_simcall_pre(req, value);
703 MC_wait_for_requests();
708 /* Update statistics */
709 mc_stats->visited_pairs++;
710 mc_stats->executed_transitions++;
712 item = xbt_fifo_get_prev_item(item);
717 /* Traverse the stack from the initial state and re-execute the transitions */
718 for (item = xbt_fifo_get_last_item(stack);
719 item != xbt_fifo_get_first_item(stack);
720 item = xbt_fifo_get_prev_item(item)) {
722 pair = (mc_pair_t) xbt_fifo_get_item_content(item);
723 state = (mc_state_t) pair->graph_state;
725 if (pair->requests > 0) {
727 saved_req = MC_state_get_executed_request(state, &value);
728 //XBT_DEBUG("SavedReq->call %u", saved_req->call);
730 if (saved_req != NULL) {
731 /* because we got a copy of the executed request, we have to fetch the
732 real one, pointed by the request field of the issuer process */
733 req = &saved_req->issuer->simcall;
734 //XBT_DEBUG("Req->call %u", req->call);
736 /* Debug information */
737 if (XBT_LOG_ISENABLED(mc_global, xbt_log_priority_debug)) {
738 req_str = MC_request_to_string(req, value);
739 XBT_DEBUG("Replay (depth = %d) : %s (%p)", depth, req_str, state);
745 SIMIX_simcall_pre(req, value);
746 MC_wait_for_requests();
751 /* Update statistics */
752 mc_stats->visited_pairs++;
753 mc_stats->executed_transitions++;
757 XBT_DEBUG("**** End Replay ****");
759 if (initial_global_state->raw_mem_set)
767 * \brief Dumps the contents of a model-checker's stack and shows the actual
769 * \param stack The stack to dump
771 void MC_dump_stack_safety(xbt_fifo_t stack)
774 int raw_mem_set = (mmalloc_get_current_heap() == mc_heap);
776 MC_show_stack_safety(stack);
778 if (!_sg_mc_checkpoint) {
783 while ((state = (mc_state_t) xbt_fifo_pop(stack)) != NULL)
784 MC_state_delete(state);
797 void MC_show_stack_safety(xbt_fifo_t stack)
800 int raw_mem_set = (mmalloc_get_current_heap() == mc_heap);
806 xbt_fifo_item_t item;
808 char *req_str = NULL;
810 for (item = xbt_fifo_get_last_item(stack);
811 (item ? (state = (mc_state_t) (xbt_fifo_get_item_content(item)))
812 : (NULL)); item = xbt_fifo_get_prev_item(item)) {
813 req = MC_state_get_executed_request(state, &value);
815 req_str = MC_request_to_string(req, value);
816 XBT_INFO("%s", req_str);
825 void MC_show_deadlock(smx_simcall_t req)
827 /*char *req_str = NULL; */
828 XBT_INFO("**************************");
829 XBT_INFO("*** DEAD-LOCK DETECTED ***");
830 XBT_INFO("**************************");
831 XBT_INFO("Locked request:");
832 /*req_str = MC_request_to_string(req);
833 XBT_INFO("%s", req_str);
834 xbt_free(req_str); */
835 XBT_INFO("Counter-example execution trace:");
836 MC_dump_stack_safety(mc_stack);
837 MC_print_statistics(mc_stats);
841 void MC_show_stack_liveness(xbt_fifo_t stack)
845 xbt_fifo_item_t item;
847 char *req_str = NULL;
849 for (item = xbt_fifo_get_last_item(stack);
850 (item ? (pair = (mc_pair_t) (xbt_fifo_get_item_content(item)))
851 : (NULL)); item = xbt_fifo_get_prev_item(item)) {
852 req = MC_state_get_executed_request(pair->graph_state, &value);
854 if (pair->requests > 0) {
855 req_str = MC_request_to_string(req, value);
856 XBT_INFO("%s", req_str);
859 XBT_INFO("End of system requests but evolution in Büchi automaton");
865 void MC_dump_stack_liveness(xbt_fifo_t stack)
868 int raw_mem_set = (mmalloc_get_current_heap() == mc_heap);
873 while ((pair = (mc_pair_t) xbt_fifo_pop(stack)) != NULL)
874 MC_pair_delete(pair);
883 void MC_print_statistics(mc_stats_t stats)
885 if (stats->expanded_pairs == 0) {
886 XBT_INFO("Expanded states = %lu", stats->expanded_states);
887 XBT_INFO("Visited states = %lu", stats->visited_states);
889 XBT_INFO("Expanded pairs = %lu", stats->expanded_pairs);
890 XBT_INFO("Visited pairs = %lu", stats->visited_pairs);
892 XBT_INFO("Executed transitions = %lu", stats->executed_transitions);
894 if ((_sg_mc_dot_output_file != NULL) && (_sg_mc_dot_output_file[0] != '\0')) {
895 fprintf(dot_output, "}\n");
898 if (initial_global_state != NULL) {
899 if (_sg_mc_comms_determinism)
900 XBT_INFO("Communication-deterministic : %s",
901 !initial_global_state->comm_deterministic ? "No" : "Yes");
902 if (_sg_mc_send_determinism)
903 XBT_INFO("Send-deterministic : %s",
904 !initial_global_state->send_deterministic ? "No" : "Yes");
909 void MC_assert(int prop)
911 if (MC_is_active() && !prop) {
912 XBT_INFO("**************************");
913 XBT_INFO("*** PROPERTY NOT VALID ***");
914 XBT_INFO("**************************");
915 XBT_INFO("Counter-example execution trace:");
916 MC_dump_stack_safety(mc_stack);
917 MC_print_statistics(mc_stats);
924 user_max_depth_reached = 1;
927 void MC_process_clock_add(smx_process_t process, double amount)
929 mc_time[process->pid] += amount;
932 double MC_process_clock_get(smx_process_t process)
936 return mc_time[process->pid];
944 void MC_automaton_load(const char *file)
947 int raw_mem_set = (mmalloc_get_current_heap() == mc_heap);
951 if (_mc_property_automaton == NULL)
952 _mc_property_automaton = xbt_automaton_new();
954 xbt_automaton_load(_mc_property_automaton, file);
963 void MC_automaton_new_propositional_symbol(const char *id, void *fct)
966 int raw_mem_set = (mmalloc_get_current_heap() == mc_heap);
970 if (_mc_property_automaton == NULL)
971 _mc_property_automaton = xbt_automaton_new();
973 xbt_automaton_propositional_symbol_new(_mc_property_automaton, id, fct);