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);
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;
- // FIXME, remote process access
pattern->dst_host = MC_smx_process_get_host_name(issuer);
} else {
xbt_die("Unexpected call_type %i", (int) call_type);
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)
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)
{