Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Make type_is an integer instead of a string and use std:: containers
[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)
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   std::vector<simgrid::mc::Variable>& variables = object_info->global_variables;
298
299   for (simgrid::mc::Variable& current_var : variables) {
300
301     // If the variable is not in this object, skip it:
302     // We do not expect to find a pointer to something which is not reachable
303     // by the global variables.
304     if ((char *) current_var.address < (char *) object_info->start_rw
305         || (char *) current_var.address > (char *) object_info->end_rw)
306       continue;
307
308     mc_type_t bvariable_type = current_var.type;
309     int res =
310         compare_areas_with_type(state, process_index,
311                                 (char *) current_var.address, snapshot1, r1,
312                                 (char *) current_var.address, snapshot2, r2,
313                                 bvariable_type, 0);
314     if (res == 1) {
315       XBT_TRACE3(mc, global_diff, -1, -1, current_var->name);
316       XBT_VERB("Global variable %s (%p) is different between snapshots",
317                current_var.name.c_str(),
318                (char *) current_var.address);
319       return 1;
320     }
321
322   }
323
324   return 0;
325
326 }
327
328 static int compare_local_variables(int process_index,
329                                    mc_snapshot_t snapshot1,
330                                    mc_snapshot_t snapshot2,
331                                    mc_snapshot_stack_t stack1,
332                                    mc_snapshot_stack_t stack2)
333 {
334   struct mc_compare_state state;
335
336   if (stack1->local_variables.size() != stack2->local_variables.size()) {
337     XBT_VERB("Different number of local variables");
338     return 1;
339   } else {
340     unsigned int cursor = 0;
341     local_variable_t current_var1, current_var2;
342     int res;
343     while (cursor < stack1->local_variables.size()) {
344       current_var1 = &stack1->local_variables[cursor];
345       current_var2 = &stack1->local_variables[cursor];
346       if (current_var1->name != current_var2->name
347           || current_var1->subprogram != current_var1->subprogram
348           || current_var1->ip != current_var2->ip) {
349         // TODO, fix current_varX->subprogram->name to include name if DW_TAG_inlined_subprogram
350         XBT_VERB
351             ("Different name of variable (%s - %s) "
352              "or frame (%s - %s) or ip (%lu - %lu)",
353              current_var1->name.c_str(),
354              current_var2->name.c_str(),
355              current_var1->subprogram->name.c_str(),
356              current_var2->subprogram->name.c_str(),
357              current_var1->ip, current_var2->ip);
358         return 1;
359       }
360       // TODO, fix current_varX->subprogram->name to include name if DW_TAG_inlined_subprogram
361
362         mc_type_t subtype = current_var1->type;
363         res =
364             compare_areas_with_type(state, process_index,
365                                     current_var1->address, snapshot1, mc_get_snapshot_region(current_var1->address, snapshot1, process_index),
366                                     current_var2->address, snapshot2, mc_get_snapshot_region(current_var2->address, snapshot2, process_index),
367                                     subtype, 0);
368
369       if (res == 1) {
370         // TODO, fix current_varX->subprogram->name to include name if DW_TAG_inlined_subprogram
371         XBT_TRACE3(mc, local_diff, -1, -1, current_var1->name);
372         XBT_VERB
373             ("Local variable %s (%p - %p) in frame %s "
374              "is different between snapshots",
375              current_var1->name.c_str(),
376              current_var1->address,
377              current_var2->address,
378              current_var1->subprogram->name.c_str());
379         return res;
380       }
381       cursor++;
382     }
383     return 0;
384   }
385 }
386
387 int snapshot_compare(void *state1, void *state2)
388 {
389   mc_process_t process = &mc_model_checker->process();
390
391   mc_snapshot_t s1, s2;
392   int num1, num2;
393
394   if (_sg_mc_liveness) {        /* Liveness MC */
395     s1 = ((mc_visited_pair_t) state1)->graph_state->system_state;
396     s2 = ((mc_visited_pair_t) state2)->graph_state->system_state;
397     num1 = ((mc_visited_pair_t) state1)->num;
398     num2 = ((mc_visited_pair_t) state2)->num;
399   }else if (_sg_mc_termination) { /* Non-progressive cycle MC */
400     s1 = ((mc_state_t) state1)->system_state;
401     s2 = ((mc_state_t) state2)->system_state;
402     num1 = ((mc_state_t) state1)->num;
403     num2 = ((mc_state_t) state2)->num;
404   } else {                      /* Safety or comm determinism MC */
405     s1 = ((mc_visited_state_t) state1)->system_state;
406     s2 = ((mc_visited_state_t) state2)->system_state;
407     num1 = ((mc_visited_state_t) state1)->num;
408     num2 = ((mc_visited_state_t) state2)->num;
409   }
410
411   int errors = 0;
412   int res_init;
413
414   xbt_os_timer_t global_timer = xbt_os_timer_new();
415   xbt_os_timer_t timer = xbt_os_timer_new();
416
417   xbt_os_walltimer_start(global_timer);
418
419 #ifdef MC_DEBUG
420   xbt_os_walltimer_start(timer);
421 #endif
422
423   int hash_result = 0;
424   if (_sg_mc_hash) {
425     hash_result = (s1->hash != s2->hash);
426     if (hash_result) {
427       XBT_TRACE2(mc, hash_diff, num1, num2);
428       XBT_VERB("(%d - %d) Different hash : 0x%" PRIx64 "--0x%" PRIx64, num1,
429                num2, s1->hash, s2->hash);
430 #ifndef MC_DEBUG
431       return 1;
432 #endif
433     } else {
434       XBT_VERB("(%d - %d) Same hash : 0x%" PRIx64, num1, num2, s1->hash);
435     }
436   }
437
438   /* Compare enabled processes */
439   if (s1->enabled_processes != s2->enabled_processes) {
440       //XBT_TRACE3(mc, state_diff, num1, num2, "Different enabled processes");
441       XBT_VERB("(%d - %d) Different enabled processes", num1, num2);
442       // return 1; ??
443   }
444
445   unsigned long i = 0;
446   size_t size_used1, size_used2;
447   int is_diff = 0;
448
449   /* Compare size of stacks */
450   while (i < s1->stacks.size()) {
451     size_used1 = s1->stack_sizes[i];
452     size_used2 = s2->stack_sizes[i];
453     if (size_used1 != size_used2) {
454 #ifdef MC_DEBUG
455       if (is_diff == 0) {
456         xbt_os_walltimer_stop(timer);
457         mc_comp_times->stacks_sizes_comparison_time =
458             xbt_os_timer_elapsed(timer);
459       }
460       XBT_DEBUG("(%d - %d) Different size used in stacks : %zu - %zu", num1,
461                 num2, size_used1, size_used2);
462       errors++;
463       is_diff = 1;
464 #else
465 #ifdef MC_VERBOSE
466       XBT_VERB("(%d - %d) Different size used in stacks : %zu - %zu", num1,
467                num2, size_used1, size_used2);
468 #endif
469       XBT_TRACE3(mc, state_diff, num1, num2, "Different stack size");
470
471       xbt_os_walltimer_stop(timer);
472       xbt_os_timer_free(timer);
473       xbt_os_walltimer_stop(global_timer);
474       mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
475       xbt_os_timer_free(global_timer);
476
477       return 1;
478 #endif
479     }
480     i++;
481   }
482
483 #ifdef MC_DEBUG
484   if (is_diff == 0)
485     xbt_os_walltimer_stop(timer);
486   xbt_os_walltimer_start(timer);
487 #endif
488
489   /* Init heap information used in heap comparison algorithm */
490   xbt_mheap_t heap1 = (xbt_mheap_t)s1->read_bytes(
491     alloca(sizeof(struct mdesc)), sizeof(struct mdesc),
492     remote(process->heap_address),
493     simgrid::mc::ProcessIndexMissing, simgrid::mc::AddressSpace::Lazy);
494   xbt_mheap_t heap2 = (xbt_mheap_t)s2->read_bytes(
495     alloca(sizeof(struct mdesc)), sizeof(struct mdesc),
496     remote(process->heap_address),
497     simgrid::mc::ProcessIndexMissing, simgrid::mc::AddressSpace::Lazy);
498   res_init = init_heap_information(heap1, heap2, &s1->to_ignore, &s2->to_ignore);
499   if (res_init == -1) {
500 #ifdef MC_DEBUG
501     XBT_DEBUG("(%d - %d) Different heap information", num1, num2);
502     errors++;
503 #else
504 #ifdef MC_VERBOSE
505     XBT_TRACE3(mc, state_diff, num1, num2, "Different heap information");
506     XBT_VERB("(%d - %d) Different heap information", num1, num2);
507 #endif
508
509     xbt_os_walltimer_stop(global_timer);
510     mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
511     xbt_os_timer_free(global_timer);
512
513     return 1;
514 #endif
515   }
516 #ifdef MC_DEBUG
517   xbt_os_walltimer_start(timer);
518 #endif
519
520   /* Stacks comparison */
521   unsigned cursor = 0;
522   int diff_local = 0;
523 #ifdef MC_DEBUG
524   is_diff = 0;
525 #endif
526   mc_snapshot_stack_t stack1, stack2;
527   while (cursor < s1->stacks.size()) {
528     stack1 = &s1->stacks[cursor];
529     stack2 = &s1->stacks[cursor];
530
531     if (stack1->process_index != stack2->process_index) {
532       diff_local = 1;
533       XBT_DEBUG("(%d - %d) Stacks with different process index (%i vs %i)", num1, num2,
534         stack1->process_index, stack2->process_index);
535     }
536     else diff_local =
537         compare_local_variables(stack1->process_index, s1, s2, stack1, stack2);
538     if (diff_local > 0) {
539       XBT_TRACE3(mc, state_diff, num1, num2, "Different local variables");
540 #ifdef MC_DEBUG
541       if (is_diff == 0) {
542         xbt_os_walltimer_stop(timer);
543         mc_comp_times->stacks_comparison_time = xbt_os_timer_elapsed(timer);
544       }
545       XBT_DEBUG("(%d - %d) Different local variables between stacks %d", num1,
546                 num2, cursor + 1);
547       errors++;
548       is_diff = 1;
549 #else
550
551 #ifdef MC_VERBOSE
552       XBT_VERB("(%d - %d) Different local variables between stacks %d", num1,
553                num2, cursor + 1);
554 #endif
555
556       reset_heap_information();
557       xbt_os_walltimer_stop(timer);
558       xbt_os_timer_free(timer);
559       xbt_os_walltimer_stop(global_timer);
560       mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
561       xbt_os_timer_free(global_timer);
562
563       return 1;
564 #endif
565     }
566     cursor++;
567   }
568
569   size_t regions_count = s1->snapshot_regions.size();
570   // TODO, raise a difference instead?
571   xbt_assert(regions_count == s2->snapshot_regions.size());
572
573   mc_comp_times->global_variables_comparison_time = 0;
574
575   for (size_t k = 0; k != regions_count; ++k) {
576     mc_mem_region_t region1 = s1->snapshot_regions[k].get();
577     mc_mem_region_t region2 = s2->snapshot_regions[k].get();
578
579     // Preconditions:
580     if (region1->region_type() != simgrid::mc::RegionType::Data)
581       continue;
582
583     xbt_assert(region1->region_type() == region2->region_type());
584     xbt_assert(region1->object_info() == region2->object_info());
585     xbt_assert(region1->object_info());
586
587     const char* name = region1->object_info()->file_name;
588
589 #ifdef MC_DEBUG
590     if (is_diff == 0)
591       xbt_os_walltimer_stop(timer);
592     xbt_os_walltimer_start(timer);
593 #endif
594
595     /* Compare global variables */
596     is_diff =
597       compare_global_variables(region1->object_info(  ), simgrid::mc::AddressSpace::Normal,
598         region1, region2,
599         s1, s2);
600
601     if (is_diff != 0) {
602       XBT_TRACE3(mc, state_diff, num1, num2, "Different global variables");
603 #ifdef MC_DEBUG
604       xbt_os_walltimer_stop(timer);
605       mc_comp_times->global_variables_comparison_time
606         += xbt_os_timer_elapsed(timer);
607       XBT_DEBUG("(%d - %d) Different global variables in %s", num1, num2,
608                 name);
609       errors++;
610 #else
611 #ifdef MC_VERBOSE
612       XBT_VERB("(%d - %d) Different global variables in %s", num1, num2,
613                name);
614 #endif
615
616       reset_heap_information();
617       xbt_os_walltimer_stop(timer);
618       xbt_os_timer_free(timer);
619       xbt_os_walltimer_stop(global_timer);
620       mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
621       xbt_os_timer_free(global_timer);
622
623       return 1;
624 #endif
625     }
626   }
627
628 #ifdef MC_DEBUG
629   xbt_os_walltimer_start(timer);
630 #endif
631
632   /* Compare heap */
633   if (mmalloc_compare_heap(s1, s2) > 0) {
634     XBT_TRACE3(mc, state_diff, num1, num2, "Different heap");
635
636 #ifdef MC_DEBUG
637     xbt_os_walltimer_stop(timer);
638     mc_comp_times->heap_comparison_time = xbt_os_timer_elapsed(timer);
639     XBT_DEBUG("(%d - %d) Different heap (mmalloc_compare)", num1, num2);
640     errors++;
641 #else
642
643 #ifdef MC_VERBOSE
644     XBT_VERB("(%d - %d) Different heap (mmalloc_compare)", num1, num2);
645 #endif
646
647     reset_heap_information();
648     xbt_os_walltimer_stop(timer);
649     xbt_os_timer_free(timer);
650     xbt_os_walltimer_stop(global_timer);
651     mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
652     xbt_os_timer_free(global_timer);
653
654     return 1;
655 #endif
656   } else {
657 #ifdef MC_DEBUG
658     xbt_os_walltimer_stop(timer);
659 #endif
660   }
661
662   reset_heap_information();
663
664   xbt_os_walltimer_stop(timer);
665   xbt_os_timer_free(timer);
666
667 #ifdef MC_VERBOSE
668   xbt_os_walltimer_stop(global_timer);
669   mc_snapshot_comparison_time = xbt_os_timer_elapsed(global_timer);
670 #endif
671
672   xbt_os_timer_free(global_timer);
673
674 #ifdef MC_DEBUG
675   print_comparison_times();
676 #endif
677
678 #ifdef MC_VERBOSE
679   if (errors || hash_result)
680     XBT_VERB("(%d - %d) Difference found", num1, num2);
681   else
682     XBT_VERB("(%d - %d) No difference found", num1, num2);
683 #endif
684
685 #if defined(MC_DEBUG) && defined(MC_VERBOSE)
686   if (_sg_mc_hash) {
687     // * false positive SHOULD be avoided.
688     // * There MUST not be any false negative.
689
690     XBT_VERB("(%d - %d) State equality hash test is %s %s", num1, num2,
691              (hash_result != 0) == (errors != 0) ? "true" : "false",
692              !hash_result ? "positive" : "negative");
693   }
694 #endif
695
696   return errors > 0 || hash_result;
697
698 }
699
700 /***************************** Statistics *****************************/
701 /*******************************************************************/
702
703 void print_comparison_times()
704 {
705   XBT_DEBUG("*** Comparison times ***");
706   XBT_DEBUG("- Nb processes : %f", mc_comp_times->nb_processes_comparison_time);
707   XBT_DEBUG("- Nb bytes used : %f", mc_comp_times->bytes_used_comparison_time);
708   XBT_DEBUG("- Stacks sizes : %f", mc_comp_times->stacks_sizes_comparison_time);
709   XBT_DEBUG("- GLobal variables : %f", mc_comp_times->global_variables_comparison_time);
710   XBT_DEBUG("- Heap : %f", mc_comp_times->heap_comparison_time);
711   XBT_DEBUG("- Stacks : %f", mc_comp_times->stacks_comparison_time);
712 }
713
714 }