Algorithmique Numérique Distribuée Public GIT Repository
 author Gabriel Corona Thu, 28 May 2015 09:11:02 +0000 (11:11 +0200) committer Gabriel Corona Thu, 28 May 2015 09:53:54 +0000 (11:53 +0200)
 src/mc/AddressSpace.hpp patch | blob | history src/mc/mc_diff.cpp patch | blob | history src/mc/mc_process.cpp patch | blob | history src/mc/mc_process.h patch | blob | history src/mc/mc_server.cpp patch | blob | history

index 05665fb..1da65e8 100644 (file)
@@ -35,6 +35,10 @@ public:
{
}
+  bool operator!() const
+  {
+  }
operator remote_ptr<void>() const
{
@@ -59,6 +63,42 @@ public:
}
};

+template<class X, class Y>
+bool operator<(remote_ptr<X> const& x, remote_ptr<Y> const& y)
+{
+}
+
+template<class X, class Y>
+bool operator>(remote_ptr<X> const& x, remote_ptr<Y> const& y)
+{
+}
+
+template<class X, class Y>
+bool operator>=(remote_ptr<X> const& x, remote_ptr<Y> const& y)
+{
+}
+
+template<class X, class Y>
+bool operator<=(remote_ptr<X> const& x, remote_ptr<Y> const& y)
+{
+}
+
+template<class X, class Y>
+bool operator==(remote_ptr<X> const& x, remote_ptr<Y> const& y)
+{
+}
+
+template<class X, class Y>
+bool operator!=(remote_ptr<X> const& x, remote_ptr<Y> const& y)
+{
+}
+
template<class T> inline
remote_ptr<T> remote(T *p)
{
index 1f11579..d14424b 100644 (file)
@@ -825,10 +825,8 @@ static int compare_heap_area_without_type(struct s_mc_diff *state, int process_i
remote((void**)((char *) real_area2 + pointer_align)), process_index);

-          && addr_pointed2 < process->maestro_stack_end) {
i = pointer_align + sizeof(void *);
continue;
} else if (addr_pointed1 > state->std_heap_copy.heapbase
index 9f944d3..316c722 100644 (file)
@@ -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)) {
}
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 !");
}
index 00251e4..5879580 100644 (file)
@@ -114,6 +114,27 @@ public:

pid_t pid() const { return pid_; }

+  bool in_maestro_stack(remote_ptr<void> 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<void> maestro_stack_start_, maestro_stack_end_;
+  int memory_file;
+  std::vector<IgnoredRegion> 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<IgnoredRegion> ignored_regions_;
};

/** Open a FD to a remote process memory (`/dev/\$pid/mem`)
index 92c0e2e..9ea15bd 100644 (file)
@@ -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;
}