Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
1ec78d3a59e2996354faced5fa3ac5c7077e9d35
[simgrid.git] / src / mc / mc_compare.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
8 #include "xbt/mmalloc.h"
9
10 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_compare, mc,
11                                 "Logging specific to mc_compare");
12
13 static int heap_region_compare(void *d1, void *d2, size_t size);
14
15 static int compare_stack(stack_region_t s1, stack_region_t s2, void *sp1, void *sp2, void *heap1, void *heap2, xbt_dynar_t equals);
16 static int is_heap_equality(xbt_dynar_t equals, void *a1, void *a2);
17 static size_t heap_ignore_size(void *address);
18
19 static void stack_region_free(stack_region_t s);
20 static void heap_equality_free(heap_equality_t e);
21
22 static int is_stack_ignore_variable(char *frame, char *var_name);
23 static int compare_local_variables(char *s1, char *s2, xbt_dynar_t heap_equals);
24
25 static size_t heap_ignore_size(void *address){
26   unsigned int cursor = 0;
27   int start = 0;
28   int end = xbt_dynar_length(mc_heap_comparison_ignore) - 1;
29   mc_heap_ignore_region_t region;
30
31   while(start <= end){
32     cursor = (start + end) / 2;
33     region = (mc_heap_ignore_region_t)xbt_dynar_get_as(mc_heap_comparison_ignore, cursor, mc_heap_ignore_region_t);
34     if(region->address == address)
35       return region->size;
36     if(region->address < address)
37       start = cursor + 1;
38     if(region->address > address)
39       end = cursor - 1;   
40   }
41
42   return 0;
43 }
44
45 static int compare_global_variables(int region_type, void *d1, void *d2){
46
47   unsigned int cursor = 0;
48   size_t offset; 
49   int i = 0;
50   global_variable_t current_var; 
51   int pointer_align; 
52   void *addr_pointed1 = NULL, *addr_pointed2 = NULL;
53
54   if(region_type == 1){ /* libsimgrid */
55     xbt_dynar_foreach(mc_global_variables, cursor, current_var){
56       if(current_var->address < start_data_libsimgrid)
57         continue;
58       offset = (char *)current_var->address - (char *)start_data_libsimgrid;
59       i = 0;
60       while(i < current_var->size){
61         if(memcmp((char*)d1 + offset + i, (char*)d2 + offset + i, 1) != 0){
62           pointer_align = (i / sizeof(void*)) * sizeof(void*); 
63           addr_pointed1 = *((void **)((char *)d1 + offset + pointer_align));
64           addr_pointed2 = *((void **)((char *)d2 + offset + pointer_align));
65           if((addr_pointed1 > start_plt_libsimgrid && addr_pointed1 < end_plt_libsimgrid) || (addr_pointed2 > start_plt_libsimgrid && addr_pointed2 < end_plt_libsimgrid)){
66             i = current_var->size;
67             continue;
68           }else{
69             if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_verbose)){
70               XBT_VERB("Different global variable in libsimgrid : %s at addresses %p - %p (size = %zu)", current_var->name, (char *)d1+offset, (char *)d2+offset, current_var->size);
71             }
72             return 1;
73           }
74         } 
75         i++;
76       }
77     }
78   }else{ /* binary */
79     xbt_dynar_foreach(mc_global_variables, cursor, current_var){
80       if(current_var->address > start_data_libsimgrid)
81         break;
82       offset = (char *)current_var->address - (char *)start_data_binary;
83       i = 0;
84       while(i < current_var->size){
85         if(memcmp((char*)d1 + offset + i, (char*)d2 + offset + i, 1) != 0){
86           pointer_align = (i / sizeof(void*)) * sizeof(void*); 
87           addr_pointed1 = *((void **)((char *)d1 + offset + pointer_align));
88           addr_pointed2 = *((void **)((char *)d2 + offset + pointer_align));
89           if((addr_pointed1 > start_plt_binary && addr_pointed1 < end_plt_binary) || (addr_pointed2 > start_plt_binary && addr_pointed2 < end_plt_binary)){
90             i = current_var->size;
91             continue;
92           }else{
93             if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_verbose)){
94               XBT_VERB("Different global variable in binary : %s", current_var->name);
95             }
96             return 1;
97           }
98         } 
99         i++;
100       }
101       
102     }
103   }
104
105   return 0;
106 }
107
108 static int heap_region_compare(void *d1, void *d2, size_t size){
109   
110   size_t i = 0;
111   
112   for(i=0; i<size; i++){
113     if(memcmp(((char *)d1) + i, ((char *)d2) + i, 1) != 0){
114       if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_verbose)){
115         XBT_VERB("Different byte (offset=%zu) (%p - %p) in heap region", i, (char *)d1 + i, (char *)d2 + i);
116       }
117       return 1;
118     }
119   }
120   
121   return 0;
122 }
123
124 static void stack_region_free(stack_region_t s){
125   if(s){
126     xbt_free(s->process_name);
127     xbt_free(s);
128   }
129 }
130
131 void stack_region_free_voidp(void *s){
132   stack_region_free((stack_region_t) * (void **) s);
133 }
134
135 static void heap_equality_free(heap_equality_t e){
136   if(e){
137     xbt_free(e);
138   }
139 }
140
141 void heap_equality_free_voidp(void *e){
142   heap_equality_free((heap_equality_t) * (void **) e);
143 }
144
145 int SIMIX_pre_mc_compare_snapshots(smx_simcall_t simcall,
146                                    mc_snapshot_t s1, mc_snapshot_t s2){
147   return snapshot_compare(s1, s2);
148 }
149
150 int get_heap_region_index(mc_snapshot_t s){
151   int i = 0;
152   while(i < s->num_reg){
153     switch(s->regions[i]->type){
154     case 0:
155       return i;
156       break;
157     default:
158       i++;
159       break;
160     }
161   }
162   return -1;
163 }
164
165 int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2){
166
167   int raw_mem = (mmalloc_get_current_heap() == raw_heap);
168   
169   MC_SET_RAW_MEM;
170       
171   int errors = 0;
172
173   xbt_os_timer_t global_timer = xbt_os_timer_new();
174   xbt_os_timer_t timer = xbt_os_timer_new();
175
176   xbt_os_timer_start(global_timer);
177
178   #ifdef MC_DEBUG
179     xbt_os_timer_start(timer);
180   #endif
181
182   /* Compare number of processes */
183   if(s1->nb_processes != s2->nb_processes){
184     #ifdef MC_DEBUG
185       xbt_os_timer_stop(timer);
186       mc_comp_times->nb_processes_comparison_time =  xbt_os_timer_elapsed(timer);
187       XBT_DEBUG("Different number of processes : %d - %d", s1->nb_processes, s2->nb_processes);
188       errors++;
189     #else
190       #ifdef MC_VERBOSE
191         XBT_VERB("Different number of processes : %d - %d", s1->nb_processes, s2->nb_processes);
192       #endif
193      
194       xbt_os_timer_free(timer);
195       xbt_os_timer_stop(global_timer);
196       mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
197       xbt_os_timer_free(global_timer);
198
199       if(!raw_mem)
200         MC_UNSET_RAW_MEM;
201
202       return 1;
203     #endif
204   }
205
206   /* Compare number of blocks/fragments used in each heap */
207   if(s1->heap_chunks_used != s2->heap_chunks_used){
208     #ifdef MC_DEBUG
209       xbt_os_timer_stop(timer);
210       mc_comp_times->chunks_used_comparison_time = xbt_os_timer_elapsed(timer);
211       XBT_DEBUG("Different number of chunks used in each heap : %zu - %zu", s1->heap_chunks_used, s2->heap_chunks_used);
212       errors++;
213     #else
214       #ifdef MC_VERBOSE
215         XBT_VERB("Different number of chunks used in each heap : %zu - %zu", s1->heap_chunks_used, s2->heap_chunks_used);
216       #endif
217
218       xbt_os_timer_free(timer);
219       xbt_os_timer_stop(global_timer);
220       mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
221       xbt_os_timer_free(global_timer);
222
223       if(!raw_mem)
224         MC_UNSET_RAW_MEM;
225
226       return 1;
227     #endif
228   }else{
229     #ifdef MC_DEBUG
230       xbt_os_timer_stop(timer);
231     #endif
232   }
233   
234   #ifdef MC_DEBUG
235     xbt_os_timer_start(timer);
236   #endif
237   
238   /* Compare size of stacks */
239   int i = 0;
240   size_t size_used1, size_used2;
241   int is_diff = 0;
242   while(i < xbt_dynar_length(s1->stacks)){
243     size_used1 = s1->stack_sizes[i];
244     size_used2 = s2->stack_sizes[i];
245     if(size_used1 != size_used2){
246     #ifdef MC_DEBUG
247       if(is_diff == 0){
248         xbt_os_timer_stop(timer);
249         mc_comp_times->stacks_sizes_comparison_time = xbt_os_timer_elapsed(timer);
250       }
251       XBT_DEBUG("Different size used in stacks : %zu - %zu", size_used1, size_used2);
252       errors++;
253       is_diff = 1;
254     #else
255       #ifdef MC_VERBOSE
256         XBT_VERB("Different size used in stacks : %zu - %zu", size_used1, size_used2);
257       #endif
258  
259       xbt_os_timer_free(timer);
260       xbt_os_timer_stop(global_timer);
261       mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
262       xbt_os_timer_free(global_timer);
263
264       if(!raw_mem)
265         MC_UNSET_RAW_MEM;
266
267       return 1;
268     #endif  
269     }
270     i++;
271   }
272
273   #ifdef MC_DEBUG
274     if(is_diff == 0)
275       xbt_os_timer_stop(timer);
276     xbt_os_timer_start(timer);
277   #endif
278
279   int heap_index = 0, data_libsimgrid_index = 0, data_program_index = 0;
280   i = 0;
281   
282   /* Get index of regions */
283   while(i < s1->num_reg){
284     switch(s1->region_type[i]){
285     case 0:
286       heap_index = i;
287       i++;
288       break;
289     case 1:
290       data_libsimgrid_index = i;
291       i++;
292       while( i < s1->num_reg && s1->region_type[i] == 1)
293         i++;
294       break;
295     case 2:
296       data_program_index = i;
297       i++;
298       while( i < s1->num_reg && s1->region_type[i] == 2)
299         i++;
300       break;
301     }
302   }
303
304   /* Init heap information used in heap comparison algorithm */
305   init_heap_information((xbt_mheap_t)s1->regions[heap_index]->data, (xbt_mheap_t)s2->regions[heap_index]->data);
306
307   /* Compare binary global variables */
308   is_diff = compare_global_variables(s1->region_type[data_program_index], s1->regions[data_program_index]->data, s2->regions[data_program_index]->data);
309   if(is_diff != 0){
310     #ifdef MC_DEBUG
311       xbt_os_timer_stop(timer);
312       mc_comp_times->binary_global_variables_comparison_time = xbt_os_timer_elapsed(timer);
313       XBT_DEBUG("Different global variables in binary"); 
314       errors++; 
315     #else
316       #ifdef MC_VERBOSE
317         XBT_VERB("Different global variables in binary"); 
318       #endif
319     
320       xbt_os_timer_free(timer);
321       xbt_os_timer_stop(global_timer);
322       mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
323       xbt_os_timer_free(global_timer);
324     
325       if(!raw_mem)
326         MC_UNSET_RAW_MEM;
327
328       return 1;
329     #endif
330   }
331
332   #ifdef MC_VERBOSE
333     if(is_diff == 0)
334       xbt_os_timer_stop(timer);
335     xbt_os_timer_start(timer);
336   #endif
337
338   /* Compare libsimgrid global variables */
339   is_diff = compare_global_variables(s1->region_type[data_libsimgrid_index], s1->regions[data_libsimgrid_index]->data, s2->regions[data_libsimgrid_index]->data);
340   if(is_diff != 0){
341     #ifdef MC_DEBUG
342       xbt_os_timer_stop(timer);
343       mc_comp_times->libsimgrid_global_variables_comparison_time = xbt_os_timer_elapsed(timer); 
344       XBT_DEBUG("Different global variables in libsimgrid"); 
345       errors++; 
346     #else
347       #ifdef MC_VERBOSE
348         XBT_VERB("Different global variables in libsimgrid"); 
349       #endif
350     
351       xbt_os_timer_free(timer);
352       xbt_os_timer_stop(global_timer);
353       mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
354       xbt_os_timer_free(global_timer);
355     
356       if(!raw_mem)
357         MC_UNSET_RAW_MEM;
358
359       return 1;
360     #endif
361   }  
362
363   #ifdef MC_DEBUG
364     if(is_diff == 0)
365       xbt_os_timer_stop(timer);
366     xbt_os_timer_start(timer);
367   #endif
368
369   /* Compare heap */
370   xbt_dynar_t stacks1 = xbt_dynar_new(sizeof(stack_region_t), stack_region_free_voidp);
371   xbt_dynar_t stacks2 = xbt_dynar_new(sizeof(stack_region_t), stack_region_free_voidp);
372   xbt_dynar_t equals = xbt_dynar_new(sizeof(heap_equality_t), heap_equality_free_voidp);
373   
374   void *heap1 = s1->regions[heap_index]->data, *heap2 = s2->regions[heap_index]->data;
375  
376   if(mmalloc_compare_heap((xbt_mheap_t)s1->regions[heap_index]->data, (xbt_mheap_t)s2->regions[heap_index]->data, &stacks1, &stacks2, &equals)){
377
378     #ifdef MC_DEBUG
379       xbt_os_timer_stop(timer);
380       mc_comp_times->heap_comparison_time = xbt_os_timer_elapsed(timer); 
381       XBT_DEBUG("Different heap (mmalloc_compare)");
382       errors++;
383     #else
384
385       xbt_os_timer_free(timer);
386       xbt_dynar_free(&stacks1);
387       xbt_dynar_free(&stacks2);
388       xbt_dynar_free(&equals);
389  
390       #ifdef MC_VERBOSE
391         XBT_VERB("Different heap (mmalloc_compare)");
392       #endif
393        
394       xbt_os_timer_stop(global_timer);
395       mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
396       xbt_os_timer_free(global_timer);
397
398       if(!raw_mem)
399         MC_UNSET_RAW_MEM;
400
401       return 1;
402     #endif
403   }else{
404     #ifdef MC_DEBUG
405       xbt_os_timer_stop(timer);
406     #endif
407   }
408
409   #ifdef MC_DEBUG
410     xbt_os_timer_start(timer);
411   #endif
412
413   /* Stacks comparison */
414   unsigned int  cursor = 0;
415   stack_region_t stack_region1, stack_region2;
416   int diff = 0, diff_local = 0;
417   void *sp1, *sp2;
418   is_diff = 0;
419
420   while(cursor < xbt_dynar_length(stacks1)){
421     stack_region1 = (stack_region_t)(xbt_dynar_get_as(stacks1, cursor, stack_region_t));
422     stack_region2 = (stack_region_t)(xbt_dynar_get_as(stacks2, cursor, stack_region_t));
423     sp1 = ((mc_snapshot_stack_t)xbt_dynar_get_as(s1->stacks, cursor, mc_snapshot_stack_t))->stack_pointer;
424     sp2 = ((mc_snapshot_stack_t)xbt_dynar_get_as(s2->stacks, cursor, mc_snapshot_stack_t))->stack_pointer;
425     diff = compare_stack(stack_region1, stack_region2, sp1, sp2, heap1, heap2, equals);
426
427     if(diff > 0){ /* Differences may be due to padding */  
428       diff_local = compare_local_variables(((mc_snapshot_stack_t)xbt_dynar_get_as(s1->stacks, cursor, mc_snapshot_stack_t))->local_variables->data, ((mc_snapshot_stack_t)xbt_dynar_get_as(s2->stacks, cursor, mc_snapshot_stack_t))->local_variables->data, equals);
429       if(diff_local > 0){
430         #ifdef MC_DEBUG
431           if(is_diff == 0){
432             xbt_os_timer_stop(timer);
433             mc_comp_times->stacks_comparison_time = xbt_os_timer_elapsed(timer); 
434           }
435           XBT_DEBUG("Different local variables between stacks %d", cursor + 1);
436           errors++;
437           is_diff = 1;
438         #else
439           xbt_dynar_free(&stacks1);
440           xbt_dynar_free(&stacks2);
441           xbt_dynar_free(&equals);
442
443           #ifdef MC_VERBOSE
444             XBT_VERB("Different local variables between stacks %d", cursor + 1);
445           #endif
446           
447           xbt_os_timer_free(timer);
448           xbt_os_timer_stop(global_timer);
449           mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
450           xbt_os_timer_free(global_timer);
451           
452           if(!raw_mem)
453             MC_UNSET_RAW_MEM;
454
455           return 1;
456         #endif
457       }
458     }
459     cursor++;
460   }
461
462   xbt_dynar_free(&stacks1);
463   xbt_dynar_free(&stacks2);
464   xbt_dynar_free(&equals);
465    
466   xbt_os_timer_free(timer);
467
468   #ifdef MC_VERBOSE
469     xbt_os_timer_stop(global_timer);
470     mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
471   #endif
472
473   xbt_os_timer_free(global_timer);
474
475   #ifdef MC_DEBUG
476     print_comparison_times();
477   #endif
478
479   if(!raw_mem)
480     MC_UNSET_RAW_MEM;
481
482   return errors > 0;
483   
484 }
485
486 static int is_stack_ignore_variable(char *frame, char *var_name){
487
488   unsigned int cursor = 0;
489   int start = 0;
490   int end = xbt_dynar_length(mc_stack_comparison_ignore) - 1;
491   mc_stack_ignore_variable_t current_var;
492
493   while(start <= end){
494     cursor = (start + end) / 2;
495     current_var = (mc_stack_ignore_variable_t)xbt_dynar_get_as(mc_stack_comparison_ignore, cursor, mc_stack_ignore_variable_t);
496     if(strcmp(current_var->frame, frame) == 0 || strcmp(current_var->frame, "*") == 0){
497       if(strcmp(current_var->var_name, var_name) == 0)
498         return 1;
499       if(strcmp(current_var->var_name, var_name) < 0)
500         start = cursor + 1;
501       if(strcmp(current_var->var_name, var_name) > 0)
502         end = cursor - 1;
503     }else if(strcmp(current_var->frame, frame) < 0){
504       start = cursor + 1;
505     }else if(strcmp(current_var->frame, frame) > 0){
506       end = cursor - 1; 
507     }
508   }
509
510   return 0;
511 }
512
513 static int compare_local_variables(char *s1, char *s2, xbt_dynar_t heap_equals){
514   
515   xbt_dynar_t tokens1 = xbt_str_split(s1, NULL);
516   xbt_dynar_t tokens2 = xbt_str_split(s2, NULL);
517
518   xbt_dynar_t s_tokens1, s_tokens2;
519   unsigned int cursor = 0;
520   void *addr1, *addr2;
521   char *ip1 = NULL, *ip2 = NULL;
522   
523   while(cursor < xbt_dynar_length(tokens1)){
524     s_tokens1 = xbt_str_split(xbt_dynar_get_as(tokens1, cursor, char *), "=");
525     s_tokens2 = xbt_str_split(xbt_dynar_get_as(tokens2, cursor, char *), "=");
526     if(xbt_dynar_length(s_tokens1) > 1 && xbt_dynar_length(s_tokens2) > 1){
527       if((strcmp(xbt_dynar_get_as(s_tokens1, 0, char *), "ip") == 0) && (strcmp(xbt_dynar_get_as(s_tokens2, 0, char *), "ip") == 0)){
528         xbt_free(ip1);
529         xbt_free(ip2);
530         ip1 = strdup(xbt_dynar_get_as(s_tokens1, 1, char *));
531         ip2 = strdup(xbt_dynar_get_as(s_tokens2, 1, char *));
532       }
533       if(strcmp(xbt_dynar_get_as(s_tokens1, 1, char *), xbt_dynar_get_as(s_tokens2, 1, char *)) != 0){   
534         /* Ignore this variable ?  */
535         if(is_stack_ignore_variable(ip1, xbt_dynar_get_as(s_tokens1, 0, char *)) && is_stack_ignore_variable(ip2, xbt_dynar_get_as(s_tokens2, 0, char *))){
536           xbt_dynar_free(&s_tokens1);
537           xbt_dynar_free(&s_tokens2);
538           cursor++;
539           continue;
540         }
541         addr1 = (void *) strtoul(xbt_dynar_get_as(s_tokens1, 1, char *), NULL, 16);
542         addr2 = (void *) strtoul(xbt_dynar_get_as(s_tokens2, 1, char *), NULL, 16);
543         if(is_heap_equality(heap_equals, addr1, addr2) == 0){
544           if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_verbose))
545             XBT_VERB("Variable %s is different between stacks in %s : %s - %s", xbt_dynar_get_as(s_tokens1, 0, char *), ip1, xbt_dynar_get_as(s_tokens1, 1, char *), xbt_dynar_get_as(s_tokens2, 1, char *));
546           xbt_dynar_free(&s_tokens1);
547           xbt_dynar_free(&s_tokens2);
548           xbt_dynar_free(&tokens1);
549           xbt_dynar_free(&tokens2);
550           xbt_free(ip1);
551           xbt_free(ip2);
552           return 1;
553         }
554       }
555     }
556     xbt_dynar_free(&s_tokens1);
557     xbt_dynar_free(&s_tokens2);
558          
559     cursor++;
560   }
561
562   xbt_free(ip1);
563   xbt_free(ip2);
564   xbt_dynar_free(&tokens1);
565   xbt_dynar_free(&tokens2);
566   return 0;
567   
568 }
569
570 static int is_heap_equality(xbt_dynar_t equals, void *a1, void *a2){
571
572   unsigned int cursor = 0;
573   int start = 0;
574   int end = xbt_dynar_length(equals) - 1;
575   heap_equality_t current_equality;
576
577   while(start <= end){
578     cursor = (start + end) / 2;
579     current_equality = (heap_equality_t)xbt_dynar_get_as(equals, cursor, heap_equality_t);
580     if(current_equality->address1 == a1){
581       if(current_equality->address2 == a2)
582         return 1;
583       if(current_equality->address2 < a2)
584         start = cursor + 1;
585       if(current_equality->address2 > a2)
586         end = cursor - 1;
587     }
588     if(current_equality->address1 < a1)
589       start = cursor + 1;
590     if(current_equality->address1 > a1)
591       end = cursor - 1; 
592   }
593
594   return 0;
595
596 }
597
598
599 static int compare_stack(stack_region_t s1, stack_region_t s2, void *sp1, void *sp2, void *heap1, void *heap2, xbt_dynar_t equals){
600   
601   size_t k = 0;
602   size_t size_used1 = s1->size - ((char*)sp1 - (char*)s1->address);
603   size_t size_used2 = s2->size - ((char*)sp2 - (char*)s2->address);
604
605   int pointer_align;
606   void *addr_pointed1 = NULL, *addr_pointed2 = NULL;  
607   
608   while(k < size_used1){
609     if(memcmp((char *)s1->address + s1->size - k, (char *)s2->address + s2->size - k, 1) != 0){
610       pointer_align = ((size_used1 - k) / sizeof(void*)) * sizeof(void*);
611       addr_pointed1 = *((void **)(((char*)s1->address + (s1->size - size_used1)) + pointer_align));
612       addr_pointed2 = *((void **)(((char*)s2->address + (s2->size - size_used2)) + pointer_align));
613       if(is_heap_equality(equals, addr_pointed1, addr_pointed2) == 0){
614         if((addr_pointed1 > std_heap) && (addr_pointed1 < (void *)((char *)std_heap + STD_HEAP_SIZE)) && (addr_pointed2 > std_heap) && (addr_pointed2 < (void *)((char *)std_heap + STD_HEAP_SIZE))){
615           if(is_free_area(addr_pointed1, (xbt_mheap_t)heap1) == 0 || is_free_area(addr_pointed2, (xbt_mheap_t)heap2) == 0){
616             return 1;
617           }
618         }else{
619           return 1;
620         } 
621       }
622     } 
623     k++;
624   }
625  
626   return 0;
627 }
628
629 int MC_compare_snapshots(void *s1, void *s2){
630   
631   MC_ignore_stack("self", "simcall_BODY_mc_snapshot");
632
633   return simcall_mc_compare_snapshots(s1, s2);
634
635 }
636
637 void print_comparison_times(){
638   XBT_DEBUG("*** Comparison times ***");
639   XBT_DEBUG("- Nb processes : %f", mc_comp_times->nb_processes_comparison_time);
640   XBT_DEBUG("- Nb chunks used : %f", mc_comp_times->chunks_used_comparison_time);
641   XBT_DEBUG("- Stacks sizes : %f", mc_comp_times->stacks_sizes_comparison_time);
642   XBT_DEBUG("- Binary global variables : %f", mc_comp_times->binary_global_variables_comparison_time);
643   XBT_DEBUG("- Libsimgrid global variables : %f", mc_comp_times->libsimgrid_global_variables_comparison_time);
644   XBT_DEBUG("- Heap : %f", mc_comp_times->heap_comparison_time);
645   XBT_DEBUG("- Stacks : %f", mc_comp_times->stacks_comparison_time);
646 }