Logo AND Algorithmique Numérique Distribuée

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