{
return address_;
}
+ bool operator!() const
+ {
+ return !address_;
+ }
operator remote_ptr<void>() const
{
return remote_ptr<void>(address_);
}
};
+template<class X, class Y>
+bool operator<(remote_ptr<X> const& x, remote_ptr<Y> const& y)
+{
+ return x.address() < y.address();
+}
+
+template<class X, class Y>
+bool operator>(remote_ptr<X> const& x, remote_ptr<Y> const& y)
+{
+ return x.address() > y.address();
+}
+
+template<class X, class Y>
+bool operator>=(remote_ptr<X> const& x, remote_ptr<Y> const& y)
+{
+ return x.address() >= y.address();
+}
+
+template<class X, class Y>
+bool operator<=(remote_ptr<X> const& x, remote_ptr<Y> const& y)
+{
+ return x.address() <= y.address();
+}
+
+template<class X, class Y>
+bool operator==(remote_ptr<X> const& x, remote_ptr<Y> const& y)
+{
+ return x.address() == y.address();
+}
+
+template<class X, class Y>
+bool operator!=(remote_ptr<X> const& x, remote_ptr<Y> const& y)
+{
+ return x.address() != y.address();
+}
+
template<class T> inline
remote_ptr<T> remote(T *p)
{
addr_pointed2 = snapshot2->read(
remote((void**)((char *) real_area2 + pointer_align)), process_index);
- if (addr_pointed1 > process->maestro_stack_start
- && addr_pointed1 < process->maestro_stack_end
- && addr_pointed2 > process->maestro_stack_start
- && addr_pointed2 < process->maestro_stack_end) {
+ if (process->in_maestro_stack(remote(addr_pointed1))
+ && process->in_maestro_stack(remote(addr_pointed2))) {
i = pointer_align + sizeof(void *);
continue;
} else if (addr_pointed1 > state->std_heap_copy.heapbase
process->pid_ = pid;
if (pid==getpid())
process->process_flags |= MC_PROCESS_SELF_FLAG;
- process->running = true;
- process->status = 0;
+ process->running_ = true;
+ process->status_ = 0;
process->memory_map = MC_get_memory_map(pid);
process->cache_flags = MC_PROCESS_CACHE_FLAG_NONE;
process->heap = NULL;
MC_free_memory_map(process->memory_map);
process->memory_map = NULL;
- process->maestro_stack_start = NULL;
- process->maestro_stack_end = NULL;
+ process->maestro_stack_start_ = nullptr;
+ process->maestro_stack_end_ = nullptr;
xbt_dynar_free(&process->smx_process_infos);
xbt_dynar_free(&process->smx_old_process_infos);
void Process::init_memory_map_info()
{
XBT_DEBUG("Get debug information ...");
- this->maestro_stack_start = NULL;
- this->maestro_stack_end = NULL;
+ this->maestro_stack_start_ = nullptr;
+ this->maestro_stack_end_ = nullptr;
this->object_infos = NULL;
this->object_infos_size = 0;
this->binary_info = NULL;
// [stack], [vvar], [vsyscall], [vdso] ...
if (pathname[0] == '[') {
if ((reg->prot & PROT_WRITE) && !memcmp(pathname, "[stack]", 7)) {
- this->maestro_stack_start = reg->start_addr;
- this->maestro_stack_end = reg->end_addr;
+ this->maestro_stack_start_ = remote(reg->start_addr);
+ this->maestro_stack_end_ = remote(reg->end_addr);
}
current_name = NULL;
continue;
for (size_t i=0; i!=this->object_infos_size; ++i)
MC_post_process_object_info(this, this->object_infos[i]);
- xbt_assert(this->maestro_stack_start, "Did not find maestro_stack_start");
- xbt_assert(this->maestro_stack_end, "Did not find maestro_stack_end");
+ xbt_assert(this->maestro_stack_start_, "Did not find maestro_stack_start");
+ xbt_assert(this->maestro_stack_end_, "Did not find maestro_stack_end");
XBT_DEBUG("Get debug information done !");
}
pid_t pid() const { return pid_; }
+ bool in_maestro_stack(remote_ptr<void> p) const
+ {
+ return p >= this->maestro_stack_start_ && p < this->maestro_stack_end_;
+ }
+
+ bool running() const
+ {
+ return running_;
+ }
+
+ void terminate(int status)
+ {
+ status_ = status;
+ running_ = false;
+ }
+
+ int status() const
+ {
+ return status_;
+ }
+
private:
void init_memory_map_info();
void refresh_heap();
pid_t pid_;
public: // to be private
int socket;
- int status;
- bool running;
+private:
+ int status_;
+ bool running_;
memory_map_t memory_map;
- void *maestro_stack_start, *maestro_stack_end;
+ remote_ptr<void> maestro_stack_start_, maestro_stack_end_;
+ int memory_file;
+ std::vector<IgnoredRegion> ignored_regions_;
+
+public: // object info
+ // TODO, make private (first, objectify mc_object_info_t)
mc_object_info_t libsimgrid_info;
mc_object_info_t binary_info;
mc_object_info_t* object_infos;
size_t object_infos_size;
- int memory_file;
+public: // Copies of MCed SMX data structures
/** Copy of `simix_global->process_list`
*
* See mc_smx.c.
*/
malloc_info* heap_info;
- // ***** Libunwind-data
+public: // Libunwind-data
/** Full-featured MC-aware libunwind address space for the process
*
/** The corresponding context
*/
void* unw_underlying_context;
-
-private:
- std::vector<IgnoredRegion> ignored_regions_;
};
/** Open a FD to a remote process memory (`/dev/$pid/mem`)
XBT_DEBUG("Shuting down model-checker");
mc_process_t process = &mc_model_checker->process();
- int status = process->status;
- if (process->running) {
+ int status = process->status();
+ if (process->running()) {
XBT_DEBUG("Killing process");
kill(process->pid(), SIGTERM);
if (waitpid(process->pid(), &status, 0) == -1)
throw std::system_error(errno, std::system_category());
// TODO, handle the case when the process does not want to die with a timeout
- process->status = status;
+ process->terminate(status);
}
}
void s_mc_server::exit()
{
// Finished:
- int status = mc_model_checker->process().status;
+ int status = mc_model_checker->process().status();
if (WIFEXITED(status))
::exit(WEXITSTATUS(status));
else if (WIFSIGNALED(status)) {
void s_mc_server::loop()
{
- while (mc_model_checker->process().running)
+ while (mc_model_checker->process().running())
this->handle_events();
}
if (pid == -1) {
if (errno == ECHILD) {
// No more children:
- if (mc_model_checker->process().running)
+ if (mc_model_checker->process().running())
xbt_die("Inconsistent state");
else
break;
if (pid == mc_model_checker->process().pid()) {
if (WIFEXITED(status) || WIFSIGNALED(status)) {
XBT_DEBUG("Child process is over");
- mc_model_checker->process().status = status;
- mc_model_checker->process().running = false;
+ mc_model_checker->process().terminate(status);
}
}
}
void MC_server_wait_client(mc_process_t process)
{
mc_server->resume(process);
- while (mc_model_checker->process().running) {
+ while (mc_model_checker->process().running()) {
if (!mc_server->handle_events())
return;
}
m.value = value;
MC_protocol_send(mc_model_checker->process().socket, &m, sizeof(m));
process->cache_flags = (mc_process_cache_flags_t) 0;
- while (mc_model_checker->process().running) {
+ while (mc_model_checker->process().running()) {
if (!mc_server->handle_events())
return;
}