X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/9dbeb2372ad9a123d0558132ebb6e003e10aa641..13388755930c20f4c3785153b8952cf30c23183a:/src/mc/mc_process.cpp diff --git a/src/mc/mc_process.cpp b/src/mc/mc_process.cpp index 8c465ff023..3ebec2a3a7 100644 --- a/src/mc/mc_process.cpp +++ b/src/mc/mc_process.cpp @@ -4,6 +4,8 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ +#define _FILE_OFFSET_BITS 64 + #include #include #include @@ -109,12 +111,12 @@ static char* MC_get_lib_name(const char* pathname, struct s_mc_memory_map_re* re return libname; } -static ssize_t pread_whole(int fd, void *buf, size_t count, off_t offset) +static ssize_t pread_whole(int fd, void *buf, size_t count, std::uint64_t offset) { char* buffer = (char*) buf; ssize_t real_count = count; while (count) { - ssize_t res = pread(fd, buffer, count, offset); + ssize_t res = pread(fd, buffer, count, (std::int64_t) offset); if (res > 0) { count -= res; buffer += res; @@ -409,9 +411,9 @@ std::shared_ptr Process::find_object_info(remote_ptr a return NULL; } -std::shared_ptr Process::find_object_info_exec(remote_ptr addr) const +std::shared_ptr Process::find_object_info_exec(remote_ptr addr) const { - for (std::shared_ptr const& info : this->object_infos) { + for (std::shared_ptr const& info : this->object_infos) { if (addr.address() >= (std::uint64_t) info->start_exec && addr.address() <= (std::uint64_t) info->end_exec) { return info; @@ -420,9 +422,9 @@ std::shared_ptr Process::find_object_info_exec(remote_ptr Process::find_object_info_rw(remote_ptr addr) const +std::shared_ptr Process::find_object_info_rw(remote_ptr addr) const { - for (std::shared_ptr const& info : this->object_infos) { + for (std::shared_ptr const& info : this->object_infos) { if (addr.address() >= (std::uint64_t)info->start_rw && addr.address() <= (std::uint64_t)info->end_rw) { return info; @@ -434,10 +436,7 @@ std::shared_ptr Process::find_object_info_rw(remote_ptr ip) const { std::shared_ptr info = this->find_object_info_exec(ip); - if (!info) - return nullptr; - else - return MC_file_object_info_find_function(info.get(), (void*) ip.address()); + return info ? info->find_function((void*) ip.address()) : nullptr; } /** Find (one occurence of) the named variable definition @@ -450,13 +449,13 @@ dw_variable_t Process::find_variable(const char* name) const // We need to look up the variable in the execvutable first. if (this->binary_info) { std::shared_ptr const& info = this->binary_info; - dw_variable_t var = MC_file_object_info_find_variable_by_name(info.get(), name); + dw_variable_t var = info->find_variable(name); if (var) return var; } for (std::shared_ptr const& info : this->object_infos) { - dw_variable_t var = MC_file_object_info_find_variable_by_name(info.get(), name); + dw_variable_t var = info->find_variable(name); if (var) return var; } @@ -519,7 +518,7 @@ const void *Process::read_bytes(void* buffer, std::size_t size, std::shared_ptr const& info = this->find_object_info_rw((void*)address.address()); // Segment overlap is not handled. - if (MC_object_info_is_privatized(info.get())) { + if (info.get() && info.get()->privatized()) { if (process_index < 0) xbt_die("Missing process index"); if (process_index >= (int) MC_smpi_process_count()) @@ -548,7 +547,7 @@ const void *Process::read_bytes(void* buffer, std::size_t size, return buffer; } } else { - if (pread_whole(this->memory_file, buffer, size, (off_t) address.address()) < 0) + if (pread_whole(this->memory_file, buffer, size, address.address()) < 0) xbt_die("Read from process %lli failed", (long long) this->pid_); return buffer; }