X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/a69dbf9a2522d0ccde10350b49c5866ed9d731bd..e3f5ca3fd3726e67046afbd03e48e9cd7294b835:/src/mc/mc_compare.cpp diff --git a/src/mc/mc_compare.cpp b/src/mc/mc_compare.cpp index 1f7814aa63..ca13c3e002 100644 --- a/src/mc/mc_compare.cpp +++ b/src/mc/mc_compare.cpp @@ -9,6 +9,9 @@ #include #include "internal_config.h" +#include "mc_object_info.h" +#include "mc_safety.h" +#include "mc_liveness.h" #include "mc_private.h" #ifdef HAVE_SMPI @@ -18,6 +21,8 @@ #include "xbt/mmalloc.h" #include "xbt/mmalloc/mmprivate.h" +#include + XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_compare, mc, "Logging specific to mc_compare"); @@ -255,6 +260,32 @@ static int compare_global_variables(mc_object_info_t object_info, mc_snapshot_t snapshot2) { xbt_assert(r1 && r2, "Missing region."); + +#ifdef HAVE_SMPI + if (r1->storage_type == MC_REGION_STORAGE_TYPE_PRIVATIZED) { + xbt_assert(process_index >= 0); + if (r2->storage_type != MC_REGION_STORAGE_TYPE_PRIVATIZED) { + return 1; + } + + size_t process_count = smpi_process_count(); + xbt_assert(process_count == r1->privatized.regions_count + && process_count == r2->privatized.regions_count); + + // Compare the global variables separately for each simulates process: + for (size_t process_index = 0; process_index < process_count; process_index++) { + int is_diff = compare_global_variables(object_info, process_index, + r1->privatized.regions[process_index], r2->privatized.regions[process_index], + snapshot1, snapshot2); + if (is_diff) return 1; + } + return 0; + } +#else + xbt_assert(r1->storage_type != MC_REGION_STORAGE_TYPE_PRIVATIZED); +#endif + xbt_assert(r2->storage_type != MC_REGION_STORAGE_TYPE_PRIVATIZED); + struct mc_compare_state state; xbt_dynar_t variables; @@ -280,6 +311,7 @@ static int compare_global_variables(mc_object_info_t object_info, (char *) current_var->address, snapshot2, r2, bvariable_type, 0); if (res == 1) { + XBT_TRACE3(mc, global_diff, -1, -1, current_var->name); XBT_VERB("Global variable %s (%p) is different between snapshots", current_var->name, (char *) current_var->address); return 1; @@ -336,6 +368,7 @@ static int compare_local_variables(int process_index, if (res == 1) { // TODO, fix current_varX->subprogram->name to include name if DW_TAG_inlined_subprogram + XBT_TRACE3(mc, local_diff, -1, -1, current_var1->name); XBT_VERB ("Local variable %s (%p - %p) in frame %s is different between snapshots", current_var1->name, current_var1->address, current_var2->address, @@ -350,7 +383,6 @@ static int compare_local_variables(int process_index, int snapshot_compare(void *state1, void *state2) { - mc_snapshot_t s1, s2; int num1, num2; @@ -382,6 +414,7 @@ int snapshot_compare(void *state1, void *state2) if (_sg_mc_hash) { hash_result = (s1->hash != s2->hash); if (hash_result) { + XBT_TRACE2(mc, hash_diff, num1, num2); XBT_VERB("(%d - %d) Different hash : 0x%" PRIx64 "--0x%" PRIx64, num1, num2, s1->hash, s2->hash); #ifndef MC_DEBUG @@ -396,8 +429,11 @@ int snapshot_compare(void *state1, void *state2) unsigned int cursor; int pid; xbt_dynar_foreach(s1->enabled_processes, cursor, pid){ - if(!xbt_dynar_member(s2->enabled_processes, &pid)) + if(!xbt_dynar_member(s2->enabled_processes, &pid)) { + //XBT_TRACE3(mc, state_diff, num1, num2, "Different enabled processes"); XBT_VERB("(%d - %d) Different enabled processes", num1, num2); + // return 1; ?? + } } unsigned long i = 0; @@ -424,6 +460,7 @@ int snapshot_compare(void *state1, void *state2) XBT_VERB("(%d - %d) Different size used in stacks : %zu - %zu", num1, num2, size_used1, size_used2); #endif + XBT_TRACE3(mc, state_diff, num1, num2, "Different stack size"); xbt_os_walltimer_stop(timer); xbt_os_timer_free(timer); @@ -455,6 +492,7 @@ int snapshot_compare(void *state1, void *state2) errors++; #else #ifdef MC_VERBOSE + XBT_TRACE3(mc, state_diff, num1, num2, "Different heap information"); XBT_VERB("(%d - %d) Different heap information", num1, num2); #endif @@ -492,6 +530,7 @@ int snapshot_compare(void *state1, void *state2) else diff_local = compare_local_variables(stack1->process_index, s1, s2, stack1, stack2); if (diff_local > 0) { + XBT_TRACE3(mc, state_diff, num1, num2, "Different local variables"); #ifdef MC_DEBUG if (is_diff == 0) { xbt_os_walltimer_stop(timer); @@ -532,10 +571,22 @@ int snapshot_compare(void *state1, void *state2) }; #endif - mc_object_info_t object_infos[] = { NULL, mc_libsimgrid_info, mc_binary_info }; + size_t regions_count = s1->snapshot_regions_count; + // TODO, raise a difference instead? + xbt_assert(regions_count == s2->snapshot_regions_count); + + for (size_t k = 0; k != regions_count; ++k) { + mc_mem_region_t region1 = s1->snapshot_regions[k]; + mc_mem_region_t region2 = s2->snapshot_regions[k]; + + // Preconditions: + if (region1->region_type != MC_REGION_TYPE_DATA) + continue; - int k = 0; - for (k = 2; k != 0; --k) { + xbt_assert(region1->region_type == region2->region_type); + xbt_assert(region1->object_info == region2->object_info); + + xbt_assert(region1->object_info); #ifdef MC_DEBUG if (is_diff == 0) xbt_os_walltimer_stop(timer); @@ -543,22 +594,13 @@ int snapshot_compare(void *state1, void *state2) #endif /* Compare global variables */ -#ifdef HAVE_SMPI - if (object_infos[k] == mc_binary_info && smpi_privatize_global_variables) { - // Compare the global variables separately for each simulates process: - for (int process_index = 0; process_index < smpi_process_count(); process_index++) { - is_diff = - compare_global_variables(object_infos[k], process_index, - s1->privatization_regions[process_index], s2->privatization_regions[process_index], s1, s2); - if (is_diff) break; - } - } - else -#endif - is_diff = - compare_global_variables(object_infos[k], MC_NO_PROCESS_INDEX, s1->regions[k], s2->regions[k], s1, s2); + is_diff = + compare_global_variables(region1->object_info, MC_NO_PROCESS_INDEX, + region1, region2, + s1, s2); if (is_diff != 0) { + XBT_TRACE3(mc, state_diff, num1, num2, "Different global variables"); #ifdef MC_DEBUG xbt_os_walltimer_stop(timer); *times[k] = xbt_os_timer_elapsed(timer); @@ -589,6 +631,7 @@ int snapshot_compare(void *state1, void *state2) /* Compare heap */ if (mmalloc_compare_heap(s1, s2) > 0) { + XBT_TRACE3(mc, state_diff, num1, num2, "Different heap"); #ifdef MC_DEBUG xbt_os_walltimer_stop(timer);