From: Gabriel Corona Date: Thu, 28 May 2015 09:11:02 +0000 (+0200) Subject: [mc] Mark some Process attributes as private X-Git-Tag: v3_12~708 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/89df17fd2f872e224e49bbdeeba43ca76a5b7d71?hp=e9401099487c0170193c87c12126cf719051a1c1 [mc] Mark some Process attributes as private --- diff --git a/src/mc/AddressSpace.hpp b/src/mc/AddressSpace.hpp index 05665fb4d6..1da65e81cd 100644 --- a/src/mc/AddressSpace.hpp +++ b/src/mc/AddressSpace.hpp @@ -35,6 +35,10 @@ public: { return address_; } + bool operator!() const + { + return !address_; + } operator remote_ptr() const { return remote_ptr(address_); @@ -59,6 +63,42 @@ public: } }; +template +bool operator<(remote_ptr const& x, remote_ptr const& y) +{ + return x.address() < y.address(); +} + +template +bool operator>(remote_ptr const& x, remote_ptr const& y) +{ + return x.address() > y.address(); +} + +template +bool operator>=(remote_ptr const& x, remote_ptr const& y) +{ + return x.address() >= y.address(); +} + +template +bool operator<=(remote_ptr const& x, remote_ptr const& y) +{ + return x.address() <= y.address(); +} + +template +bool operator==(remote_ptr const& x, remote_ptr const& y) +{ + return x.address() == y.address(); +} + +template +bool operator!=(remote_ptr const& x, remote_ptr const& y) +{ + return x.address() != y.address(); +} + template inline remote_ptr remote(T *p) { diff --git a/src/mc/mc_diff.cpp b/src/mc/mc_diff.cpp index 1f11579876..d14424b9b1 100644 --- a/src/mc/mc_diff.cpp +++ b/src/mc/mc_diff.cpp @@ -825,10 +825,8 @@ static int compare_heap_area_without_type(struct s_mc_diff *state, int process_i addr_pointed2 = snapshot2->read( remote((void**)((char *) real_area2 + pointer_align)), process_index); - if (addr_pointed1 > process->maestro_stack_start - && addr_pointed1 < process->maestro_stack_end - && addr_pointed2 > process->maestro_stack_start - && addr_pointed2 < process->maestro_stack_end) { + if (process->in_maestro_stack(remote(addr_pointed1)) + && process->in_maestro_stack(remote(addr_pointed2))) { i = pointer_align + sizeof(void *); continue; } else if (addr_pointed1 > state->std_heap_copy.heapbase diff --git a/src/mc/mc_process.cpp b/src/mc/mc_process.cpp index 9f944d3909..316c722f17 100644 --- a/src/mc/mc_process.cpp +++ b/src/mc/mc_process.cpp @@ -194,8 +194,8 @@ Process::Process(pid_t pid, int sockfd) process->pid_ = pid; if (pid==getpid()) process->process_flags |= MC_PROCESS_SELF_FLAG; - process->running = true; - process->status = 0; + process->running_ = true; + process->status_ = 0; process->memory_map = MC_get_memory_map(pid); process->cache_flags = MC_PROCESS_CACHE_FLAG_NONE; process->heap = NULL; @@ -245,8 +245,8 @@ Process::~Process() MC_free_memory_map(process->memory_map); process->memory_map = NULL; - 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 +323,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; @@ -352,8 +352,8 @@ void Process::init_memory_map_info() // [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; + this->maestro_stack_start_ = remote(reg->start_addr); + this->maestro_stack_end_ = remote(reg->end_addr); } current_name = NULL; continue; @@ -398,8 +398,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 !"); } diff --git a/src/mc/mc_process.h b/src/mc/mc_process.h index 00251e4eb5..5879580461 100644 --- a/src/mc/mc_process.h +++ b/src/mc/mc_process.h @@ -114,6 +114,27 @@ public: pid_t pid() const { return pid_; } + bool in_maestro_stack(remote_ptr p) const + { + return p >= this->maestro_stack_start_ && p < this->maestro_stack_end_; + } + + bool running() const + { + return running_; + } + + void terminate(int status) + { + status_ = status; + running_ = false; + } + + int status() const + { + return status_; + } + private: void init_memory_map_info(); void refresh_heap(); @@ -123,16 +144,22 @@ private: pid_t pid_; public: // to be private int socket; - int status; - bool running; +private: + int status_; + bool running_; memory_map_t memory_map; - void *maestro_stack_start, *maestro_stack_end; + remote_ptr maestro_stack_start_, maestro_stack_end_; + int memory_file; + std::vector ignored_regions_; + +public: // object info + // TODO, make private (first, objectify mc_object_info_t) mc_object_info_t libsimgrid_info; mc_object_info_t binary_info; mc_object_info_t* object_infos; size_t object_infos_size; - int memory_file; +public: // Copies of MCed SMX data structures /** Copy of `simix_global->process_list` * * See mc_smx.c. @@ -167,7 +194,7 @@ public: // to be private */ malloc_info* heap_info; - // ***** Libunwind-data +public: // Libunwind-data /** Full-featured MC-aware libunwind address space for the process * @@ -187,9 +214,6 @@ public: // to be private /** The corresponding context */ void* unw_underlying_context; - -private: - std::vector ignored_regions_; }; /** Open a FD to a remote process memory (`/dev/$pid/mem`) diff --git a/src/mc/mc_server.cpp b/src/mc/mc_server.cpp index 92c0e2efaf..9ea15bd0ba 100644 --- a/src/mc/mc_server.cpp +++ b/src/mc/mc_server.cpp @@ -95,21 +95,21 @@ void s_mc_server::shutdown() XBT_DEBUG("Shuting down model-checker"); mc_process_t process = &mc_model_checker->process(); - int status = process->status; - if (process->running) { + int status = process->status(); + if (process->running()) { XBT_DEBUG("Killing process"); kill(process->pid(), SIGTERM); if (waitpid(process->pid(), &status, 0) == -1) throw std::system_error(errno, std::system_category()); // TODO, handle the case when the process does not want to die with a timeout - process->status = status; + process->terminate(status); } } void s_mc_server::exit() { // Finished: - int status = mc_model_checker->process().status; + int status = mc_model_checker->process().status(); if (WIFEXITED(status)) ::exit(WEXITSTATUS(status)); else if (WIFSIGNALED(status)) { @@ -272,7 +272,7 @@ bool s_mc_server::handle_events() void s_mc_server::loop() { - while (mc_model_checker->process().running) + while (mc_model_checker->process().running()) this->handle_events(); } @@ -305,7 +305,7 @@ void s_mc_server::handle_waitpid() if (pid == -1) { if (errno == ECHILD) { // No more children: - if (mc_model_checker->process().running) + if (mc_model_checker->process().running()) xbt_die("Inconsistent state"); else break; @@ -318,8 +318,7 @@ void s_mc_server::handle_waitpid() if (pid == mc_model_checker->process().pid()) { if (WIFEXITED(status) || WIFSIGNALED(status)) { XBT_DEBUG("Child process is over"); - mc_model_checker->process().status = status; - mc_model_checker->process().running = false; + mc_model_checker->process().terminate(status); } } } @@ -339,7 +338,7 @@ void s_mc_server::on_signal(const struct signalfd_siginfo* info) void MC_server_wait_client(mc_process_t process) { mc_server->resume(process); - while (mc_model_checker->process().running) { + while (mc_model_checker->process().running()) { if (!mc_server->handle_events()) return; } @@ -354,7 +353,7 @@ void MC_server_simcall_handle(mc_process_t process, unsigned long pid, int value m.value = value; MC_protocol_send(mc_model_checker->process().socket, &m, sizeof(m)); process->cache_flags = (mc_process_cache_flags_t) 0; - while (mc_model_checker->process().running) { + while (mc_model_checker->process().running()) { if (!mc_server->handle_events()) return; }