X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/c882e24932c718fad85c22cb546f30e158f1b31d..7aa52bfbfe54f5be7c01add5ee242ee4c03b7e4e:/src/mc/mc_checkpoint.c diff --git a/src/mc/mc_checkpoint.c b/src/mc/mc_checkpoint.c index 4af29d3447..904d127896 100644 --- a/src/mc/mc_checkpoint.c +++ b/src/mc/mc_checkpoint.c @@ -16,7 +16,9 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_checkpoint, mc, void *start_text_libsimgrid; void *start_plt_libsimgrid, *end_plt_libsimgrid; +void *start_got_plt_libsimgrid, *end_got_plt_libsimgrid; void *start_plt_binary, *end_plt_binary; +void *start_got_plt_binary, *end_got_plt_binary; char *libsimgrid_path; void *start_data_libsimgrid, *start_bss_libsimgrid; void *start_data_binary, *start_bss_binary; @@ -76,43 +78,6 @@ static void MC_snapshot_add_region(mc_snapshot_t snapshot, int type, void *start return; } -/* void MC_take_snapshot(mc_snapshot_t snapshot) */ -/* { */ -/* unsigned int i = 0; */ -/* s_map_region_t reg; */ -/* memory_map_t maps = get_memory_map(); */ - -/* /\* Save the std heap and the writable mapped pages of libsimgrid *\/ */ -/* while (i < maps->mapsize) { */ -/* reg = maps->regions[i]; */ -/* if ((reg.prot & PROT_WRITE)){ */ -/* 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); */ -/* } */ -/* i++; */ -/* } else { */ -/* if (!memcmp(basename(maps->regions[i].pathname), "libsimgrid", 10)){ */ -/* MC_snapshot_add_region(snapshot, 1, reg.start_addr, (char*)reg.end_addr - (char*)reg.start_addr); */ -/* i++; */ -/* reg = maps->regions[i]; */ -/* while(reg.pathname == NULL && (reg.prot & PROT_WRITE) && i < maps->mapsize){ */ -/* MC_snapshot_add_region(snapshot, 1, reg.start_addr, (char*)reg.end_addr - (char*)reg.start_addr); */ -/* i++; */ -/* reg = maps->regions[i]; */ -/* } */ -/* }else{ */ -/* i++; */ -/* } */ -/* } */ -/* }else{ */ -/* i++; */ -/* } */ -/* } */ - -/* free_memory_map(maps); */ -/* } */ - void MC_init_memory_map_info(){ int raw_mem_set = (mmalloc_get_current_heap() == raw_heap); @@ -147,7 +112,7 @@ void MC_init_memory_map_info(){ } } } - }else if ((reg.prot & PROT_READ)){ + }else if ((reg.prot & PROT_READ) && (reg.prot & PROT_EXEC)){ if (maps->regions[i].pathname != NULL){ if (!memcmp(basename(maps->regions[i].pathname), "libsimgrid", 10)){ start_text_libsimgrid = reg.start_addr; @@ -189,6 +154,8 @@ mc_snapshot_t MC_take_snapshot() memory_map_t maps = get_memory_map(); int nb_reg = 0; void *heap = NULL; + size_t size = 0; + void *start = NULL; /* Save the std heap and the writable mapped pages of libsimgrid */ while (i < maps->mapsize) { @@ -205,17 +172,18 @@ mc_snapshot_t MC_take_snapshot() i++; } else { if (!memcmp(basename(maps->regions[i].pathname), "libsimgrid", 10)){ - MC_snapshot_add_region(snapshot, 1, reg.start_addr, (char*)reg.end_addr - (char*)reg.start_addr); - start_data_libsimgrid = reg.start_addr; + size = (char*)reg.end_addr - (char*)reg.start_addr; + start = reg.start_addr; nb_reg++; i++; reg = maps->regions[i]; if(reg.pathname == NULL && (reg.prot & PROT_WRITE) && i < maps->mapsize){ - MC_snapshot_add_region(snapshot, 1, reg.start_addr, (char*)reg.end_addr - (char*)reg.start_addr); + size += (char*)reg.end_addr - (char*)reg.start_addr; reg = maps->regions[i]; i++; nb_reg++; } + MC_snapshot_add_region(snapshot, 1, start, size); } else { if (!memcmp(basename(maps->regions[i].pathname), basename(xbt_binary_name), strlen(basename(xbt_binary_name)))){ MC_snapshot_add_region(snapshot, 2, reg.start_addr, (char*)reg.end_addr - (char*)reg.start_addr); @@ -232,24 +200,12 @@ mc_snapshot_t MC_take_snapshot() } } } - }else if ((reg.prot & PROT_READ)){ - if (maps->regions[i].pathname != NULL){ - if (!memcmp(basename(maps->regions[i].pathname), "libsimgrid", 10)){ - start_text_libsimgrid = reg.start_addr; - libsimgrid_path = strdup(maps->regions[i].pathname); - }else{ - if (!memcmp(basename(maps->regions[i].pathname), basename(xbt_binary_name), strlen(basename(xbt_binary_name)))){ - start_text_binary = reg.start_addr; - } - } - } - i++; }else{ i++; } } - if(_surf_mc_visited > 0 || strcmp(_surf_mc_property_file,"")) + if(_sg_mc_visited > 0 || strcmp(_sg_mc_property_file,"")) snapshot->stacks = take_snapshot_stacks(heap); free_memory_map(maps); @@ -291,12 +247,9 @@ void get_libsimgrid_plt_section(){ size_t n = 0; /* Amount of bytes to read by getline */ char *lfields[7]; - int i, plt_not_found = 1; + int i, plt_found = 0; unsigned long int size, offset; - if(libsimgrid_path == NULL) - libsimgrid_path = get_libsimgrid_path(); - char *command = bprintf("objdump --section-headers %s", libsimgrid_path); fp = popen(command, "r"); @@ -306,7 +259,7 @@ void get_libsimgrid_plt_section(){ xbt_abort(); } - while ((read = getline(&line, &n, fp)) != -1 && plt_not_found == 1) { + while ((read = getline(&line, &n, fp)) != -1 && plt_found != 2) { if(n == 0) continue; @@ -332,8 +285,15 @@ void get_libsimgrid_plt_section(){ offset = strtoul(lfields[5], NULL, 16); start_plt_libsimgrid = (char *)start_text_libsimgrid + offset; end_plt_libsimgrid = (char *)start_plt_libsimgrid + size; - plt_not_found = 0; - } + plt_found++; + }else if(strcmp(lfields[1], ".got.plt") == 0){ + size = strtoul(lfields[2], NULL, 16); + offset = strtoul(lfields[5], NULL, 16); + start_got_plt_libsimgrid = (char *)start_text_libsimgrid + offset; + end_got_plt_libsimgrid = (char *)start_got_plt_libsimgrid + size; + plt_found++; + } + } } @@ -352,8 +312,8 @@ void get_binary_plt_section(){ size_t n = 0; /* Amount of bytes to read by getline */ char *lfields[7]; - int i, plt_not_found = 1; - unsigned long int size, offset; + int i, plt_found = 0; + unsigned long int size; char *command = bprintf( "objdump --section-headers %s", xbt_binary_name); @@ -364,7 +324,7 @@ void get_binary_plt_section(){ xbt_abort(); } - while ((read = getline(&line, &n, fp)) != -1 && plt_not_found == 1) { + while ((read = getline(&line, &n, fp)) != -1 && plt_found != 2) { if(n == 0) continue; @@ -387,11 +347,15 @@ void get_binary_plt_section(){ if(i>=6){ if(strcmp(lfields[1], ".plt") == 0){ size = strtoul(lfields[2], NULL, 16); - offset = strtoul(lfields[5], NULL, 16); - start_plt_binary = (char *)start_text_binary + offset; + start_plt_binary = (void *)strtoul(lfields[3], NULL, 16); end_plt_binary = (char *)start_plt_binary + size; - plt_not_found = 0; - } + plt_found++; + }else if(strcmp(lfields[1], ".got.plt") == 0){ + size = strtoul(lfields[2], NULL, 16); + start_got_plt_binary = (char *)strtoul(lfields[3], NULL, 16); + end_got_plt_binary = (char *)start_got_plt_binary + size; + plt_found++; + } } @@ -454,7 +418,6 @@ static xbt_strbuff_t get_local_variables_values(void *stack_context, void *heap) unw_cursor_t c; int ret; - //char *stack_name; char frame_name[256]; @@ -464,8 +427,6 @@ static xbt_strbuff_t get_local_variables_values(void *stack_context, void *heap) xbt_abort(); } - //stack_name = strdup(((smx_process_t)((smx_ctx_sysv_t)(stack->address))->super.data)->name); - unw_word_t ip, sp, off; dw_frame_t frame; @@ -488,16 +449,14 @@ static xbt_strbuff_t get_local_variables_values(void *stack_context, void *heap) unw_get_reg(&c, UNW_REG_IP, &ip); unw_get_reg(&c, UNW_REG_SP, &sp); - unw_get_proc_name (&c, frame_name, sizeof (frame_name), &off); - - xbt_strbuff_append(variables, bprintf("ip=%s\n", frame_name)); + unw_get_proc_name(&c, frame_name, sizeof (frame_name), &off); frame = xbt_dict_get_or_null(mc_local_variables, frame_name); - if(frame == NULL){ - ret = unw_step(&c); - continue; - } + if(frame == NULL) + return variables; + + xbt_strbuff_append(variables, bprintf("ip=%s\n", frame_name)); true_ip = (long)frame->low_pc + (long)off; @@ -550,8 +509,6 @@ static xbt_strbuff_t get_local_variables_values(void *stack_context, void *heap) frame_found = 0; cursor = 0; - //XBT_INFO("Frame %s", frame->name); - xbt_dict_foreach(frame->variables, dict_cursor, variable_name, current_variable){ if(current_variable->location != NULL){ switch(current_variable->location->type){ @@ -581,24 +538,18 @@ static xbt_strbuff_t get_local_variables_values(void *stack_context, void *heap) } if(xbt_dynar_length(compose) > 0){ - //XBT_INFO("Variable : %s", current_variable->name); if(strcmp(xbt_dynar_get_as(compose, xbt_dynar_length(compose) - 1, variable_value_t)->type, "value") == 0){ - //XBT_INFO("Variable : %s - value : %lx", current_variable->name, xbt_dynar_get_as(compose, xbt_dynar_length(compose) - 1, variable_value_t)->value.res); xbt_strbuff_append(variables, bprintf("%s=%lx\n", current_variable->name, xbt_dynar_get_as(compose, xbt_dynar_length(compose) - 1, variable_value_t)->value.res)); }else{ if((long)xbt_dynar_get_as(compose, xbt_dynar_length(compose) - 1,variable_value_t)->value.address < 0 || *((void**)xbt_dynar_get_as(compose, xbt_dynar_length(compose) - 1,variable_value_t)->value.address) == NULL){ - //XBT_INFO("Variable : %s - address : NULL", current_variable->name); xbt_strbuff_append(variables, bprintf("%s=NULL\n", current_variable->name)); }else if(((long)*((void**)xbt_dynar_get_as(compose, xbt_dynar_length(compose) - 1,variable_value_t)->value.address) > 0xffffffff) || ((long)*((void**)xbt_dynar_get_as(compose, xbt_dynar_length(compose) - 1,variable_value_t)->value.address) < (long)start_text_binary)){ - //XBT_INFO("Variable : %s - value : %zd", current_variable->name, (size_t)*((void**)xbt_dynar_get_as(compose, xbt_dynar_length(compose) - 1, variable_value_t)->value.address)); xbt_strbuff_append(variables, bprintf("%s=%d\n", current_variable->name, (int)(long)*((void**)xbt_dynar_get_as(compose, xbt_dynar_length(compose) - 1, variable_value_t)->value.address))); - }else{ - //XBT_INFO("Variable : %s - address : %p", current_variable->name, *((void**)xbt_dynar_get_as(compose, xbt_dynar_length(compose) - 1, variable_value_t)->value.address)); + }else{ xbt_strbuff_append(variables, bprintf("%s=%p\n", current_variable->name, *((void**)xbt_dynar_get_as(compose, xbt_dynar_length(compose) - 1, variable_value_t)->value.address))); } } }else{ - //XBT_INFO("Variable %s undefined", current_variable->name); xbt_strbuff_append(variables, bprintf("%s=undefined\n", current_variable->name)); } break; @@ -606,19 +557,14 @@ static xbt_strbuff_t get_local_variables_values(void *stack_context, void *heap) break; } }else{ - //XBT_INFO("Variable : %s, no location", current_variable->name); xbt_strbuff_append(variables, bprintf("%s=undefined\n", current_variable->name)); } } ret = unw_step(&c); - - //XBT_INFO(" "); } - //free(stack_name); - return variables; }