Logo AND Algorithmique Numérique Distribuée

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