X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/74c1bf2b26c5a3aa0d8c29674dc12993e7c0de15..3e5588fc9b34239f448a523211086b05c9fee29c:/src/mc/remote/RemoteClient.cpp diff --git a/src/mc/remote/RemoteClient.cpp b/src/mc/remote/RemoteClient.cpp index 74ffde104b..297c545bc3 100644 --- a/src/mc/remote/RemoteClient.cpp +++ b/src/mc/remote/RemoteClient.cpp @@ -28,12 +28,13 @@ #include #include "xbt/base.h" +#include "xbt/file.hpp" #include "xbt/log.h" #include -#include "src/mc/mc_smx.h" -#include "src/mc/mc_snapshot.h" -#include "src/mc/mc_unw.h" +#include "src/mc/mc_smx.hpp" +#include "src/mc/mc_snapshot.hpp" +#include "src/mc/mc_unw.hpp" #include "src/mc/AddressSpace.hpp" #include "src/mc/ObjectInformation.hpp" @@ -46,12 +47,12 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_process, mc, "MC process information"); // ***** Helper stuff -namespace simgrid { -namespace mc { - #define SO_RE "\\.so[\\.0-9]*$" #define VERSION_RE "-[\\.0-9-]*$" +namespace simgrid { +namespace mc { + // List of library which memory segments are not considered: static const char* const filtered_libraries[] = { #ifdef __linux__ @@ -116,19 +117,15 @@ struct s_mc_memory_map_re { regex_t version_re; }; -static char* get_lib_name(const char* pathname, struct s_mc_memory_map_re* res) +static char* get_lib_name(const char* pathname, s_mc_memory_map_re* res) { - char* map_basename = xbt_basename(pathname); + std::string map_basename = simgrid::xbt::Path(pathname).getBasename(); regmatch_t match; - if (regexec(&res->so_re, map_basename, 1, &match, 0)) { - free(map_basename); + if (regexec(&res->so_re, map_basename.c_str(), 1, &match, 0)) return nullptr; - } - char* libname = strndup(map_basename, match.rm_so); - free(map_basename); - map_basename = nullptr; + char* libname = strndup(map_basename.c_str(), match.rm_so); // Strip the version suffix: if (libname && not regexec(&res->version_re, libname, 1, &match, 0)) { @@ -227,7 +224,7 @@ void RemoteClient::init() xbt_die("No heap information in the target process"); if (not std_heap_var->address) xbt_die("No constant address for this variable"); - this->read_bytes(&this->heap_address, sizeof(struct mdesc*), remote(std_heap_var->address), + this->read_bytes(&this->heap_address, sizeof(mdesc*), remote(std_heap_var->address), simgrid::mc::ProcessIndexDisabled); this->smx_actors_infos.clear(); @@ -262,8 +259,7 @@ void RemoteClient::refresh_heap() // Read/dereference/refresh the std_heap pointer: if (not this->heap) this->heap = std::unique_ptr(new s_xbt_mheap_t()); - this->read_bytes(this->heap.get(), sizeof(struct mdesc), remote(this->heap_address), - simgrid::mc::ProcessIndexDisabled); + this->read_bytes(this->heap.get(), sizeof(mdesc), remote(this->heap_address), simgrid::mc::ProcessIndexDisabled); this->cache_flags_ |= RemoteClient::cache_heap; } @@ -295,7 +291,7 @@ void RemoteClient::init_memory_map_info() this->binary_info = nullptr; this->libsimgrid_info = nullptr; - struct s_mc_memory_map_re res; + s_mc_memory_map_re res; if (regcomp(&res.so_re, SO_RE, 0) || regcomp(&res.version_re, VERSION_RE, 0)) xbt_die(".so regexp did not compile");