region->permanent_addr = permanent_addr;
region->size = size;
region->flat.data = xbt_malloc(size);
- MC_process_read(&mc_model_checker->process, region->flat.data, permanent_addr, size);
+ MC_process_read(&mc_model_checker->process, MC_ADDRESS_SPACE_READ_FLAGS_NONE,
+ region->flat.data, permanent_addr, size,
+ MC_PROCESS_INDEX_DISABLED);
XBT_DEBUG("New region : type : %d, data : %p (real addr %p), size : %zu",
region_type, region->flat.data, permanent_addr, size);
return region;
}
}
+// FIXME, multiple privatisation regions
+// FIXME, cross-process
static inline
void* MC_privatization_address(mc_process_t process, int process_index)
{
ref_reg = mc_model_checker->parent_snapshot->snapshot_regions[index];
mc_mem_region_t region;
- const bool privatization_aware = object_info && MC_object_info_executable(object_info);
- if (privatization_aware && smpi_privatize_global_variables && smpi_process_count())
+ const bool privatization_aware = MC_object_info_is_privatized(object_info);
+ if (privatization_aware && smpi_process_count())
region = MC_region_new_privatized(type, start_addr, permanent_addr, size, ref_reg);
else
region = MC_region_new(type, start_addr, permanent_addr, size, ref_reg);
#ifdef HAVE_SMPI
if (smpi_privatize_global_variables && smpi_process_count()) {
+ // FIXME, cross-process
snapshot->privatization_index = smpi_loaded_page;
} else
#endif
{
- snapshot->privatization_index = MC_NO_PROCESS_INDEX;
+ snapshot->privatization_index = MC_PROCESS_INDEX_MISSING;
}
}
/** \brief Fills the position of the segments (executable, read-only, read/write).
*
- * TODO, use dl_iterate_phdr to be more robust
+ * `dl_iterate_phdr` would be more robust but would not work in cross-process.
* */
void MC_find_object_address(memory_map_t maps, mc_object_info_t result)
{
i++;
}
+ result->start = result->start_rw;
+ if ((const void*) result->start_ro > result->start)
+ result->start = result->start_ro;
+ if ((const void*) result->start_exec > result->start)
+ result->start = result->start_exec;
+
+ result->end = result->end_rw;
+ if (result->end_ro && (const void*) result->end_ro < result->end)
+ result->end = result->end_ro;
+ if (result->end_exec && (const void*) result->end_exec > result->end)
+ result->end = result->end_exec;
+
xbt_assert(result->file_name);
xbt_assert(result->start_rw);
xbt_assert(result->start_exec);
continue;
int region_type;
+ // FIXME, get rid of `region_type`
if ((long) stack_frame->ip > (long) process->libsimgrid_info->start_exec)
region_type = 1;
else
new_var->address = current_variable->address;
} else if (current_variable->locations.size != 0) {
s_mc_location_t location;
+ // FIXME, cross-process support
mc_dwarf_resolve_locations(&location, ¤t_variable->locations,
current_variable->object_info,
&(stack_frame->unw_cursor),
unw_cursor_t c;
// TODO, check condition check (unw_init_local==0 means end of frame)
+ // FIXME, cross-process support
if (unw_init_local(&c, (unw_context_t *) stack_context) != 0) {
xbt_die("Could not initialize stack unwinding");
unsigned int cursor = 0;
stack_region_t current_stack;
+ // FIXME, cross-process support (stack_areas)
xbt_dynar_foreach(stacks_areas, cursor, current_stack) {
mc_snapshot_stack_t st = xbt_new(s_mc_snapshot_stack_t, 1);
st->stack_frames = MC_unwind_stack_frames(current_stack->context);
}
+// FIXME, cross-process support (mc_heap_comparison_ignore)
static xbt_dynar_t MC_take_snapshot_ignore()
{
static void MC_snapshot_handle_ignore(mc_snapshot_t snapshot)
{
+ xbt_assert(snapshot->process);
snapshot->ignored_data = xbt_dynar_new(sizeof(s_mc_snapshot_ignored_data_t), mc_free_snapshot_ignored_data_pvoid);
// Copy the memory:
unsigned int cursor = 0;
mc_checkpoint_ignore_region_t region;
+ // FIXME, cross-process support (mc_checkpoint_ignore)
xbt_dynar_foreach (mc_checkpoint_ignore, cursor, region) {
s_mc_snapshot_ignored_data_t ignored_data;
ignored_data.start = region->addr;
ignored_data.size = region->size;
ignored_data.data = malloc(region->size);
- memcpy(ignored_data.data, region->addr, region->size);
+ // TODO, we should do this once per privatization segment:
+ MC_process_read(snapshot->process,
+ MC_ADDRESS_SPACE_READ_FLAGS_NONE,
+ ignored_data.data, region->addr, region->size, MC_PROCESS_INDEX_DISABLED);
xbt_dynar_push(snapshot->ignored_data, &ignored_data);
}
// Zero the memory:
xbt_dynar_foreach (mc_checkpoint_ignore, cursor, region) {
- memset(region->addr, 0, region->size);
+ MC_process_clear_memory(snapshot->process, region->addr, region->size);
}
}
unsigned int cursor = 0;
s_mc_snapshot_ignored_data_t ignored_data;
xbt_dynar_foreach (snapshot->ignored_data, cursor, ignored_data) {
- memcpy(ignored_data.start, ignored_data.data, ignored_data.size);
+ MC_process_write(snapshot->process,
+ ignored_data.data, ignored_data.start, ignored_data.size);
}
}
return false;
}
-static void MC_get_current_fd(mc_snapshot_t snapshot){
+static void MC_get_current_fd(mc_snapshot_t snapshot)
+{
snapshot->total_fd = 0;
const size_t fd_dir_path_size = 20;
char fd_dir_path[fd_dir_path_size];
if (snprintf(fd_dir_path, fd_dir_path_size,
- "/proc/%lli/fd", (long long int) getpid()) > fd_dir_path_size)
+ "/proc/%lli/fd", (long long int) snapshot->process->pid) > fd_dir_path_size)
xbt_die("Unexpected buffer is too small for fd_dir_path");
- DIR* fd_dir = opendir (fd_dir_path);
+ DIR* fd_dir = opendir(fd_dir_path);
if (fd_dir == NULL)
xbt_die("Cannot open directory '/proc/self/fd'\n");
const size_t source_size = 25;
char source[25];
- if (snprintf(source, source_size, "/proc/self/fd/%s", fd_number->d_name) > source_size)
+ if (snprintf(source, source_size, "/proc/%lli/fd/%s",
+ (long long int) snapshot->process->pid, fd_number->d_name) > source_size)
xbt_die("Unexpected buffer is too small for fd %s", fd_number->d_name);
const size_t link_size = 200;
closedir (fd_dir);
}
+static s_mc_address_space_class_t mc_snapshot_class = {
+ .read = (void*) &MC_snapshot_read
+};
+
mc_snapshot_t MC_take_snapshot(int num_state)
{
mc_process_t mc_process = &mc_model_checker->process;
mc_snapshot_t snapshot = xbt_new0(s_mc_snapshot_t, 1);
+ snapshot->process = mc_process;
+ snapshot->address_space.address_space_class = &mc_snapshot_class;
snapshot->enabled_processes = xbt_dynar_new(sizeof(int), NULL);
smx_process_t process;
+ // FIXME, cross-process support (simix_global->process_list)
xbt_swag_foreach(process, simix_global->process_list) {
xbt_dynar_push_as(snapshot->enabled_processes, int, (int)process->pid);
}
#endif
}
+// FIXME, cross-process support ~ we need to implement this on the app side
+// or use some form of [remote syscall execution](http://criu.org/Remote_syscall_execution)
+// based on [parasite code execution](http://criu.org/Parasite_code).
static inline
void MC_restore_snapshot_fds(mc_snapshot_t snapshot)
{