Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Don't define variables in header file.!
[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   /* Compare number of blocks/fragments used in each heap */
229   if(s1->heap_chunks_used != s2->heap_chunks_used){
230     #ifdef MC_DEBUG
231       xbt_os_timer_stop(timer);
232       mc_comp_times->chunks_used_comparison_time = xbt_os_timer_elapsed(timer);
233       XBT_DEBUG("Different number of chunks used in each heap : %zu - %zu", s1->heap_chunks_used, s2->heap_chunks_used);
234       errors++;
235     #else
236       #ifdef MC_VERBOSE
237         XBT_VERB("Different number of chunks used in each heap : %zu - %zu", s1->heap_chunks_used, s2->heap_chunks_used);
238       #endif
239
240       xbt_os_timer_free(timer);
241       xbt_os_timer_stop(global_timer);
242       mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
243       xbt_os_timer_free(global_timer);
244
245       if(!raw_mem)
246         MC_UNSET_RAW_MEM;
247
248       return 1;
249     #endif
250   }else{
251     #ifdef MC_DEBUG
252       xbt_os_timer_stop(timer);
253     #endif
254   }
255   
256   #ifdef MC_DEBUG
257     xbt_os_timer_start(timer);
258   #endif
259   
260   /* Compare size of stacks */
261   int i = 0;
262   size_t size_used1, size_used2;
263   int is_diff = 0;
264   while(i < xbt_dynar_length(s1->stacks)){
265     size_used1 = s1->stack_sizes[i];
266     size_used2 = s2->stack_sizes[i];
267     if(size_used1 != size_used2){
268     #ifdef MC_DEBUG
269       if(is_diff == 0){
270         xbt_os_timer_stop(timer);
271         mc_comp_times->stacks_sizes_comparison_time = xbt_os_timer_elapsed(timer);
272       }
273       XBT_DEBUG("Different size used in stacks : %zu - %zu", size_used1, size_used2);
274       errors++;
275       is_diff = 1;
276     #else
277       #ifdef MC_VERBOSE
278         XBT_VERB("Different size used in stacks : %zu - %zu", size_used1, size_used2);
279       #endif
280  
281       xbt_os_timer_free(timer);
282       xbt_os_timer_stop(global_timer);
283       mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
284       xbt_os_timer_free(global_timer);
285
286       if(!raw_mem)
287         MC_UNSET_RAW_MEM;
288
289       return 1;
290     #endif  
291     }
292     i++;
293   }
294
295   #ifdef MC_DEBUG
296     if(is_diff == 0)
297       xbt_os_timer_stop(timer);
298     xbt_os_timer_start(timer);
299   #endif
300
301   int heap_index = 0, data_libsimgrid_index = 0, data_program_index = 0;
302   i = 0;
303   
304   /* Get index of regions */
305   while(i < s1->num_reg){
306     switch(s1->region_type[i]){
307     case 0:
308       heap_index = i;
309       i++;
310       break;
311     case 1:
312       data_libsimgrid_index = i;
313       i++;
314       while( i < s1->num_reg && s1->region_type[i] == 1)
315         i++;
316       break;
317     case 2:
318       data_program_index = i;
319       i++;
320       while( i < s1->num_reg && s1->region_type[i] == 2)
321         i++;
322       break;
323     }
324   }
325
326   /* Init heap information used in heap comparison algorithm */
327   init_heap_information((xbt_mheap_t)s1->regions[heap_index]->data, (xbt_mheap_t)s2->regions[heap_index]->data);
328
329   xbt_dynar_t equals = xbt_dynar_new(sizeof(heap_equality_t), heap_equality_free_voidp);
330
331   /* Compare binary global variables */
332   is_diff = compare_global_variables(s1->region_type[data_program_index], s1->regions[data_program_index]->data, s2->regions[data_program_index]->data, equals);
333   if(is_diff != 0){
334     #ifdef MC_DEBUG
335       xbt_os_timer_stop(timer);
336       mc_comp_times->binary_global_variables_comparison_time = xbt_os_timer_elapsed(timer);
337       XBT_DEBUG("Different global variables in binary"); 
338       errors++; 
339     #else
340       #ifdef MC_VERBOSE
341         XBT_VERB("Different global variables in binary"); 
342       #endif
343     
344       xbt_os_timer_free(timer);
345       xbt_os_timer_stop(global_timer);
346       mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
347       xbt_os_timer_free(global_timer);
348     
349       if(!raw_mem)
350         MC_UNSET_RAW_MEM;
351
352       return 1;
353     #endif
354   }
355
356   #ifdef MC_VERBOSE
357     if(is_diff == 0)
358       xbt_os_timer_stop(timer);
359     xbt_os_timer_start(timer);
360   #endif
361
362   /* Compare libsimgrid global variables */
363     is_diff = compare_global_variables(s1->region_type[data_libsimgrid_index], s1->regions[data_libsimgrid_index]->data, s2->regions[data_libsimgrid_index]->data, equals);
364   if(is_diff != 0){
365     #ifdef MC_DEBUG
366       xbt_os_timer_stop(timer);
367       mc_comp_times->libsimgrid_global_variables_comparison_time = xbt_os_timer_elapsed(timer); 
368       XBT_DEBUG("Different global variables in libsimgrid"); 
369       errors++; 
370     #else
371       #ifdef MC_VERBOSE
372         XBT_VERB("Different global variables in libsimgrid"); 
373       #endif
374     
375       xbt_os_timer_free(timer);
376       xbt_os_timer_stop(global_timer);
377       mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
378       xbt_os_timer_free(global_timer);
379     
380       if(!raw_mem)
381         MC_UNSET_RAW_MEM;
382
383       return 1;
384     #endif
385   }  
386
387   #ifdef MC_DEBUG
388     if(is_diff == 0)
389       xbt_os_timer_stop(timer);
390     xbt_os_timer_start(timer);
391   #endif
392
393   /* Compare heap */
394   xbt_dynar_t stacks1 = xbt_dynar_new(sizeof(stack_region_t), stack_region_free_voidp);
395   xbt_dynar_t stacks2 = xbt_dynar_new(sizeof(stack_region_t), stack_region_free_voidp);
396  
397   if(mmalloc_compare_heap((xbt_mheap_t)s1->regions[heap_index]->data, (xbt_mheap_t)s2->regions[heap_index]->data, &stacks1, &stacks2, equals)){
398
399     #ifdef MC_DEBUG
400       xbt_os_timer_stop(timer);
401       mc_comp_times->heap_comparison_time = xbt_os_timer_elapsed(timer); 
402       XBT_DEBUG("Different heap (mmalloc_compare)");
403       errors++;
404     #else
405
406       xbt_os_timer_free(timer);
407       xbt_dynar_free(&stacks1);
408       xbt_dynar_free(&stacks2);
409       xbt_dynar_free(&equals);
410  
411       #ifdef MC_VERBOSE
412         XBT_VERB("Different heap (mmalloc_compare)");
413       #endif
414        
415       xbt_os_timer_stop(global_timer);
416       mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
417       xbt_os_timer_free(global_timer);
418
419       if(!raw_mem)
420         MC_UNSET_RAW_MEM;
421
422       return 1;
423     #endif
424   }else{
425     #ifdef MC_DEBUG
426       xbt_os_timer_stop(timer);
427     #endif
428   }
429
430   #ifdef MC_DEBUG
431     xbt_os_timer_start(timer);
432   #endif
433
434   /* Stacks comparison */
435   unsigned int  cursor = 0;
436   int diff_local = 0;
437   is_diff = 0;
438
439   while(cursor < xbt_dynar_length(stacks1)){
440     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);
441     if(diff_local > 0){
442       #ifdef MC_DEBUG
443         if(is_diff == 0){
444           xbt_os_timer_stop(timer);
445           mc_comp_times->stacks_comparison_time = xbt_os_timer_elapsed(timer); 
446         }
447         XBT_DEBUG("Different local variables between stacks %d", cursor + 1);
448         errors++;
449         is_diff = 1;
450       #else
451         xbt_dynar_free(&stacks1);
452         xbt_dynar_free(&stacks2);
453         xbt_dynar_free(&equals);
454         
455       #ifdef MC_VERBOSE
456         XBT_VERB("Different local variables between stacks %d", cursor + 1);
457       #endif
458           
459         xbt_os_timer_free(timer);
460         xbt_os_timer_stop(global_timer);
461         mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
462         xbt_os_timer_free(global_timer);
463         
464         if(!raw_mem)
465           MC_UNSET_RAW_MEM;
466         
467         return 1;
468       #endif
469     }
470     cursor++;
471   }
472
473   xbt_dynar_free(&stacks1);
474   xbt_dynar_free(&stacks2);
475   xbt_dynar_free(&equals);
476    
477   xbt_os_timer_free(timer);
478
479   #ifdef MC_VERBOSE
480     xbt_os_timer_stop(global_timer);
481     mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
482   #endif
483
484   xbt_os_timer_free(global_timer);
485
486   #ifdef MC_DEBUG
487     print_comparison_times();
488   #endif
489
490   if(!raw_mem)
491     MC_UNSET_RAW_MEM;
492
493   return errors > 0;
494   
495 }
496
497 static int is_stack_ignore_variable(char *frame, char *var_name){
498
499   unsigned int cursor = 0;
500   int start = 0;
501   int end = xbt_dynar_length(mc_stack_comparison_ignore) - 1;
502   mc_stack_ignore_variable_t current_var;
503
504   while(start <= end){
505     cursor = (start + end) / 2;
506     current_var = (mc_stack_ignore_variable_t)xbt_dynar_get_as(mc_stack_comparison_ignore, cursor, mc_stack_ignore_variable_t);
507     if(strcmp(current_var->frame, frame) == 0 || strcmp(current_var->frame, "*") == 0){
508       if(strcmp(current_var->var_name, var_name) == 0)
509         return 1;
510       if(strcmp(current_var->var_name, var_name) < 0)
511         start = cursor + 1;
512       if(strcmp(current_var->var_name, var_name) > 0)
513         end = cursor - 1;
514     }else if(strcmp(current_var->frame, frame) < 0){
515       start = cursor + 1;
516     }else if(strcmp(current_var->frame, frame) > 0){
517       end = cursor - 1; 
518     }
519   }
520
521   return 0;
522 }
523
524 static int compare_local_variables(char *s1, char *s2, xbt_dynar_t heap_equals){
525   
526   xbt_dynar_t tokens1 = xbt_str_split(s1, NULL);
527   xbt_dynar_t tokens2 = xbt_str_split(s2, NULL);
528
529   xbt_dynar_t s_tokens1, s_tokens2;
530   unsigned int cursor = 0;
531   void *addr1, *addr2;
532   char *ip1 = NULL, *ip2 = NULL;
533   
534   while(cursor < xbt_dynar_length(tokens1)){
535     s_tokens1 = xbt_str_split(xbt_dynar_get_as(tokens1, cursor, char *), "=");
536     s_tokens2 = xbt_str_split(xbt_dynar_get_as(tokens2, cursor, char *), "=");
537     if(xbt_dynar_length(s_tokens1) > 1 && xbt_dynar_length(s_tokens2) > 1){
538       if((strcmp(xbt_dynar_get_as(s_tokens1, 0, char *), "ip") == 0) && (strcmp(xbt_dynar_get_as(s_tokens2, 0, char *), "ip") == 0)){
539         xbt_free(ip1);
540         xbt_free(ip2);
541         ip1 = strdup(xbt_dynar_get_as(s_tokens1, 1, char *));
542         ip2 = strdup(xbt_dynar_get_as(s_tokens2, 1, char *));
543       }
544       if(strcmp(xbt_dynar_get_as(s_tokens1, 1, char *), xbt_dynar_get_as(s_tokens2, 1, char *)) != 0){   
545         /* Ignore this variable ?  */
546         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 *))){
547           xbt_dynar_free(&s_tokens1);
548           xbt_dynar_free(&s_tokens2);
549           cursor++;
550           continue;
551         }
552         addr1 = (void *) strtoul(xbt_dynar_get_as(s_tokens1, 1, char *), NULL, 16);
553         addr2 = (void *) strtoul(xbt_dynar_get_as(s_tokens2, 1, char *), NULL, 16);
554         if(is_heap_equality(heap_equals, addr1, addr2) == 0){
555           if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_verbose))
556             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 *));
557           xbt_dynar_free(&s_tokens1);
558           xbt_dynar_free(&s_tokens2);
559           xbt_dynar_free(&tokens1);
560           xbt_dynar_free(&tokens2);
561           xbt_free(ip1);
562           xbt_free(ip2);
563           return 1;
564         }
565       }
566     }
567     xbt_dynar_free(&s_tokens1);
568     xbt_dynar_free(&s_tokens2);
569          
570     cursor++;
571   }
572
573   xbt_free(ip1);
574   xbt_free(ip2);
575   xbt_dynar_free(&tokens1);
576   xbt_dynar_free(&tokens2);
577   return 0;
578   
579 }
580
581 static int is_heap_equality(xbt_dynar_t equals, void *a1, void *a2){
582
583   unsigned int cursor = 0;
584   int start = 0;
585   int end = xbt_dynar_length(equals) - 1;
586   heap_equality_t current_equality;
587
588   while(start <= end){
589     cursor = (start + end) / 2;
590     current_equality = (heap_equality_t)xbt_dynar_get_as(equals, cursor, heap_equality_t);
591     if(current_equality->address1 == a1){
592       if(current_equality->address2 == a2)
593         return 1;
594       if(current_equality->address2 < a2)
595         start = cursor + 1;
596       if(current_equality->address2 > a2)
597         end = cursor - 1;
598     }
599     if(current_equality->address1 < a1)
600       start = cursor + 1;
601     if(current_equality->address1 > a1)
602       end = cursor - 1; 
603   }
604
605   return 0;
606
607 }
608
609
610 static int compare_stack(stack_region_t s1, stack_region_t s2, void *sp1, void *sp2, void *heap1, void *heap2, xbt_dynar_t equals){
611   
612   size_t k = 0;
613   size_t size_used1 = s1->size - ((char*)sp1 - (char*)s1->address);
614   size_t size_used2 = s2->size - ((char*)sp2 - (char*)s2->address);
615
616   int pointer_align;
617   void *addr_pointed1 = NULL, *addr_pointed2 = NULL;  
618   
619   while(k < size_used1){
620     if(memcmp((char *)s1->address + s1->size - k, (char *)s2->address + s2->size - k, 1) != 0){
621       pointer_align = ((size_used1 - k) / sizeof(void*)) * sizeof(void*);
622       addr_pointed1 = *((void **)(((char*)s1->address + (s1->size - size_used1)) + pointer_align));
623       addr_pointed2 = *((void **)(((char*)s2->address + (s2->size - size_used2)) + pointer_align));
624       if(is_heap_equality(equals, addr_pointed1, addr_pointed2) == 0){
625         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))){
626           if(is_free_area(addr_pointed1, (xbt_mheap_t)heap1) == 0 || is_free_area(addr_pointed2, (xbt_mheap_t)heap2) == 0){
627             return 1;
628           }
629         }else{
630           return 1;
631         } 
632       }
633     } 
634     k++;
635   }
636  
637   return 0;
638 }
639
640 int MC_compare_snapshots(void *s1, void *s2){
641   
642   MC_ignore_stack("self", "simcall_BODY_mc_snapshot");
643
644   return simcall_mc_compare_snapshots(s1, s2);
645
646 }
647
648 void print_comparison_times(){
649   XBT_DEBUG("*** Comparison times ***");
650   XBT_DEBUG("- Nb processes : %f", mc_comp_times->nb_processes_comparison_time);
651   XBT_DEBUG("- Nb chunks used : %f", mc_comp_times->chunks_used_comparison_time);
652   XBT_DEBUG("- Stacks sizes : %f", mc_comp_times->stacks_sizes_comparison_time);
653   XBT_DEBUG("- Binary global variables : %f", mc_comp_times->binary_global_variables_comparison_time);
654   XBT_DEBUG("- Libsimgrid global variables : %f", mc_comp_times->libsimgrid_global_variables_comparison_time);
655   XBT_DEBUG("- Heap : %f", mc_comp_times->heap_comparison_time);
656   XBT_DEBUG("- Stacks : %f", mc_comp_times->stacks_comparison_time);
657 }