X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/149c63f36e15b8500b1e826bda5138318ff7ba2b..ea74f5d95928a521a588737e81f1de94eef25d19:/src/mc/inspect/mc_unw_vmread.cpp diff --git a/src/mc/inspect/mc_unw_vmread.cpp b/src/mc/inspect/mc_unw_vmread.cpp index 9601c0e771..ac8d259c5d 100644 --- a/src/mc/inspect/mc_unw_vmread.cpp +++ b/src/mc/inspect/mc_unw_vmread.cpp @@ -1,10 +1,10 @@ -/* Copyright (c) 2015-2020. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2015-2022. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ #include "src/mc/inspect/mc_unw.hpp" -#include "src/mc/remote/RemoteClient.hpp" +#include "src/mc/remote/RemoteProcess.hpp" #include #include @@ -57,17 +57,17 @@ static int access_mem(const unw_addr_space_t as, const unw_word_t addr, unw_word return -UNW_EINVAL; else return 0; - } - if (s < 0 && errno != ENOSYS) + } else if (errno != ENOSYS) { return -UNW_EINVAL; + } #endif // /proc/${pid}/mem implementation. // On recent kernels, we do not need to ptrace the target process. // On older kernels, it is necessary to ptrace the target process. size_t count = size; - off_t off = (off_t)addr; - char* buf = (char*)valp; + auto off = static_cast(addr); + auto* buf = reinterpret_cast(valp); int fd = simgrid::mc::open_vm(pid, O_RDONLY); if (fd < 0) return -UNW_EINVAL; @@ -94,25 +94,24 @@ static int access_mem(const unw_addr_space_t as, const unw_word_t addr, unw_word namespace simgrid { namespace unw { -/** Virtual table for our `libunwind-process_vm_readv` implementation. - * - * This implementation reuse most the code of `libunwind-ptrace` but - * does not use ptrace() to read the target process memory by - * `process_vm_readv()` or `/dev/${pid}/mem` if possible. - * - * Does not support any MC-specific behavior (privatization, snapshots) - * and `ucontext_t`. - * - * It works with `void*` contexts allocated with `_UPT_create(pid)`. - */ -// TODO, we could get rid of this if we properly stop the model-checked -// process before reading the memory. -static unw_accessors_t accessors = {&_UPT_find_proc_info, &_UPT_put_unwind_info, &_UPT_get_dyn_info_list_addr, - &access_mem, &_UPT_access_reg, &_UPT_access_fpreg, - &_UPT_resume, &_UPT_get_proc_name}; - unw_addr_space_t create_addr_space() { + /** Virtual table for our `libunwind-process_vm_readv` implementation. + * + * This implementation reuse most the code of `libunwind-ptrace` but + * does not use ptrace() to read the target process memory by + * `process_vm_readv()` or `/dev/${pid}/mem` if possible. + * + * Does not support any MC-specific behavior (privatization, snapshots) + * and `ucontext_t`. + * + * It works with `void*` contexts allocated with `_UPT_create(pid)`. + */ + // TODO, we could get rid of this if we properly stop the model-checked + // process before reading the memory. + unw_accessors_t accessors = {&_UPT_find_proc_info, &_UPT_put_unwind_info, &_UPT_get_dyn_info_list_addr, + &access_mem, &_UPT_access_reg, &_UPT_access_fpreg, + &_UPT_resume, &_UPT_get_proc_name}; return unw_create_addr_space(&accessors, BYTE_ORDER); }