From: Gabriel Corona Date: Fri, 22 May 2015 08:20:03 +0000 (+0200) Subject: [mc] Private Process::pid X-Git-Tag: v3_12~721 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/52f5862b6fa36444df90587234b36308bb645121 [mc] Private Process::pid --- diff --git a/src/mc/mc_checkpoint.cpp b/src/mc/mc_checkpoint.cpp index aca9153fc5..081aeadf9e 100644 --- a/src/mc/mc_checkpoint.cpp +++ b/src/mc/mc_checkpoint.cpp @@ -606,13 +606,12 @@ static void MC_snapshot_ignore_restore(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]; 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"); @@ -633,7 +632,7 @@ static void MC_get_current_fd(mc_snapshot_t snapshot) 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); diff --git a/src/mc/mc_process.cpp b/src/mc/mc_process.cpp index e80715b5a2..0b4a9ba065 100644 --- a/src/mc/mc_process.cpp +++ b/src/mc/mc_process.cpp @@ -191,7 +191,7 @@ Process::Process(pid_t pid, int sockfd) 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; @@ -206,7 +206,7 @@ Process::Process(pid_t pid, int sockfd) 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; @@ -240,7 +240,7 @@ Process::~Process() 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; @@ -550,7 +550,7 @@ const void *Process::read_bytes(void* buffer, std::size_t size, } } 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; } } @@ -568,7 +568,7 @@ void Process::write_bytes(const void* buffer, size_t len, remote_ptr addre 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_); } } diff --git a/src/mc/mc_process.h b/src/mc/mc_process.h index b8408c1f8e..238fa366a5 100644 --- a/src/mc/mc_process.h +++ b/src/mc/mc_process.h @@ -104,13 +104,16 @@ public: } 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; diff --git a/src/mc/mc_server.cpp b/src/mc/mc_server.cpp index 0e567b10e4..92c0e2efaf 100644 --- a/src/mc/mc_server.cpp +++ b/src/mc/mc_server.cpp @@ -98,8 +98,8 @@ void s_mc_server::shutdown() 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; @@ -115,7 +115,7 @@ void s_mc_server::exit() 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"); @@ -315,7 +315,7 @@ void s_mc_server::handle_waitpid() } } - 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;