Logo AND Algorithmique Numérique Distribuée

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