Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
0314dfca71e3afb7cbbf0aebc9c79bd9deb2029f
[simgrid.git] / src / mc / mc_compare.cpp
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 #define __STDC_FORMAT_MACROS
8 #include <cinttypes>
9 #include <boost/unordered_set.hpp>
10
11 #include <xbt/sysdep.h>
12
13 #include "internal_config.h"
14 #include "mc_object_info.h"
15 #include "mc_safety.h"
16 #include "mc_liveness.h"
17 #include "mc_private.h"
18 #include "mc_smx.h"
19
20 #ifdef HAVE_SMPI
21 #include "smpi/private.h"
22 #endif
23
24 #include "xbt/mmalloc.h"
25 #include "xbt/mmalloc/mmprivate.h"
26
27 #include <xbt/probes.h>
28
29 using simgrid::mc::remote;
30
31 typedef struct s_pointers_pair {
32   void *p1;
33   void *p2;
34   bool operator==(s_pointers_pair const& x) const {
35     return this->p1 == x.p1 && this->p2 == x.p2;
36   }
37   bool operator<(s_pointers_pair const& x) const {
38     return this->p1 < x.p1 || (this->p1 == x.p1 && this->p2 < x.p2);
39   }
40 } s_pointers_pair_t, *pointers_pair_t;
41
42 namespace boost {
43   template<>
44   struct hash<s_pointers_pair> {
45     typedef uintptr_t result_type;
46     result_type operator()(s_pointers_pair const& x) const {
47       return (result_type) x.p1 ^
48         ((result_type) x.p2 << 8 | (result_type) x.p2 >> (8*sizeof(uintptr_t) - 8));
49     }
50   };
51 }
52
53 struct mc_compare_state {
54   boost::unordered_set<s_pointers_pair> compared_pointers;
55 };
56
57 extern "C" {
58
59 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_compare, xbt,
60                                 "Logging specific to mc_compare in mc");
61
62 /************************** Free functions ****************************/
63 /********************************************************************/
64
65 static void stack_region_free(stack_region_t s)
66 {
67   if (s) {
68     xbt_free(s);
69   }
70 }
71
72 static void stack_region_free_voidp(void *s)
73 {
74   stack_region_free((stack_region_t) * (void **) s);
75 }
76
77 static void pointers_pair_free(pointers_pair_t p)
78 {
79   xbt_free(p);
80 }
81
82 static void pointers_pair_free_voidp(void *p)
83 {
84   pointers_pair_free((pointers_pair_t) * (void **) p);
85 }
86
87 /************************** Snapshot comparison *******************************/
88 /******************************************************************************/
89
90 /** \brief Try to add a pair a compared pointers to the set of compared pointers
91  *
92  *  \result !=0 if the pointers were added (they were not in the set),
93  *      0 otherwise (they were already in the set)
94  */
95 static int add_compared_pointers(mc_compare_state& state, void *p1, void *p2)
96 {
97   s_pointers_pair_t new_pair;
98   new_pair.p1 = p1;
99   new_pair.p2 = p2;
100   return state.compared_pointers.insert(new_pair).second ? 1 : 0;
101 }
102
103 static int compare_areas_with_type(struct mc_compare_state& state,
104                                    int process_index,
105                                    void* real_area1, mc_snapshot_t snapshot1, mc_mem_region_t region1,
106                                    void* real_area2, mc_snapshot_t snapshot2, mc_mem_region_t region2,
107                                    mc_type_t type, int pointer_level)
108 {
109   mc_process_t process = &mc_model_checker->process();
110
111   mc_type_t subtype, subsubtype;
112   int elm_size, i, res;
113
114   top:
115   switch (type->type) {
116   case DW_TAG_unspecified_type:
117     return 1;
118
119   case DW_TAG_base_type:
120   case DW_TAG_enumeration_type:
121   case DW_TAG_union_type:
122   {
123     return MC_snapshot_region_memcmp(
124       real_area1, region1, real_area2, region2,
125       type->byte_size) != 0;
126   }
127   case DW_TAG_typedef:
128   case DW_TAG_volatile_type:
129   case DW_TAG_const_type:
130     // Poor man's TCO:
131     type = type->subtype;
132     goto top;
133   case DW_TAG_array_type:
134     subtype = type->subtype;
135     switch (subtype->type) {
136     case DW_TAG_unspecified_type:
137       return 1;
138
139     case DW_TAG_base_type:
140     case DW_TAG_enumeration_type:
141     case DW_TAG_pointer_type:
142     case DW_TAG_reference_type:
143     case DW_TAG_rvalue_reference_type:
144     case DW_TAG_structure_type:
145     case DW_TAG_class_type:
146     case DW_TAG_union_type:
147       if (subtype->full_type)
148         subtype = subtype->full_type;
149       elm_size = subtype->byte_size;
150       break;
151     case DW_TAG_const_type:
152     case DW_TAG_typedef:
153     case DW_TAG_volatile_type:
154       subsubtype = subtype->subtype;
155       if (subsubtype->full_type)
156         subsubtype = subsubtype->full_type;
157       elm_size = subsubtype->byte_size;
158       break;
159     default:
160       return 0;
161       break;
162     }
163     for (i = 0; i < type->element_count; i++) {
164       size_t off = i * elm_size;
165       res = compare_areas_with_type(state, process_index,
166             (char*) real_area1 + off, snapshot1, region1,
167             (char*) real_area2 + off, snapshot2, region2,
168             type->subtype, pointer_level);
169       if (res == 1)
170         return res;
171     }
172     break;
173   case DW_TAG_pointer_type:
174   case DW_TAG_reference_type:
175   case DW_TAG_rvalue_reference_type:
176   {
177     void* addr_pointed1 = MC_region_read_pointer(region1, real_area1);
178     void* addr_pointed2 = MC_region_read_pointer(region2, real_area2);
179
180     if (type->subtype && type->subtype->type == DW_TAG_subroutine_type) {
181       return (addr_pointed1 != addr_pointed2);
182     } else {
183
184       if (addr_pointed1 == NULL && addr_pointed2 == NULL)
185         return 0;
186       if (addr_pointed1 == NULL || addr_pointed2 == NULL)
187         return 1;
188       if (!add_compared_pointers(state, addr_pointed1, addr_pointed2))
189         return 0;
190
191       pointer_level++;
192
193       // Some cases are not handled here:
194       // * the pointers lead to different areas (one to the heap, the other to the RW segment ...);
195       // * a pointer leads to the read-only segment of the current object;
196       // * a pointer lead to a different ELF object.
197
198       if (addr_pointed1 > process->heap_address
199           && addr_pointed1 < mc_snapshot_get_heap_end(snapshot1)) {
200         if (!
201             (addr_pointed2 > process->heap_address
202              && addr_pointed2 < mc_snapshot_get_heap_end(snapshot2)))
203           return 1;
204         // The pointers are both in the heap:
205         return compare_heap_area(process_index, addr_pointed1, addr_pointed2, snapshot1,
206                                  snapshot2, NULL, type->subtype, pointer_level);
207       }
208
209       // The pointers are both in the current object R/W segment:
210       else if (region1->contain(simgrid::mc::remote(addr_pointed1))) {
211         if (!region2->contain(simgrid::mc::remote(addr_pointed2)))
212           return 1;
213         if (type->type_id.empty())
214           return (addr_pointed1 != addr_pointed2);
215         else {
216           return compare_areas_with_type(state, process_index,
217                                          addr_pointed1, snapshot1, region1,
218                                          addr_pointed2, snapshot2, region2,
219                                          type->subtype, pointer_level);
220         }
221       }
222
223       // TODO, We do not handle very well the case where
224       // it belongs to a different (non-heap) region from the current one.
225
226       else {
227         return (addr_pointed1 != addr_pointed2);
228       }
229     }
230     break;
231   }
232   case DW_TAG_structure_type:
233   case DW_TAG_class_type:
234     for(simgrid::mc::Type& member : type->members) {
235       void *member1 =
236         mc_member_resolve(real_area1, type, &member, snapshot1, process_index);
237       void *member2 =
238         mc_member_resolve(real_area2, type, &member, snapshot2, process_index);
239       mc_mem_region_t subregion1 = mc_get_region_hinted(member1, snapshot1, process_index, region1);
240       mc_mem_region_t subregion2 = mc_get_region_hinted(member2, snapshot2, process_index, region2);
241       res =
242           compare_areas_with_type(state, process_index,
243                                   member1, snapshot1, subregion1,
244                                   member2, snapshot2, subregion2,
245                                   member.subtype, pointer_level);
246       if (res == 1)
247         return res;
248     }
249     break;
250   case DW_TAG_subroutine_type:
251     return -1;
252     break;
253   default:
254     XBT_VERB("Unknown case : %d", type->type);
255     break;
256   }
257
258   return 0;
259 }
260
261 static int compare_global_variables(mc_object_info_t object_info,
262                                     int process_index,
263                                     mc_mem_region_t r1,
264                                     mc_mem_region_t r2, mc_snapshot_t snapshot1,
265                                     mc_snapshot_t snapshot2)
266 {
267   xbt_assert(r1 && r2, "Missing region.");
268
269 #ifdef HAVE_SMPI
270   if (r1->storage_type() == simgrid::mc::StorageType::Privatized) {
271     xbt_assert(process_index >= 0);
272     if (r2->storage_type() != simgrid::mc::StorageType::Privatized) {
273       return 1;
274     }
275
276     size_t process_count = MC_smpi_process_count();
277     xbt_assert(process_count == r1->privatized_data().size()
278       && process_count == r2->privatized_data().size());
279
280     // Compare the global variables separately for each simulates process:
281     for (size_t process_index = 0; process_index < process_count; process_index++) {
282       int is_diff = compare_global_variables(object_info, process_index,
283         &r1->privatized_data()[process_index],
284         &r2->privatized_data()[process_index],
285         snapshot1, snapshot2);
286       if (is_diff) return 1;
287     }
288     return 0;
289   }
290 #else
291   xbt_assert(r1->storage_type() != simgrid::mc::StorageType::Privatized);
292 #endif
293   xbt_assert(r2->storage_type() != simgrid::mc::StorageType::Privatized);
294
295   struct mc_compare_state state;
296
297   xbt_dynar_t variables;
298   int res;
299   unsigned int cursor = 0;
300   mc_variable_t current_var;
301
302   variables = object_info->global_variables;
303
304   xbt_dynar_foreach(variables, cursor, current_var) {
305
306     // If the variable is not in this object, skip it:
307     // We do not expect to find a pointer to something which is not reachable
308     // by the global variables.
309     if ((char *) current_var->address < (char *) object_info->start_rw
310         || (char *) current_var->address > (char *) object_info->end_rw)
311       continue;
312
313     mc_type_t bvariable_type = current_var->type;
314     res =
315         compare_areas_with_type(state, process_index,
316                                 (char *) current_var->address, snapshot1, r1,
317                                 (char *) current_var->address, snapshot2, r2,
318                                 bvariable_type, 0);
319     if (res == 1) {
320       XBT_TRACE3(mc, global_diff, -1, -1, current_var->name);
321       XBT_VERB("Global variable %s (%p) is different between snapshots",
322                current_var->name.c_str(),
323                (char *) current_var->address);
324       return 1;
325     }
326
327   }
328
329   return 0;
330
331 }
332
333 static int compare_local_variables(int process_index,
334                                    mc_snapshot_t snapshot1,
335                                    mc_snapshot_t snapshot2,
336                                    mc_snapshot_stack_t stack1,
337                                    mc_snapshot_stack_t stack2)
338 {
339   struct mc_compare_state state;
340
341   if (stack1->local_variables.size() != stack2->local_variables.size()) {
342     XBT_VERB("Different number of local variables");
343     return 1;
344   } else {
345     unsigned int cursor = 0;
346     local_variable_t current_var1, current_var2;
347     int res;
348     while (cursor < stack1->local_variables.size()) {
349       current_var1 = &stack1->local_variables[cursor];
350       current_var2 = &stack1->local_variables[cursor];
351       if (current_var1->name != current_var2->name
352           || current_var1->subprogram != current_var1->subprogram
353           || current_var1->ip != current_var2->ip) {
354         // TODO, fix current_varX->subprogram->name to include name if DW_TAG_inlined_subprogram
355         XBT_VERB
356             ("Different name of variable (%s - %s) "
357              "or frame (%s - %s) or ip (%lu - %lu)",
358              current_var1->name.c_str(),
359              current_var2->name.c_str(),
360              current_var1->subprogram->name.c_str(),
361              current_var2->subprogram->name.c_str(),
362              current_var1->ip, current_var2->ip);
363         return 1;
364       }
365       // TODO, fix current_varX->subprogram->name to include name if DW_TAG_inlined_subprogram
366
367         mc_type_t subtype = current_var1->type;
368         res =
369             compare_areas_with_type(state, process_index,
370                                     current_var1->address, snapshot1, mc_get_snapshot_region(current_var1->address, snapshot1, process_index),
371                                     current_var2->address, snapshot2, mc_get_snapshot_region(current_var2->address, snapshot2, process_index),
372                                     subtype, 0);
373
374       if (res == 1) {
375         // TODO, fix current_varX->subprogram->name to include name if DW_TAG_inlined_subprogram
376         XBT_TRACE3(mc, local_diff, -1, -1, current_var1->name);
377         XBT_VERB
378             ("Local variable %s (%p - %p) in frame %s "
379              "is different between snapshots",
380              current_var1->name.c_str(),
381              current_var1->address,
382              current_var2->address,
383              current_var1->subprogram->name.c_str());
384         return res;
385       }
386       cursor++;
387     }
388     return 0;
389   }
390 }
391
392 int snapshot_compare(void *state1, void *state2)
393 {
394   mc_process_t process = &mc_model_checker->process();
395
396   mc_snapshot_t s1, s2;
397   int num1, num2;
398
399   if (_sg_mc_liveness) {        /* Liveness MC */
400     s1 = ((mc_visited_pair_t) state1)->graph_state->system_state;
401     s2 = ((mc_visited_pair_t) state2)->graph_state->system_state;
402     num1 = ((mc_visited_pair_t) state1)->num;
403     num2 = ((mc_visited_pair_t) state2)->num;
404   }else if (_sg_mc_termination) { /* Non-progressive cycle MC */
405     s1 = ((mc_state_t) state1)->system_state;
406     s2 = ((mc_state_t) state2)->system_state;
407     num1 = ((mc_state_t) state1)->num;
408     num2 = ((mc_state_t) state2)->num;
409   } else {                      /* Safety or comm determinism MC */
410     s1 = ((mc_visited_state_t) state1)->system_state;
411     s2 = ((mc_visited_state_t) state2)->system_state;
412     num1 = ((mc_visited_state_t) state1)->num;
413     num2 = ((mc_visited_state_t) state2)->num;
414   }
415
416   int errors = 0;
417   int res_init;
418
419   xbt_os_timer_t global_timer = xbt_os_timer_new();
420   xbt_os_timer_t timer = xbt_os_timer_new();
421
422   xbt_os_walltimer_start(global_timer);
423
424 #ifdef MC_DEBUG
425   xbt_os_walltimer_start(timer);
426 #endif
427
428   int hash_result = 0;
429   if (_sg_mc_hash) {
430     hash_result = (s1->hash != s2->hash);
431     if (hash_result) {
432       XBT_TRACE2(mc, hash_diff, num1, num2);
433       XBT_VERB("(%d - %d) Different hash : 0x%" PRIx64 "--0x%" PRIx64, num1,
434                num2, s1->hash, s2->hash);
435 #ifndef MC_DEBUG
436       return 1;
437 #endif
438     } else {
439       XBT_VERB("(%d - %d) Same hash : 0x%" PRIx64, num1, num2, s1->hash);
440     }
441   }
442
443   /* Compare enabled processes */
444   if (s1->enabled_processes != s2->enabled_processes) {
445       //XBT_TRACE3(mc, state_diff, num1, num2, "Different enabled processes");
446       XBT_VERB("(%d - %d) Different enabled processes", num1, num2);
447       // return 1; ??
448   }
449
450   unsigned long i = 0;
451   size_t size_used1, size_used2;
452   int is_diff = 0;
453
454   /* Compare size of stacks */
455   while (i < s1->stacks.size()) {
456     size_used1 = s1->stack_sizes[i];
457     size_used2 = s2->stack_sizes[i];
458     if (size_used1 != size_used2) {
459 #ifdef MC_DEBUG
460       if (is_diff == 0) {
461         xbt_os_walltimer_stop(timer);
462         mc_comp_times->stacks_sizes_comparison_time =
463             xbt_os_timer_elapsed(timer);
464       }
465       XBT_DEBUG("(%d - %d) Different size used in stacks : %zu - %zu", num1,
466                 num2, size_used1, size_used2);
467       errors++;
468       is_diff = 1;
469 #else
470 #ifdef MC_VERBOSE
471       XBT_VERB("(%d - %d) Different size used in stacks : %zu - %zu", num1,
472                num2, size_used1, size_used2);
473 #endif
474       XBT_TRACE3(mc, state_diff, num1, num2, "Different stack size");
475
476       xbt_os_walltimer_stop(timer);
477       xbt_os_timer_free(timer);
478       xbt_os_walltimer_stop(global_timer);
479       mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
480       xbt_os_timer_free(global_timer);
481
482       return 1;
483 #endif
484     }
485     i++;
486   }
487
488 #ifdef MC_DEBUG
489   if (is_diff == 0)
490     xbt_os_walltimer_stop(timer);
491   xbt_os_walltimer_start(timer);
492 #endif
493
494   /* Init heap information used in heap comparison algorithm */
495   xbt_mheap_t heap1 = (xbt_mheap_t)s1->read_bytes(
496     alloca(sizeof(struct mdesc)), sizeof(struct mdesc),
497     remote(process->heap_address),
498     simgrid::mc::ProcessIndexMissing, simgrid::mc::AddressSpace::Lazy);
499   xbt_mheap_t heap2 = (xbt_mheap_t)s2->read_bytes(
500     alloca(sizeof(struct mdesc)), sizeof(struct mdesc),
501     remote(process->heap_address),
502     simgrid::mc::ProcessIndexMissing, simgrid::mc::AddressSpace::Lazy);
503   res_init = init_heap_information(heap1, heap2, &s1->to_ignore, &s2->to_ignore);
504   if (res_init == -1) {
505 #ifdef MC_DEBUG
506     XBT_DEBUG("(%d - %d) Different heap information", num1, num2);
507     errors++;
508 #else
509 #ifdef MC_VERBOSE
510     XBT_TRACE3(mc, state_diff, num1, num2, "Different heap information");
511     XBT_VERB("(%d - %d) Different heap information", num1, num2);
512 #endif
513
514     xbt_os_walltimer_stop(global_timer);
515     mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
516     xbt_os_timer_free(global_timer);
517
518     return 1;
519 #endif
520   }
521 #ifdef MC_DEBUG
522   xbt_os_walltimer_start(timer);
523 #endif
524
525   /* Stacks comparison */
526   unsigned cursor = 0;
527   int diff_local = 0;
528 #ifdef MC_DEBUG
529   is_diff = 0;
530 #endif
531   mc_snapshot_stack_t stack1, stack2;
532   while (cursor < s1->stacks.size()) {
533     stack1 = &s1->stacks[cursor];
534     stack2 = &s1->stacks[cursor];
535
536     if (stack1->process_index != stack2->process_index) {
537       diff_local = 1;
538       XBT_DEBUG("(%d - %d) Stacks with different process index (%i vs %i)", num1, num2,
539         stack1->process_index, stack2->process_index);
540     }
541     else diff_local =
542         compare_local_variables(stack1->process_index, s1, s2, stack1, stack2);
543     if (diff_local > 0) {
544       XBT_TRACE3(mc, state_diff, num1, num2, "Different local variables");
545 #ifdef MC_DEBUG
546       if (is_diff == 0) {
547         xbt_os_walltimer_stop(timer);
548         mc_comp_times->stacks_comparison_time = xbt_os_timer_elapsed(timer);
549       }
550       XBT_DEBUG("(%d - %d) Different local variables between stacks %d", num1,
551                 num2, cursor + 1);
552       errors++;
553       is_diff = 1;
554 #else
555
556 #ifdef MC_VERBOSE
557       XBT_VERB("(%d - %d) Different local variables between stacks %d", num1,
558                num2, cursor + 1);
559 #endif
560
561       reset_heap_information();
562       xbt_os_walltimer_stop(timer);
563       xbt_os_timer_free(timer);
564       xbt_os_walltimer_stop(global_timer);
565       mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
566       xbt_os_timer_free(global_timer);
567
568       return 1;
569 #endif
570     }
571     cursor++;
572   }
573
574   size_t regions_count = s1->snapshot_regions.size();
575   // TODO, raise a difference instead?
576   xbt_assert(regions_count == s2->snapshot_regions.size());
577
578   mc_comp_times->global_variables_comparison_time = 0;
579
580   for (size_t k = 0; k != regions_count; ++k) {
581     mc_mem_region_t region1 = s1->snapshot_regions[k].get();
582     mc_mem_region_t region2 = s2->snapshot_regions[k].get();
583
584     // Preconditions:
585     if (region1->region_type() != simgrid::mc::RegionType::Data)
586       continue;
587
588     xbt_assert(region1->region_type() == region2->region_type());
589     xbt_assert(region1->object_info() == region2->object_info());
590     xbt_assert(region1->object_info());
591
592     const char* name = region1->object_info()->file_name;
593
594 #ifdef MC_DEBUG
595     if (is_diff == 0)
596       xbt_os_walltimer_stop(timer);
597     xbt_os_walltimer_start(timer);
598 #endif
599
600     /* Compare global variables */
601     is_diff =
602       compare_global_variables(region1->object_info(  ), simgrid::mc::AddressSpace::Normal,
603         region1, region2,
604         s1, s2);
605
606     if (is_diff != 0) {
607       XBT_TRACE3(mc, state_diff, num1, num2, "Different global variables");
608 #ifdef MC_DEBUG
609       xbt_os_walltimer_stop(timer);
610       mc_comp_times->global_variables_comparison_time
611         += xbt_os_timer_elapsed(timer);
612       XBT_DEBUG("(%d - %d) Different global variables in %s", num1, num2,
613                 name);
614       errors++;
615 #else
616 #ifdef MC_VERBOSE
617       XBT_VERB("(%d - %d) Different global variables in %s", num1, num2,
618                name);
619 #endif
620
621       reset_heap_information();
622       xbt_os_walltimer_stop(timer);
623       xbt_os_timer_free(timer);
624       xbt_os_walltimer_stop(global_timer);
625       mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
626       xbt_os_timer_free(global_timer);
627
628       return 1;
629 #endif
630     }
631   }
632
633 #ifdef MC_DEBUG
634   xbt_os_walltimer_start(timer);
635 #endif
636
637   /* Compare heap */
638   if (mmalloc_compare_heap(s1, s2) > 0) {
639     XBT_TRACE3(mc, state_diff, num1, num2, "Different heap");
640
641 #ifdef MC_DEBUG
642     xbt_os_walltimer_stop(timer);
643     mc_comp_times->heap_comparison_time = xbt_os_timer_elapsed(timer);
644     XBT_DEBUG("(%d - %d) Different heap (mmalloc_compare)", num1, num2);
645     errors++;
646 #else
647
648 #ifdef MC_VERBOSE
649     XBT_VERB("(%d - %d) Different heap (mmalloc_compare)", num1, num2);
650 #endif
651
652     reset_heap_information();
653     xbt_os_walltimer_stop(timer);
654     xbt_os_timer_free(timer);
655     xbt_os_walltimer_stop(global_timer);
656     mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
657     xbt_os_timer_free(global_timer);
658
659     return 1;
660 #endif
661   } else {
662 #ifdef MC_DEBUG
663     xbt_os_walltimer_stop(timer);
664 #endif
665   }
666
667   reset_heap_information();
668
669   xbt_os_walltimer_stop(timer);
670   xbt_os_timer_free(timer);
671
672 #ifdef MC_VERBOSE
673   xbt_os_walltimer_stop(global_timer);
674   mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
675 #endif
676
677   xbt_os_timer_free(global_timer);
678
679 #ifdef MC_DEBUG
680   print_comparison_times();
681 #endif
682
683 #ifdef MC_VERBOSE
684   if (errors || hash_result)
685     XBT_VERB("(%d - %d) Difference found", num1, num2);
686   else
687     XBT_VERB("(%d - %d) No difference found", num1, num2);
688 #endif
689
690 #if defined(MC_DEBUG) && defined(MC_VERBOSE)
691   if (_sg_mc_hash) {
692     // * false positive SHOULD be avoided.
693     // * There MUST not be any false negative.
694
695     XBT_VERB("(%d - %d) State equality hash test is %s %s", num1, num2,
696              (hash_result != 0) == (errors != 0) ? "true" : "false",
697              !hash_result ? "positive" : "negative");
698   }
699 #endif
700
701   return errors > 0 || hash_result;
702
703 }
704
705 /***************************** Statistics *****************************/
706 /*******************************************************************/
707
708 void print_comparison_times()
709 {
710   XBT_DEBUG("*** Comparison times ***");
711   XBT_DEBUG("- Nb processes : %f", mc_comp_times->nb_processes_comparison_time);
712   XBT_DEBUG("- Nb bytes used : %f", mc_comp_times->bytes_used_comparison_time);
713   XBT_DEBUG("- Stacks sizes : %f", mc_comp_times->stacks_sizes_comparison_time);
714   XBT_DEBUG("- GLobal variables : %f", mc_comp_times->global_variables_comparison_time);
715   XBT_DEBUG("- Heap : %f", mc_comp_times->heap_comparison_time);
716   XBT_DEBUG("- Stacks : %f", mc_comp_times->stacks_comparison_time);
717 }
718
719 }