// HACK, type punning
simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_comm;
mc_model_checker->process().read(temp_comm, comm_addr);
- simgrid::kernel::activity::CommImpl* comm = temp_comm.get_buffer();
+ const simgrid::kernel::activity::CommImpl* comm = temp_comm.get_buffer();
smx_actor_t src_proc = mc_model_checker->process().resolve_actor(simgrid::mc::remote(comm->src_actor_.get()));
smx_actor_t dst_proc = mc_model_checker->process().resolve_actor(simgrid::mc::remote(comm->dst_actor_.get()));
Remote<kernel::activity::CommImpl> temp_synchro;
mc_model_checker->process().read(temp_synchro,
remote(static_cast<kernel::activity::CommImpl*>(pattern->comm_addr)));
- kernel::activity::CommImpl* synchro = static_cast<kernel::activity::CommImpl*>(temp_synchro.get_buffer());
+ const kernel::activity::CommImpl* synchro = static_cast<kernel::activity::CommImpl*>(temp_synchro.get_buffer());
char* remote_name = mc_model_checker->process().read<char*>(RemotePtr<char*>(
(uint64_t)(synchro->get_mailbox() ? &synchro->get_mailbox()->name_ : &synchro->mbox_cpy->name_)));
Remote<kernel::activity::CommImpl> temp_comm;
mc_model_checker->process().read(temp_comm, remote(static_cast<kernel::activity::CommImpl*>(pattern->comm_addr)));
- kernel::activity::CommImpl* comm = temp_comm.get_buffer();
+ const kernel::activity::CommImpl* comm = temp_comm.get_buffer();
char* remote_name;
mc_model_checker->process().read(
break;
int req_num = state->transition_.argument_;
- smx_simcall_t saved_req = &state->executed_req_;
+ const s_smx_simcall* saved_req = &state->executed_req_;
xbt_assert(saved_req);
/* because we got a copy of the executed request, we have to fetch the
/* Intermediate backtracking */
if(_sg_mc_checkpoint > 0) {
- Pair* pair = exploration_stack_.back().get();
+ const Pair* pair = exploration_stack_.back().get();
if (pair->graph_state->system_state_) {
pair->graph_state->system_state_->restore(&mc_model_checker->process());
return;
if (pair->exploration_started) {
int req_num = state->transition_.argument_;
- smx_simcall_t saved_req = &state->executed_req_;
+ const s_smx_simcall* saved_req = &state->executed_req_;
smx_simcall_t req = nullptr;
auto range = boost::range::equal_range(visited_pairs_, visited_pair.get(), DerefAndCompareByActorsCountAndUsedHeap());
for (auto i = range.first; i != range.second; ++i) {
- VisitedPair* pair_test = i->get();
+ const VisitedPair* pair_test = i->get();
if (xbt_automaton_state_compare(pair_test->automaton_state, visited_pair->automaton_state) != 0 ||
*(pair_test->atomic_propositions) != *(visited_pair->atomic_propositions) ||
not snapshot_equal(pair_test->graph_state->system_state_.get(), visited_pair->graph_state->system_state_.get()))
// For each enabled transition in the property automaton, push a
// (application_state, automaton_state) pair to the exploration stack:
for (int i = xbt_dynar_length(current_pair->automaton_state->out) - 1; i >= 0; i--) {
- xbt_automaton_transition_t transition_succ = (xbt_automaton_transition_t)xbt_dynar_get_as(
+ const xbt_automaton_transition* transition_succ = (xbt_automaton_transition_t)xbt_dynar_get_as(
current_pair->automaton_state->out, i, xbt_automaton_transition_t);
if (evaluate_label(transition_succ->label, *prop_values))
exploration_stack_.push_back(this->create_pair(current_pair.get(), transition_succ->dst, prop_values));
SIMIX_simcall_name(prev_state->internal_req_.call_));
break;
} else {
- const smx_actor_t previous_issuer = MC_smx_simcall_get_issuer(&prev_state->internal_req_);
+ const kernel::actor::ActorImpl* previous_issuer = MC_smx_simcall_get_issuer(&prev_state->internal_req_);
XBT_DEBUG("Simcall %s, process %ld (state %d) and simcall %s, process %ld (state %d) are independent",
SIMIX_simcall_name(req->call_), issuer->get_pid(), state->num_,
SIMIX_simcall_name(prev_state->internal_req_.call_), previous_issuer->get_pid(), prev_state->num_);
void SafetyChecker::restore_state()
{
/* Intermediate backtracking */
- State* last_state = stack_.back().get();
+ const State* last_state = stack_.back().get();
if (last_state->system_state_) {
last_state->system_state_->restore(&mc_model_checker->process());
return;
/* Try first to associate to same block in the other heap */
if (heapinfo2->type == heapinfo1->type && state.equals_to_<2>(i1, 0).valid_ == 0) {
- void* addr_block2 = (ADDR2UINT(i1) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
+ const void* addr_block2 = (ADDR2UINT(i1) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
if (not heap_area_differ(state, addr_block1, addr_block2, snapshot1, snapshot2, nullptr, nullptr, 0)) {
for (size_t k = 1; k < heapinfo2->busy_block.size; k++)
state.equals_to_<2>(i1 + k, 0) = HeapArea(i1, -1);
}
while (i2 < state.heaplimit && not equal) {
- void* addr_block2 = (ADDR2UINT(i2) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
+ const void* addr_block2 = (ADDR2UINT(i2) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
if (i2 == i1) {
i2++;
/* Try first to associate to same fragment_ in the other heap */
if (heapinfo2->type == heapinfo1->type && not state.equals_to_<2>(i1, j1).valid_) {
- void* addr_block2 = (ADDR2UINT(i1) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
- void* addr_frag2 = (void*)((char*)addr_block2 + (j1 << heapinfo2->type));
+ const void* addr_block2 = (ADDR2UINT(i1) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
+ const void* addr_frag2 = (void*)((char*)addr_block2 + (j1 << heapinfo2->type));
if (not heap_area_differ(state, addr_frag1, addr_frag2, snapshot1, snapshot2, nullptr, nullptr, 0))
equal = true;
}
if (state.equals_to_<2>(i2, j2).valid_)
continue;
- void* addr_block2 = (ADDR2UINT(i2) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
- void* addr_frag2 = (void*)((char*)addr_block2 + (j2 << heapinfo2b->type));
+ const void* addr_block2 = (ADDR2UINT(i2) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
+ const void* addr_frag2 = (void*)((char*)addr_block2 + (j2 << heapinfo2b->type));
if (not heap_area_differ(state, addr_frag1, addr_frag2, snapshot1, snapshot2, nullptr, nullptr, 0)) {
equal = true;
return false;
}
- Type* subtype;
- Type* subsubtype;
+ const Type* subtype;
+ const Type* subsubtype;
int elm_size;
const void* addr_pointed1;
const void* addr_pointed2;
} else {
for (simgrid::mc::Member& member : type->members) {
// TODO, optimize this? (for the offset case)
- void* real_member1 = dwarf::resolve_member(real_area1, type, &member, &snapshot1);
- void* real_member2 = dwarf::resolve_member(real_area2, type, &member, &snapshot2);
+ const void* real_member1 = dwarf::resolve_member(real_area1, type, &member, &snapshot1);
+ const void* real_member2 = dwarf::resolve_member(real_area2, type, &member, &snapshot2);
if (heap_area_differ_with_type(state, real_member1, real_member2, snapshot1, snapshot2, previous,
member.type, -1, check_ignore, 0))
return true;
const void* real_area2, const simgrid::mc::Snapshot& snapshot2,
simgrid::mc::Region* region2, simgrid::mc::Type* type, int pointer_level)
{
- simgrid::mc::Type* subtype;
- simgrid::mc::Type* subsubtype;
+ const simgrid::mc::Type* subtype;
+ const simgrid::mc::Type* subsubtype;
int elm_size;
int i;
case DW_TAG_structure_type:
case DW_TAG_class_type:
for (simgrid::mc::Member& member : type->members) {
- void* member1 = simgrid::dwarf::resolve_member(real_area1, type, &member, &snapshot1);
- void* member2 = simgrid::dwarf::resolve_member(real_area2, type, &member, &snapshot2);
+ const void* member1 = simgrid::dwarf::resolve_member(real_area1, type, &member, &snapshot1);
+ const void* member2 = simgrid::dwarf::resolve_member(real_area2, type, &member, &snapshot2);
simgrid::mc::Region* subregion1 = snapshot1.get_region(member1, region1); // region1 is hinted
simgrid::mc::Region* subregion2 = snapshot2.get_region(member2, region2); // region2 is hinted
if (areas_differ_with_type(state, member1, snapshot1, subregion1, member2, snapshot2, subregion2, member.type,
while (first <= last) {
size_type cursor = first + (last - first) / 2;
- Variable& current_var = this->global_variables[cursor];
+ const Variable& current_var = this->global_variables[cursor];
int cmp = current_var.name.compare(name);
if (cmp == 0) {
// Binary search:
while (start <= end) {
size_type cursor = start + (end - start) / 2;
- Variable& current_var = scope.variables[cursor];
+ const Variable& current_var = scope.variables[cursor];
int compare = current_var.name.compare(var_name);
if (compare == 0) {
// Variable found, remove it:
static Elf64_Half get_type(Elf* elf)
{
- Elf64_Ehdr* ehdr64 = elf64_getehdr(elf);
+ const Elf64_Ehdr* ehdr64 = elf64_getehdr(elf);
if (ehdr64)
return ehdr64->e_type;
- Elf32_Ehdr* ehdr32 = elf32_getehdr(elf);
+ const Elf32_Ehdr* ehdr32 = elf32_getehdr(elf);
if (ehdr32)
return ehdr32->e_type;
xbt_die("Could not get ELF heeader");
// Iterate over the program headers and find the PT_NOTE ones:
for (size_t i = 0; i < phnum; ++i) {
GElf_Phdr phdr_temp;
- GElf_Phdr* phdr = gelf_getphdr(elf, i, &phdr_temp);
+ const GElf_Phdr* phdr = gelf_getphdr(elf, i, &phdr_temp);
if (phdr->p_type != PT_NOTE)
continue;
int UnwindContext::find_proc_info(unw_addr_space_t /*as*/, unw_word_t ip, unw_proc_info_t* pip, int need_unwind_info,
void* arg) noexcept
{
- simgrid::mc::UnwindContext* context = (simgrid::mc::UnwindContext*)arg;
+ const simgrid::mc::UnwindContext* context = (simgrid::mc::UnwindContext*)arg;
return unw_get_accessors(context->process_->unw_underlying_addr_space)
->find_proc_info(context->process_->unw_underlying_addr_space, ip, pip, need_unwind_info,
context->process_->unw_underlying_context);
*/
void UnwindContext::put_unwind_info(unw_addr_space_t /*as*/, unw_proc_info_t* pip, void* arg) noexcept
{
- simgrid::mc::UnwindContext* context = (simgrid::mc::UnwindContext*)arg;
+ const simgrid::mc::UnwindContext* context = (simgrid::mc::UnwindContext*)arg;
return unw_get_accessors(context->process_->unw_underlying_addr_space)
->put_unwind_info(context->process_->unw_underlying_addr_space, pip, context->process_->unw_underlying_context);
}
*/
int UnwindContext::get_dyn_info_list_addr(unw_addr_space_t /*as*/, unw_word_t* dilap, void* arg) noexcept
{
- simgrid::mc::UnwindContext* context = (simgrid::mc::UnwindContext*)arg;
+ const simgrid::mc::UnwindContext* context = (simgrid::mc::UnwindContext*)arg;
return unw_get_accessors(context->process_->unw_underlying_addr_space)
->get_dyn_info_list_addr(context->process_->unw_underlying_addr_space, dilap,
context->process_->unw_underlying_context);
*/
int UnwindContext::access_mem(unw_addr_space_t /*as*/, unw_word_t addr, unw_word_t* valp, int write, void* arg) noexcept
{
- simgrid::mc::UnwindContext* context = (simgrid::mc::UnwindContext*)arg;
+ const simgrid::mc::UnwindContext* context = (simgrid::mc::UnwindContext*)arg;
if (write)
return -UNW_EREADONLYREG;
context->address_space_->read_bytes(valp, sizeof(unw_word_t), remote(addr));
unw_context_t* context = &as_context->unwind_context_;
if (write)
return -UNW_EREADONLYREG;
- greg_t* preg = (greg_t*)get_reg(context, regnum);
+ const greg_t* preg = (greg_t*)get_reg(context, regnum);
if (not preg)
return -UNW_EBADREG;
*valp = *preg;
int UnwindContext::get_proc_name(unw_addr_space_t /*as*/, unw_word_t addr, char* bufp, size_t buf_len, unw_word_t* offp,
void* arg) noexcept
{
- simgrid::mc::UnwindContext* context = (simgrid::mc::UnwindContext*)arg;
- simgrid::mc::Frame* frame = context->process_->find_function(remote(addr));
+ const simgrid::mc::UnwindContext* context = (simgrid::mc::UnwindContext*)arg;
+ const simgrid::mc::Frame* frame = context->process_->find_function(remote(addr));
if (not frame)
return -UNW_ENOINFO;
*offp = (unw_word_t)frame->range.begin() - addr;
*/
static inline pid_t _UPT_getpid(void* arg)
{
- _UPT_info* info = static_cast<_UPT_info*>(arg);
+ const _UPT_info* info = static_cast<_UPT_info*>(arg);
return info->pid;
}
case SIMCALL_COMM_WAIT: {
/* FIXME: check also that src and dst processes are not suspended */
- simgrid::kernel::activity::CommImpl* act =
- static_cast<simgrid::kernel::activity::CommImpl*>(simcall_comm_wait__getraw__comm(req));
+ const kernel::activity::CommImpl* act =
+ static_cast<kernel::activity::CommImpl*>(simcall_comm_wait__getraw__comm(req));
if (act->src_timeout_ || act->dst_timeout_) {
/* If it has a timeout it will be always be enabled (regardless of who declared the timeout),
simgrid::kernel::activity::CommImpl** comms = simcall_comm_waitany__get__comms(req);
size_t count = simcall_comm_waitany__get__count(req);
for (unsigned int index = 0; index < count; ++index) {
- auto* comm = comms[index];
+ auto const* comm = comms[index];
if (comm->src_actor_ && comm->dst_actor_)
return true;
}
}
case SIMCALL_MUTEX_LOCK: {
- smx_mutex_t mutex = simcall_mutex_lock__get__mutex(req);
+ const kernel::activity::MutexImpl* mutex = simcall_mutex_lock__get__mutex(req);
if (mutex->owner_ == nullptr)
return true;
return false;
// Those are internal requests, we do not need indirection because those objects are copies:
- kernel::activity::CommImpl* synchro1 = MC_get_comm(r1);
- kernel::activity::CommImpl* synchro2 = MC_get_comm(r2);
+ const kernel::activity::CommImpl* synchro1 = MC_get_comm(r1);
+ const kernel::activity::CommImpl* synchro2 = MC_get_comm(r2);
if ((r1->call_ == SIMCALL_COMM_ISEND || r1->call_ == SIMCALL_COMM_IRECV) && r2->call_ == SIMCALL_COMM_WAIT) {
- smx_mailbox_t mbox = MC_get_mbox(r1);
+ const kernel::activity::MailboxImpl* mbox = MC_get_mbox(r1);
if (mbox != synchro2->mbox_cpy
&& simcall_comm_wait__get__timeout(r2) <= 0)
return request_depend_asymmetric(req1, req2) && request_depend_asymmetric(req2, req1);
// Those are internal requests, we do not need indirection because those objects are copies:
- kernel::activity::CommImpl* synchro1 = MC_get_comm(req1);
- kernel::activity::CommImpl* synchro2 = MC_get_comm(req2);
+ const kernel::activity::CommImpl* synchro1 = MC_get_comm(req1);
+ const kernel::activity::CommImpl* synchro2 = MC_get_comm(req2);
switch (req1->call_) {
case SIMCALL_COMM_ISEND:
p = pointer_to_string(remote_act);
simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_synchro;
- simgrid::kernel::activity::CommImpl* act;
+ const simgrid::kernel::activity::CommImpl* act;
if (use_remote_comm) {
mc_model_checker->process().read(temp_synchro,
remote(static_cast<simgrid::kernel::activity::CommImpl*>(remote_act)));
simgrid::kernel::activity::CommImpl* remote_act =
static_cast<simgrid::kernel::activity::CommImpl*>(simcall_comm_test__getraw__comm(req));
simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_synchro;
- simgrid::kernel::activity::CommImpl* act;
+ const simgrid::kernel::activity::CommImpl* act;
if (use_remote_comm) {
mc_model_checker->process().read(temp_synchro,
remote(static_cast<simgrid::kernel::activity::CommImpl*>(remote_act)));
Remote<kernel::activity::CommImpl> temp_comm;
mc_model_checker->process().read(temp_comm, remote(remote_act));
- kernel::activity::CommImpl* comm = temp_comm.get_buffer();
+ const kernel::activity::CommImpl* comm = temp_comm.get_buffer();
return comm->src_actor_.get() && comm->dst_actor_.get();
}
kernel::activity::ActivityImpl* remote_act = simcall_comm_wait__getraw__comm(req);
Remote<kernel::activity::CommImpl> temp_comm;
mc_model_checker->process().read(temp_comm, remote(static_cast<kernel::activity::CommImpl*>(remote_act)));
- kernel::activity::CommImpl* comm = temp_comm.get_buffer();
+ const kernel::activity::CommImpl* comm = temp_comm.get_buffer();
- smx_actor_t src_proc = mc_model_checker->process().resolve_actor(mc::remote(comm->src_actor_.get()));
- smx_actor_t dst_proc = mc_model_checker->process().resolve_actor(mc::remote(comm->dst_actor_.get()));
+ const kernel::actor::ActorImpl* src_proc =
+ mc_model_checker->process().resolve_actor(mc::remote(comm->src_actor_.get()));
+ const kernel::actor::ActorImpl* dst_proc =
+ mc_model_checker->process().resolve_actor(mc::remote(comm->dst_actor_.get()));
if (issuer->get_host())
label =
xbt::string_printf("[(%ld)%s] Wait [(%ld)->(%ld)]", issuer->get_pid(), MC_smx_actor_get_host_name(issuer),
kernel::activity::ActivityImpl* remote_act = simcall_comm_test__getraw__comm(req);
Remote<simgrid::kernel::activity::CommImpl> temp_comm;
mc_model_checker->process().read(temp_comm, remote(static_cast<kernel::activity::CommImpl*>(remote_act)));
- kernel::activity::CommImpl* comm = temp_comm.get_buffer();
+ const kernel::activity::CommImpl* comm = temp_comm.get_buffer();
if (comm->src_actor_.get() == nullptr || comm->dst_actor_.get() == nullptr) {
if (issuer->get_host())
label = xbt::string_printf("[(%ld)%s] Test FALSE", issuer->get_pid(), MC_smx_actor_get_host_name(issuer));
if (mc_model_checker == nullptr)
return actor->get_host()->get_cname();
- simgrid::mc::RemoteClient* process = &mc_model_checker->process();
+ const simgrid::mc::RemoteClient* process = &mc_model_checker->process();
// Read the simgrid::xbt::string in the MCed process:
simgrid::mc::ActorInformation* info = actor_info_cast(actor);
const char* MC_smx_actor_get_name(smx_actor_t actor)
{
- simgrid::mc::RemoteClient* process = &mc_model_checker->process();
+ const simgrid::mc::RemoteClient* process = &mc_model_checker->process();
if (mc_model_checker == nullptr)
return actor->get_cname();
remote(static_cast<simgrid::kernel::activity::CommImpl*>(simcall_comm_wait__getraw__comm(&actor->simcall)));
simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_act;
mc_model_checker->process().read(temp_act, remote_act);
- simgrid::kernel::activity::CommImpl* act = temp_act.get_buffer();
+ const simgrid::kernel::activity::CommImpl* act = temp_act.get_buffer();
if (act->src_actor_.get() && act->dst_actor_.get())
state->transition_.argument_ = 0; // OK
else if (act->src_actor_.get() == nullptr && act->type_ == simgrid::kernel::activity::CommImpl::Type::READY &&
_sg_do_model_check = 1;
// Fetch socket from MC_ENV_SOCKET_FD:
- char* fd_env = std::getenv(MC_ENV_SOCKET_FD);
+ const char* fd_env = std::getenv(MC_ENV_SOCKET_FD);
if (not fd_env)
xbt_die("No MC socket passed in the environment");
int fd =
void Client::ignore_heap(void* address, std::size_t size)
{
- xbt_mheap_t heap = mmalloc_get_current_heap();
+ const mdesc* heap = mmalloc_get_current_heap();
s_mc_message_ignore_heap_t message;
message.type = MC_MESSAGE_IGNORE_HEAP;
void Client::declare_stack(void* stack, size_t size, ucontext_t* context)
{
- xbt_mheap_t heap = mmalloc_get_current_heap();
+ const mdesc* heap = mmalloc_get_current_heap();
s_stack_region_t region;
memset(®ion, 0, sizeof(region));
continue;
xbt_assert(c > 0, "Could not read string from remote process");
- void* p = memchr(res.data() + off, '\0', c);
+ const void* p = memchr(res.data() + off, '\0', c);
if (p)
return std::string(res.data());
}
unsigned int cursor = 0;
- IgnoredRegion* current_region = nullptr;
+ const IgnoredRegion* current_region = nullptr;
int start = 0;
int end = ignored_regions_.size() - 1;
size_type cursor;
while (start <= end) {
cursor = start + (end - start) / 2;
- auto& current_region = ignored_heap_[cursor];
+ auto const& current_region = ignored_heap_[cursor];
if (current_region.address == region.address)
return;
else if (current_region.address < region.address)
size_type cursor;
while (start <= end) {
cursor = (start + end) / 2;
- auto& region = ignored_heap_[cursor];
+ auto const& region = ignored_heap_[cursor];
if (region.address < address)
start = cursor + 1;
else if ((char*)region.address <= ((char*)address + size)) {
// Read each page:
while (simgrid::mc::mmu::split((std::uintptr_t)addr).first != page_end) {
- void* snapshot_addr = mc_translate_address_region((uintptr_t)addr, this);
+ const void* snapshot_addr = mc_translate_address_region((uintptr_t)addr, this);
void* next_page = (void*)simgrid::mc::mmu::join(simgrid::mc::mmu::split((std::uintptr_t)addr).first + 1, 0);
size_t readable = (char*)next_page - (const char*)addr;
memcpy(dest, snapshot_addr, readable);
}
// Read the end:
- void* snapshot_addr = mc_translate_address_region((uintptr_t)addr, this);
+ const void* snapshot_addr = mc_translate_address_region((uintptr_t)addr, this);
memcpy(dest, snapshot_addr, size);
return target;
for (auto const& object_info : process->object_infos)
add_region(RegionType::Data, object_info.get(), object_info->start_rw, object_info->end_rw - object_info->start_rw);
- xbt_mheap_t heap = process->get_heap();
+ const mdesc* heap = process->get_heap();
void* start_heap = heap->base;
void* end_heap = heap->breakval;
static std::vector<s_mc_stack_frame_t> unwind_stack_frames(UnwindContext* stack_context)
{
- RemoteClient* process = &mc_model_checker->process();
+ const RemoteClient* process = &mc_model_checker->process();
std::vector<s_mc_stack_frame_t> result;
unw_cursor_t c = stack_context->cursor();
/* Regular use */
bool on_heap(const void* address) const
{
- const xbt_mheap_t heap = process()->get_heap();
+ const mdesc* heap = process()->get_heap();
return address >= heap->heapbase && address < heap->breakval;
}