X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/fc90483d87af7c41aa3dabc00a43585c6ea928e0..5ff134b7494ccde579f32d4db4cbf5ea4db0bf3f:/src/mc/mc_checkpoint.c diff --git a/src/mc/mc_checkpoint.c b/src/mc/mc_checkpoint.c index 3cfa351e16..9360df8983 100644 --- a/src/mc/mc_checkpoint.c +++ b/src/mc/mc_checkpoint.c @@ -7,6 +7,10 @@ #include "mc_private.h" #include "xbt/module.h" +#include "../simix/smx_private.h" + +#include + XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_checkpoint, mc, "Logging specific to mc_checkpoint"); @@ -20,8 +24,10 @@ static void MC_region_destroy(mc_mem_region_t reg); static void MC_snapshot_add_region(mc_snapshot_t snapshot, int type, void *start_addr, size_t size); -static int data_program_region_compare(void *d1, void *d2, size_t size); -static int data_libsimgrid_region_compare(void *d1, void *d2, size_t size); +static void add_value(xbt_dynar_t *list, const char *type, unsigned long int val); +static xbt_dynar_t take_snapshot_stacks(void *heap); +static void get_local_variables_values(xbt_dynar_t *all_variables, stack_region_t stack, void *heap); +static void print_local_variables_values(xbt_dynar_t all_variables); static mc_mem_region_t MC_region_new(int type, void *start_addr, size_t size) { @@ -94,6 +100,7 @@ void MC_take_snapshot_liveness(mc_snapshot_t snapshot) s_map_region_t reg; memory_map_t maps = get_memory_map(); int nb_reg = 0; + void *heap = NULL; /* Save the std heap and the writable mapped pages of libsimgrid */ while (i < maps->mapsize && nb_reg < 3) { @@ -102,6 +109,7 @@ void MC_take_snapshot_liveness(mc_snapshot_t snapshot) if (maps->regions[i].pathname == NULL){ if (reg.start_addr == std_heap){ // only save the std heap (and not the raw one) MC_snapshot_add_region(snapshot, 0, reg.start_addr, (char*)reg.end_addr - (char*)reg.start_addr); + heap = snapshot->regions[nb_reg]->data; nb_reg++; } } else { @@ -125,6 +133,8 @@ void MC_take_snapshot_liveness(mc_snapshot_t snapshot) } i++; } + + snapshot->stacks = take_snapshot_stacks(heap); free_memory_map(maps); @@ -179,6 +189,7 @@ static int data_libsimgrid_region_compare(void *d1, void *d2, size_t size){ continue; }else{ XBT_DEBUG("Different byte (offset=%zu) (%p - %p) in data libsimgrid region", i, (char *)d1 + i, (char *)d2 + i); + XBT_DEBUG("Addresses pointed : %p - %p\n", addr_pointed1, addr_pointed2); distance++; } } @@ -189,9 +200,30 @@ static int data_libsimgrid_region_compare(void *d1, void *d2, size_t size){ return distance; } +static int heap_region_compare(void *d1, void *d2, size_t size); + +static int heap_region_compare(void *d1, void *d2, size_t size){ + + int distance = 0; + size_t i = 0; + + for(i=0; inum_reg != s2->num_reg){ XBT_DEBUG("Different num_reg (s1 = %u, s2 = %u)", s1->num_reg, s2->num_reg); @@ -220,6 +252,14 @@ int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2){ XBT_DEBUG("Different heap (mmalloc_compare)"); errors++; } + /*if(heap_region_compare(s1->regions[i]->data, s2->regions[i]->data, s1->regions[i]->size) != 0){ + XBT_DEBUG("Different memcmp for heap"); + errors++; + }*/ + /*if((dist = mmalloc_linear_compare_heap((xbt_mheap_t)s1->regions[i]->data, (xbt_mheap_t)s2->regions[i]->data)) > 0){ + XBT_DEBUG("Different heap (mmalloc_linear_compare) : %d", dist); + errors++; + }*/ break; case 1 : /* Compare data libsimgrid region */ @@ -275,16 +315,15 @@ void get_plt_section(){ char *lfields[7]; int i, plt_not_found = 1; unsigned long int size, offset; - - char command[512]; - sprintf(command, "objdump --section-headers %s", libsimgrid_path); + + char *command = bprintf( "objdump --section-headers %s", libsimgrid_path); fp = popen(command, "r"); if(fp == NULL) perror("popen failed"); - while ((read = getline(&line, &n, fp)) != -1 && plt_not_found) { + while ((read = getline(&line, &n, fp)) != -1 && plt_not_found == 1) { if(n == 0) continue; @@ -310,7 +349,6 @@ void get_plt_section(){ offset = strtoul(lfields[4], NULL, 16); start_plt = (char *)start_text_libsimgrid + offset; end_plt = (char *)start_plt + size; - fprintf(stderr, ".plt section : %p - %p \n", start_plt, end_plt); plt_not_found = 0; } } @@ -318,6 +356,7 @@ void get_plt_section(){ } + free(command); free(line); pclose(fp);