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);
148 mc_reduce_kind = e_mc_reduce_none;
151 void _mc_cfg_cb_send_determinism(const char *name, int pos)
153 if (_sg_cfg_init_status && !_sg_do_model_check) {
155 ("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.");
157 _sg_mc_send_determinism = xbt_cfg_get_boolean(_sg_cfg_set, name);
158 mc_reduce_kind = e_mc_reduce_none;
161 /* MC global data structures */
162 mc_state_t mc_current_state = NULL;
163 char mc_replay_mode = FALSE;
164 double *mc_time = NULL;
165 __thread mc_comparison_times_t mc_comp_times = NULL;
166 __thread double mc_snapshot_comparison_time;
167 mc_stats_t mc_stats = NULL;
168 mc_global_t initial_global_state = NULL;
169 xbt_fifo_t mc_stack = NULL;
172 xbt_automaton_t _mc_property_automaton = NULL;
175 mc_object_info_t mc_libsimgrid_info = NULL;
176 mc_object_info_t mc_binary_info = NULL;
178 mc_object_info_t mc_object_infos[2] = { NULL, NULL };
180 size_t mc_object_infos_size = 2;
183 FILE *dot_output = NULL;
184 const char *colors[13];
187 /******************************* Initialisation of MC *******************************/
188 /*********************************************************************************/
190 static void MC_init_dot_output()
191 { /* FIXME : more colors */
195 colors[2] = "green3";
196 colors[3] = "goldenrod";
198 colors[5] = "purple";
199 colors[6] = "magenta";
200 colors[7] = "turquoise4";
201 colors[8] = "gray25";
202 colors[9] = "forestgreen";
203 colors[10] = "hotpink";
204 colors[11] = "lightblue";
207 dot_output = fopen(_sg_mc_dot_output_file, "w");
209 if (dot_output == NULL) {
210 perror("Error open dot output file");
215 "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");
219 static void MC_init_debug_info(void)
221 XBT_INFO("Get debug information ...");
223 memory_map_t maps = MC_get_memory_map();
225 /* Get local variables for state equality detection */
226 mc_binary_info = MC_find_object_info(maps, xbt_binary_name, 1);
227 mc_object_infos[0] = mc_binary_info;
229 mc_libsimgrid_info = MC_find_object_info(maps, libsimgrid_path, 0);
230 mc_object_infos[1] = mc_libsimgrid_info;
232 // Use information of the other objects:
233 MC_post_process_object_info(mc_binary_info);
234 MC_post_process_object_info(mc_libsimgrid_info);
236 MC_free_memory_map(maps);
237 XBT_INFO("Get debug information done !");
241 mc_model_checker_t mc_model_checker = NULL;
245 int raw_mem_set = (mmalloc_get_current_heap() == mc_heap);
247 mc_time = xbt_new0(double, simix_process_maxpid);
249 /* Initialize the data structures that must be persistent across every
250 iteration of the model-checker (in RAW memory) */
254 mc_model_checker = xbt_new0(s_mc_model_checker_t, 1);
255 mc_model_checker->pages = mc_pages_store_new();
256 mc_model_checker->fd_clear_refs = -1;
257 mc_model_checker->fd_pagemap = -1;
259 mc_comp_times = xbt_new0(s_mc_comparison_times_t, 1);
261 /* Initialize statistics */
262 mc_stats = xbt_new0(s_mc_stats_t, 1);
263 mc_stats->state_size = 1;
265 MC_init_memory_map_info();
266 MC_init_debug_info(); /* FIXME : get debug information only if liveness verification or visited state reduction */
268 if ((_sg_mc_dot_output_file != NULL) && (_sg_mc_dot_output_file[0] != '\0'))
269 MC_init_dot_output();
272 //parmap = xbt_parmap_mc_new(xbt_os_get_numcores(), XBT_PARMAP_DEFAULT);
276 if (_sg_mc_visited > 0 || _sg_mc_liveness) {
277 /* Ignore some variables from xbt/ex.h used by exception e for stacks comparison */
278 MC_ignore_local_variable("e", "*");
279 MC_ignore_local_variable("__ex_cleanup", "*");
280 MC_ignore_local_variable("__ex_mctx_en", "*");
281 MC_ignore_local_variable("__ex_mctx_me", "*");
282 MC_ignore_local_variable("__xbt_ex_ctx_ptr", "*");
283 MC_ignore_local_variable("_log_ev", "*");
284 MC_ignore_local_variable("_throw_ctx", "*");
285 MC_ignore_local_variable("ctx", "*");
287 MC_ignore_local_variable("self", "simcall_BODY_mc_snapshot");
288 MC_ignore_local_variable("next_cont"
289 "ext", "smx_ctx_sysv_suspend_serial");
290 MC_ignore_local_variable("i", "smx_ctx_sysv_suspend_serial");
292 /* Ignore local variable about time used for tracing */
293 MC_ignore_local_variable("start_time", "*");
295 MC_ignore_global_variable("mc_model_checker");
297 // Mot of those things could be moved into mc_model_checker:
298 MC_ignore_global_variable("compared_pointers");
299 MC_ignore_global_variable("mc_comp_times");
300 MC_ignore_global_variable("mc_snapshot_comparison_time");
301 MC_ignore_global_variable("mc_time");
302 MC_ignore_global_variable("smpi_current_rank");
303 MC_ignore_global_variable("counter"); /* Static variable used for tracing */
304 MC_ignore_global_variable("maestro_stack_start");
305 MC_ignore_global_variable("maestro_stack_end");
306 MC_ignore_global_variable("smx_total_comms");
307 MC_ignore_global_variable("communications_pattern");
308 MC_ignore_global_variable("initial_communications_pattern");
309 MC_ignore_global_variable("incomplete_communications_pattern");
311 if (MC_is_active()) {
312 MC_ignore_global_variable("mc_diff_info");
315 MC_ignore_heap(mc_time, simix_process_maxpid * sizeof(double));
317 smx_process_t process;
318 xbt_swag_foreach(process, simix_global->process_list) {
319 MC_ignore_heap(&(process->process_hookup),
320 sizeof(process->process_hookup));
329 /******************************* Core of MC *******************************/
330 /**************************************************************************/
332 static void MC_modelcheck_comm_determinism_init(void)
335 int mc_mem_set = (mmalloc_get_current_heap() == mc_heap);
342 /* Create exploration stack */
343 mc_stack = xbt_fifo_new();
347 MC_pre_modelcheck_comm_determinism();
350 initial_global_state = xbt_new0(s_mc_global_t, 1);
351 initial_global_state->snapshot = MC_take_snapshot(0);
352 initial_global_state->initial_communications_pattern_done = 0;
353 initial_global_state->comm_deterministic = 1;
354 initial_global_state->send_deterministic = 1;
357 MC_modelcheck_comm_determinism();
364 static void MC_modelcheck_safety_init(void)
366 int mc_mem_set = (mmalloc_get_current_heap() == mc_heap);
375 /* Create exploration stack */
376 mc_stack = xbt_fifo_new();
380 MC_pre_modelcheck_safety();
383 /* Save the initial state */
384 initial_global_state = xbt_new0(s_mc_global_t, 1);
385 initial_global_state->snapshot = MC_take_snapshot(0);
388 MC_modelcheck_safety();
397 static void MC_modelcheck_liveness_init()
400 int mc_mem_set = (mmalloc_get_current_heap() == mc_heap);
409 /* Create exploration stack */
410 mc_stack = xbt_fifo_new();
412 /* Create the initial state */
413 initial_global_state = xbt_new0(s_mc_global_t, 1);
417 MC_pre_modelcheck_liveness();
420 MC_print_statistics(mc_stats);
428 void MC_do_the_modelcheck_for_real()
431 if (_sg_mc_comms_determinism || _sg_mc_send_determinism) {
432 XBT_INFO("Check communication determinism");
433 MC_modelcheck_comm_determinism_init();
434 } else if (!_sg_mc_property_file || _sg_mc_property_file[0] == '\0') {
435 if (mc_reduce_kind == e_mc_reduce_unset)
436 mc_reduce_kind = e_mc_reduce_dpor;
437 XBT_INFO("Check a safety property");
438 MC_modelcheck_safety_init();
440 if (mc_reduce_kind == e_mc_reduce_unset)
441 mc_reduce_kind = e_mc_reduce_none;
442 XBT_INFO("Check the liveness property %s", _sg_mc_property_file);
443 MC_automaton_load(_sg_mc_property_file);
444 MC_modelcheck_liveness_init();
457 int SIMIX_pre_mc_random(smx_simcall_t simcall, int min, int max)
460 return simcall->mc_value;
464 int MC_random(int min, int max)
466 /*FIXME: return mc_current_state->executed_transition->random.value; */
467 return simcall_mc_random(min, max);
471 * \brief Schedules all the process that are ready to run
473 void MC_wait_for_requests(void)
475 smx_process_t process;
479 while (!xbt_dynar_is_empty(simix_global->process_to_run)) {
480 SIMIX_process_runall();
481 xbt_dynar_foreach(simix_global->process_that_ran, iter, process) {
482 req = &process->simcall;
483 if (req->call != SIMCALL_NONE && !MC_request_is_visible(req))
484 SIMIX_simcall_pre(req, 0);
489 int MC_deadlock_check()
491 int deadlock = FALSE;
492 smx_process_t process;
493 if (xbt_swag_size(simix_global->process_list)) {
495 xbt_swag_foreach(process, simix_global->process_list) {
496 if (process->simcall.call != SIMCALL_NONE
497 && MC_request_is_enabled(&process->simcall)) {
507 * \brief Re-executes from the state at position start all the transitions indicated by
508 * a given model-checker stack.
509 * \param stack The stack with the transitions to execute.
510 * \param start Start index to begin the re-execution.
512 void MC_replay(xbt_fifo_t stack, int start)
514 int raw_mem = (mmalloc_get_current_heap() == mc_heap);
516 int value, i = 1, count = 1, call = 0, j;
518 smx_simcall_t req = NULL, saved_req = NULL;
519 xbt_fifo_item_t item, start_item;
521 smx_process_t process = NULL;
522 smx_action_t current_comm;
524 XBT_DEBUG("**** Begin Replay ****");
527 /* Restore the initial state */
528 MC_restore_snapshot(initial_global_state->snapshot);
529 /* At the moment of taking the snapshot the raw heap was set, so restoring
530 * it will set it back again, we have to unset it to continue */
534 start_item = xbt_fifo_get_last_item(stack);
537 start_item = xbt_fifo_get_prev_item(start_item);
544 if (mc_reduce_kind == e_mc_reduce_dpor) {
545 xbt_dict_reset(first_enabled_state);
546 xbt_swag_foreach(process, simix_global->process_list) {
547 if (MC_process_is_enabled(process)) {
548 char *key = bprintf("%lu", process->pid);
549 char *data = bprintf("%d", count);
550 xbt_dict_set(first_enabled_state, key, data, NULL);
556 if (_sg_mc_comms_determinism || _sg_mc_send_determinism) {
557 for (j=0; j<simix_process_maxpid; j++) {
558 xbt_dynar_reset((xbt_dynar_t)xbt_dynar_get_as(communications_pattern, j, xbt_dynar_t));
560 for (j=0; j<simix_process_maxpid; j++) {
561 xbt_dynar_reset((xbt_dynar_t)xbt_dynar_get_as(incomplete_communications_pattern, j, xbt_dynar_t));
568 /* Traverse the stack from the state at position start and re-execute the transitions */
569 for (item = start_item;
570 item != xbt_fifo_get_first_item(stack);
571 item = xbt_fifo_get_prev_item(item)) {
573 state = (mc_state_t) xbt_fifo_get_item_content(item);
574 saved_req = MC_state_get_executed_request(state, &value);
576 if (mc_reduce_kind == e_mc_reduce_dpor) {
578 char *key = bprintf("%lu", saved_req->issuer->pid);
579 if(xbt_dict_get_or_null(first_enabled_state, key))
580 xbt_dict_remove(first_enabled_state, key);
586 /* because we got a copy of the executed request, we have to fetch the
587 real one, pointed by the request field of the issuer process */
588 req = &saved_req->issuer->simcall;
590 /* Debug information */
591 if (XBT_LOG_ISENABLED(mc_global, xbt_log_priority_debug)) {
592 req_str = MC_request_to_string(req, value);
593 XBT_DEBUG("Replay: %s (%p)", req_str, state);
597 /* TODO : handle test and testany simcalls */
598 if (_sg_mc_comms_determinism || _sg_mc_send_determinism) {
599 if (req->call == SIMCALL_COMM_ISEND)
601 else if (req->call == SIMCALL_COMM_IRECV)
603 else if (req->call == SIMCALL_COMM_WAIT)
605 else if (req->call == SIMCALL_COMM_WAITANY)
609 SIMIX_simcall_pre(req, value);
611 if (_sg_mc_comms_determinism || _sg_mc_send_determinism) {
613 if (call == 1) { /* Send */
614 get_comm_pattern(communications_pattern, req, call);
615 } else if (call == 2) { /* Recv */
616 get_comm_pattern(communications_pattern, req, call);
617 } else if (call == 3) { /* Wait */
618 current_comm = simcall_comm_wait__get__comm(req);
619 if (current_comm->comm.refcount == 1) /* First wait only must be considered */
620 complete_comm_pattern(communications_pattern, current_comm);
621 } else if (call == 4) { /* WaitAny */
622 current_comm = xbt_dynar_get_as(simcall_comm_waitany__get__comms(req), value, smx_action_t);
623 if (current_comm->comm.refcount == 1) /* First wait only must be considered */
624 complete_comm_pattern(communications_pattern, current_comm);
631 MC_wait_for_requests();
635 if (mc_reduce_kind == e_mc_reduce_dpor) {
637 /* Insert in dict all enabled processes */
638 xbt_swag_foreach(process, simix_global->process_list) {
639 if (MC_process_is_enabled(process) ) {
640 char *key = bprintf("%lu", process->pid);
641 if (xbt_dict_get_or_null(first_enabled_state, key) == NULL) {
642 char *data = bprintf("%d", count);
643 xbt_dict_set(first_enabled_state, key, data, NULL);
652 /* Update statistics */
653 mc_stats->visited_states++;
654 mc_stats->executed_transitions++;
658 XBT_DEBUG("**** End Replay ****");
668 void MC_replay_liveness(xbt_fifo_t stack, int all_stack)
671 initial_global_state->raw_mem_set = (mmalloc_get_current_heap() == mc_heap);
673 xbt_fifo_item_t item;
676 XBT_DEBUG("**** Begin Replay ****");
678 /* Restore the initial state */
679 MC_restore_snapshot(initial_global_state->snapshot);
681 /* At the moment of taking the snapshot the raw heap was set, so restoring
682 * it will set it back again, we have to unset it to continue */
683 if (!initial_global_state->raw_mem_set)
686 /* Traverse the stack from the initial state and re-execute the transitions */
687 for (item = xbt_fifo_get_last_item(stack);
688 all_stack ? depth <= xbt_fifo_size(stack) : item != xbt_fifo_get_first_item(stack);
689 item = xbt_fifo_get_prev_item(item)) {
691 mc_pair_t pair = (mc_pair_t) xbt_fifo_get_item_content(item);
693 mc_state_t state = (mc_state_t) pair->graph_state;
694 smx_simcall_t req = NULL, saved_req = NULL;
698 if (pair->requests > 0) {
700 saved_req = MC_state_get_executed_request(state, &value);
701 //XBT_DEBUG("SavedReq->call %u", saved_req->call);
703 if (saved_req != NULL) {
704 /* because we got a copy of the executed request, we have to fetch the
705 real one, pointed by the request field of the issuer process */
706 req = &saved_req->issuer->simcall;
707 //XBT_DEBUG("Req->call %u", req->call);
709 /* Debug information */
710 if (XBT_LOG_ISENABLED(mc_global, xbt_log_priority_debug)) {
711 req_str = MC_request_to_string(req, value);
712 XBT_DEBUG("Replay (depth = %d) : %s (%p)", depth, req_str, state);
718 SIMIX_simcall_pre(req, value);
719 MC_wait_for_requests();
722 /* Update statistics */
723 mc_stats->visited_pairs++;
724 mc_stats->executed_transitions++;
730 XBT_DEBUG("**** End Replay ****");
732 if (initial_global_state->raw_mem_set)
740 * \brief Dumps the contents of a model-checker's stack and shows the actual
742 * \param stack The stack to dump
744 void MC_dump_stack_safety(xbt_fifo_t stack)
747 int raw_mem_set = (mmalloc_get_current_heap() == mc_heap);
749 MC_show_stack_safety(stack);
751 if (!_sg_mc_checkpoint) {
756 while ((state = (mc_state_t) xbt_fifo_pop(stack)) != NULL)
757 MC_state_delete(state);
770 void MC_show_stack_safety(xbt_fifo_t stack)
773 int raw_mem_set = (mmalloc_get_current_heap() == mc_heap);
779 xbt_fifo_item_t item;
781 char *req_str = NULL;
783 for (item = xbt_fifo_get_last_item(stack);
784 (item ? (state = (mc_state_t) (xbt_fifo_get_item_content(item)))
785 : (NULL)); item = xbt_fifo_get_prev_item(item)) {
786 req = MC_state_get_executed_request(state, &value);
788 req_str = MC_request_to_string(req, value);
789 XBT_INFO("%s", req_str);
798 void MC_show_deadlock(smx_simcall_t req)
800 /*char *req_str = NULL; */
801 XBT_INFO("**************************");
802 XBT_INFO("*** DEAD-LOCK DETECTED ***");
803 XBT_INFO("**************************");
804 XBT_INFO("Locked request:");
805 /*req_str = MC_request_to_string(req);
806 XBT_INFO("%s", req_str);
807 xbt_free(req_str); */
808 XBT_INFO("Counter-example execution trace:");
809 MC_dump_stack_safety(mc_stack);
810 MC_print_statistics(mc_stats);
814 void MC_show_stack_liveness(xbt_fifo_t stack)
818 xbt_fifo_item_t item;
820 char *req_str = NULL;
822 for (item = xbt_fifo_get_last_item(stack);
823 (item ? (pair = (mc_pair_t) (xbt_fifo_get_item_content(item)))
824 : (NULL)); item = xbt_fifo_get_prev_item(item)) {
825 req = MC_state_get_executed_request(pair->graph_state, &value);
827 if (pair->requests > 0) {
828 req_str = MC_request_to_string(req, value);
829 XBT_INFO("%s", req_str);
832 XBT_INFO("End of system requests but evolution in Büchi automaton");
838 void MC_dump_stack_liveness(xbt_fifo_t stack)
841 int raw_mem_set = (mmalloc_get_current_heap() == mc_heap);
846 while ((pair = (mc_pair_t) xbt_fifo_pop(stack)) != NULL)
847 MC_pair_delete(pair);
856 void MC_print_statistics(mc_stats_t stats)
858 xbt_mheap_t previous_heap = mmalloc_get_current_heap();
860 if (stats->expanded_pairs == 0) {
861 XBT_INFO("Expanded states = %lu", stats->expanded_states);
862 XBT_INFO("Visited states = %lu", stats->visited_states);
864 XBT_INFO("Expanded pairs = %lu", stats->expanded_pairs);
865 XBT_INFO("Visited pairs = %lu", stats->visited_pairs);
867 XBT_INFO("Executed transitions = %lu", stats->executed_transitions);
869 if ((_sg_mc_dot_output_file != NULL) && (_sg_mc_dot_output_file[0] != '\0')) {
870 fprintf(dot_output, "}\n");
873 if (initial_global_state != NULL) {
874 if (_sg_mc_comms_determinism)
875 XBT_INFO("Communication-deterministic : %s",
876 !initial_global_state->comm_deterministic ? "No" : "Yes");
877 if (_sg_mc_send_determinism)
878 XBT_INFO("Send-deterministic : %s",
879 !initial_global_state->send_deterministic ? "No" : "Yes");
881 mmalloc_set_current_heap(previous_heap);
884 void MC_assert(int prop)
886 if (MC_is_active() && !prop) {
887 XBT_INFO("**************************");
888 XBT_INFO("*** PROPERTY NOT VALID ***");
889 XBT_INFO("**************************");
890 XBT_INFO("Counter-example execution trace:");
891 MC_dump_stack_safety(mc_stack);
892 MC_print_statistics(mc_stats);
899 user_max_depth_reached = 1;
902 void MC_process_clock_add(smx_process_t process, double amount)
904 mc_time[process->pid] += amount;
907 double MC_process_clock_get(smx_process_t process)
911 return mc_time[process->pid];
919 void MC_automaton_load(const char *file)
922 int raw_mem_set = (mmalloc_get_current_heap() == mc_heap);
926 if (_mc_property_automaton == NULL)
927 _mc_property_automaton = xbt_automaton_new();
929 xbt_automaton_load(_mc_property_automaton, file);
938 void MC_automaton_new_propositional_symbol(const char *id, void *fct)
941 int raw_mem_set = (mmalloc_get_current_heap() == mc_heap);
945 if (_mc_property_automaton == NULL)
946 _mc_property_automaton = xbt_automaton_new();
948 xbt_automaton_propositional_symbol_new(_mc_property_automaton, id, fct);