#define _FILE_OFFSET_BITS 64 /* needed for pread_whole to work as expected on 32bits */
-#include "src/mc/remote/RemoteClient.hpp"
+#include "src/mc/remote/RemoteClientMemory.hpp"
#include "src/mc/mc_smx.hpp"
#include "src/mc/sosp/Snapshot.hpp"
"libsasl2",
"libresolv",
"libcrypt",
- "libselinux"
-};
+ "libselinux"};
static bool is_simgrid_lib(const std::string& libname)
{
// ***** Process
-RemoteClient::RemoteClient(pid_t pid, int sockfd) : AddressSpace(this), pid_(pid), channel_(sockfd), running_(true)
+RemoteClientMemory::RemoteClientMemory(pid_t pid, int sockfd)
+ : AddressSpace(this), pid_(pid), channel_(sockfd), running_(true)
{
}
-void RemoteClient::init()
+void RemoteClientMemory::init()
{
this->memory_map_ = simgrid::xbt::get_memory_map(this->pid_);
this->init_memory_map_info();
this->unw_underlying_context = simgrid::unw::create_context(this->unw_underlying_addr_space, this->pid_);
}
-RemoteClient::~RemoteClient()
+RemoteClientMemory::~RemoteClientMemory()
{
if (this->memory_file >= 0)
close(this->memory_file);
* Do not use directly, this is used by the getters when appropriate
* in order to have fresh data.
*/
-void RemoteClient::refresh_heap()
+void RemoteClientMemory::refresh_heap()
{
// Read/dereference/refresh the std_heap pointer:
if (not this->heap)
this->heap.reset(new s_xbt_mheap_t());
this->read_bytes(this->heap.get(), sizeof(mdesc), remote(this->heap_address));
- this->cache_flags_ |= RemoteClient::cache_heap;
+ this->cache_flags_ |= RemoteClientMemory::cache_heap;
}
/** Refresh the information about the process
* Do not use directly, this is used by the getters when appropriate
* in order to have fresh data.
* */
-void RemoteClient::refresh_malloc_info()
+void RemoteClientMemory::refresh_malloc_info()
{
// Refresh process->heapinfo:
- if (this->cache_flags_ & RemoteClient::cache_malloc)
+ if (this->cache_flags_ & RemoteClientMemory::cache_malloc)
return;
size_t count = this->heap->heaplimit + 1;
if (this->heap_info.size() < count)
this->heap_info.resize(count);
this->read_bytes(this->heap_info.data(), count * sizeof(malloc_info), remote(this->heap->heapinfo));
- this->cache_flags_ |= RemoteClient::cache_malloc;
+ this->cache_flags_ |= RemoteClientMemory::cache_malloc;
}
/** @brief Finds the range of the different memory segments and binary paths */
-void RemoteClient::init_memory_map_info()
+void RemoteClientMemory::init_memory_map_info()
{
XBT_DEBUG("Get debug information ...");
this->maestro_stack_start_ = nullptr;
XBT_DEBUG("Get debug information done !");
}
-std::shared_ptr<simgrid::mc::ObjectInformation> RemoteClient::find_object_info(RemotePtr<void> addr) const
+std::shared_ptr<simgrid::mc::ObjectInformation> RemoteClientMemory::find_object_info(RemotePtr<void> addr) const
{
for (auto const& object_info : this->object_infos)
if (addr.address() >= (std::uint64_t)object_info->start && addr.address() <= (std::uint64_t)object_info->end)
return nullptr;
}
-std::shared_ptr<ObjectInformation> RemoteClient::find_object_info_exec(RemotePtr<void> addr) const
+std::shared_ptr<ObjectInformation> RemoteClientMemory::find_object_info_exec(RemotePtr<void> addr) const
{
for (std::shared_ptr<ObjectInformation> const& info : this->object_infos)
if (addr.address() >= (std::uint64_t)info->start_exec && addr.address() <= (std::uint64_t)info->end_exec)
return nullptr;
}
-std::shared_ptr<ObjectInformation> RemoteClient::find_object_info_rw(RemotePtr<void> addr) const
+std::shared_ptr<ObjectInformation> RemoteClientMemory::find_object_info_rw(RemotePtr<void> addr) const
{
for (std::shared_ptr<ObjectInformation> const& info : this->object_infos)
if (addr.address() >= (std::uint64_t)info->start_rw && addr.address() <= (std::uint64_t)info->end_rw)
return nullptr;
}
-simgrid::mc::Frame* RemoteClient::find_function(RemotePtr<void> ip) const
+simgrid::mc::Frame* RemoteClientMemory::find_function(RemotePtr<void> ip) const
{
std::shared_ptr<simgrid::mc::ObjectInformation> info = this->find_object_info_exec(ip);
return info ? info->find_function((void*)ip.address()) : nullptr;
/** Find (one occurrence of) the named variable definition
*/
-const simgrid::mc::Variable* RemoteClient::find_variable(const char* name) const
+const simgrid::mc::Variable* RemoteClientMemory::find_variable(const char* name) const
{
// First lookup the variable in the executable shared object.
// A global variable used directly by the executable code from a library
return nullptr;
}
-void RemoteClient::read_variable(const char* name, void* target, size_t size) const
+void RemoteClientMemory::read_variable(const char* name, void* target, size_t size) const
{
const simgrid::mc::Variable* var = this->find_variable(name);
xbt_assert(var, "Variable %s not found", name);
this->read_bytes(target, size, remote(var->address));
}
-std::string RemoteClient::read_string(RemotePtr<char> address) const
+std::string RemoteClientMemory::read_string(RemotePtr<char> address) const
{
if (not address)
return {};
}
}
-void* RemoteClient::read_bytes(void* buffer, std::size_t size, RemotePtr<void> address, ReadOptions /*options*/) const
+void* RemoteClientMemory::read_bytes(void* buffer, std::size_t size, RemotePtr<void> address,
+ ReadOptions /*options*/) const
{
if (pread_whole(this->memory_file, buffer, size, (size_t)address.address()) < 0)
xbt_die("Read at %p from process %lli failed", (void*)address.address(), (long long)this->pid_);
* @param len data size
* @param address target process memory address (target)
*/
-void RemoteClient::write_bytes(const void* buffer, size_t len, RemotePtr<void> address)
+void RemoteClientMemory::write_bytes(const void* buffer, size_t len, RemotePtr<void> address)
{
if (pwrite_whole(this->memory_file, buffer, len, (size_t)address.address()) < 0)
xbt_die("Write to process %lli failed", (long long)this->pid_);
}
-void RemoteClient::clear_bytes(RemotePtr<void> address, size_t len)
+void RemoteClientMemory::clear_bytes(RemotePtr<void> address, size_t len)
{
pthread_once(&zero_buffer_flag, zero_buffer_init);
while (len) {
}
}
-void RemoteClient::ignore_region(std::uint64_t addr, std::size_t size)
+void RemoteClientMemory::ignore_region(std::uint64_t addr, std::size_t size)
{
IgnoredRegion region;
region.addr = addr;
return;
}
- unsigned int cursor = 0;
+ unsigned int cursor = 0;
const IgnoredRegion* current_region = nullptr;
int start = 0;
ignored_regions_.insert(ignored_regions_.begin() + position, region);
}
-void RemoteClient::ignore_heap(IgnoredHeapRegion const& region)
+void RemoteClientMemory::ignore_heap(IgnoredHeapRegion const& region)
{
if (ignored_heap_.empty()) {
ignored_heap_.push_back(std::move(region));
// Binary search the position of insertion:
size_type cursor;
while (start <= end) {
- cursor = start + (end - start) / 2;
+ cursor = start + (end - start) / 2;
auto const& current_region = ignored_heap_[cursor];
if (current_region.address == region.address)
return;
ignored_heap_.insert(ignored_heap_.begin() + cursor, region);
}
-void RemoteClient::unignore_heap(void* address, size_t size)
+void RemoteClientMemory::unignore_heap(void* address, size_t size)
{
typedef std::vector<IgnoredHeapRegion>::size_type size_type;
// Binary search:
size_type cursor;
while (start <= end) {
- cursor = (start + end) / 2;
+ cursor = (start + end) / 2;
auto const& region = ignored_heap_[cursor];
if (region.address < address)
start = cursor + 1;
}
}
-void RemoteClient::ignore_local_variable(const char* var_name, const char* frame_name)
+void RemoteClientMemory::ignore_local_variable(const char* var_name, const char* frame_name)
{
if (frame_name != nullptr && strcmp(frame_name, "*") == 0)
frame_name = nullptr;
info->remove_local_variable(var_name, frame_name);
}
-std::vector<simgrid::mc::ActorInformation>& RemoteClient::actors()
+std::vector<simgrid::mc::ActorInformation>& RemoteClientMemory::actors()
{
this->refresh_simix();
return smx_actors_infos;
}
-std::vector<simgrid::mc::ActorInformation>& RemoteClient::dead_actors()
+std::vector<simgrid::mc::ActorInformation>& RemoteClientMemory::dead_actors()
{
this->refresh_simix();
return smx_dead_actors_infos;
}
-void RemoteClient::dump_stack()
+void RemoteClientMemory::dump_stack()
{
unw_addr_space_t as = unw_create_addr_space(&_UPT_accessors, BYTE_ORDER);
if (as == nullptr) {
_UPT_destroy(context);
unw_destroy_addr_space(as);
}
-}
-}
+} // namespace mc
+} // namespace simgrid