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 int _sg_mc_soft_dirty = 0;
34 char *_sg_mc_property_file = NULL;
35 int _sg_mc_timeout = 0;
37 int _sg_mc_max_depth = 1000;
38 int _sg_mc_visited = 0;
39 char *_sg_mc_dot_output_file = NULL;
40 int _sg_mc_comms_determinism = 0;
41 int _sg_mc_send_determinism = 0;
42 int _sg_mc_safety = 0;
43 int _sg_mc_liveness = 0;
45 int user_max_depth_reached = 0;
47 void _mc_cfg_cb_reduce(const char *name, int pos)
49 if (_sg_cfg_init_status && !_sg_do_model_check) {
51 ("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.");
53 char *val = xbt_cfg_get_string(_sg_cfg_set, name);
54 if (!strcasecmp(val, "none")) {
55 mc_reduce_kind = e_mc_reduce_none;
56 } else if (!strcasecmp(val, "dpor")) {
57 mc_reduce_kind = e_mc_reduce_dpor;
59 xbt_die("configuration option %s can only take 'none' or 'dpor' as a value",
64 void _mc_cfg_cb_checkpoint(const char *name, int pos)
66 if (_sg_cfg_init_status && !_sg_do_model_check) {
68 ("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.");
70 _sg_mc_checkpoint = xbt_cfg_get_int(_sg_cfg_set, name);
73 void _mc_cfg_cb_sparse_checkpoint(const char *name, int pos) {
74 if (_sg_cfg_init_status && !_sg_do_model_check) {
75 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.");
77 _sg_mc_sparse_checkpoint = xbt_cfg_get_boolean(_sg_cfg_set, name);
80 void _mc_cfg_cb_soft_dirty(const char *name, int pos) {
81 if (_sg_cfg_init_status && !_sg_do_model_check) {
82 xbt_die("You are specifying a soft dirty 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.");
84 _sg_mc_soft_dirty = xbt_cfg_get_boolean(_sg_cfg_set, name);
87 void _mc_cfg_cb_property(const char *name, int pos)
89 if (_sg_cfg_init_status && !_sg_do_model_check) {
91 ("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.");
93 _sg_mc_property_file = xbt_cfg_get_string(_sg_cfg_set, name);
96 void _mc_cfg_cb_timeout(const char *name, int pos)
98 if (_sg_cfg_init_status && !_sg_do_model_check) {
100 ("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.");
102 _sg_mc_timeout = xbt_cfg_get_boolean(_sg_cfg_set, name);
105 void _mc_cfg_cb_hash(const char *name, int pos)
107 if (_sg_cfg_init_status && !_sg_do_model_check) {
109 ("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.");
111 _sg_mc_hash = xbt_cfg_get_boolean(_sg_cfg_set, name);
114 void _mc_cfg_cb_max_depth(const char *name, int pos)
116 if (_sg_cfg_init_status && !_sg_do_model_check) {
118 ("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.");
120 _sg_mc_max_depth = xbt_cfg_get_int(_sg_cfg_set, name);
123 void _mc_cfg_cb_visited(const char *name, int pos)
125 if (_sg_cfg_init_status && !_sg_do_model_check) {
127 ("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.");
129 _sg_mc_visited = xbt_cfg_get_int(_sg_cfg_set, name);
132 void _mc_cfg_cb_dot_output(const char *name, int pos)
134 if (_sg_cfg_init_status && !_sg_do_model_check) {
136 ("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.");
138 _sg_mc_dot_output_file = xbt_cfg_get_string(_sg_cfg_set, name);
141 void _mc_cfg_cb_comms_determinism(const char *name, int pos)
143 if (_sg_cfg_init_status && !_sg_do_model_check) {
145 ("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.");
147 _sg_mc_comms_determinism = xbt_cfg_get_boolean(_sg_cfg_set, name);
150 void _mc_cfg_cb_send_determinism(const char *name, int pos)
152 if (_sg_cfg_init_status && !_sg_do_model_check) {
154 ("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.");
156 _sg_mc_send_determinism = xbt_cfg_get_boolean(_sg_cfg_set, name);
159 /* MC global data structures */
160 mc_state_t mc_current_state = NULL;
161 char mc_replay_mode = FALSE;
162 double *mc_time = NULL;
163 __thread mc_comparison_times_t mc_comp_times = NULL;
164 __thread double mc_snapshot_comparison_time;
165 mc_stats_t mc_stats = NULL;
166 mc_global_t initial_global_state = NULL;
167 xbt_fifo_t mc_stack = NULL;
170 xbt_automaton_t _mc_property_automaton = NULL;
173 mc_object_info_t mc_libsimgrid_info = NULL;
174 mc_object_info_t mc_binary_info = NULL;
176 mc_object_info_t mc_object_infos[2] = { NULL, NULL };
178 size_t mc_object_infos_size = 2;
181 FILE *dot_output = NULL;
182 const char *colors[13];
185 /******************************* Initialisation of MC *******************************/
186 /*********************************************************************************/
188 static void MC_init_dot_output()
189 { /* FIXME : more colors */
193 colors[2] = "green3";
194 colors[3] = "goldenrod";
196 colors[5] = "purple";
197 colors[6] = "magenta";
198 colors[7] = "turquoise4";
199 colors[8] = "gray25";
200 colors[9] = "forestgreen";
201 colors[10] = "hotpink";
202 colors[11] = "lightblue";
205 dot_output = fopen(_sg_mc_dot_output_file, "w");
207 if (dot_output == NULL) {
208 perror("Error open dot output file");
213 "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");
217 static void MC_init_debug_info(void)
219 XBT_INFO("Get debug information ...");
221 memory_map_t maps = MC_get_memory_map();
223 /* Get local variables for state equality detection */
224 mc_binary_info = MC_find_object_info(maps, xbt_binary_name, 1);
225 mc_object_infos[0] = mc_binary_info;
227 mc_libsimgrid_info = MC_find_object_info(maps, libsimgrid_path, 0);
228 mc_object_infos[1] = mc_libsimgrid_info;
230 // Use information of the other objects:
231 MC_post_process_object_info(mc_binary_info);
232 MC_post_process_object_info(mc_libsimgrid_info);
234 MC_free_memory_map(maps);
235 XBT_INFO("Get debug information done !");
239 mc_model_checker_t mc_model_checker = NULL;
243 int raw_mem_set = (mmalloc_get_current_heap() == mc_heap);
245 mc_time = xbt_new0(double, simix_process_maxpid);
247 /* Initialize the data structures that must be persistent across every
248 iteration of the model-checker (in RAW memory) */
252 mc_model_checker = xbt_new0(s_mc_model_checker_t, 1);
253 mc_model_checker->pages = mc_pages_store_new();
254 mc_model_checker->fd_clear_refs = -1;
255 mc_model_checker->fd_pagemap = -1;
257 mc_comp_times = xbt_new0(s_mc_comparison_times_t, 1);
259 /* Initialize statistics */
260 mc_stats = xbt_new0(s_mc_stats_t, 1);
261 mc_stats->state_size = 1;
263 MC_init_memory_map_info();
264 MC_init_debug_info(); /* FIXME : get debug information only if liveness verification or visited state reduction */
266 if ((_sg_mc_dot_output_file != NULL) && (_sg_mc_dot_output_file[0] != '\0'))
267 MC_init_dot_output();
270 //parmap = xbt_parmap_mc_new(xbt_os_get_numcores(), XBT_PARMAP_DEFAULT);
274 if (_sg_mc_visited > 0 || _sg_mc_liveness) {
275 /* Ignore some variables from xbt/ex.h used by exception e for stacks comparison */
276 MC_ignore_local_variable("e", "*");
277 MC_ignore_local_variable("__ex_cleanup", "*");
278 MC_ignore_local_variable("__ex_mctx_en", "*");
279 MC_ignore_local_variable("__ex_mctx_me", "*");
280 MC_ignore_local_variable("__xbt_ex_ctx_ptr", "*");
281 MC_ignore_local_variable("_log_ev", "*");
282 MC_ignore_local_variable("_throw_ctx", "*");
283 MC_ignore_local_variable("ctx", "*");
285 MC_ignore_local_variable("self", "simcall_BODY_mc_snapshot");
286 MC_ignore_local_variable("next_cont"
287 "ext", "smx_ctx_sysv_suspend_serial");
288 MC_ignore_local_variable("i", "smx_ctx_sysv_suspend_serial");
290 /* Ignore local variable about time used for tracing */
291 MC_ignore_local_variable("start_time", "*");
293 MC_ignore_global_variable("mc_model_checker");
295 // Mot of those things could be moved into mc_model_checker:
296 MC_ignore_global_variable("compared_pointers");
297 MC_ignore_global_variable("mc_comp_times");
298 MC_ignore_global_variable("mc_snapshot_comparison_time");
299 MC_ignore_global_variable("mc_time");
300 MC_ignore_global_variable("smpi_current_rank");
301 MC_ignore_global_variable("counter"); /* Static variable used for tracing */
302 MC_ignore_global_variable("maestro_stack_start");
303 MC_ignore_global_variable("maestro_stack_end");
304 MC_ignore_global_variable("smx_total_comms");
306 if (MC_is_active()) {
307 MC_ignore_global_variable("mc_diff_info");
310 MC_ignore_heap(mc_time, simix_process_maxpid * sizeof(double));
312 smx_process_t process;
313 xbt_swag_foreach(process, simix_global->process_list) {
314 MC_ignore_heap(&(process->process_hookup),
315 sizeof(process->process_hookup));
324 /******************************* Core of MC *******************************/
325 /**************************************************************************/
327 static void MC_modelcheck_comm_determinism_init(void)
330 int mc_mem_set = (mmalloc_get_current_heap() == mc_heap);
337 /* Create exploration stack */
338 mc_stack = xbt_fifo_new();
342 MC_pre_modelcheck_comm_determinism();
345 initial_global_state = xbt_new0(s_mc_global_t, 1);
346 initial_global_state->snapshot = MC_take_snapshot(0);
347 initial_global_state->initial_communications_pattern_done = 0;
348 initial_global_state->comm_deterministic = 1;
349 initial_global_state->send_deterministic = 1;
352 MC_modelcheck_comm_determinism();
359 static void MC_modelcheck_safety_init(void)
361 int mc_mem_set = (mmalloc_get_current_heap() == mc_heap);
370 /* Create exploration stack */
371 mc_stack = xbt_fifo_new();
375 MC_pre_modelcheck_safety();
378 /* Save the initial state */
379 initial_global_state = xbt_new0(s_mc_global_t, 1);
380 initial_global_state->snapshot = MC_take_snapshot(0);
383 MC_modelcheck_safety();
392 static void MC_modelcheck_liveness_init()
395 int mc_mem_set = (mmalloc_get_current_heap() == mc_heap);
404 /* Create exploration stack */
405 mc_stack = xbt_fifo_new();
407 /* Create the initial state */
408 initial_global_state = xbt_new0(s_mc_global_t, 1);
412 MC_pre_modelcheck_liveness();
415 MC_print_statistics(mc_stats);
423 void MC_do_the_modelcheck_for_real()
426 if (_sg_mc_comms_determinism || _sg_mc_send_determinism) {
427 XBT_INFO("Check communication determinism");
428 MC_modelcheck_comm_determinism_init();
429 } else if (!_sg_mc_property_file || _sg_mc_property_file[0] == '\0') {
430 if (mc_reduce_kind == e_mc_reduce_unset)
431 mc_reduce_kind = e_mc_reduce_dpor;
432 XBT_INFO("Check a safety property");
433 MC_modelcheck_safety_init();
435 if (mc_reduce_kind == e_mc_reduce_unset)
436 mc_reduce_kind = e_mc_reduce_none;
437 XBT_INFO("Check the liveness property %s", _sg_mc_property_file);
438 MC_automaton_load(_sg_mc_property_file);
439 MC_modelcheck_liveness_init();
452 int SIMIX_pre_mc_random(smx_simcall_t simcall, int min, int max)
455 return simcall->mc_value;
459 int MC_random(int min, int max)
461 /*FIXME: return mc_current_state->executed_transition->random.value; */
462 return simcall_mc_random(min, max);
466 * \brief Schedules all the process that are ready to run
468 void MC_wait_for_requests(void)
470 smx_process_t process;
474 while (!xbt_dynar_is_empty(simix_global->process_to_run)) {
475 SIMIX_process_runall();
476 xbt_dynar_foreach(simix_global->process_that_ran, iter, process) {
477 req = &process->simcall;
478 if (req->call != SIMCALL_NONE && !MC_request_is_visible(req))
479 SIMIX_simcall_pre(req, 0);
484 int MC_deadlock_check()
486 int deadlock = FALSE;
487 smx_process_t process;
488 if (xbt_swag_size(simix_global->process_list)) {
490 xbt_swag_foreach(process, simix_global->process_list) {
491 if (process->simcall.call != SIMCALL_NONE
492 && MC_request_is_enabled(&process->simcall)) {
502 * \brief Re-executes from the state at position start all the transitions indicated by
503 * a given model-checker stack.
504 * \param stack The stack with the transitions to execute.
505 * \param start Start index to begin the re-execution.
507 void MC_replay(xbt_fifo_t stack, int start)
509 int raw_mem = (mmalloc_get_current_heap() == mc_heap);
511 int value, i = 1, count = 1;
513 smx_simcall_t req = NULL, saved_req = NULL;
514 xbt_fifo_item_t item, start_item;
516 smx_process_t process = NULL;
517 int comm_pattern = 0;
518 smx_action_t current_comm;
520 XBT_DEBUG("**** Begin Replay ****");
523 /* Restore the initial state */
524 MC_restore_snapshot(initial_global_state->snapshot);
525 /* At the moment of taking the snapshot the raw heap was set, so restoring
526 * it will set it back again, we have to unset it to continue */
530 start_item = xbt_fifo_get_last_item(stack);
533 start_item = xbt_fifo_get_prev_item(start_item);
540 if ((mc_reduce_kind == e_mc_reduce_dpor) && !_sg_mc_comms_determinism && !_sg_mc_send_determinism) {
541 xbt_dict_reset(first_enabled_state);
542 xbt_swag_foreach(process, simix_global->process_list) {
543 if (MC_process_is_enabled(process)) {
544 char *key = bprintf("%lu", process->pid);
545 char *data = bprintf("%d", count);
546 xbt_dict_set(first_enabled_state, key, data, NULL);
552 if (_sg_mc_comms_determinism || _sg_mc_send_determinism) {
553 xbt_dynar_reset(communications_pattern);
554 xbt_dynar_reset(incomplete_communications_pattern);
560 /* Traverse the stack from the state at position start and re-execute the transitions */
561 for (item = start_item;
562 item != xbt_fifo_get_first_item(stack);
563 item = xbt_fifo_get_prev_item(item)) {
565 state = (mc_state_t) xbt_fifo_get_item_content(item);
566 saved_req = MC_state_get_executed_request(state, &value);
568 if ((mc_reduce_kind == e_mc_reduce_dpor) && !_sg_mc_comms_determinism && !_sg_mc_send_determinism) {
570 char *key = bprintf("%lu", saved_req->issuer->pid);
571 xbt_dict_remove(first_enabled_state, key);
577 /* because we got a copy of the executed request, we have to fetch the
578 real one, pointed by the request field of the issuer process */
579 req = &saved_req->issuer->simcall;
581 /* Debug information */
582 if (XBT_LOG_ISENABLED(mc_global, xbt_log_priority_debug)) {
583 req_str = MC_request_to_string(req, value);
584 XBT_DEBUG("Replay: %s (%p)", req_str, state);
588 /* TODO : handle test and testany simcalls */
589 if (_sg_mc_comms_determinism || _sg_mc_send_determinism) {
590 if (req->call == SIMCALL_COMM_ISEND)
592 else if (req->call == SIMCALL_COMM_IRECV)
594 else if (req->call == SIMCALL_COMM_WAIT)
596 else if (req->call == SIMCALL_COMM_WAITANY)
600 SIMIX_simcall_pre(req, value);
602 if (_sg_mc_comms_determinism || _sg_mc_send_determinism) {
604 if (comm_pattern == 1 || comm_pattern == 2) {
605 get_comm_pattern(communications_pattern, req, comm_pattern);
606 } else if (comm_pattern == 3 /* || comm_pattern == 4 */ ) {
607 current_comm = simcall_comm_wait__get__comm(req);
608 if (current_comm->comm.refcount == 1) { /* First wait only must be considered */
609 complete_comm_pattern(communications_pattern, current_comm);
611 } else if (comm_pattern == 4 /* || comm_pattern == 4 */ ) {
613 xbt_dynar_get_as(simcall_comm_waitany__get__comms(req), value,
615 if (current_comm->comm.refcount == 1) { /* First wait only must be considered */
616 complete_comm_pattern(communications_pattern, current_comm);
624 MC_wait_for_requests();
628 if ((mc_reduce_kind == e_mc_reduce_dpor) && !_sg_mc_comms_determinism && !_sg_mc_send_determinism) {
630 /* Insert in dict all enabled processes */
631 xbt_swag_foreach(process, simix_global->process_list) {
632 if (MC_process_is_enabled(process) ) {
633 char *key = bprintf("%lu", process->pid);
634 if (xbt_dict_get_or_null(first_enabled_state, key) == NULL) {
635 char *data = bprintf("%d", count);
636 xbt_dict_set(first_enabled_state, key, data, NULL);
645 /* Update statistics */
646 mc_stats->visited_states++;
647 mc_stats->executed_transitions++;
651 XBT_DEBUG("**** End Replay ****");
661 void MC_replay_liveness(xbt_fifo_t stack, int all_stack)
664 initial_global_state->raw_mem_set = (mmalloc_get_current_heap() == mc_heap);
668 smx_simcall_t req = NULL, saved_req = NULL;
669 xbt_fifo_item_t item;
674 XBT_DEBUG("**** Begin Replay ****");
676 /* Restore the initial state */
677 MC_restore_snapshot(initial_global_state->snapshot);
679 /* At the moment of taking the snapshot the raw heap was set, so restoring
680 * it will set it back again, we have to unset it to continue */
681 if (!initial_global_state->raw_mem_set)
686 item = xbt_fifo_get_last_item(stack);
688 while (depth <= xbt_fifo_size(stack)) {
690 pair = (mc_pair_t) xbt_fifo_get_item_content(item);
691 state = (mc_state_t) pair->graph_state;
693 if (pair->requests > 0) {
695 saved_req = MC_state_get_executed_request(state, &value);
696 //XBT_DEBUG("SavedReq->call %u", saved_req->call);
698 if (saved_req != NULL) {
699 /* because we got a copy of the executed request, we have to fetch the
700 real one, pointed by the request field of the issuer process */
701 req = &saved_req->issuer->simcall;
702 //XBT_DEBUG("Req->call %u", req->call);
704 /* Debug information */
705 if (XBT_LOG_ISENABLED(mc_global, xbt_log_priority_debug)) {
706 req_str = MC_request_to_string(req, value);
707 XBT_DEBUG("Replay (depth = %d) : %s (%p)", depth, req_str, state);
713 SIMIX_simcall_pre(req, value);
714 MC_wait_for_requests();
719 /* Update statistics */
720 mc_stats->visited_pairs++;
721 mc_stats->executed_transitions++;
723 item = xbt_fifo_get_prev_item(item);
728 /* Traverse the stack from the initial state and re-execute the transitions */
729 for (item = xbt_fifo_get_last_item(stack);
730 item != xbt_fifo_get_first_item(stack);
731 item = xbt_fifo_get_prev_item(item)) {
733 pair = (mc_pair_t) xbt_fifo_get_item_content(item);
734 state = (mc_state_t) pair->graph_state;
736 if (pair->requests > 0) {
738 saved_req = MC_state_get_executed_request(state, &value);
739 //XBT_DEBUG("SavedReq->call %u", saved_req->call);
741 if (saved_req != NULL) {
742 /* because we got a copy of the executed request, we have to fetch the
743 real one, pointed by the request field of the issuer process */
744 req = &saved_req->issuer->simcall;
745 //XBT_DEBUG("Req->call %u", req->call);
747 /* Debug information */
748 if (XBT_LOG_ISENABLED(mc_global, xbt_log_priority_debug)) {
749 req_str = MC_request_to_string(req, value);
750 XBT_DEBUG("Replay (depth = %d) : %s (%p)", depth, req_str, state);
756 SIMIX_simcall_pre(req, value);
757 MC_wait_for_requests();
762 /* Update statistics */
763 mc_stats->visited_pairs++;
764 mc_stats->executed_transitions++;
768 XBT_DEBUG("**** End Replay ****");
770 if (initial_global_state->raw_mem_set)
778 * \brief Dumps the contents of a model-checker's stack and shows the actual
780 * \param stack The stack to dump
782 void MC_dump_stack_safety(xbt_fifo_t stack)
785 int raw_mem_set = (mmalloc_get_current_heap() == mc_heap);
787 MC_show_stack_safety(stack);
789 if (!_sg_mc_checkpoint) {
794 while ((state = (mc_state_t) xbt_fifo_pop(stack)) != NULL)
795 MC_state_delete(state);
808 void MC_show_stack_safety(xbt_fifo_t stack)
811 int raw_mem_set = (mmalloc_get_current_heap() == mc_heap);
817 xbt_fifo_item_t item;
819 char *req_str = NULL;
821 for (item = xbt_fifo_get_last_item(stack);
822 (item ? (state = (mc_state_t) (xbt_fifo_get_item_content(item)))
823 : (NULL)); item = xbt_fifo_get_prev_item(item)) {
824 req = MC_state_get_executed_request(state, &value);
826 req_str = MC_request_to_string(req, value);
827 XBT_INFO("%s", req_str);
836 void MC_show_deadlock(smx_simcall_t req)
838 /*char *req_str = NULL; */
839 XBT_INFO("**************************");
840 XBT_INFO("*** DEAD-LOCK DETECTED ***");
841 XBT_INFO("**************************");
842 XBT_INFO("Locked request:");
843 /*req_str = MC_request_to_string(req);
844 XBT_INFO("%s", req_str);
845 xbt_free(req_str); */
846 XBT_INFO("Counter-example execution trace:");
847 MC_dump_stack_safety(mc_stack);
848 MC_print_statistics(mc_stats);
852 void MC_show_stack_liveness(xbt_fifo_t stack)
856 xbt_fifo_item_t item;
858 char *req_str = NULL;
860 for (item = xbt_fifo_get_last_item(stack);
861 (item ? (pair = (mc_pair_t) (xbt_fifo_get_item_content(item)))
862 : (NULL)); item = xbt_fifo_get_prev_item(item)) {
863 req = MC_state_get_executed_request(pair->graph_state, &value);
865 if (pair->requests > 0) {
866 req_str = MC_request_to_string(req, value);
867 XBT_INFO("%s", req_str);
870 XBT_INFO("End of system requests but evolution in Büchi automaton");
876 void MC_dump_stack_liveness(xbt_fifo_t stack)
879 int raw_mem_set = (mmalloc_get_current_heap() == mc_heap);
884 while ((pair = (mc_pair_t) xbt_fifo_pop(stack)) != NULL)
885 MC_pair_delete(pair);
894 void MC_print_statistics(mc_stats_t stats)
896 if (stats->expanded_pairs == 0) {
897 XBT_INFO("Expanded states = %lu", stats->expanded_states);
898 XBT_INFO("Visited states = %lu", stats->visited_states);
900 XBT_INFO("Expanded pairs = %lu", stats->expanded_pairs);
901 XBT_INFO("Visited pairs = %lu", stats->visited_pairs);
903 XBT_INFO("Executed transitions = %lu", stats->executed_transitions);
905 if ((_sg_mc_dot_output_file != NULL) && (_sg_mc_dot_output_file[0] != '\0')) {
906 fprintf(dot_output, "}\n");
909 if (initial_global_state != NULL) {
910 if (_sg_mc_comms_determinism)
911 XBT_INFO("Communication-deterministic : %s",
912 !initial_global_state->comm_deterministic ? "No" : "Yes");
913 if (_sg_mc_send_determinism)
914 XBT_INFO("Send-deterministic : %s",
915 !initial_global_state->send_deterministic ? "No" : "Yes");
920 void MC_assert(int prop)
922 if (MC_is_active() && !prop) {
923 XBT_INFO("**************************");
924 XBT_INFO("*** PROPERTY NOT VALID ***");
925 XBT_INFO("**************************");
926 XBT_INFO("Counter-example execution trace:");
927 MC_dump_stack_safety(mc_stack);
928 MC_print_statistics(mc_stats);
935 user_max_depth_reached = 1;
938 void MC_process_clock_add(smx_process_t process, double amount)
940 mc_time[process->pid] += amount;
943 double MC_process_clock_get(smx_process_t process)
947 return mc_time[process->pid];
955 void MC_automaton_load(const char *file)
958 int raw_mem_set = (mmalloc_get_current_heap() == mc_heap);
962 if (_mc_property_automaton == NULL)
963 _mc_property_automaton = xbt_automaton_new();
965 xbt_automaton_load(_mc_property_automaton, file);
974 void MC_automaton_new_propositional_symbol(const char *id, void *fct)
977 int raw_mem_set = (mmalloc_get_current_heap() == mc_heap);
981 if (_mc_property_automaton == NULL)
982 _mc_property_automaton = xbt_automaton_new();
984 xbt_automaton_propositional_symbol_new(_mc_property_automaton, id, fct);