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];
int res = snprintf(fd_dir_path, fd_dir_path_size,
- "/proc/%lli/fd", (long long int) snapshot->process->pid);
+ "/proc/%lli/fd", (long long int) snapshot->process->pid());
xbt_assert(res >= 0);
if ((size_t) res > fd_dir_path_size)
xbt_die("Unexpected buffer is too small for fd_dir_path");
const size_t source_size = 25;
char source[25];
int res = snprintf(source, source_size, "/proc/%lli/fd/%s",
- (long long int) snapshot->process->pid, fd_number->d_name);
+ (long long int) snapshot->process->pid(), fd_number->d_name);
xbt_assert(res >= 0);
if ((size_t) res > source_size)
xbt_die("Unexpected buffer is too small for fd %s", fd_number->d_name);
process->process_flags = MC_PROCESS_NO_FLAG;
process->socket = sockfd;
- process->pid = pid;
+ process->pid_ = pid;
if (pid==getpid())
process->process_flags |= MC_PROCESS_SELF_FLAG;
process->running = true;
if (process->is_self())
process->memory_file = -1;
else {
- int fd = open_vm(process->pid, O_RDWR);
+ int fd = open_vm(process->pid_, O_RDWR);
if (fd<0)
xbt_die("Could not open file for process virtual address space");
process->memory_file = fd;
Process* process = this;
process->process_flags = MC_PROCESS_NO_FLAG;
- process->pid = 0;
+ process->pid_ = 0;
MC_free_memory_map(process->memory_map);
process->memory_map = NULL;
}
} else {
if (pread_whole(this->memory_file, buffer, size, (off_t) address.address()) < 0)
- xbt_die("Read from process %lli failed", (long long) this->pid);
+ xbt_die("Read from process %lli failed", (long long) this->pid_);
return buffer;
}
}
memcpy((void*)address.address(), buffer, len);
} else {
if (pwrite_whole(this->memory_file, buffer, len, address.address()) < 0)
- xbt_die("Write to process %lli failed", (long long) this->pid);
+ xbt_die("Write to process %lli failed", (long long) this->pid_);
}
}
}
void ignore_region(std::uint64_t address, std::size_t size);
+ pid_t pid() const { return pid_; }
+
private:
void init_memory_map_info();
void refresh_heap();
void refresh_malloc_info();
-public: // to be private
+private:
mc_process_flags_t process_flags;
- pid_t pid;
+ pid_t pid_;
+public: // to be private
int socket;
int status;
bool running;
int status = process->status;
if (process->running) {
XBT_DEBUG("Killing process");
- kill(process->pid, SIGTERM);
- if (waitpid(process->pid, &status, 0) == -1)
+ 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;
else if (WIFSIGNALED(status)) {
// Try to uplicate the signal of the model-checked process.
// This is a temporary hack so we don't try too hard.
- kill(mc_model_checker->process().pid, WTERMSIG(status));
+ kill(mc_model_checker->process().pid(), WTERMSIG(status));
abort();
} else {
xbt_die("Unexpected status from model-checked process");
}
}
- if (pid == mc_model_checker->process().pid) {
+ if (pid == mc_model_checker->process().pid()) {
if (WIFEXITED(status) || WIFSIGNALED(status)) {
XBT_DEBUG("Child process is over");
mc_model_checker->process().status = status;