1 /* Copyright (c) 2008-2012 Da SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #include "mc_private.h"
10 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_liveness, mc,
11 "Logging specific to algorithms for liveness properties verification");
13 xbt_dynar_t reached_pairs;
14 xbt_dynar_t visited_pairs;
15 xbt_dynar_t successors;
17 int create_dump(int pair)
19 // Try to enable core dumps
20 struct rlimit core_limit;
21 core_limit.rlim_cur = RLIM_INFINITY;
22 core_limit.rlim_max = RLIM_INFINITY;
24 if(setrlimit(RLIMIT_CORE, &core_limit) < 0)
25 fprintf(stderr, "setrlimit: %s\nWarning: core dumps may be truncated or non-existant\n", strerror(errno));
30 // We are the child process -- run the actual program
35 // An error occurred, shouldn't happen
40 // We are the parent process -- wait for the child process to exit
43 if(WIFSIGNALED(status) && WCOREDUMP(status)){
44 char *core_name = malloc(20);
45 sprintf(core_name,"core_%d", pair);
46 rename("core", core_name);
54 void MC_print_comparison_times_statistics(mc_comparison_times_t ct){
56 XBT_DEBUG("Comparisons done : %d", ct->nb_comparisons);
58 double total, min, max;
61 if(xbt_dynar_length(ct->chunks_used_comparison_times) > 0){
65 min = xbt_dynar_get_as(ct->chunks_used_comparison_times, cursor, double);
66 while(cursor < xbt_dynar_length(ct->chunks_used_comparison_times) - 1){
67 total += xbt_dynar_get_as(ct->chunks_used_comparison_times, cursor, double);
68 if(xbt_dynar_get_as(ct->chunks_used_comparison_times, cursor, double) > max)
69 max = xbt_dynar_get_as(ct->chunks_used_comparison_times, cursor, double);
70 if(xbt_dynar_get_as(ct->chunks_used_comparison_times, cursor, double) < min)
71 min = xbt_dynar_get_as(ct->chunks_used_comparison_times, cursor, double);
74 XBT_DEBUG("Chunks used comparison -- Different states : %lu/%d, time (in seconds) : average = %lf, max = %lf, min = %lf", xbt_dynar_length(ct->chunks_used_comparison_times), ct->nb_comparisons, total/xbt_dynar_length(ct->chunks_used_comparison_times), max, min);
77 if(xbt_dynar_length(ct->stacks_sizes_comparison_times) > 0){
81 min = xbt_dynar_get_as(ct->stacks_sizes_comparison_times, cursor, double);
82 while(cursor < xbt_dynar_length(ct->stacks_sizes_comparison_times) - 1){
83 total += xbt_dynar_get_as(ct->stacks_sizes_comparison_times, cursor, double);
84 if(xbt_dynar_get_as(ct->stacks_sizes_comparison_times, cursor, double) > max)
85 max = xbt_dynar_get_as(ct->stacks_sizes_comparison_times, cursor, double);
86 if(xbt_dynar_get_as(ct->stacks_sizes_comparison_times, cursor, double) < min)
87 min = xbt_dynar_get_as(ct->stacks_sizes_comparison_times, cursor, double);
90 XBT_DEBUG("Stacks sizes comparison -- Different states : %lu/%d, time (in seconds) : average = %lf, max = %lf, min = %lf", xbt_dynar_length(ct->stacks_sizes_comparison_times), ct->nb_comparisons, total/xbt_dynar_length(ct->stacks_sizes_comparison_times), max, min);
93 if(xbt_dynar_length(ct->program_data_segment_comparison_times) > 0){
97 min = xbt_dynar_get_as(ct->program_data_segment_comparison_times, cursor, double);
98 while(cursor < xbt_dynar_length(ct->program_data_segment_comparison_times) - 1){
99 total += xbt_dynar_get_as(ct->program_data_segment_comparison_times, cursor, double);
100 if(xbt_dynar_get_as(ct->program_data_segment_comparison_times, cursor, double) > max)
101 max = xbt_dynar_get_as(ct->program_data_segment_comparison_times, cursor, double);
102 if(xbt_dynar_get_as(ct->program_data_segment_comparison_times, cursor, double) < min)
103 min = xbt_dynar_get_as(ct->program_data_segment_comparison_times, cursor, double);
106 XBT_DEBUG("Program data/bss segments comparison -- Different states : %lu/%d, time (in seconds) : average = %lf, max = %lf, min = %lf", xbt_dynar_length(ct->program_data_segment_comparison_times), ct->nb_comparisons, total/xbt_dynar_length(ct->program_data_segment_comparison_times), max, min);
109 if(xbt_dynar_length(ct->libsimgrid_data_segment_comparison_times) > 0){
113 min = xbt_dynar_get_as(ct->libsimgrid_data_segment_comparison_times, cursor, double);
114 while(cursor < xbt_dynar_length(ct->libsimgrid_data_segment_comparison_times) - 1){
115 total += xbt_dynar_get_as(ct->libsimgrid_data_segment_comparison_times, cursor, double);
116 if(xbt_dynar_get_as(ct->libsimgrid_data_segment_comparison_times, cursor, double) > max)
117 max = xbt_dynar_get_as(ct->libsimgrid_data_segment_comparison_times, cursor, double);
118 if(xbt_dynar_get_as(ct->libsimgrid_data_segment_comparison_times, cursor, double) < min)
119 min = xbt_dynar_get_as(ct->libsimgrid_data_segment_comparison_times, cursor, double);
122 XBT_DEBUG("Libsimgrid data/bss segments comparison -- Different states : %lu/%d, time (in seconds) : average = %lf, max = %lf, min = %lf", xbt_dynar_length(ct->libsimgrid_data_segment_comparison_times), ct->nb_comparisons, total/xbt_dynar_length(ct->libsimgrid_data_segment_comparison_times), max, min);
125 if(xbt_dynar_length(ct->heap_comparison_times) > 0){
129 min = xbt_dynar_get_as(ct->heap_comparison_times, cursor, double);
130 while(cursor < xbt_dynar_length(ct->heap_comparison_times) - 1){
131 total += xbt_dynar_get_as(ct->heap_comparison_times, cursor, double);
132 if(xbt_dynar_get_as(ct->heap_comparison_times, cursor, double) > max)
133 max = xbt_dynar_get_as(ct->heap_comparison_times, cursor, double);
134 if(xbt_dynar_get_as(ct->heap_comparison_times, cursor, double) < min)
135 min = xbt_dynar_get_as(ct->heap_comparison_times, cursor, double);
138 XBT_DEBUG("Heap comparison -- Different states : %lu/%d, time (in seconds) : average = %lf, max = %lf, min = %lf", xbt_dynar_length(ct->heap_comparison_times), ct->nb_comparisons, total/xbt_dynar_length(ct->heap_comparison_times), max, min);
141 if(xbt_dynar_length(ct->stacks_comparison_times) > 0){
145 min = xbt_dynar_get_as(ct->stacks_comparison_times, cursor, double);
146 while(cursor < xbt_dynar_length(ct->stacks_comparison_times) - 1){
147 total += xbt_dynar_get_as(ct->stacks_comparison_times, cursor, double);
148 if(xbt_dynar_get_as(ct->stacks_comparison_times, cursor, double) > max)
149 max = xbt_dynar_get_as(ct->stacks_comparison_times, cursor, double);
150 if(xbt_dynar_get_as(ct->stacks_comparison_times, cursor, double) < min)
151 min = xbt_dynar_get_as(ct->stacks_comparison_times, cursor, double);
154 XBT_DEBUG("Stacks comparison -- Different states : %lu/%d, time (in seconds) : average = %lf, max = %lf, min = %lf", xbt_dynar_length(ct->stacks_comparison_times), ct->nb_comparisons, total/xbt_dynar_length(ct->stacks_comparison_times), max, min);
157 if(xbt_dynar_length(ct->snapshot_comparison_times) > 0){
161 min = xbt_dynar_get_as(ct->snapshot_comparison_times, cursor, double);
162 while(cursor < xbt_dynar_length(ct->snapshot_comparison_times) - 1){
163 total += xbt_dynar_get_as(ct->snapshot_comparison_times, cursor, double);
164 if(xbt_dynar_get_as(ct->snapshot_comparison_times, cursor, double) > max)
165 max = xbt_dynar_get_as(ct->snapshot_comparison_times, cursor, double);
166 if(xbt_dynar_get_as(ct->snapshot_comparison_times, cursor, double) < min)
167 min = xbt_dynar_get_as(ct->snapshot_comparison_times, cursor, double);
170 XBT_DEBUG("Snapshot comparison (Whole funnel) -- Different states : %lu/%d, time (in seconds) : average = %lf, max = %lf, min = %lf", xbt_dynar_length(ct->snapshot_comparison_times), ct->nb_comparisons, total/xbt_dynar_length(ct->snapshot_comparison_times), max, min);
175 mc_comparison_times_t new_comparison_times(){
176 mc_comparison_times_t ct = NULL;
177 ct = xbt_new0(s_mc_comparison_times_t, 1);
178 ct->nb_comparisons = 0;
179 ct->snapshot_comparison_times = xbt_dynar_new(sizeof(double), NULL);
180 ct->chunks_used_comparison_times = xbt_dynar_new(sizeof(double), NULL);
181 ct->stacks_sizes_comparison_times = xbt_dynar_new(sizeof(double), NULL);
182 ct->program_data_segment_comparison_times = xbt_dynar_new(sizeof(double), NULL);
183 ct->libsimgrid_data_segment_comparison_times = xbt_dynar_new(sizeof(double), NULL);
184 ct->heap_comparison_times = xbt_dynar_new(sizeof(double), NULL);
185 ct->stacks_comparison_times = xbt_dynar_new(sizeof(double), NULL);
189 int reached(xbt_state_t st){
191 raw_mem_set = (mmalloc_get_current_heap() == raw_heap);
195 mc_pair_reached_t new_pair = NULL;
196 new_pair = xbt_new0(s_mc_pair_reached_t, 1);
197 new_pair->nb = xbt_dynar_length(reached_pairs) + 1;
198 new_pair->automaton_state = st;
199 new_pair->prop_ato = xbt_dynar_new(sizeof(int), NULL);
200 new_pair->comparison_times = new_comparison_times();
201 new_pair->system_state = MC_take_snapshot_liveness();
203 /* Get values of propositional symbols */
206 unsigned int cursor = 0;
207 xbt_propositional_symbol_t ps = NULL;
208 xbt_dynar_foreach(_mc_property_automaton->propositional_symbols, cursor, ps){
209 f = (int_f_void_t)ps->function;
211 xbt_dynar_push_as(new_pair->prop_ato, int, res);
216 if(xbt_dynar_is_empty(reached_pairs)/* || !compare*/){
219 /* New pair reached */
220 xbt_dynar_push(reached_pairs, &new_pair);
233 mc_pair_reached_t pair_test = NULL;
235 xbt_dynar_foreach(reached_pairs, cursor, pair_test){
236 if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug))
237 XBT_DEBUG("****** Pair reached #%d ******", pair_test->nb);
238 if(automaton_state_compare(pair_test->automaton_state, st) == 0){
239 if(propositional_symbols_compare_value(pair_test->prop_ato, new_pair->prop_ato) == 0){
240 if(snapshot_compare(new_pair->system_state, pair_test->system_state, new_pair->comparison_times, pair_test->comparison_times) == 0){
250 XBT_INFO("Different values of propositional symbols");
253 XBT_INFO("Different automaton state");
255 if(pair_test->comparison_times != NULL && XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
256 XBT_DEBUG("*** Comparison times statistics ***");
257 MC_print_comparison_times_statistics(pair_test->comparison_times);
261 /* New pair reached */
262 xbt_dynar_push(reached_pairs, &new_pair);
277 void set_pair_reached(xbt_state_t st){
279 raw_mem_set = (mmalloc_get_current_heap() == raw_heap);
283 mc_pair_reached_t pair = NULL;
284 pair = xbt_new0(s_mc_pair_reached_t, 1);
285 pair->nb = xbt_dynar_length(reached_pairs) + 1;
286 pair->automaton_state = st;
287 pair->prop_ato = xbt_dynar_new(sizeof(int), NULL);
288 pair->comparison_times = new_comparison_times();
289 pair->system_state = MC_take_snapshot_liveness();
291 /* Get values of propositional symbols */
292 unsigned int cursor = 0;
293 xbt_propositional_symbol_t ps = NULL;
297 xbt_dynar_foreach(_mc_property_automaton->propositional_symbols, cursor, ps){
298 f = (int_f_void_t)ps->function;
300 xbt_dynar_push_as(pair->prop_ato, int, res);
303 xbt_dynar_push(reached_pairs, &pair);
312 int visited(xbt_state_t st){
314 if(_surf_mc_stateful == 0)
317 int raw_mem_set = (mmalloc_get_current_heap() == raw_heap);
321 mc_pair_visited_t new_pair = NULL;
322 new_pair = xbt_new0(s_mc_pair_visited_t, 1);
323 new_pair->automaton_state = st;
324 new_pair->prop_ato = xbt_dynar_new(sizeof(int), NULL);
325 new_pair->system_state = MC_take_snapshot_liveness();
327 /* Get values of propositional symbols */
330 unsigned int cursor = 0;
331 xbt_propositional_symbol_t ps = NULL;
332 xbt_dynar_foreach(_mc_property_automaton->propositional_symbols, cursor, ps){
333 f = (int_f_void_t)ps->function;
335 xbt_dynar_push_as(new_pair->prop_ato, int, res);
340 if(xbt_dynar_is_empty(visited_pairs)){
343 /* New pair visited */
344 xbt_dynar_push(visited_pairs, &new_pair);
357 mc_pair_visited_t pair_test = NULL;
359 xbt_dynar_foreach(visited_pairs, cursor, pair_test){
360 if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug))
361 XBT_DEBUG("****** Pair visited #%d ******", cursor + 1);
362 if(automaton_state_compare(pair_test->automaton_state, st) == 0){
363 if(propositional_symbols_compare_value(pair_test->prop_ato, new_pair->prop_ato) == 0){
364 if(snapshot_compare(new_pair->system_state, pair_test->system_state, NULL, NULL) == 0){
373 XBT_INFO("Different values of propositional symbols");
376 XBT_INFO("Different automaton state");
380 if(xbt_dynar_length(visited_pairs) == _surf_mc_stateful){
381 xbt_dynar_remove_at(visited_pairs, 0, NULL);
384 /* New pair visited */
385 xbt_dynar_push(visited_pairs, &new_pair);
397 void MC_pair_delete(mc_pair_t pair){
398 xbt_free(pair->graph_state->proc_status);
399 xbt_free(pair->graph_state);
405 int MC_automaton_evaluate_label(xbt_exp_label_t l){
409 int left_res = MC_automaton_evaluate_label(l->u.or_and.left_exp);
410 int right_res = MC_automaton_evaluate_label(l->u.or_and.right_exp);
411 return (left_res || right_res);
414 int left_res = MC_automaton_evaluate_label(l->u.or_and.left_exp);
415 int right_res = MC_automaton_evaluate_label(l->u.or_and.right_exp);
416 return (left_res && right_res);
419 int res = MC_automaton_evaluate_label(l->u.exp_not);
423 unsigned int cursor = 0;
424 xbt_propositional_symbol_t p = NULL;
426 xbt_dynar_foreach(_mc_property_automaton->propositional_symbols, cursor, p){
427 if(strcmp(p->pred, l->u.predicat) == 0){
428 f = (int_f_void_t)p->function;
443 /********************* Double-DFS stateless *******************/
445 void pair_visited_free(mc_pair_visited_t pair){
447 pair->automaton_state = NULL;
448 xbt_dynar_free(&(pair->prop_ato));
449 MC_free_snapshot(pair->system_state);
454 void pair_visited_free_voidp(void *p){
455 pair_visited_free((mc_pair_visited_t) * (void **) p);
458 void pair_stateless_free(mc_pair_stateless_t pair){
459 xbt_free(pair->graph_state->system_state);
460 xbt_free(pair->graph_state->proc_status);
461 xbt_free(pair->graph_state);
465 void pair_stateless_free_voidp(void *p){
466 pair_stateless_free((mc_pair_stateless_t) * (void **) p);
469 mc_pair_stateless_t new_pair_stateless(mc_state_t sg, xbt_state_t st, int r){
470 mc_pair_stateless_t p = NULL;
471 p = xbt_new0(s_mc_pair_stateless_t, 1);
472 p->automaton_state = st;
475 mc_stats_pair->expanded_pairs++;
479 void pair_reached_free(mc_pair_reached_t pair){
481 pair->automaton_state = NULL;
482 xbt_dynar_free(&(pair->prop_ato));
483 MC_free_snapshot(pair->system_state);
488 void pair_reached_free_voidp(void *p){
489 pair_reached_free((mc_pair_reached_t) * (void **) p);
492 void MC_ddfs_init(void){
494 raw_mem_set = (mmalloc_get_current_heap() == raw_heap);
496 XBT_INFO("**************************************************");
497 XBT_INFO("Double-DFS init");
498 XBT_INFO("**************************************************");
500 mc_pair_stateless_t mc_initial_pair = NULL;
501 mc_state_t initial_graph_state = NULL;
502 smx_process_t process;
505 MC_wait_for_requests();
509 initial_graph_state = MC_state_pair_new();
510 xbt_swag_foreach(process, simix_global->process_list){
511 if(MC_process_is_enabled(process)){
512 MC_state_interleave_process(initial_graph_state, process);
516 reached_pairs = xbt_dynar_new(sizeof(mc_pair_reached_t), pair_reached_free_voidp);
517 visited_pairs = xbt_dynar_new(sizeof(mc_pair_visited_t), pair_visited_free_voidp);
518 successors = xbt_dynar_new(sizeof(mc_pair_stateless_t), NULL);
520 /* Save the initial state */
521 initial_state_liveness->initial_snapshot = MC_take_snapshot_liveness();
525 unsigned int cursor = 0;
528 xbt_dynar_foreach(_mc_property_automaton->states, cursor, state){
529 if(state->type == -1){
532 mc_initial_pair = new_pair_stateless(initial_graph_state, state, MC_state_interleave_size(initial_graph_state));
533 xbt_fifo_unshift(mc_stack_liveness, mc_initial_pair);
537 MC_restore_snapshot(initial_state_liveness->initial_snapshot);
544 if(state->type == 2){
547 mc_initial_pair = new_pair_stateless(initial_graph_state, state, MC_state_interleave_size(initial_graph_state));
548 xbt_fifo_unshift(mc_stack_liveness, mc_initial_pair);
551 set_pair_reached(state);
554 MC_restore_snapshot(initial_state_liveness->initial_snapshot);
573 void MC_ddfs(int search_cycle){
575 raw_mem_set = (mmalloc_get_current_heap() == raw_heap);
577 smx_process_t process;
578 mc_pair_stateless_t current_pair = NULL;
580 if(xbt_fifo_size(mc_stack_liveness) == 0)
584 /* Get current pair */
585 current_pair = (mc_pair_stateless_t)xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack_liveness));
587 /* Update current state in buchi automaton */
588 _mc_property_automaton->current_state = current_pair->automaton_state;
591 XBT_DEBUG("********************* ( Depth = %d, search_cycle = %d )", xbt_fifo_size(mc_stack_liveness), search_cycle);
593 mc_stats_pair->visited_pairs++;
598 mc_state_t next_graph_state = NULL;
599 smx_simcall_t req = NULL;
602 xbt_transition_t transition_succ;
603 unsigned int cursor = 0;
606 mc_pair_stateless_t next_pair = NULL;
607 mc_pair_stateless_t pair_succ;
609 mc_pair_stateless_t remove_pair;
610 mc_pair_reached_t remove_pair_reached;
612 if(xbt_fifo_size(mc_stack_liveness) < _surf_mc_max_depth){
614 if(current_pair->requests > 0){
616 while((req = MC_state_get_request(current_pair->graph_state, &value)) != NULL){
618 /* Debug information */
620 req_str = MC_request_to_string(req, value);
621 XBT_DEBUG("Execute: %s", req_str);
624 MC_state_set_executed_request(current_pair->graph_state, req, value);
626 /* Answer the request */
627 SIMIX_simcall_pre(req, value);
629 /* Wait for requests (schedules processes) */
630 MC_wait_for_requests();
634 /* Create the new expanded graph_state */
635 next_graph_state = MC_state_pair_new();
637 /* Get enabled process and insert it in the interleave set of the next graph_state */
639 xbt_swag_foreach(process, simix_global->process_list){
640 if(MC_process_is_enabled(process)){
641 XBT_DEBUG("Process %lu enabled with simcall : %d", process->pid, (&process->simcall)->call);
645 xbt_swag_foreach(process, simix_global->process_list){
646 if(MC_process_is_enabled(process)){
647 MC_state_interleave_process(next_graph_state, process);
651 xbt_dynar_reset(successors);
657 xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
659 res = MC_automaton_evaluate_label(transition_succ->label);
661 if(res == 1){ // enabled transition in automaton
663 next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
664 xbt_dynar_push(successors, &next_pair);
672 xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
674 res = MC_automaton_evaluate_label(transition_succ->label);
676 if(res == 2){ // true transition in automaton
678 next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
679 xbt_dynar_push(successors, &next_pair);
687 xbt_dynar_foreach(successors, cursor, pair_succ){
689 if(search_cycle == 1){
691 if((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2)){
693 if(reached(pair_succ->automaton_state)){
695 XBT_INFO("Next pair (depth = %d, %u interleave) already reached !", xbt_fifo_size(mc_stack_liveness) + 1, MC_state_interleave_size(pair_succ->graph_state));
697 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
698 XBT_INFO("| ACCEPTANCE CYCLE |");
699 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
700 XBT_INFO("Counter-example that violates formula :");
701 MC_show_stack_liveness(mc_stack_liveness);
702 MC_dump_stack_liveness(mc_stack_liveness);
703 MC_print_statistics_pairs(mc_stats_pair);
708 if(visited(pair_succ->automaton_state)){
710 XBT_DEBUG("Next pair already visited !");
715 XBT_DEBUG("Next pair (depth =%d) -> Acceptance pair (%s)", xbt_fifo_size(mc_stack_liveness) + 1, pair_succ->automaton_state->id);
717 XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs));
720 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
723 MC_ddfs(search_cycle);
731 if(visited(pair_succ->automaton_state)){
733 XBT_DEBUG("Next pair already visited !");
739 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
742 MC_ddfs(search_cycle);
749 if(visited(pair_succ->automaton_state)){
751 XBT_DEBUG("Next pair already visited !");
756 if(((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2))){
758 XBT_DEBUG("Next pair (depth =%d) -> Acceptance pair (%s)", xbt_fifo_size(mc_stack_liveness) + 1, pair_succ->automaton_state->id);
760 set_pair_reached(pair_succ->automaton_state);
764 XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs));
769 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
772 MC_ddfs(search_cycle);
778 /* Restore system before checking others successors */
779 if(cursor != (xbt_dynar_length(successors) - 1))
780 MC_replay_liveness(mc_stack_liveness, 1);
784 if(MC_state_interleave_size(current_pair->graph_state) > 0){
785 XBT_DEBUG("Backtracking to depth %d", xbt_fifo_size(mc_stack_liveness));
786 MC_replay_liveness(mc_stack_liveness, 0);
793 XBT_DEBUG("No more request to execute in this state, search evolution in Büchi Automaton.");
797 /* Create the new expanded graph_state */
798 next_graph_state = MC_state_pair_new();
800 xbt_dynar_reset(successors);
806 xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
808 res = MC_automaton_evaluate_label(transition_succ->label);
810 if(res == 1){ // enabled transition in automaton
812 next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
813 xbt_dynar_push(successors, &next_pair);
821 xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
823 res = MC_automaton_evaluate_label(transition_succ->label);
825 if(res == 2){ // true transition in automaton
827 next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
828 xbt_dynar_push(successors, &next_pair);
836 xbt_dynar_foreach(successors, cursor, pair_succ){
838 if(search_cycle == 1){
840 if((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2)){
842 if(reached(pair_succ->automaton_state)){
844 XBT_INFO("Next pair (depth = %d) already reached !", xbt_fifo_size(mc_stack_liveness) + 1);
846 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
847 XBT_INFO("| ACCEPTANCE CYCLE |");
848 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
849 XBT_INFO("Counter-example that violates formula :");
850 MC_show_stack_liveness(mc_stack_liveness);
851 MC_dump_stack_liveness(mc_stack_liveness);
852 MC_print_statistics_pairs(mc_stats_pair);
857 XBT_INFO("Next pair (depth = %d) -> Acceptance pair (%s)", xbt_fifo_size(mc_stack_liveness) + 1, pair_succ->automaton_state->id);
859 XBT_INFO("Reached pairs : %lu", xbt_dynar_length(reached_pairs));
862 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
865 MC_ddfs(search_cycle);
872 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
875 MC_ddfs(search_cycle);
882 if(((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2))){
884 set_pair_reached(pair_succ->automaton_state);
888 XBT_INFO("Reached pairs : %lu", xbt_dynar_length(reached_pairs));
893 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
896 MC_ddfs(search_cycle);
900 /* Restore system before checking others successors */
901 if(cursor != xbt_dynar_length(successors) - 1)
902 MC_replay_liveness(mc_stack_liveness, 1);
910 XBT_DEBUG("Max depth reached");
914 if(xbt_fifo_size(mc_stack_liveness) == _surf_mc_max_depth ){
915 XBT_DEBUG("Pair (depth = %d) shifted in stack, maximum depth reached", xbt_fifo_size(mc_stack_liveness) );
917 XBT_DEBUG("Pair (depth = %d) shifted in stack", xbt_fifo_size(mc_stack_liveness) );
922 remove_pair = xbt_fifo_shift(mc_stack_liveness);
923 xbt_fifo_remove(mc_stack_liveness, remove_pair);
925 if((current_pair->automaton_state->type == 1) || (current_pair->automaton_state->type == 2)){
926 remove_pair_reached = xbt_dynar_pop_as(reached_pairs, mc_pair_reached_t);
927 pair_reached_free(remove_pair_reached);
928 remove_pair_reached = NULL;