#include "mc_forward.h"
-// Compatibility stuff, will be removed:
-#define MC_ADDRESS_SPACE_READ_FLAGS_NONE ::simgrid::mc::AddressSpace::Normal
-#define MC_ADDRESS_SPACE_READ_FLAGS_LAZY ::simgrid::mc::AddressSpace::Lazy
-
-// Compatibility stuff, will be removed:
-#define MC_PROCESS_INDEX_MISSING ::simgrid::mc::ProcessIndexMissing
-#define MC_PROCESS_INDEX_DISABLED ::simgrid::mc::ProcessIndexDisabled
-#define MC_PROCESS_INDEX_ANY ::simgrid::mc::ProcessIndexAny
-
namespace simgrid {
namespace mc {
{
static_assert(std::is_trivial<T>::value, "Cannot read a non-trivial type");
T res;
- this->read_bytes(&res, sizeof(T), address, process_index);
- return res;
+ return *(T*)this->read_bytes(&res, sizeof(T), address, process_index);
}
};
}
}
-// Deprecated compatibility wrapper:
-static inline
-const void* MC_address_space_read(
- mc_address_space_t address_space, simgrid::mc::AddressSpace::ReadMode mode,
- void* target, const void* addr, size_t size,
- int process_index)
-{
- return address_space->read_bytes(target, size, (std::uint64_t) addr,
- process_index, mode);
-}
-
#endif
#ifdef HAVE_MC
// Fetch from MCed memory:
if (mc_mode == MC_MODE_SERVER) {
- MC_process_read(&mc_model_checker->process(), MC_ADDRESS_SPACE_READ_FLAGS_NONE,
- &temp_synchro, act, sizeof(temp_synchro),
- MC_PROCESS_INDEX_ANY);
+ mc_model_checker->process().read_bytes(
+ &temp_synchro, sizeof(temp_synchro), (std::uint64_t)act);
act = &temp_synchro;
}
#endif
size_t buffer_size = 0;
if (mc_mode == MC_MODE_SERVER) {
// Read dynar:
- MC_process_read_simple(&mc_model_checker->process(),
- &comms_buffer, simcall_comm_waitany__get__comms(req), sizeof(comms_buffer));
+ mc_model_checker->process().read_bytes(
+ &comms_buffer, sizeof(comms_buffer),
+ (std::uint64_t)simcall_comm_waitany__get__comms(req));
assert(comms_buffer.elmsize == sizeof(act));
buffer_size = comms_buffer.elmsize * comms_buffer.used;
comms = &comms_buffer;
// Read all the dynar buffer:
char buffer[buffer_size];
if (mc_mode == MC_MODE_SERVER)
- MC_process_read_simple(&mc_model_checker->process(),
- buffer, comms->data, sizeof(buffer));
+ mc_model_checker->process().read_bytes(buffer, sizeof(buffer),
+ (std::uint64_t)comms->data);
#else
comms = simcall_comm_waitany__get__comms(req);
#endif
// Fetch act from MCed memory:
if (mc_mode == MC_MODE_SERVER) {
memcpy(&act, buffer + comms->elmsize * index, sizeof(act));
- MC_process_read(&mc_model_checker->process(), MC_ADDRESS_SPACE_READ_FLAGS_NONE,
- &temp_synchro, act, sizeof(temp_synchro),
- MC_PROCESS_INDEX_ANY);
+ mc_model_checker->process().read_bytes(
+ &temp_synchro, sizeof(temp_synchro), (std::uint64_t)act);
act = &temp_synchro;
}
else
#ifdef HAVE_MC
s_smx_mutex_t temp_mutex;
if (mc_mode == MC_MODE_SERVER) {
- MC_process_read(&mc_model_checker->process(), MC_ADDRESS_SPACE_READ_FLAGS_NONE,
- &temp_mutex, mutex, sizeof(temp_mutex),
- MC_PROCESS_INDEX_ANY);
+ mc_model_checker->process().read_bytes(
+ &temp_mutex, sizeof(temp_mutex), (std::uint64_t)mutex);
mutex = &temp_mutex;
}
#endif
region->permanent_addr = permanent_addr;
region->size = size;
region->flat.data = xbt_malloc(size);
- MC_process_read(&mc_model_checker->process(), MC_ADDRESS_SPACE_READ_FLAGS_NONE,
- region->flat.data, permanent_addr, size,
- MC_PROCESS_INDEX_DISABLED);
+ mc_model_checker->process().read_bytes(region->flat.data, size,
+ (std::uint64_t)permanent_addr,
+ simgrid::mc::ProcessIndexDisabled);
XBT_DEBUG("New region : type : %d, data : %p (real addr %p), size : %zu",
region_type, region->flat.data, permanent_addr, size);
return region;
"smpi_privatisation_regions",
&remote_smpi_privatisation_regions, sizeof(remote_smpi_privatisation_regions));
s_smpi_privatisation_region_t privatisation_regions[process_count];
- MC_process_read_simple(&mc_model_checker->process(), &privatisation_regions,
- remote_smpi_privatisation_regions, sizeof(privatisation_regions));
+ mc_model_checker->process().read_bytes(
+ &privatisation_regions, sizeof(privatisation_regions),
+ (std::uint64_t)remote_smpi_privatisation_regions);
for (size_t i = 0; i < process_count; i++) {
region->privatized.regions[i] =
} else
#endif
{
- snapshot->privatization_index = MC_PROCESS_INDEX_MISSING;
+ snapshot->privatization_index = simgrid::mc::ProcessIndexMissing;
}
}
// Read the context from remote process:
unw_context_t context;
- MC_process_read_simple(&mc_model_checker->process(),
- &context, (unw_context_t*) current_stack->context, sizeof(context));
+ mc_model_checker->process().read_bytes(
+ &context, sizeof(context), (std::uint64_t) current_stack->context);
st->context = xbt_new0(s_mc_unw_context_t, 1);
if (mc_unw_init_context(st->context, &mc_model_checker->process(),
ignored_data.size = region->size;
ignored_data.data = malloc(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);
+ snapshot->process->read_bytes(
+ ignored_data.data, region->size, (std::uint64_t) region->addr,
+ simgrid::mc::ProcessIndexDisabled);
xbt_dynar_push(snapshot->ignored_data, &ignored_data);
}
static void update_comm_pattern(mc_comm_pattern_t comm_pattern, smx_synchro_t comm_addr)
{
s_smx_synchro_t comm;
- MC_process_read_simple(&mc_model_checker->process(),
- &comm, comm_addr, sizeof(comm));
+ mc_model_checker->process().read_bytes(
+ &comm, sizeof(comm), (std::uint64_t)comm_addr);
smx_process_t src_proc = MC_smx_resolve_process(comm.comm.src_proc);
smx_process_t dst_proc = MC_smx_resolve_process(comm.comm.dst_proc);
comm_pattern->dst_host = MC_smx_process_get_host_name(dst_proc);
if (comm_pattern->data_size == -1 && comm.comm.src_buff != NULL) {
size_t buff_size;
- MC_process_read_simple(&mc_model_checker->process(),
- &buff_size, comm.comm.dst_buff_size, sizeof(buff_size));
+ mc_model_checker->process().read_bytes(
+ &buff_size, sizeof(buff_size), (std::uint64_t)comm.comm.dst_buff_size);
comm_pattern->data_size = buff_size;
comm_pattern->data = xbt_malloc0(comm_pattern->data_size);
- MC_process_read_simple(&mc_model_checker->process(),
- comm_pattern->data, comm.comm.src_buff, comm_pattern->data_size);
+ mc_model_checker->process().read_bytes(
+ comm_pattern->data, comm_pattern->data_size,
+ (std::uint64_t) comm.comm.src_buff);
}
}
pattern->type = SIMIX_COMM_SEND;
pattern->comm_addr = simcall_comm_isend__get__result(request);
- s_smx_synchro_t synchro;
- MC_process_read_simple(&mc_model_checker->process(),
- &synchro, pattern->comm_addr, sizeof(synchro));
+ s_smx_synchro_t synchro = mc_model_checker->process().read<s_smx_synchro_t>(
+ (std::uint64_t) pattern->comm_addr);
- 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));
+ char* remote_name = mc_model_checker->process().read<char*>(
+ (std::uint64_t)(synchro.comm.rdv ? &synchro.comm.rdv->name : &synchro.comm.rdv_cpy->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);
- struct s_smpi_mpi_request mpi_request;
- MC_process_read_simple(&mc_model_checker->process(),
- &mpi_request, (MPI_Request) simcall_comm_isend__get__data(request),
- sizeof(mpi_request));
+ struct s_smpi_mpi_request mpi_request =
+ mc_model_checker->process().read<s_smpi_mpi_request>(
+ (std::uint64_t) simcall_comm_isend__get__data(request));
pattern->tag = mpi_request.tag;
if(synchro.comm.src_buff != NULL){
pattern->data_size = synchro.comm.src_buff_size;
pattern->data = xbt_malloc0(pattern->data_size);
- MC_process_read_simple(&mc_model_checker->process(),
- pattern->data, synchro.comm.src_buff, pattern->data_size);
+ mc_model_checker->process().read_bytes(
+ pattern->data, pattern->data_size, (std::uint64_t)synchro.comm.src_buff);
}
if(mpi_request.detached){
if (!initial_global_state->initial_communications_pattern_done) {
pattern->comm_addr = simcall_comm_irecv__get__result(request);
struct s_smpi_mpi_request mpi_request;
- MC_process_read_simple(&mc_model_checker->process(),
- &mpi_request, (MPI_Request) simcall_comm_irecv__get__data(request),
- sizeof(mpi_request));
+ mc_model_checker->process().read_bytes(
+ &mpi_request, sizeof(mpi_request),
+ (std::uint64_t) simcall_comm_irecv__get__data(request));
pattern->tag = mpi_request.tag;
s_smx_synchro_t synchro;
- MC_process_read_simple(&mc_model_checker->process(),
- &synchro, pattern->comm_addr, sizeof(synchro));
+ mc_model_checker->process().read_bytes(
+ &synchro, sizeof(synchro), (std::uint64_t)pattern->comm_addr);
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));
+ mc_model_checker->process().read_bytes(
+ &remote_name, sizeof(remote_name),
+ (std::uint64_t)(synchro.comm.rdv ? &synchro.comm.rdv->name : &synchro.comm.rdv_cpy->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;
#endif
/* Init heap information used in heap comparison algorithm */
- xbt_mheap_t heap1 = (xbt_mheap_t) MC_snapshot_read(
- s1, MC_ADDRESS_SPACE_READ_FLAGS_LAZY,
- alloca(sizeof(struct mdesc)), process->heap_address, sizeof(struct mdesc),
- MC_PROCESS_INDEX_MISSING);
- xbt_mheap_t heap2 = (xbt_mheap_t) MC_snapshot_read(
- s2, MC_ADDRESS_SPACE_READ_FLAGS_LAZY,
- alloca(sizeof(struct mdesc)), process->heap_address, sizeof(struct mdesc),
- MC_PROCESS_INDEX_MISSING);
+ xbt_mheap_t heap1 = (xbt_mheap_t)s1->read_bytes(
+ alloca(sizeof(struct mdesc)), sizeof(struct mdesc),
+ (std::uint64_t)process->heap_address,
+ simgrid::mc::ProcessIndexMissing, simgrid::mc::AddressSpace::Lazy);
+ xbt_mheap_t heap2 = (xbt_mheap_t)s2->read_bytes(
+ alloca(sizeof(struct mdesc)), sizeof(struct mdesc),
+ (std::uint64_t)process->heap_address,
+ simgrid::mc::ProcessIndexMissing, simgrid::mc::AddressSpace::Lazy);
res_init = init_heap_information(heap1, heap2, s1->to_ignore, s2->to_ignore);
if (res_init == -1) {
#ifdef MC_DEBUG
/* Compare global variables */
is_diff =
- compare_global_variables(region1->object_info, MC_ADDRESS_SPACE_READ_FLAGS_NONE,
+ compare_global_variables(region1->object_info, simgrid::mc::AddressSpace::Normal,
region1, region2,
s1, s2);
void* heapinfo_address = &((xbt_mheap_t) process->heap_address)->heapinfo;
// This is in snapshot do not use them directly:
- const malloc_info* heapinfos1 = (const malloc_info*) MC_snapshot_read_pointer(snapshot1, heapinfo_address, MC_PROCESS_INDEX_MISSING);
- const malloc_info* heapinfos2 = (const malloc_info*) MC_snapshot_read_pointer(snapshot2, heapinfo_address, MC_PROCESS_INDEX_MISSING);
+ const malloc_info* heapinfos1 = snapshot1->read<malloc_info*>(
+ (std::uint64_t)heapinfo_address, simgrid::mc::ProcessIndexMissing);
+ const malloc_info* heapinfos2 = snapshot2->read<malloc_info*>(
+ (std::uint64_t)heapinfo_address, simgrid::mc::ProcessIndexMissing);
while (i1 <= state->heaplimit) {
(char *) state->std_heap_copy.heapbase;
res_compare =
- compare_heap_area(MC_PROCESS_INDEX_MISSING, addr_block1, addr_block2, snapshot1, snapshot2,
+ compare_heap_area(simgrid::mc::ProcessIndexMissing, addr_block1, addr_block2, snapshot1, snapshot2,
NULL, NULL, 0);
if (res_compare != 1) {
}
res_compare =
- compare_heap_area(MC_PROCESS_INDEX_MISSING, addr_block1, addr_block2, snapshot1, snapshot2,
+ compare_heap_area(simgrid::mc::ProcessIndexMissing, addr_block1, addr_block2, snapshot1, snapshot2,
NULL, NULL, 0);
if (res_compare != 1) {
(j1 << heapinfo2->type));
res_compare =
- compare_heap_area(MC_PROCESS_INDEX_MISSING, addr_frag1, addr_frag2, snapshot1, snapshot2,
+ compare_heap_area(simgrid::mc::ProcessIndexMissing, addr_frag1, addr_frag2, snapshot1, snapshot2,
NULL, NULL, 0);
if (res_compare != 1)
(j2 << heapinfo2b->type));
res_compare =
- compare_heap_area(MC_PROCESS_INDEX_MISSING, addr_frag1, addr_frag2, snapshot2, snapshot2,
+ compare_heap_area(simgrid::mc::ProcessIndexMissing, addr_frag1, addr_frag2, snapshot2, snapshot2,
NULL, NULL, 0);
if (res_compare != 1) {
uintptr_t address = (uintptr_t) state->stack[state->stack_size - 1];
if (!state->address_space)
xbt_die("Missing address space");
- MC_address_space_read(
- state->address_space, MC_ADDRESS_SPACE_READ_FLAGS_NONE,
- &state->stack[state->stack_size - 1], (const void*) address,
- sizeof(uintptr_t), state->process_index);
+ state->address_space->read_bytes(
+ &state->stack[state->stack_size - 1], sizeof(uintptr_t),
+ address, state->process_index);
}
break;
- move the segments in shared memory (this will break `fork` however).
*/
page_data = temp;
- MC_process_read(process, MC_ADDRESS_SPACE_READ_FLAGS_NONE,
- temp, page, xbt_pagesize, MC_PROCESS_INDEX_DISABLED);
+ process->read_bytes(
+ temp, xbt_pagesize, (std::uint64_t) page,
+ simgrid::mc::ProcessIndexDisabled);
}
pagenos[i] = mc_model_checker->page_store().store_page(page_data);
xbt_die("No heap information in the target process");
if(!std_heap_var->address)
xbt_die("No constant address for this variable");
- MC_process_read(process, MC_ADDRESS_SPACE_READ_FLAGS_NONE,
+ MC_process_read(process, simgrid::mc::AddressSpace::Normal,
&process->heap_address, std_heap_var->address, sizeof(struct mdesc*),
- MC_PROCESS_INDEX_DISABLED);
+ simgrid::mc::ProcessIndexDisabled);
process->smx_process_infos = MC_smx_process_info_list_new();
process->smx_old_process_infos = MC_smx_process_info_list_new();
if (!process->heap) {
process->heap = (struct mdesc*) malloc(sizeof(struct mdesc));
}
- MC_process_read(process, MC_ADDRESS_SPACE_READ_FLAGS_NONE,
+ MC_process_read(process, simgrid::mc::AddressSpace::Normal,
process->heap, process->heap_address, sizeof(struct mdesc),
- MC_PROCESS_INDEX_DISABLED
+ simgrid::mc::ProcessIndexDisabled
);
process->cache_flags |= MC_PROCESS_CACHE_FLAG_HEAP;
}
size_t malloc_info_bytesize =
(process->heap->heaplimit + 1) * sizeof(malloc_info);
process->heap_info = (malloc_info*) realloc(process->heap_info, malloc_info_bytesize);
- MC_process_read(process, MC_ADDRESS_SPACE_READ_FLAGS_NONE,
+ MC_process_read(process, simgrid::mc::AddressSpace::Normal,
process->heap_info,
process->heap->heapinfo, malloc_info_bytesize,
- MC_PROCESS_INDEX_DISABLED);
+ simgrid::mc::ProcessIndexDisabled);
process->cache_flags |= MC_PROCESS_CACHE_FLAG_MALLOC_INFO;
}
if ((size_t) var->type->full_type->byte_size != size)
xbt_die("Unexpected size for %s (expected %zi, was %zi)",
name, size, (size_t) var->type->full_type->byte_size);
- MC_process_read(process, MC_ADDRESS_SPACE_READ_FLAGS_NONE, target, var->address, size,
- MC_PROCESS_INDEX_ANY);
+ MC_process_read(process, simgrid::mc::AddressSpace::Normal, target, var->address, size,
+ simgrid::mc::ProcessIndexAny);
}
char* MC_process_read_string(mc_process_t process, void* address)
std::uint64_t address, int process_index,
AddressSpace::ReadMode mode)
{
- if (process_index != MC_PROCESS_INDEX_DISABLED) {
+ if (process_index != simgrid::mc::ProcessIndexDisabled) {
mc_object_info_t info = MC_process_find_object_info_rw(this, (void*)address);
// Segment overlap is not handled.
if (MC_object_info_is_privatized(info)) {
}
if (MC_process_is_self(this)) {
- if (mode == MC_ADDRESS_SPACE_READ_FLAGS_LAZY)
+ if (mode == simgrid::mc::AddressSpace::Lazy)
return (void*)address;
else {
memcpy(buffer, (void*)address, size);
extern "C" {
-const void* MC_process_read_simple(mc_process_t process,
- void* local, const void* remote, size_t len)
-{
- simgrid::mc::AddressSpace::ReadMode mode = MC_ADDRESS_SPACE_READ_FLAGS_NONE;
- int index = MC_PROCESS_INDEX_ANY;
- MC_process_read(process, mode, local, remote, len, index);
- return local;
-}
-
const void* MC_process_read_dynar_element(mc_process_t process,
void* local, const void* remote_dynar, size_t i, size_t len)
{
}
// Simplified versions/wrappers (whould be moved in mc_address_space):
-XBT_INTERNAL const void* MC_process_read_simple(mc_process_t process,
- void* local, const void* remote, size_t len);
+static inline const void* MC_process_read_simple(mc_process_t process,
+ void* local, const void* remote, size_t len)
+{
+ return process->read_bytes(local, len, (std::uint64_t)remote);
+}
+
XBT_INTERNAL const void* MC_process_read_dynar_element(mc_process_t process,
void* local, const void* remote_dynar, size_t i, size_t len);
XBT_INTERNAL unsigned long MC_process_read_dynar_length(mc_process_t process,
{
struct mc_symbol_pointer_callback* callback = (struct mc_symbol_pointer_callback*) p;
int value;
- MC_process_read(callback->process, MC_ADDRESS_SPACE_READ_FLAGS_NONE,
- &value, callback->value, sizeof(value), MC_PROCESS_INDEX_ANY);
+ MC_process_read(callback->process, simgrid::mc::AddressSpace::Normal,
+ &value, callback->value, sizeof(value), simgrid::mc::ProcessIndexAny);
return value;
}
{
// swag = REMOTE(*simix_global->process_list)
s_xbt_swag_t swag;
- MC_process_read(process, MC_ADDRESS_SPACE_READ_FLAGS_NONE, &swag, remote_swag, sizeof(swag),
- MC_PROCESS_INDEX_ANY);
+ MC_process_read(process, simgrid::mc::AddressSpace::Normal, &swag, remote_swag, sizeof(swag),
+ simgrid::mc::ProcessIndexAny);
smx_process_t p;
xbt_dynar_reset(target);
info.address = p;
info.name = NULL;
info.hostname = NULL;
- MC_process_read(process, MC_ADDRESS_SPACE_READ_FLAGS_NONE,
- &info.copy, p, sizeof(info.copy), MC_PROCESS_INDEX_ANY);
+ MC_process_read(process, simgrid::mc::AddressSpace::Normal,
+ &info.copy, p, sizeof(info.copy), simgrid::mc::ProcessIndexAny);
xbt_dynar_push(target, &info);
// Lookup next process address:
// simix_global = REMOTE(*simix_global)
s_smx_global_t simix_global;
- MC_process_read(process, MC_ADDRESS_SPACE_READ_FLAGS_NONE, &simix_global,
+ MC_process_read(process, simgrid::mc::AddressSpace::Normal, &simix_global,
simix_global_p, sizeof(simix_global),
- MC_PROCESS_INDEX_ANY);
+ simgrid::mc::ProcessIndexAny);
MC_process_refresh_simix_process_list(
process, process->smx_process_infos, simix_global.process_list);
if (region->storage_type == MC_REGION_STORAGE_TYPE_PRIVATIZED) {
#ifdef HAVE_SMPI
// Use the current process index of the snapshot:
- if (process_index == MC_PROCESS_INDEX_DISABLED) {
+ if (process_index == simgrid::mc::ProcessIndexDisabled) {
process_index = snapshot->privatization_index;
}
if (process_index < 0) {
{
return snapshot->read_bytes(target, size, (uint64_t)addr, process_index, mode);
}
+
MC_SHOULD_BE_INTERNAL int MC_snapshot_region_memcmp(
const void* addr1, mc_mem_region_t region1,
const void* addr2, mc_mem_region_t region2, size_t size);
const void* MC_snapshot_read_pointer(mc_snapshot_t snapshot, const void* addr, int process_index)
{
void* res;
- return *(const void**) MC_snapshot_read(snapshot, MC_ADDRESS_SPACE_READ_FLAGS_LAZY,
+ return *(const void**) MC_snapshot_read(snapshot, simgrid::mc::AddressSpace::Lazy,
&res, addr, sizeof(void*), process_index);
}
static inline __attribute__((always_inline))
const void* MC_region_read(mc_mem_region_t region, void* target, const void* addr, size_t size)
{
- if (region==NULL)
- // Should be deprecated:
- return addr;
+ xbt_assert(region);
uintptr_t offset = (char*) addr - (char*) region->start_addr;
mc_unw_context_t context = (mc_unw_context_t) arg;
if (write)
return - UNW_EREADONLYREG;
- MC_address_space_read(context->address_space,
- MC_ADDRESS_SPACE_READ_FLAGS_NONE, valp, (void*) addr, sizeof(unw_word_t), MC_PROCESS_INDEX_ANY);
- // We don't handle failure gracefully.
+ context->address_space->read_bytes(valp, sizeof(unw_word_t), addr);
return 0;
}