Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot//simgrid/simgrid
[simgrid.git] / src / mc / mc_liveness.c
1 /* Copyright (c) 2008-2012 Da SimGrid Team. All rights reserved.            */
2
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. */
5
6 #include "mc_private.h"
7 #include <unistd.h>
8
9 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_liveness, mc,
10                                 "Logging specific to algorithms for liveness properties verification");
11
12 xbt_dynar_t reached_pairs;
13 xbt_dynar_t reached_pairs_hash;
14 xbt_dynar_t visited_pairs;
15 xbt_dynar_t visited_pairs_hash;
16 xbt_dynar_t successors;
17
18 xbt_dynar_t hosts_table;
19
20
21 /* fast implementation of djb2 algorithm */
22 unsigned int hash_region(char *str, int str_len){
23
24   int c;
25   register unsigned int hash = 5381;
26
27   while (str_len--) {
28     c = *str++;
29     hash = ((hash << 5) + hash) + c;    /* hash * 33 + c */
30   }
31
32   return hash;
33
34 }
35
36 const char* get_memory_map_addr(void *addr){
37
38   FILE *fp;                     /* File pointer to process's proc maps file */
39   char *line = NULL;            /* Temporal storage for each line that is readed */
40   ssize_t read;                 /* Number of bytes readed */
41   size_t n = 0;                 /* Amount of bytes to read by getline */
42
43   fp = fopen("/proc/self/maps", "r");
44   
45   if(fp == NULL)
46     perror("fopen failed");
47
48   if(addr == NULL)
49     return "nil";
50
51   char *lfields[6], *start, *end, *endptr;
52   int i;
53   void *start_addr;
54   void *end_addr;
55
56   while ((read = getline(&line, &n, fp)) != -1) {
57
58     line[read - 1] = '\0';
59
60     lfields[0] = strtok(line, " ");
61
62     for (i = 1; i < 6 && lfields[i - 1] != NULL; i++) {
63       lfields[i] = strtok(NULL, " ");
64     }
65
66     start = strtok(lfields[0], "-");
67     start_addr = (void *) strtoul(start, &endptr, 16); 
68    
69     if(start_addr == std_heap)
70       lfields[5] = strdup("std_heap");
71     if(start_addr == raw_heap)
72       lfields[5] = strdup("raw_heap");
73     end = strtok(NULL, "-");
74     end_addr = (void *) strtoul(end, &endptr, 16); 
75    
76     if((addr > start_addr) && ( addr < end_addr)){
77       free(line);
78       fclose(fp);
79       if(lfields[5] != NULL){
80         return lfields[5];
81       }else{
82         return "Anonymous";
83       }
84     }
85     
86   }
87
88   return "Unknown area";
89
90 }
91
92 int data_program_region_compare(void *d1, void *d2, size_t size){
93   int distance = 0;
94   int pointer_align;
95   int i;
96   
97   for(i=0; i<size; i++){
98     if(memcmp(((char *)d1) + i, ((char *)d2) + i, 1) != 0){
99       fprintf(stderr,"Different byte (offset=%d) (%p - %p) in data program region\n", i, (char *)d1 + i, (char *)d2 + i);
100       distance++;
101       pointer_align = (i /sizeof(void *)) * sizeof(void *);
102       fprintf(stderr, "Pointed address : %p (in %s) - %p (in %s)\n", *((void **)((char *)d1 + pointer_align)),  get_memory_map_addr(*((void **)((char *)d1 + pointer_align))), *((void **)((char *)d2 + pointer_align)), get_memory_map_addr(*((void **)((char *)d2 + pointer_align))));
103     }
104   }
105   
106   fprintf(stderr, "Hamming distance between data program regions : %d\n", distance);
107
108   return distance;
109 }
110
111 int data_libsimgrid_region_compare(void *d1, void *d2, size_t size){
112   int distance = 0;
113   int pointer_align;
114   int i;
115   
116   for(i=0; i<size; i++){
117     if(memcmp(((char *)d1) + i, ((char *)d2) + i, 1) != 0){
118       fprintf(stderr, "Different byte (offset=%d) (%p - %p) in data libsimgrid region\n", i, (char *)d1 + i, (char *)d2 + i);
119       distance++;
120       pointer_align = (i /sizeof(void *)) * sizeof(void *);
121       fprintf(stderr, "Pointed address : %p (in %s) - %p (in %s)\n", *((void **)((char *)d1 + pointer_align)), get_memory_map_addr(*((void **)((char *)d1 + pointer_align))), *((void **)((char *)d2 + pointer_align)), get_memory_map_addr(*((void **)((char *)d2 + pointer_align))));
122     }
123   }
124   
125   fprintf(stderr, "Hamming distance between data libsimgrid regions : %d\n", distance);
126   
127   return distance;
128 }
129
130 int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2, void* s_heap, void* r_heap){
131
132   
133   if(s1->num_reg != s2->num_reg){
134     XBT_DEBUG("Different num_reg (s1 = %u, s2 = %u)", s1->num_reg, s2->num_reg);
135     return 1;
136   }
137
138   int i;
139   int errors = 0;
140
141   for(i=0 ; i< s1->num_reg ; i++){
142
143     if(s1->regions[i]->type != s2->regions[i]->type){
144       if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
145         XBT_DEBUG("Different type of region");
146         errors++;
147       }else{
148         return 1;
149       }
150     }
151
152     switch(s1->regions[i]->type){
153       case 0:
154       if(s1->regions[i]->size != s2->regions[i]->size){
155         if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
156           XBT_DEBUG("Different size of heap (s1 = %zu, s2 = %zu)", s1->regions[i]->size, s2->regions[i]->size);
157           errors++;
158         }else{
159           return 1;
160         }
161       }
162       if(s1->regions[i]->start_addr != s2->regions[i]->start_addr){
163         if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
164           XBT_DEBUG("Different start addr of heap (s1 = %p, s2 = %p)", s1->regions[i]->start_addr, s2->regions[i]->start_addr);
165           errors++;
166         }else{
167           return 1;
168         }
169       }
170       if(mmalloc_compare_heap(s1->regions[i]->data, s2->regions[i]->data, s_heap, r_heap)){
171         if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
172           XBT_DEBUG("Different heap (mmalloc_compare)");
173           errors++; 
174         }else{
175           return 1;
176         }
177       }
178       break;
179     case 1 :
180       if(s1->regions[i]->size != s2->regions[i]->size){
181         if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
182           XBT_DEBUG("Different size of libsimgrid (s1 = %zu, s2 = %zu)", s1->regions[i]->size, s2->regions[i]->size);
183           errors++;
184         }else{
185           return 1;
186         }
187       }
188       if(s1->regions[i]->start_addr != s2->regions[i]->start_addr){
189         if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
190           XBT_DEBUG("Different start addr of libsimgrid (s1 = %p, s2 = %p)", s1->regions[i]->start_addr, s2->regions[i]->start_addr);
191           errors++;
192         }else{
193           return 1;
194         }
195       }
196       if(data_program_region_compare(s1->regions[i]->data, s2->regions[i]->data, s1->regions[i]->size) != 0){
197         if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
198           XBT_DEBUG("Different memcmp for data in libsimgrid");
199           errors++;
200         }else{
201           return 1;
202         }
203       }
204       break;
205     case 2 :
206       if(s1->regions[i]->size != s2->regions[i]->size){
207         if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
208           XBT_DEBUG("Different size of data program (s1 = %zu, s2 = %zu)", s1->regions[i]->size, s2->regions[i]->size);
209           errors++;
210         }else{
211           return 1;
212         }
213       }
214       if(s1->regions[i]->start_addr != s2->regions[i]->start_addr){
215         if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
216           XBT_DEBUG("Different start addr of data program (s1 = %p, s2 = %p)", s1->regions[i]->start_addr, s2->regions[i]->start_addr);
217           errors++;
218         }else{
219           return 1;
220         }
221       }
222       if(data_libsimgrid_region_compare(s1->regions[i]->data, s2->regions[i]->data, s1->regions[i]->size) != 0){
223         if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
224           XBT_DEBUG("Different memcmp for data in libsimgrid");
225           errors++;
226         }else{
227           return 1;
228         }
229       }
230       break;
231     default:
232       break;
233     }
234   }
235
236   return (errors > 0);
237   
238 }
239
240 int reached(xbt_state_t st){
241
242
243   if(xbt_dynar_is_empty(reached_pairs)){
244
245     return 0;
246
247   }else{
248
249     MC_SET_RAW_MEM;
250
251     mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
252     MC_take_snapshot_liveness(sn);    
253     
254     xbt_dynar_t prop_ato = xbt_dynar_new(sizeof(int), NULL);
255     int res;
256     int_f_void_t f;
257
258     /* Get values of propositional symbols */
259     unsigned int cursor = 0;
260     xbt_propositional_symbol_t ps = NULL;
261     xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
262       f = (int_f_void_t)ps->function;
263       res = (*f)();
264       xbt_dynar_push_as(prop_ato, int, res);
265     }
266
267     cursor = 0;
268     mc_pair_reached_t pair_test = NULL;
269
270     //xbt_dict_t current_rdv_points = SIMIX_get_rdv_points();
271      
272     xbt_dynar_foreach(reached_pairs, cursor, pair_test){
273       XBT_DEBUG("Pair reached #%u", cursor+1);
274       if(automaton_state_compare(pair_test->automaton_state, st) == 0){
275         if(propositional_symbols_compare_value(pair_test->prop_ato, prop_ato) == 0){
276           //XBT_DEBUG("Rdv points size %d - %d", xbt_dict_length(pair_test->rdv_points), xbt_dict_length(current_rdv_points));
277           //if(xbt_dict_length(pair_test->rdv_points) == xbt_dict_length(current_rdv_points)){
278           //if(rdv_points_compare(pair_test->rdv_points, current_rdv_points) == 0){
279           if(snapshot_compare(pair_test->system_state, sn, std_heap, raw_heap) == 0){
280                 MC_free_snapshot(sn);
281                 xbt_dynar_reset(prop_ato);
282                 xbt_free(prop_ato);
283                 MC_UNSET_RAW_MEM;
284                 return 1;
285               }
286               /* }
287           }else{
288             XBT_DEBUG("Different size of rdv points (%d - %d)",xbt_dict_length(pair_test->rdv_points), xbt_dict_length(current_rdv_points) );
289             }*/
290         }else{
291           XBT_DEBUG("Different values of propositional symbols");
292         }
293       }else{
294         XBT_DEBUG("Different automaton state");
295       }
296     }
297
298     MC_free_snapshot(sn);
299     xbt_dynar_reset(prop_ato);
300     xbt_free(prop_ato);
301     MC_UNSET_RAW_MEM;
302     return 0;
303     
304   }
305 }
306
307 int rdv_points_compare(xbt_dict_t d1, xbt_dict_t d2){ /* d1 = pair_test, d2 = current_pair */ 
308   
309    xbt_dict_cursor_t cursor_dict = NULL;
310    char *key;
311    char *data;
312    smx_rdv_t rdv1, rdv2;
313    xbt_fifo_item_t item1, item2;
314    smx_action_t action1, action2;
315    xbt_fifo_item_t item_req1, item_req2;
316    smx_simcall_t req1, req2;
317    int i=0;
318    int j=0;
319
320    xbt_dict_foreach(d1, cursor_dict, key, data){
321      rdv1 = (smx_rdv_t)data;
322      rdv2 = xbt_dict_get_or_null(d2, rdv1->name);
323      if(rdv2 == NULL){
324        XBT_DEBUG("Rdv point unknown");
325        return 1;
326      }else{
327        if(xbt_fifo_size(rdv1->comm_fifo) != xbt_fifo_size(rdv2->comm_fifo)){
328          XBT_DEBUG("Different total of actions in mailbox \"%s\" (%d - %d)", rdv1->name, xbt_fifo_size(rdv1->comm_fifo),xbt_fifo_size(rdv2->comm_fifo) );
329          return 1;
330        }else{
331          
332          XBT_DEBUG("Total of actions in mailbox \"%s\" : %d", rdv1->name, xbt_fifo_size(rdv1->comm_fifo)); 
333          
334          item1 = xbt_fifo_get_first_item(rdv1->comm_fifo);      
335          item2 = xbt_fifo_get_first_item(rdv2->comm_fifo);
336
337          while(i<xbt_fifo_size(rdv1->comm_fifo)){
338            action1 = (smx_action_t) xbt_fifo_get_item_content(item1);
339            action2 = (smx_action_t) xbt_fifo_get_item_content(item2);
340
341            if(action1->type != action2->type){
342              XBT_DEBUG("Different type of action");
343              return 1;
344            }
345
346            if(action1->state != action2->state){
347              XBT_DEBUG("Different state of action");
348              return 1;
349            }
350
351            if(xbt_fifo_size(action1->simcalls) != xbt_fifo_size(action2->simcalls)){
352              XBT_DEBUG("Different size of simcall list (%d - %d", xbt_fifo_size(action1->simcalls), xbt_fifo_size(action2->simcalls));
353              return 1;
354            }else{
355
356              item_req1 = xbt_fifo_get_first_item(action1->simcalls);    
357              item_req2 = xbt_fifo_get_first_item(action2->simcalls);
358
359              while(j<xbt_fifo_size(action1->simcalls)){
360
361                req1 = (smx_simcall_t) xbt_fifo_get_item_content(item_req1);
362                req2 = (smx_simcall_t) xbt_fifo_get_item_content(item_req2);
363                
364                if(req1->call != req2->call){
365                  XBT_DEBUG("Different simcall call in simcalls of action (%d - %d)", (int)req1->call, (int)req2->call);
366                  return 1;
367                }
368                if(req1->issuer->pid != req2->issuer->pid){
369                  XBT_DEBUG("Different simcall issuer in simcalls of action (%lu- %lu)", req1->issuer->pid, req2->issuer->pid);
370                  return 1;
371                }
372
373                item_req1 = xbt_fifo_get_next_item(item_req1);   
374                item_req2 = xbt_fifo_get_next_item(item_req2);
375                j++;
376                
377              }
378            }
379
380            switch(action1->type){
381            case 0: /* execution */
382            case 1: /* parallel execution */
383              if(strcmp(action1->execution.host->name, action2->execution.host->name) != 0)
384                return 1;
385              break;
386            case 2: /* comm */
387              if(action1->comm.type != action2->comm.type)
388                return 1;
389              //XBT_DEBUG("Type of comm : %d", action1->comm.type);
390              
391              switch(action1->comm.type){
392              case 0: /* SEND */
393                if(action1->comm.src_proc->pid != action2->comm.src_proc->pid)
394                  return 1;
395                if(strcmp(action1->comm.src_proc->smx_host->name, action2->comm.src_proc->smx_host->name) != 0)
396                  return 1;
397                break;
398              case 1: /* RECEIVE */
399                if(action1->comm.dst_proc->pid != action2->comm.dst_proc->pid)
400                  return 1;
401                if(strcmp(action1->comm.dst_proc->smx_host->name, action2->comm.dst_proc->smx_host->name) != 0)
402                  return 1;
403                break;
404              case 2: /* READY */
405                if(action1->comm.src_proc->pid != action2->comm.src_proc->pid)
406                  return 1;
407                if(strcmp(action1->comm.src_proc->smx_host->name, action2->comm.src_proc->smx_host->name) != 0)
408                  return 1;
409                if(action1->comm.dst_proc->pid != action2->comm.dst_proc->pid)
410                  return 1;
411                if(strcmp(action1->comm.dst_proc->smx_host->name, action2->comm.dst_proc->smx_host->name) != 0)
412                  return 1;
413                break;
414              case 3: /* DONE */
415                if(action1->comm.src_proc->pid != action2->comm.src_proc->pid)
416                  return 1;
417                if(strcmp(action1->comm.src_proc->smx_host->name, action2->comm.src_proc->smx_host->name) != 0)
418                  return 1;
419                if(action1->comm.dst_proc->pid != action2->comm.dst_proc->pid)
420                  return 1;
421                if(strcmp(action1->comm.dst_proc->smx_host->name, action2->comm.dst_proc->smx_host->name) != 0)
422                  return 1;
423                break;
424                
425              } /* end of switch on type of comm */
426              
427              if(action1->comm.refcount != action2->comm.refcount)
428                return 1;
429              if(action1->comm.detached != action2->comm.detached)
430                return 1;
431              if(action1->comm.rate != action2->comm.rate)
432                return 1;
433              if(action1->comm.task_size != action2->comm.task_size)
434                return 1;
435              if(action1->comm.src_buff != action2->comm.src_buff)
436                return 1;
437              if(action1->comm.dst_buff != action2->comm.dst_buff)
438                return 1;
439              if(action1->comm.src_data != action2->comm.src_data)
440                return 1;
441              if(action1->comm.dst_data != action2->comm.dst_data)
442                return 1;
443              
444              break;
445            case 3: /* sleep */
446              if(strcmp(action1->sleep.host->name, action2->sleep.host->name) != 0)
447                return 1;
448              break;
449            case 4: /* synchro */
450              
451              break;
452            default:
453              break;
454            }
455
456            item1 = xbt_fifo_get_next_item(item1);       
457            item2 = xbt_fifo_get_next_item(item2);
458            i++;
459          }
460        }
461      }
462    }
463
464    return 0;
465    
466 }
467
468 void set_pair_reached(xbt_state_t st){
469
470  
471   MC_SET_RAW_MEM;
472   
473   mc_pair_reached_t pair = NULL;
474   pair = xbt_new0(s_mc_pair_reached_t, 1);
475   pair->automaton_state = st;
476   pair->prop_ato = xbt_dynar_new(sizeof(int), NULL);
477   pair->system_state = xbt_new0(s_mc_snapshot_t, 1);
478   //pair->rdv_points = xbt_dict_new();  
479   MC_take_snapshot_liveness(pair->system_state);
480
481   /* Get values of propositional symbols */
482   unsigned int cursor = 0;
483   xbt_propositional_symbol_t ps = NULL;
484   int res;
485   int_f_void_t f;
486
487   xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
488     f = (int_f_void_t)ps->function;
489     res = (*f)();
490     xbt_dynar_push_as(pair->prop_ato, int, res);
491   }
492
493   /*xbt_dict_t rdv_points = SIMIX_get_rdv_points();
494
495   xbt_dict_cursor_t cursor_dict = NULL;
496   char *key;
497   char *data;
498   xbt_fifo_item_t item;
499   smx_action_t action;
500
501   xbt_dict_foreach(rdv_points, cursor_dict, key, data){
502     smx_rdv_t new_rdv = xbt_new0(s_smx_rvpoint_t, 1);
503     new_rdv->name = strdup(((smx_rdv_t)data)->name);
504     new_rdv->comm_fifo = xbt_fifo_new();
505     xbt_fifo_foreach(((smx_rdv_t)data)->comm_fifo, item, action, smx_action_t) {
506       smx_action_t a = xbt_new0(s_smx_action_t, 1);
507       memcpy(a, action, sizeof(s_smx_action_t));
508       xbt_fifo_push(new_rdv->comm_fifo, a);
509       XBT_DEBUG("New action (type = %d, state = %d) in mailbox \"%s\"", action->type, action->state, key);
510       if(action->type==2)
511         XBT_DEBUG("Type of communication : %d, Ref count = %d", action->comm.type, action->comm.refcount);
512     }
513     //new_rdv->comm_fifo = xbt_fifo_copy(((smx_rdv_t)data)->comm_fifo);
514     xbt_dict_set(pair->rdv_points, new_rdv->name, new_rdv, NULL);
515     }*/
516  
517   xbt_dynar_push(reached_pairs, &pair); 
518
519   MC_UNSET_RAW_MEM;
520   
521 }
522
523
524 int reached_hash(xbt_state_t st){
525
526
527   if(xbt_dynar_is_empty(reached_pairs_hash)){
528
529     return 0;
530
531   }else{
532
533     MC_SET_RAW_MEM;
534
535     mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
536     MC_take_snapshot_liveness(sn);
537
538     int j;
539     unsigned int hash_regions[sn->num_reg];
540     for(j=0; j<sn->num_reg; j++){
541       hash_regions[j] = hash_region(sn->regions[j]->data, sn->regions[j]->size);
542     }
543
544
545     /* Get values of propositional symbols */
546     xbt_dynar_t prop_ato = xbt_dynar_new(sizeof(int), NULL);
547     unsigned int cursor = 0;
548     xbt_propositional_symbol_t ps = NULL;
549     int res;
550     int_f_void_t f;
551
552     xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
553       f = (int_f_void_t)ps->function;
554       res = (*f)();
555       xbt_dynar_push_as(prop_ato, int, res);
556     }
557
558     mc_pair_reached_hash_t pair_test = NULL;
559
560     int region_diff = 0;
561
562     cursor = 0;
563
564     xbt_dynar_foreach(reached_pairs_hash, cursor, pair_test){
565
566       if(automaton_state_compare(pair_test->automaton_state, st) == 0){
567         if(propositional_symbols_compare_value(pair_test->prop_ato, prop_ato) == 0){
568           for(j=0 ; j< sn->num_reg ; j++){
569             if(hash_regions[j] != pair_test->hash_regions[j]){
570               region_diff++;
571             }
572           }
573           if(region_diff == 0){
574             MC_free_snapshot(sn);
575             xbt_dynar_reset(prop_ato);
576             xbt_free(prop_ato);
577             MC_UNSET_RAW_MEM;
578             return 1;
579           }else{
580             XBT_DEBUG("Different snapshot");
581           }
582         }else{
583           XBT_DEBUG("Different values of propositional symbols");
584         }
585       }else{
586         XBT_DEBUG("Different automaton state");
587       }
588
589       region_diff = 0;
590     }
591     
592     MC_free_snapshot(sn);
593     xbt_dynar_reset(prop_ato);
594     xbt_free(prop_ato);
595     MC_UNSET_RAW_MEM;
596     return 0;
597     
598   }
599 }
600
601 void set_pair_reached_hash(xbt_state_t st){
602  
603   MC_SET_RAW_MEM;
604
605   mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
606   MC_take_snapshot_liveness(sn);
607  
608   mc_pair_reached_hash_t pair = NULL;
609   pair = xbt_new0(s_mc_pair_reached_hash_t, 1);
610   pair->automaton_state = st;
611   pair->prop_ato = xbt_dynar_new(sizeof(int), NULL);
612   pair->hash_regions = malloc(sizeof(unsigned int) * sn->num_reg);
613   
614   int i;
615
616   for(i=0 ; i< sn->num_reg ; i++){
617     pair->hash_regions[i] = hash_region(sn->regions[i]->data, sn->regions[i]->size);
618   }
619   
620   /* Get values of propositional symbols */
621   unsigned int cursor = 0;
622   xbt_propositional_symbol_t ps = NULL;
623   int res;
624   int_f_void_t f;
625
626   xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
627     f = (int_f_void_t)ps->function;
628     res = (*f)();
629     xbt_dynar_push_as(pair->prop_ato, int, res);
630   }
631   
632   xbt_dynar_push(reached_pairs_hash, &pair);
633
634   MC_free_snapshot(sn);
635   
636   MC_UNSET_RAW_MEM;
637     
638 }
639
640
641 int visited(xbt_state_t st, int sc){
642
643
644   if(xbt_dynar_is_empty(visited_pairs)){
645
646     return 0;
647
648   }else{
649
650     MC_SET_RAW_MEM;
651
652     mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
653     MC_take_snapshot_liveness(sn);
654
655     xbt_dynar_t prop_ato = xbt_dynar_new(sizeof(int), NULL);
656
657     /* Get values of propositional symbols */
658     unsigned int cursor = 0;
659     xbt_propositional_symbol_t ps = NULL;
660     int res;
661     int_f_void_t f;
662
663     xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
664       f = (int_f_void_t)ps->function;
665       res = (*f)();
666       xbt_dynar_push_as(prop_ato, int, res);
667     }
668
669     cursor = 0;
670     mc_pair_visited_t pair_test = NULL;
671
672     xbt_dynar_foreach(visited_pairs, cursor, pair_test){
673       if(pair_test->search_cycle == sc) {
674         if(automaton_state_compare(pair_test->automaton_state, st) == 0){
675           if(propositional_symbols_compare_value(pair_test->prop_ato, prop_ato) == 0){
676             if(snapshot_compare(pair_test->system_state, sn, std_heap, raw_heap) == 0){
677             
678               MC_free_snapshot(sn);
679               xbt_dynar_reset(prop_ato);
680               xbt_free(prop_ato);
681               MC_UNSET_RAW_MEM;
682                 
683               return 1;
684         
685             }else{
686               XBT_DEBUG("Different snapshot");
687             }
688           }else{
689             XBT_DEBUG("Different values of propositional symbols"); 
690           }
691         }else{
692           XBT_DEBUG("Different automaton state");
693         }
694       }else{
695         XBT_DEBUG("Different value of search_cycle");
696       }
697     }
698
699
700     MC_free_snapshot(sn);
701     xbt_dynar_reset(prop_ato);
702     xbt_free(prop_ato);
703     MC_UNSET_RAW_MEM;
704     return 0;
705     
706   }
707 }
708
709
710 int visited_hash(xbt_state_t st, int sc){
711
712
713   if(xbt_dynar_is_empty(visited_pairs_hash)){
714
715     return 0;
716
717   }else{
718
719     MC_SET_RAW_MEM;
720
721     mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
722     MC_take_snapshot_liveness(sn);
723
724     int j;
725     unsigned int hash_regions[sn->num_reg];
726     for(j=0; j<sn->num_reg; j++){
727       hash_regions[j] = hash_region(sn->regions[j]->data, sn->regions[j]->size);
728     }
729
730     
731     /* Get values of propositional symbols */
732     xbt_dynar_t prop_ato = xbt_dynar_new(sizeof(int), NULL);
733     unsigned int cursor = 0;
734     xbt_propositional_symbol_t ps = NULL;
735     int res;
736     int_f_void_t f;
737
738     xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
739       f = (int_f_void_t)ps->function;
740       res = (*f)();
741       xbt_dynar_push_as(prop_ato, int, res);
742     }
743
744     mc_pair_visited_hash_t pair_test = NULL;
745
746     int region_diff = 0;
747     cursor = 0;
748
749     xbt_dynar_foreach(visited_pairs_hash, cursor, pair_test){
750   
751       if(pair_test->search_cycle == sc) {
752         if(automaton_state_compare(pair_test->automaton_state, st) == 0){
753           if(propositional_symbols_compare_value(pair_test->prop_ato, prop_ato) == 0){
754             for(j=0 ; j< sn->num_reg ; j++){
755               if(hash_regions[j] != pair_test->hash_regions[j]){
756                 region_diff++;
757               }
758             }
759             if(region_diff == 0){
760               MC_free_snapshot(sn);
761               xbt_dynar_reset(prop_ato);
762               xbt_free(prop_ato);
763               MC_UNSET_RAW_MEM;
764               return 1;
765             }else{
766               //XBT_DEBUG("Different snapshot");
767             }
768           }else{
769             //XBT_DEBUG("Different values of propositional symbols"); 
770           }
771         }else{
772           //XBT_DEBUG("Different automaton state");
773         }
774       }else{
775         //XBT_DEBUG("Different value of search_cycle");
776       }
777       
778       region_diff = 0;
779     }
780     
781     MC_free_snapshot(sn);
782     xbt_dynar_reset(prop_ato);
783     xbt_free(prop_ato);
784     MC_UNSET_RAW_MEM;
785     return 0;
786     
787   }
788 }
789
790 void set_pair_visited_hash(xbt_state_t st, int sc){
791  
792   MC_SET_RAW_MEM;
793
794   mc_snapshot_t sn = xbt_new0(s_mc_snapshot_t, 1);
795   MC_take_snapshot_liveness(sn);
796  
797   mc_pair_visited_hash_t pair = NULL;
798   pair = xbt_new0(s_mc_pair_visited_hash_t, 1);
799   pair->automaton_state = st;
800   pair->prop_ato = xbt_dynar_new(sizeof(int), NULL);
801   pair->search_cycle = sc;
802   pair->hash_regions = malloc(sizeof(unsigned int) * sn->num_reg);
803   
804   int i;
805
806   for(i=0 ; i< sn->num_reg ; i++){
807     pair->hash_regions[i] = hash_region(sn->regions[i]->data, sn->regions[i]->size);
808   }
809   
810   /* Get values of propositional symbols */
811   unsigned int cursor = 0;
812   xbt_propositional_symbol_t ps = NULL;
813   int res;
814   int_f_void_t f;
815
816   xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
817     f = (int_f_void_t)ps->function;
818     res = (*f)();
819     xbt_dynar_push_as(pair->prop_ato, int, res);
820   }
821   
822   xbt_dynar_push(visited_pairs_hash, &pair);
823
824   MC_free_snapshot(sn);
825   
826   MC_UNSET_RAW_MEM;
827     
828 }
829
830 void set_pair_visited(xbt_state_t st, int sc){
831
832  
833   MC_SET_RAW_MEM;
834  
835   mc_pair_visited_t pair = NULL;
836   pair = xbt_new0(s_mc_pair_visited_t, 1);
837   pair->automaton_state = st;
838   pair->prop_ato = xbt_dynar_new(sizeof(int), NULL);
839   pair->search_cycle = sc;
840   pair->system_state = xbt_new0(s_mc_snapshot_t, 1);
841   MC_take_snapshot_liveness(pair->system_state);
842
843
844   /* Get values of propositional symbols */
845   unsigned int cursor = 0;
846   xbt_propositional_symbol_t ps = NULL;
847   int res;
848   int_f_void_t f;
849
850   xbt_dynar_foreach(automaton->propositional_symbols, cursor, ps){
851     f = (int_f_void_t)ps->function;
852     res = (*f)();
853     xbt_dynar_push_as(pair->prop_ato, int, res);
854   }
855   
856   xbt_dynar_push(visited_pairs, &pair);
857   
858   MC_UNSET_RAW_MEM;
859   
860   
861 }
862
863 void MC_pair_delete(mc_pair_t pair){
864   xbt_free(pair->graph_state->proc_status);
865   xbt_free(pair->graph_state);
866   xbt_free(pair);
867 }
868
869
870
871 int MC_automaton_evaluate_label(xbt_exp_label_t l){
872   
873   switch(l->type){
874   case 0 : {
875     int left_res = MC_automaton_evaluate_label(l->u.or_and.left_exp);
876     int right_res = MC_automaton_evaluate_label(l->u.or_and.right_exp);
877     return (left_res || right_res);
878   }
879   case 1 : {
880     int left_res = MC_automaton_evaluate_label(l->u.or_and.left_exp);
881     int right_res = MC_automaton_evaluate_label(l->u.or_and.right_exp);
882     return (left_res && right_res);
883   }
884   case 2 : {
885     int res = MC_automaton_evaluate_label(l->u.exp_not);
886     return (!res);
887   }
888   case 3 : { 
889     unsigned int cursor = 0;
890     xbt_propositional_symbol_t p = NULL;
891     int_f_void_t f;
892     xbt_dynar_foreach(automaton->propositional_symbols, cursor, p){
893       if(strcmp(p->pred, l->u.predicat) == 0){
894         f = (int_f_void_t)p->function;
895         return (*f)();
896       }
897     }
898     return -1;
899   }
900   case 4 : {
901     return 2;
902   }
903   default : 
904     return -1;
905   }
906 }
907
908
909 /********************* Double-DFS stateless *******************/
910
911 void MC_pair_stateless_delete(mc_pair_stateless_t pair){
912   xbt_free(pair->graph_state->proc_status);
913   xbt_free(pair->graph_state);
914   xbt_free(pair);
915 }
916
917 mc_pair_stateless_t new_pair_stateless(mc_state_t sg, xbt_state_t st, int r){
918   mc_pair_stateless_t p = NULL;
919   p = xbt_new0(s_mc_pair_stateless_t, 1);
920   p->automaton_state = st;
921   p->graph_state = sg;
922   p->requests = r;
923   mc_stats_pair->expanded_pairs++;
924   return p;
925 }
926
927 void MC_ddfs_init(void){
928
929   XBT_DEBUG("**************************************************");
930   XBT_DEBUG("Double-DFS init");
931   XBT_DEBUG("**************************************************");
932
933   XBT_DEBUG("Std heap : %p", std_heap);
934   XBT_DEBUG("Raw heap : %p", raw_heap);
935
936   mc_pair_stateless_t mc_initial_pair = NULL;
937   mc_state_t initial_graph_state = NULL;
938   smx_process_t process; 
939
940  
941   MC_wait_for_requests();
942
943   MC_SET_RAW_MEM;
944
945   initial_graph_state = MC_state_pair_new();
946   xbt_swag_foreach(process, simix_global->process_list){
947     if(MC_process_is_enabled(process)){
948       MC_state_interleave_process(initial_graph_state, process);
949     }
950   }
951
952   reached_pairs = xbt_dynar_new(sizeof(mc_pair_reached_t), NULL);
953   //reached_pairs_hash = xbt_dynar_new(sizeof(mc_pair_reached_hash_t), NULL);
954   //visited_pairs = xbt_dynar_new(sizeof(mc_pair_visited_t), NULL);
955   visited_pairs_hash = xbt_dynar_new(sizeof(mc_pair_visited_hash_t), NULL);
956   successors = xbt_dynar_new(sizeof(mc_pair_stateless_t), NULL);
957
958   /* Save the initial state */
959   initial_snapshot_liveness = xbt_new0(s_mc_snapshot_t, 1);
960   MC_take_snapshot_liveness(initial_snapshot_liveness);
961
962   MC_UNSET_RAW_MEM; 
963
964   unsigned int cursor = 0;
965   xbt_state_t state;
966
967   xbt_dynar_foreach(automaton->states, cursor, state){
968     if(state->type == -1){
969       
970       MC_SET_RAW_MEM;
971       mc_initial_pair = new_pair_stateless(initial_graph_state, state, MC_state_interleave_size(initial_graph_state));
972       xbt_fifo_unshift(mc_stack_liveness, mc_initial_pair);
973       MC_UNSET_RAW_MEM;
974       
975       if(cursor != 0){
976         MC_restore_snapshot(initial_snapshot_liveness);
977         MC_UNSET_RAW_MEM;
978       }
979
980       MC_ddfs(0);
981
982     }else{
983       if(state->type == 2){
984       
985         MC_SET_RAW_MEM;
986         mc_initial_pair = new_pair_stateless(initial_graph_state, state, MC_state_interleave_size(initial_graph_state));
987         xbt_fifo_unshift(mc_stack_liveness, mc_initial_pair);
988         MC_UNSET_RAW_MEM;
989
990         set_pair_reached(state);
991         //set_pair_reached_hash(state);
992
993         if(cursor != 0){
994           MC_restore_snapshot(initial_snapshot_liveness);
995           MC_UNSET_RAW_MEM;
996         }
997         
998         MC_ddfs(1);
999         
1000       }
1001     }
1002   } 
1003
1004 }
1005
1006
1007 void MC_ddfs(int search_cycle){
1008
1009   smx_process_t process;
1010   mc_pair_stateless_t current_pair = NULL;
1011
1012   if(xbt_fifo_size(mc_stack_liveness) == 0)
1013     return;
1014
1015
1016   /* Get current pair */
1017   current_pair = (mc_pair_stateless_t)xbt_fifo_get_item_content(xbt_fifo_get_first_item(mc_stack_liveness));
1018
1019   /* Update current state in buchi automaton */
1020   automaton->current_state = current_pair->automaton_state;
1021
1022  
1023   XBT_DEBUG("********************* ( Depth = %d, search_cycle = %d )", xbt_fifo_size(mc_stack_liveness), search_cycle);
1024   XBT_DEBUG("Pair : graph=%p, automaton=%p(%s), %u interleave", current_pair->graph_state, current_pair->automaton_state, current_pair->automaton_state->id, MC_state_interleave_size(current_pair->graph_state));
1025  
1026   mc_stats_pair->visited_pairs++;
1027
1028   //sleep(1);
1029
1030   int value;
1031   mc_state_t next_graph_state = NULL;
1032   smx_simcall_t req = NULL;
1033   char *req_str;
1034
1035   xbt_transition_t transition_succ;
1036   unsigned int cursor = 0;
1037   int res;
1038
1039   mc_pair_stateless_t next_pair = NULL;
1040   mc_pair_stateless_t pair_succ;
1041
1042   if(xbt_fifo_size(mc_stack_liveness) < MAX_DEPTH_LIVENESS){
1043
1044     //set_pair_visited(current_pair->automaton_state, search_cycle);
1045     set_pair_visited_hash(current_pair->automaton_state, search_cycle);
1046
1047     //XBT_DEBUG("Visited pairs : %lu", xbt_dynar_length(visited_pairs));
1048     XBT_DEBUG("Visited pairs : %lu", xbt_dynar_length(visited_pairs_hash));
1049
1050     if(current_pair->requests > 0){
1051
1052       while((req = MC_state_get_request(current_pair->graph_state, &value)) != NULL){
1053    
1054         /* Debug information */
1055         if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
1056           req_str = MC_request_to_string(req, value);
1057           XBT_DEBUG("Execute: %s", req_str);
1058           xbt_free(req_str);
1059         }
1060
1061         MC_state_set_executed_request(current_pair->graph_state, req, value);   
1062     
1063         /* Answer the request */
1064         SIMIX_simcall_pre(req, value);
1065
1066         /* Wait for requests (schedules processes) */
1067         MC_wait_for_requests();
1068
1069
1070         MC_SET_RAW_MEM;
1071
1072         /* Create the new expanded graph_state */
1073         next_graph_state = MC_state_pair_new();
1074
1075         /* Get enabled process and insert it in the interleave set of the next graph_state */
1076         xbt_swag_foreach(process, simix_global->process_list){
1077           if(MC_process_is_enabled(process)){
1078             MC_state_interleave_process(next_graph_state, process);
1079           }
1080         }
1081
1082         xbt_dynar_reset(successors);
1083
1084         MC_UNSET_RAW_MEM;
1085
1086
1087         cursor= 0;
1088         xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
1089
1090           res = MC_automaton_evaluate_label(transition_succ->label);
1091
1092           if(res == 1){ // enabled transition in automaton
1093             MC_SET_RAW_MEM;
1094             next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
1095             xbt_dynar_push(successors, &next_pair);
1096             MC_UNSET_RAW_MEM;
1097           }
1098
1099         }
1100
1101         cursor = 0;
1102    
1103         xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
1104       
1105           res = MC_automaton_evaluate_label(transition_succ->label);
1106         
1107           if(res == 2){ // true transition in automaton
1108             MC_SET_RAW_MEM;
1109             next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
1110             xbt_dynar_push(successors, &next_pair);
1111             MC_UNSET_RAW_MEM;
1112           }
1113
1114         }
1115
1116         cursor = 0; 
1117         
1118         xbt_dynar_foreach(successors, cursor, pair_succ){
1119
1120           if(search_cycle == 1){
1121
1122             if((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2)){ 
1123                       
1124               if(reached(pair_succ->automaton_state)){
1125                 //if(reached_hash(pair_succ->automaton_state)){
1126               
1127                 XBT_DEBUG("Next pair (depth = %d, %u interleave) already reached !", xbt_fifo_size(mc_stack_liveness) + 1, MC_state_interleave_size(pair_succ->graph_state));
1128
1129                 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
1130                 XBT_INFO("|             ACCEPTANCE CYCLE            |");
1131                 XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
1132                 XBT_INFO("Counter-example that violates formula :");
1133                 MC_show_stack_liveness(mc_stack_liveness);
1134                 MC_dump_stack_liveness(mc_stack_liveness);
1135                 MC_print_statistics_pairs(mc_stats_pair);
1136                 exit(0);
1137
1138               }else{
1139
1140                 XBT_DEBUG("Next pair (depth =%d) -> Acceptance pair : graph=%p, automaton=%p(%s)", xbt_fifo_size(mc_stack_liveness) + 1, pair_succ->graph_state, pair_succ->automaton_state, pair_succ->automaton_state->id);
1141               
1142                 set_pair_reached(pair_succ->automaton_state);
1143                 //set_pair_reached_hash(pair_succ->automaton_state);
1144
1145                 XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs));
1146                 //XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs_hash));
1147
1148                 MC_SET_RAW_MEM;
1149                 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
1150                 MC_UNSET_RAW_MEM;
1151                 
1152                 MC_ddfs(search_cycle);
1153
1154               }
1155
1156             }else{
1157
1158               if(!visited_hash(pair_succ->automaton_state, search_cycle)){
1159                 //if(!visited(pair_succ->automaton_state, search_cycle)){
1160                 
1161                 MC_SET_RAW_MEM;
1162                 xbt_fifo_unshift(mc_stack_liveness, pair_succ);
1163                 MC_UNSET_RAW_MEM;
1164                 
1165                 MC_ddfs(search_cycle);
1166                 
1167               }else{
1168
1169                 XBT_DEBUG("Next pair already visited ! ");
1170
1171               }
1172               
1173             }
1174
1175           }else{
1176           
1177             if(((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2))){
1178
1179               XBT_DEBUG("Next pair (depth =%d) -> Acceptance pair : graph=%p, automaton=%p(%s)", xbt_fifo_size(mc_stack_liveness) + 1, pair_succ->graph_state, pair_succ->automaton_state, pair_succ->automaton_state->id);
1180             
1181               set_pair_reached(pair_succ->automaton_state); 
1182               //set_pair_reached_hash(pair_succ->automaton_state);
1183
1184               search_cycle = 1;
1185
1186               XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs));
1187               //XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs_hash));
1188
1189             }
1190
1191             if(!visited_hash(pair_succ->automaton_state, search_cycle)){
1192               //if(!visited(pair_succ->automaton_state, search_cycle)){
1193               
1194               MC_SET_RAW_MEM;
1195               xbt_fifo_unshift(mc_stack_liveness, pair_succ);
1196               MC_UNSET_RAW_MEM;
1197               
1198               MC_ddfs(search_cycle);
1199               
1200             }else{
1201
1202               XBT_DEBUG("Next pair already visited ! ");
1203
1204             }
1205
1206           }
1207
1208          
1209           /* Restore system before checking others successors */
1210           if(cursor != (xbt_dynar_length(successors) - 1))
1211             MC_replay_liveness(mc_stack_liveness, 1);
1212         
1213           
1214         }
1215
1216         if(MC_state_interleave_size(current_pair->graph_state) > 0){
1217           XBT_DEBUG("Backtracking to depth %d", xbt_fifo_size(mc_stack_liveness));
1218           MC_replay_liveness(mc_stack_liveness, 0);
1219         }
1220       }
1221
1222  
1223     }else{  /*No request to execute, search evolution in Büchi automaton */
1224
1225       MC_SET_RAW_MEM;
1226
1227       /* Create the new expanded graph_state */
1228       next_graph_state = MC_state_pair_new();
1229
1230       xbt_dynar_reset(successors);
1231
1232       MC_UNSET_RAW_MEM;
1233
1234
1235       cursor= 0;
1236       xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
1237
1238         res = MC_automaton_evaluate_label(transition_succ->label);
1239
1240         if(res == 1){ // enabled transition in automaton
1241           MC_SET_RAW_MEM;
1242           next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
1243           xbt_dynar_push(successors, &next_pair);
1244           MC_UNSET_RAW_MEM;
1245         }
1246
1247       }
1248
1249       cursor = 0;
1250    
1251       xbt_dynar_foreach(current_pair->automaton_state->out, cursor, transition_succ){
1252       
1253         res = MC_automaton_evaluate_label(transition_succ->label);
1254         
1255         if(res == 2){ // true transition in automaton
1256           MC_SET_RAW_MEM;
1257           next_pair = new_pair_stateless(next_graph_state, transition_succ->dst, MC_state_interleave_size(next_graph_state));
1258           xbt_dynar_push(successors, &next_pair);
1259           MC_UNSET_RAW_MEM;
1260         }
1261
1262       }
1263
1264       cursor = 0; 
1265      
1266       xbt_dynar_foreach(successors, cursor, pair_succ){
1267
1268         if(search_cycle == 1){
1269
1270           if((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2)){ 
1271
1272             if(reached(pair_succ->automaton_state)){
1273               //if(reached_hash(pair_succ->automaton_state)){
1274
1275               XBT_DEBUG("Next pair (depth = %d) already reached !", xbt_fifo_size(mc_stack_liveness) + 1);
1276
1277               XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
1278               XBT_INFO("|             ACCEPTANCE CYCLE            |");
1279               XBT_INFO("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
1280               XBT_INFO("Counter-example that violates formula :");
1281               MC_show_stack_liveness(mc_stack_liveness);
1282               MC_dump_stack_liveness(mc_stack_liveness);
1283               MC_print_statistics_pairs(mc_stats_pair);
1284               exit(0);
1285
1286             }else{
1287
1288               XBT_DEBUG("Next pair (depth = %d) -> Acceptance pair : graph=%p, automaton=%p(%s)", xbt_fifo_size(mc_stack_liveness) + 1, pair_succ->graph_state, pair_succ->automaton_state, pair_succ->automaton_state->id);
1289               
1290               set_pair_reached(pair_succ->automaton_state);
1291               //set_pair_reached_hash(pair_succ->automaton_state);
1292                 
1293               XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs));
1294               //XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs_hash));
1295
1296               MC_SET_RAW_MEM;
1297               xbt_fifo_unshift(mc_stack_liveness, pair_succ);
1298               MC_UNSET_RAW_MEM;
1299               
1300               MC_ddfs(search_cycle);
1301
1302             }
1303
1304           }else{
1305
1306             if(!visited_hash(pair_succ->automaton_state, search_cycle)){
1307               //if(!visited(pair_succ->automaton_state, search_cycle)){
1308
1309               MC_SET_RAW_MEM;
1310               xbt_fifo_unshift(mc_stack_liveness, pair_succ);
1311               MC_UNSET_RAW_MEM;
1312               
1313               MC_ddfs(search_cycle);
1314               
1315             }else{
1316
1317               XBT_DEBUG("Next pair already visited ! ");
1318
1319             }
1320           }
1321             
1322
1323         }else{
1324             
1325           if(((pair_succ->automaton_state->type == 1) || (pair_succ->automaton_state->type == 2))){
1326
1327             set_pair_reached(pair_succ->automaton_state);
1328             //set_pair_reached_hash(pair_succ->automaton_state);
1329                     
1330             search_cycle = 1;
1331
1332             XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs));
1333             //XBT_DEBUG("Reached pairs : %lu", xbt_dynar_length(reached_pairs_hash));
1334
1335           }
1336
1337           if(!visited_hash(pair_succ->automaton_state, search_cycle)){
1338             //if(!visited(pair_succ->automaton_state, search_cycle)){
1339
1340             MC_SET_RAW_MEM;
1341             xbt_fifo_unshift(mc_stack_liveness, pair_succ);
1342             MC_UNSET_RAW_MEM;
1343             
1344             MC_ddfs(search_cycle);
1345             
1346           }else{
1347
1348             XBT_DEBUG("Next pair already visited ! ");
1349
1350           }
1351
1352         }
1353
1354         /* Restore system before checking others successors */
1355         if(cursor != xbt_dynar_length(successors) - 1)
1356           MC_replay_liveness(mc_stack_liveness, 1);
1357
1358          
1359       }
1360            
1361     }
1362     
1363   }else{
1364     
1365     XBT_DEBUG("Max depth reached");
1366
1367   }
1368
1369   if(xbt_fifo_size(mc_stack_liveness) == MAX_DEPTH_LIVENESS ){
1370     XBT_DEBUG("Pair (graph=%p, automaton =%p, search_cycle = %d, depth = %d) shifted in stack, maximum depth reached", current_pair->graph_state, current_pair->automaton_state, search_cycle, xbt_fifo_size(mc_stack_liveness) );
1371   }else{
1372     XBT_DEBUG("Pair (graph=%p, automaton =%p, search_cycle = %d, depth = %d) shifted in stack", current_pair->graph_state, current_pair->automaton_state, search_cycle, xbt_fifo_size(mc_stack_liveness) );
1373   }
1374
1375   
1376   MC_SET_RAW_MEM;
1377   xbt_fifo_shift(mc_stack_liveness);
1378   if((current_pair->automaton_state->type == 1) || (current_pair->automaton_state->type == 2)){
1379     xbt_dynar_pop(reached_pairs, NULL);
1380     //xbt_dynar_pop(reached_pairs_hash, NULL);
1381   }
1382   MC_UNSET_RAW_MEM;
1383   
1384   
1385
1386 }