Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Read rdv->name from MCed in mc_comm_determinism.c
authorGabriel Corona <gabriel.corona@loria.fr>
Thu, 19 Mar 2015 13:04:47 +0000 (14:04 +0100)
committerGabriel Corona <gabriel.corona@loria.fr>
Thu, 19 Mar 2015 14:06:18 +0000 (15:06 +0100)
src/mc/mc_comm_determinism.c
src/mc/mc_process.c
src/mc/mc_process.h

index caf2601..aed01ee 100644 (file)
@@ -177,8 +177,12 @@ void MC_get_comm_pattern(xbt_dynar_t list, smx_simcall_t request, e_mc_call_type
     MC_process_read_simple(&mc_model_checker->process,
       &synchro, pattern->comm, sizeof(synchro));
 
     MC_process_read_simple(&mc_model_checker->process,
       &synchro, pattern->comm, sizeof(synchro));
 
-    // TODO, remote access to rdv->name and rdv_copy->name
-    pattern->rdv = (synchro.comm.rdv != NULL) ? strdup(synchro.comm.rdv->name) : strdup(synchro.comm.rdv_cpy->name);
+    char* remote_name;
+    MC_process_read_simple(&mc_model_checker->process, &remote_name,
+      synchro.comm.rdv ? &synchro.comm.rdv->name : &synchro.comm.rdv_cpy->name,
+      sizeof(remote_name));
+    pattern->rdv =
+      MC_process_read_string(&mc_model_checker->process, remote_name);
     pattern->src_proc = MC_smx_resolve_process(synchro.comm.src_proc)->pid;
     pattern->src_host = MC_smx_process_get_host_name(issuer);
 
     pattern->src_proc = MC_smx_resolve_process(synchro.comm.src_proc)->pid;
     pattern->src_host = MC_smx_process_get_host_name(issuer);
 
@@ -219,9 +223,13 @@ void MC_get_comm_pattern(xbt_dynar_t list, smx_simcall_t request, e_mc_call_type
     MC_process_read_simple(&mc_model_checker->process,
       &synchro, pattern->comm, sizeof(synchro));
 
     MC_process_read_simple(&mc_model_checker->process,
       &synchro, pattern->comm, sizeof(synchro));
 
-    pattern->rdv = (synchro.comm.rdv != NULL) ? strdup(synchro.comm.rdv->name) : strdup(synchro.comm.rdv_cpy->name);
+    char* remote_name;
+    MC_process_read_simple(&mc_model_checker->process, &remote_name,
+      synchro.comm.rdv ? &synchro.comm.rdv->name : &synchro.comm.rdv_cpy->name,
+      sizeof(remote_name));
+    pattern->rdv =
+      MC_process_read_string(&mc_model_checker->process, remote_name);
     pattern->dst_proc = MC_smx_resolve_process(synchro.comm.dst_proc)->pid;
     pattern->dst_proc = MC_smx_resolve_process(synchro.comm.dst_proc)->pid;
-    // FIXME, remote process access
     pattern->dst_host = MC_smx_process_get_host_name(issuer);
   } else {
     xbt_die("Unexpected call_type %i", (int) call_type);
     pattern->dst_host = MC_smx_process_get_host_name(issuer);
   } else {
     xbt_die("Unexpected call_type %i", (int) call_type);
index 9c89ada..47c907d 100644 (file)
@@ -414,6 +414,40 @@ void MC_process_read_variable(mc_process_t process, const char* name, void* targ
     MC_PROCESS_INDEX_ANY);
 }
 
     MC_PROCESS_INDEX_ANY);
 }
 
+char* MC_process_read_string(mc_process_t process, void* address)
+{
+  if (!address)
+    return NULL;
+  if (MC_process_is_self(process))
+    return strdup((char*) address);
+
+  size_t len = 128;
+  char* res = malloc(len);
+  off_t off = 0;
+
+  while (1) {
+    ssize_t c = pread(process->memory_file, res + off, len - off, (off_t) address + off);
+    if (c == -1) {
+      if (errno == EINTR)
+        continue;
+      else
+        xbt_die("Could not read from from remote process");
+    }
+    if (c==0)
+      xbt_die("Could not read string from remote process");
+
+    void* p = memchr(res + off, '\0', c);
+    if (p)
+      return res;
+
+    off += c;
+    if (off == len) {
+      len *= 2;
+      res = realloc(res, len);
+    }
+  }
+}
+
 // ***** Memory access
 
 int MC_process_vm_open(pid_t pid, int flags)
 // ***** Memory access
 
 int MC_process_vm_open(pid_t pid, int flags)
index 770bf3c..3334096 100644 (file)
@@ -186,6 +186,7 @@ mc_object_info_t MC_process_find_object_info_rw(mc_process_t process, const void
 dw_frame_t MC_process_find_function(mc_process_t process, const void* ip);
 
 void MC_process_read_variable(mc_process_t process, const char* name, void* target, size_t size);
 dw_frame_t MC_process_find_function(mc_process_t process, const void* ip);
 
 void MC_process_read_variable(mc_process_t process, const char* name, void* target, size_t size);
+char* MC_process_read_string(mc_process_t, void* address);
 
 static inline xbt_mheap_t MC_process_get_heap(mc_process_t process)
 {
 
 static inline xbt_mheap_t MC_process_get_heap(mc_process_t process)
 {