X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/3ae4039533d80613612bb81524c164f33384df92..573a49afcc1a146f9776a7a772d87efd9db77657:/src/mc/mc_process.cpp diff --git a/src/mc/mc_process.cpp b/src/mc/mc_process.cpp index e80715b5a2..836cf4b393 100644 --- a/src/mc/mc_process.cpp +++ b/src/mc/mc_process.cpp @@ -48,6 +48,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_process, mc, static const char *const FILTERED_LIBS[] = { "libstdc++", + "libboost_context", "libc++", "libm", "libgcc_s", @@ -190,13 +191,13 @@ Process::Process(pid_t pid, int sockfd) Process* process = this; process->process_flags = MC_PROCESS_NO_FLAG; - process->socket = sockfd; - process->pid = pid; + process->socket_ = sockfd; + process->pid_ = pid; if (pid==getpid()) process->process_flags |= MC_PROCESS_SELF_FLAG; - process->running = true; - process->status = 0; - process->memory_map = MC_get_memory_map(pid); + process->running_ = true; + process->status_ = 0; + process->memory_map_ = get_memory_map(pid); process->cache_flags = MC_PROCESS_CACHE_FLAG_NONE; process->heap = NULL; process->heap_info = NULL; @@ -206,7 +207,7 @@ Process::Process(pid_t pid, int sockfd) if (process->is_self()) process->memory_file = -1; else { - int fd = open_vm(process->pid, O_RDWR); + int fd = open_vm(process->pid_, O_RDWR); if (fd<0) xbt_die("Could not open file for process virtual address space"); process->memory_file = fd; @@ -239,14 +240,14 @@ Process::~Process() { Process* process = this; - process->process_flags = MC_PROCESS_NO_FLAG; - process->pid = 0; + if (this->socket_ >= 0 && close(this->socket_) < 0) + xbt_die("Could not close communication socket"); - MC_free_memory_map(process->memory_map); - process->memory_map = NULL; + process->process_flags = MC_PROCESS_NO_FLAG; + process->pid_ = 0; - process->maestro_stack_start = NULL; - process->maestro_stack_end = NULL; + process->maestro_stack_start_ = nullptr; + process->maestro_stack_end_ = nullptr; xbt_dynar_free(&process->smx_process_infos); xbt_dynar_free(&process->smx_old_process_infos); @@ -323,8 +324,8 @@ void Process::refresh_malloc_info() void Process::init_memory_map_info() { XBT_DEBUG("Get debug information ..."); - this->maestro_stack_start = NULL; - this->maestro_stack_end = NULL; + this->maestro_stack_start_ = nullptr; + this->maestro_stack_end_ = nullptr; this->object_infos = NULL; this->object_infos_size = 0; this->binary_info = NULL; @@ -335,25 +336,25 @@ void Process::init_memory_map_info() if(regcomp(&res.so_re, SO_RE, 0) || regcomp(&res.version_re, VERSION_RE, 0)) xbt_die(".so regexp did not compile"); - memory_map_t maps = this->memory_map; + std::vector const& maps = this->memory_map_; const char* current_name = NULL; - for (ssize_t i=0; i < maps->mapsize; i++) { - map_region_t reg = &(maps->regions[i]); - const char* pathname = maps->regions[i].pathname; + for (size_t i=0; i < maps.size(); i++) { + simgrid::mc::VmMap const& reg = maps[i]; + const char* pathname = maps[i].pathname.c_str(); // Nothing to do - if (maps->regions[i].pathname == NULL) { + if (maps[i].pathname.empty()) { current_name = NULL; continue; } // [stack], [vvar], [vsyscall], [vdso] ... if (pathname[0] == '[') { - if ((reg->prot & PROT_WRITE) && !memcmp(pathname, "[stack]", 7)) { - this->maestro_stack_start = reg->start_addr; - this->maestro_stack_end = reg->end_addr; + if ((reg.prot & PROT_WRITE) && !memcmp(pathname, "[stack]", 7)) { + this->maestro_stack_start_ = remote(reg.start_addr); + this->maestro_stack_end_ = remote(reg.end_addr); } current_name = NULL; continue; @@ -363,7 +364,7 @@ void Process::init_memory_map_info() continue; current_name = pathname; - if (!(reg->prot & PROT_READ) && (reg->prot & PROT_EXEC)) + if (!(reg.prot & PROT_READ) && (reg.prot & PROT_EXEC)) continue; const bool is_executable = !i; @@ -379,9 +380,9 @@ void Process::init_memory_map_info() } mc_object_info_t info = - MC_find_object_info(this->memory_map, pathname, is_executable); + MC_find_object_info(this->memory_map_, pathname, is_executable); this->object_infos = (mc_object_info_t*) realloc(this->object_infos, - (this->object_infos_size+1) * sizeof(mc_object_info_t*)); + (this->object_infos_size+1) * sizeof(mc_object_info_t)); this->object_infos[this->object_infos_size] = info; this->object_infos_size++; if (is_executable) @@ -398,8 +399,8 @@ void Process::init_memory_map_info() for (size_t i=0; i!=this->object_infos_size; ++i) MC_post_process_object_info(this, this->object_infos[i]); - xbt_assert(this->maestro_stack_start, "Did not find maestro_stack_start"); - xbt_assert(this->maestro_stack_end, "Did not find maestro_stack_end"); + xbt_assert(this->maestro_stack_start_, "Did not find maestro_stack_start"); + xbt_assert(this->maestro_stack_end_, "Did not find maestro_stack_end"); XBT_DEBUG("Get debug information done !"); } @@ -534,10 +535,21 @@ const void *Process::read_bytes(void* buffer, std::size_t size, if (MC_object_info_is_privatized(info)) { if (process_index < 0) xbt_die("Missing process index"); + if (process_index >= (int) MC_smpi_process_count()) + xbt_die("Invalid process index"); + + // Read smpi_privatisation_regions from MCed: + smpi_privatisation_region_t remote_smpi_privatisation_regions = + mc_model_checker->process().read_variable( + "smpi_privatisation_regions"); + + s_smpi_privatisation_region_t privatisation_region = + mc_model_checker->process().read( + remote(remote_smpi_privatisation_regions + process_index)); + // Address translation in the privaization segment: - // TODO, fix me (broken) size_t offset = address.address() - (std::uint64_t)info->start_rw; - address = remote(address.address() - offset); + address = remote((char*)privatisation_region.address + offset); } } @@ -550,7 +562,7 @@ const void *Process::read_bytes(void* buffer, std::size_t size, } } else { if (pread_whole(this->memory_file, buffer, size, (off_t) address.address()) < 0) - xbt_die("Read from process %lli failed", (long long) this->pid); + xbt_die("Read from process %lli failed", (long long) this->pid_); return buffer; } } @@ -568,7 +580,7 @@ void Process::write_bytes(const void* buffer, size_t len, remote_ptr addre memcpy((void*)address.address(), buffer, len); } else { if (pwrite_whole(this->memory_file, buffer, len, address.address()) < 0) - xbt_die("Write to process %lli failed", (long long) this->pid); + xbt_die("Write to process %lli failed", (long long) this->pid_); } }