Logo AND Algorithmique Numérique Distribuée

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