Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
b2be1fd2ffe8bdb984f94e05e2d18ec7f711f6dd
[simgrid.git] / src / mc / mc_compare.c
1 /* Copyright (c) 2012-2014. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include <inttypes.h>
8
9 #include "mc_private.h"
10
11 #include "xbt/mmalloc.h"
12
13 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_compare, mc,
14                                 "Logging specific to mc_compare");
15
16 typedef struct s_pointers_pair{
17   void *p1;
18   void *p2;
19 }s_pointers_pair_t, *pointers_pair_t;
20
21 __thread xbt_dynar_t compared_pointers;
22
23 /************************** Free functions ****************************/
24 /********************************************************************/
25
26 static void stack_region_free(stack_region_t s){
27   if(s){
28     xbt_free(s->process_name);
29     xbt_free(s);
30   }
31 }
32
33 static void stack_region_free_voidp(void *s){
34   stack_region_free((stack_region_t) * (void **) s);
35 }
36
37 static void pointers_pair_free(pointers_pair_t p){
38   xbt_free(p);
39 }
40
41 static void pointers_pair_free_voidp(void *p){
42   pointers_pair_free((pointers_pair_t) * (void **)p);
43 }
44
45 /************************** Snapshot comparison *******************************/
46 /******************************************************************************/
47
48 /** \brief Try to add a pair a compared pointers to the set of compared pointers
49  *
50  *  \result !=0 if the pointers were added (they were not in the set),
51  *      0 otherwise (they were already in the set)
52  */
53 static int add_compared_pointers(void *p1, void *p2){
54
55   pointers_pair_t new_pair = xbt_new0(s_pointers_pair_t, 1);
56   new_pair->p1 = p1;
57   new_pair->p2 = p2;
58   
59   if(xbt_dynar_is_empty(compared_pointers)){
60     xbt_dynar_push(compared_pointers, &new_pair);
61     return 1;
62   }
63
64   unsigned int cursor = 0;
65   int start = 0;
66   int end = xbt_dynar_length(compared_pointers) - 1;
67   pointers_pair_t pair = NULL;
68
69   pointers_pair_t* p = (pointers_pair_t*) xbt_dynar_get_ptr(compared_pointers, 0);
70
71   while(start <= end){
72     cursor = (start + end) / 2;
73     pair = p[cursor];
74     if(pair->p1 < p1){
75       start = cursor + 1;
76     } else if(pair->p1 > p1) {
77       end = cursor - 1 ;
78     } else if(pair->p2 < p2){
79       start = cursor + 1;
80     } else if(pair->p2 > p2) {
81       end = cursor - 1 ;
82     } else {
83       pointers_pair_free(new_pair);
84       return 0;
85     }
86   }
87
88   if(pair->p1 < p1)
89     xbt_dynar_insert_at(compared_pointers, cursor + 1, &new_pair);
90   else if(pair->p1 > p1)
91     xbt_dynar_insert_at(compared_pointers, cursor, &new_pair);
92   else if(pair->p2 < p2)
93     xbt_dynar_insert_at(compared_pointers, cursor + 1, &new_pair);
94   else if(pair->p2 > p2)
95     xbt_dynar_insert_at(compared_pointers, cursor, &new_pair);
96   else
97     xbt_die("Unrecheable");
98
99   return 1;
100 }
101
102 static int compare_areas_with_type(void *area1, void *area2, mc_snapshot_t snapshot1, mc_snapshot_t snapshot2, mc_object_info_t info, mc_object_info_t other_info, dw_type_t type, int region_size, int region_type, void *start_data, int pointer_level){
103
104   unsigned int cursor = 0;
105   dw_type_t member, subtype, subsubtype;
106   int elm_size, i, res, switch_types = 0;
107   void *addr_pointed1, *addr_pointed2;
108
109   switch(type->type){
110   case DW_TAG_unspecified_type:
111     return 1;
112
113   case DW_TAG_base_type:
114   case DW_TAG_enumeration_type:
115   case DW_TAG_union_type:
116     return (memcmp(area1, area2, type->byte_size) != 0);
117     break;
118   case DW_TAG_typedef:
119   case DW_TAG_volatile_type:
120   case DW_TAG_const_type:
121     return compare_areas_with_type(area1, area2, snapshot1, snapshot2, info, other_info, type->subtype, region_size, region_type, start_data, pointer_level);
122     break;
123   case DW_TAG_array_type:
124     subtype = type->subtype;
125     switch(subtype->type){
126     case DW_TAG_unspecified_type:
127       return 1;
128
129     case DW_TAG_base_type:
130     case DW_TAG_enumeration_type:
131     case DW_TAG_pointer_type:
132     case DW_TAG_reference_type:
133     case DW_TAG_rvalue_reference_type:
134     case DW_TAG_structure_type:
135     case DW_TAG_class_type:
136     case DW_TAG_union_type:
137       if(subtype->byte_size == 0){ /*declaration of the type, need the complete description */
138           subtype = subtype->other_object_same_type;
139           switch_types = 1;
140       }
141       elm_size = subtype->byte_size;
142       break;
143     case DW_TAG_const_type:
144     case DW_TAG_typedef:
145     case DW_TAG_volatile_type:
146       subsubtype = subtype->subtype;
147       if(subsubtype->byte_size == 0){ /*declaration of the type, need the complete description */
148           subsubtype = subsubtype->other_object_same_type;
149           switch_types = 1;
150       }
151       elm_size = subsubtype->byte_size;
152       break;
153     default : 
154       return 0;
155       break;
156     }
157     for(i=0; i<type->element_count; i++){
158       if(switch_types)
159         res = compare_areas_with_type((char *)area1 + (i*elm_size), (char *)area2 + (i*elm_size), snapshot1, snapshot2, other_info, info, type->subtype, region_size, region_type, start_data, pointer_level);
160       else
161         res = compare_areas_with_type((char *)area1 + (i*elm_size), (char *)area2 + (i*elm_size), snapshot1, snapshot2, info, other_info, type->subtype, region_size, region_type, start_data, pointer_level);
162       if(res == 1)
163         return res;
164     }
165     break;
166   case DW_TAG_pointer_type:
167   case DW_TAG_reference_type:
168   case DW_TAG_rvalue_reference_type:
169
170     addr_pointed1 = *((void **)(area1));
171     addr_pointed2 = *((void **)(area2));
172
173     if(type->subtype && type->subtype->type == DW_TAG_subroutine_type){
174       return (addr_pointed1 != addr_pointed2);
175     }else{
176       
177       if(addr_pointed1 == NULL && addr_pointed2 == NULL)
178         return 0;
179       if(!add_compared_pointers(addr_pointed1, addr_pointed2))
180         return 0;
181
182       pointer_level++;
183       
184       // Some cases are not handled here:
185       // * the pointers lead to different areas (one to the heap, the other to the RW segment ...);
186       // * a pointer leads to the read-only segment of the current object;
187       // * a pointer lead to a different ELF object.
188
189       // The pointers are both in the heap:
190       if(addr_pointed1 > std_heap && (char *)addr_pointed1 < (char*) std_heap + STD_HEAP_SIZE){
191         if(!(addr_pointed2 > std_heap && (char *)addr_pointed2 < (char*) std_heap + STD_HEAP_SIZE))
192           return 1;
193         return compare_heap_area(addr_pointed1, addr_pointed2, snapshot1, snapshot2, NULL, info, other_info, type->dw_type_id, pointer_level);
194       }
195
196       // The pointers are both in the current object R/W segment:
197       else if(addr_pointed1 > start_data && (char*)addr_pointed1 <= (char *)start_data + region_size){
198         if(!(addr_pointed2 > start_data && (char*)addr_pointed2 <= (char *)start_data + region_size))
199           return 1;
200         if(type->dw_type_id == NULL)
201           return  (addr_pointed1 != addr_pointed2);
202         else {
203           void* translated_addr_pointer1 = mc_translate_address((uintptr_t)addr_pointed1, snapshot1);
204           void* translated_addr_pointer2 = mc_translate_address((uintptr_t)addr_pointed2, snapshot2);
205           return  compare_areas_with_type(
206             translated_addr_pointer1, translated_addr_pointer2, snapshot1, snapshot2, info, other_info, type->subtype, region_size, region_type, start_data, pointer_level);
207         }
208       }
209
210       else{
211         return (addr_pointed1 != addr_pointed2);
212       }
213     }
214     break;
215   case DW_TAG_structure_type:
216   case DW_TAG_class_type:
217     xbt_dynar_foreach(type->members, cursor, member){
218       XBT_DEBUG("Compare member %s", member->name);
219       void* member1 = mc_member_snapshot_resolve(area1, type, member, snapshot1);
220       void* member2 = mc_member_snapshot_resolve(area2, type, member, snapshot2);
221       res = compare_areas_with_type(member1, member2, snapshot1, snapshot2, info, other_info, member->subtype, region_size, region_type, start_data, pointer_level);
222       if(res == 1)
223         return res;
224     }
225     break;
226   case DW_TAG_subroutine_type:
227     return -1;
228     break;
229   default:
230     XBT_VERB("Unknown case : %d", type->type);
231     break;
232   }
233   
234   return 0;
235 }
236
237 static int compare_global_variables(int region_type, mc_mem_region_t r1, mc_mem_region_t r2, mc_snapshot_t snapshot1, mc_snapshot_t snapshot2){
238
239   if(!compared_pointers){
240     compared_pointers = xbt_dynar_new(sizeof(pointers_pair_t), pointers_pair_free_voidp);
241   }else{
242     xbt_dynar_reset(compared_pointers);
243   }
244
245   xbt_dynar_t variables;
246   int res;
247   unsigned int cursor = 0;
248   dw_variable_t current_var;
249   size_t offset;
250   void *start_data;
251   void* start_data_binary = mc_binary_info->start_rw;
252   void* start_data_libsimgrid = mc_libsimgrid_info->start_rw;
253
254   mc_object_info_t object_info = NULL;
255   mc_object_info_t other_object_info = NULL;
256   if(region_type == 2){
257     object_info = mc_binary_info;
258     other_object_info = mc_libsimgrid_info;
259     start_data = start_data_binary;
260   }else{
261     object_info = mc_libsimgrid_info;
262     other_object_info = mc_binary_info;
263     start_data = start_data_libsimgrid;
264   }
265   variables = object_info->global_variables;
266
267   xbt_dynar_foreach(variables, cursor, current_var){
268
269     // If the variable is not in this object, skip it:
270     // We do not expect to find a pointer to something which is not reachable
271     // by the global variables.
272     if((char*) current_var->address < (char*) object_info->start_rw
273       || (char*) current_var->address > (char*) object_info->end_rw)
274        continue;
275
276     offset = (char *)current_var->address - (char *)object_info->start_rw;
277
278     dw_type_t bvariable_type = current_var->type;
279     res = compare_areas_with_type((char *)r1->data + offset, (char *)r2->data + offset, snapshot1, snapshot2, object_info, other_object_info, bvariable_type, r1->size, region_type, start_data, 0);
280     if(res == 1){
281       XBT_VERB("Global variable %s (%p - %p) is different between snapshots", current_var->name, (char *)r1->data + offset, (char *)r2->data + offset);
282       xbt_dynar_free(&compared_pointers);
283       compared_pointers = NULL;
284       return 1;
285     }
286
287   }
288
289   xbt_dynar_free(&compared_pointers);
290   compared_pointers = NULL;
291
292   return 0;
293
294 }
295
296 static int compare_local_variables(mc_snapshot_t snapshot1, mc_snapshot_t snapshot2, mc_snapshot_stack_t stack1, mc_snapshot_stack_t stack2, void *heap1, void *heap2){
297   void* start_data_binary = mc_binary_info->start_rw;
298   void* start_data_libsimgrid = mc_libsimgrid_info->start_rw;
299
300   if(!compared_pointers){
301     compared_pointers = xbt_dynar_new(sizeof(pointers_pair_t), pointers_pair_free_voidp);
302   }else{
303     xbt_dynar_reset(compared_pointers);
304   }
305
306   if(xbt_dynar_length(stack1->local_variables) != xbt_dynar_length(stack2->local_variables)){
307     XBT_VERB("Different number of local variables");
308     xbt_dynar_free(&compared_pointers);
309     compared_pointers = NULL;
310     return 1;
311   }else{
312     unsigned int cursor = 0;
313     local_variable_t current_var1, current_var2;
314     int offset1, offset2, res;
315     while(cursor < xbt_dynar_length(stack1->local_variables)){
316       current_var1 = (local_variable_t)xbt_dynar_get_as(stack1->local_variables, cursor, local_variable_t);
317       current_var2 = (local_variable_t)xbt_dynar_get_as(stack2->local_variables, cursor, local_variable_t);
318       if(strcmp(current_var1->name, current_var2->name) != 0 || strcmp(current_var1->frame, current_var2->frame) != 0 || current_var1->ip != current_var2->ip){
319         xbt_dynar_free(&compared_pointers);
320         XBT_VERB("Different name of variable (%s - %s) or frame (%s - %s) or ip (%lu - %lu)", current_var1->name, current_var2->name, current_var1->frame, current_var2->frame, current_var1->ip, current_var2->ip);
321         return 1;
322       }
323       offset1 = (char *)current_var1->address - (char *)std_heap;
324       offset2 = (char *)current_var2->address - (char *)std_heap;
325       XBT_DEBUG("Compare local variable %s of frame %s", current_var1->name, current_var1->frame);
326
327
328       if(current_var1->region == 1) {
329         dw_type_t subtype = current_var1->type;
330         res = compare_areas_with_type( (char *)heap1 + offset1, (char *)heap2 + offset2, snapshot1, snapshot2, mc_libsimgrid_info, mc_binary_info, subtype, 0, 1, start_data_libsimgrid, 0);
331       } else {
332         dw_type_t subtype = current_var2->type;
333         res = compare_areas_with_type( (char *)heap1 + offset1, (char *)heap2 + offset2, snapshot1, snapshot2, mc_binary_info, mc_libsimgrid_info, subtype, 0, 2, start_data_binary, 0);
334       }
335       if(res == 1){
336         XBT_VERB("Local variable %s (%p - %p) in frame %s  is different between snapshots", current_var1->name,(char *)heap1 + offset1, (char *)heap2 + offset2, current_var1->frame);
337         xbt_dynar_free(&compared_pointers);
338         compared_pointers = NULL;
339         return res;
340       }
341       cursor++;
342     }
343     xbt_dynar_free(&compared_pointers);
344     compared_pointers = NULL;
345     return 0;
346   }
347 }
348
349 int snapshot_compare(void *state1, void *state2){
350
351   mc_snapshot_t s1, s2;
352   int num1, num2;
353   
354   if(_sg_mc_property_file && _sg_mc_property_file[0] != '\0'){ /* Liveness MC */
355     s1 = ((mc_visited_pair_t)state1)->graph_state->system_state;
356     s2 = ((mc_visited_pair_t)state2)->graph_state->system_state;
357     num1 = ((mc_visited_pair_t)state1)->num;
358     num2 =  ((mc_visited_pair_t)state2)->num;
359     /* Firstly compare automaton state */
360     /*if(xbt_automaton_state_compare(((mc_pair_t)state1)->automaton_state, ((mc_pair_t)state2)->automaton_state) != 0)
361       return 1;
362     if(xbt_automaton_propositional_symbols_compare_value(((mc_pair_t)state1)->atomic_propositions, ((mc_pair_t)state2)->atomic_propositions) != 0)
363     return 1;*/
364   }else{ /* Safety MC */
365     s1 = ((mc_visited_state_t)state1)->system_state;
366     s2 = ((mc_visited_state_t)state2)->system_state;
367     num1 = ((mc_visited_state_t)state1)->num;
368     num2 = ((mc_visited_state_t)state2)->num;
369   }
370
371   int errors = 0;
372   int res_init;
373
374   xbt_os_timer_t global_timer = xbt_os_timer_new();
375   xbt_os_timer_t timer = xbt_os_timer_new();
376
377   xbt_os_walltimer_start(global_timer);
378
379   #ifdef MC_DEBUG
380     xbt_os_walltimer_start(timer);
381   #endif
382
383   int hash_result = 0;
384   if(_sg_mc_hash) {
385     hash_result = (s1->hash != s2->hash);
386     if(hash_result) {
387       XBT_VERB("(%d - %d) Different hash : 0x%" PRIx64 "--0x%" PRIx64, num1, num2, s1->hash, s2->hash);
388 #ifndef MC_DEBUG
389       return 1;
390 #endif
391     } else {
392       XBT_VERB("(%d - %d) Same hash : 0x%" PRIx64, num1, num2, s1->hash);
393     }
394   }
395
396   int i = 0;
397   size_t size_used1, size_used2;
398   int is_diff = 0;
399
400
401   /* Compare size of stacks */
402   while(i < xbt_dynar_length(s1->stacks)){
403     size_used1 = s1->stack_sizes[i];
404     size_used2 = s2->stack_sizes[i];
405     if(size_used1 != size_used2){
406     #ifdef MC_DEBUG
407       if(is_diff == 0){
408         xbt_os_walltimer_stop(timer);
409         mc_comp_times->stacks_sizes_comparison_time = xbt_os_timer_elapsed(timer);
410       }
411       XBT_DEBUG("(%d - %d) Different size used in stacks : %zu - %zu", num1, num2, size_used1, size_used2);
412       errors++;
413       is_diff = 1;
414     #else
415       #ifdef MC_VERBOSE
416       XBT_VERB("(%d - %d) Different size used in stacks : %zu - %zu", num1, num2, size_used1, size_used2);
417       #endif
418
419       xbt_os_walltimer_stop(timer);
420       xbt_os_timer_free(timer);
421       xbt_os_walltimer_stop(global_timer);
422       mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
423       xbt_os_timer_free(global_timer);
424
425       return 1;
426     #endif  
427     }
428     i++;
429   }
430
431   #ifdef MC_DEBUG
432     if(is_diff == 0)
433       xbt_os_walltimer_stop(timer);
434     xbt_os_walltimer_start(timer);
435   #endif
436
437   /* Init heap information used in heap comparison algorithm */
438   res_init = init_heap_information((xbt_mheap_t)s1->regions[0]->data, (xbt_mheap_t)s2->regions[0]->data, s1->to_ignore, s2->to_ignore);
439   if(res_init == -1){
440      #ifdef MC_DEBUG
441     XBT_DEBUG("(%d - %d) Different heap information", num1, num2); 
442         errors++; 
443       #else
444         #ifdef MC_VERBOSE
445         XBT_VERB("(%d - %d) Different heap information", num1, num2); 
446         #endif
447
448         xbt_os_walltimer_stop(global_timer);
449         mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
450         xbt_os_timer_free(global_timer);
451
452         return 1;
453       #endif
454   }
455
456   #ifdef MC_DEBUG
457     xbt_os_walltimer_start(timer);
458   #endif
459
460   /* Stacks comparison */
461   unsigned int  cursor = 0;
462   int diff_local = 0;
463   is_diff = 0;
464   mc_snapshot_stack_t stack1, stack2;
465     
466   while(cursor < xbt_dynar_length(s1->stacks)){
467     stack1 = (mc_snapshot_stack_t)xbt_dynar_get_as(s1->stacks, cursor, mc_snapshot_stack_t);
468     stack2 = (mc_snapshot_stack_t)xbt_dynar_get_as(s2->stacks, cursor, mc_snapshot_stack_t);
469     diff_local = compare_local_variables(s1, s2, stack1, stack2, s1->regions[0]->data, s2->regions[0]->data);
470     if(diff_local > 0){
471       #ifdef MC_DEBUG
472         if(is_diff == 0){
473           xbt_os_walltimer_stop(timer);
474           mc_comp_times->stacks_comparison_time = xbt_os_timer_elapsed(timer);
475         }
476         XBT_DEBUG("(%d - %d) Different local variables between stacks %d", num1, num2, cursor + 1);
477         errors++;
478         is_diff = 1;
479       #else
480         
481         #ifdef MC_VERBOSE
482         XBT_VERB("(%d - %d) Different local variables between stacks %d", num1, num2, cursor + 1);
483         #endif
484           
485         reset_heap_information();
486         xbt_os_walltimer_stop(timer);
487         xbt_os_timer_free(timer);
488         xbt_os_walltimer_stop(global_timer);
489         mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
490         xbt_os_timer_free(global_timer);
491  
492         return 1;
493       #endif
494     }
495     cursor++;
496   }
497
498
499
500  const char* names[3] = { "?", "libsimgrid", "binary" };
501 #ifdef MC_DEBUG
502  double *times[3] = {
503    NULL,
504    &mc_comp_times->libsimgrid_global_variables_comparison_time,
505    &mc_comp_times->binary_global_variables_comparison_time
506  };
507 #endif
508
509  int k=0;
510  for(k=2; k!=0; --k) {
511     #ifdef MC_DEBUG
512       if(is_diff == 0)
513         xbt_os_walltimer_stop(timer);
514       xbt_os_walltimer_start(timer);
515     #endif
516
517   /* Compare global variables */
518   is_diff = compare_global_variables(k, s1->regions[k], s2->regions[k], s1, s2);
519   if(is_diff != 0){
520     #ifdef MC_DEBUG
521       xbt_os_walltimer_stop(timer);
522       *times[k] = xbt_os_timer_elapsed(timer);
523       XBT_DEBUG("(%d - %d) Different global variables in %s", num1, num2, names[k]);
524       errors++;
525     #else
526       #ifdef MC_VERBOSE
527       XBT_VERB("(%d - %d) Different global variables in %s", num1, num2, names[k]);
528       #endif
529
530       reset_heap_information();
531       xbt_os_walltimer_stop(timer);
532       xbt_os_timer_free(timer);
533       xbt_os_walltimer_stop(global_timer);
534       mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
535       xbt_os_timer_free(global_timer);
536
537       return 1;
538     #endif
539   }
540  }
541
542   #ifdef MC_DEBUG
543     xbt_os_walltimer_start(timer);
544   #endif
545
546   /* Compare heap */
547     if(mmalloc_compare_heap(s1, s2, (xbt_mheap_t)s1->regions[0]->data,
548                             (xbt_mheap_t)s2->regions[0]->data,
549                             mc_libsimgrid_info,
550                             mc_binary_info) > 0){
551
552     #ifdef MC_DEBUG
553       xbt_os_walltimer_stop(timer);
554       mc_comp_times->heap_comparison_time = xbt_os_timer_elapsed(timer); 
555       XBT_DEBUG("(%d - %d) Different heap (mmalloc_compare)", num1, num2);
556       errors++;
557     #else
558  
559       #ifdef MC_VERBOSE
560       XBT_VERB("(%d - %d) Different heap (mmalloc_compare)", num1, num2);
561       #endif
562        
563       reset_heap_information();
564       xbt_os_walltimer_stop(timer);
565       xbt_os_timer_free(timer);
566       xbt_os_walltimer_stop(global_timer);
567       mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
568       xbt_os_timer_free(global_timer);
569
570       return 1;
571     #endif
572   }else{
573     #ifdef MC_DEBUG
574       xbt_os_walltimer_stop(timer);
575     #endif
576   }
577
578   reset_heap_information();
579   
580   xbt_os_walltimer_stop(timer);
581   xbt_os_timer_free(timer);
582
583   #ifdef MC_VERBOSE
584     xbt_os_walltimer_stop(global_timer);
585     mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
586   #endif
587
588   xbt_os_timer_free(global_timer);
589
590   #ifdef MC_DEBUG
591     print_comparison_times();
592   #endif
593
594 #ifdef MC_VERBOSE
595    if(errors || hash_result)
596      XBT_VERB("(%d - %d) Difference found", num1, num2);
597    else
598      XBT_VERB("(%d - %d) No difference found", num1, num2);
599 #endif
600
601 #if defined(MC_DEBUG) && defined(MC_VERBOSE)
602    if(_sg_mc_hash) {
603      // * false positive SHOULD be avoided.
604      // * There MUST not be any false negative.
605
606      XBT_VERB("(%d - %d) State equality hash test is %s %s", num1, num2,
607        (hash_result!=0) == (errors!=0) ? "true" : "false",
608        !hash_result ? "positive" : "negative");
609    }
610 #endif
611
612    return errors > 0 || hash_result;
613   
614 }
615
616 /***************************** Statistics *****************************/
617 /*******************************************************************/
618
619 void print_comparison_times(){
620   XBT_DEBUG("*** Comparison times ***");
621   XBT_DEBUG("- Nb processes : %f", mc_comp_times->nb_processes_comparison_time);
622   XBT_DEBUG("- Nb bytes used : %f", mc_comp_times->bytes_used_comparison_time);
623   XBT_DEBUG("- Stacks sizes : %f", mc_comp_times->stacks_sizes_comparison_time);
624   XBT_DEBUG("- Binary global variables : %f", mc_comp_times->binary_global_variables_comparison_time);
625   XBT_DEBUG("- Libsimgrid global variables : %f", mc_comp_times->libsimgrid_global_variables_comparison_time);
626   XBT_DEBUG("- Heap : %f", mc_comp_times->heap_comparison_time);
627   XBT_DEBUG("- Stacks : %f", mc_comp_times->stacks_comparison_time);
628 }
629
630 /**************************** MC snapshot compare simcall **************************/
631 /***********************************************************************************/
632
633 int SIMIX_pre_mc_compare_snapshots(smx_simcall_t simcall,
634                                    mc_snapshot_t s1, mc_snapshot_t s2){
635   return snapshot_compare(s1, s2);
636 }
637
638 int MC_compare_snapshots(void *s1, void *s2){
639
640   return simcall_mc_compare_snapshots(s1, s2);
641
642 }