From: Martin Quinson Date: Tue, 15 Mar 2016 10:23:57 +0000 (+0100) Subject: Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid X-Git-Tag: v3_13~428 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/1e1a18a0b8d75deb509860d08b75a27df4e935c8?hp=25a83061ae2c4418c119fb6e47956793183f9c57 Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid --- diff --git a/appveyor.yml b/appveyor.yml index ca36670247..4a6b36855f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -13,13 +13,13 @@ init: environment: global: - BOOST_ROOT: c:\Libraries\boost - BOOST_LIBRARYDIR: c:\Libraries\boost\stage\lib + BOOST_ROOT: c:\Libraries\boost_1_59_0 + BOOST_LIBRARYDIR: c:\Libraries\boost_1_59_0\stage\lib TESH_ARGS: C:/projects/simgrid/bin/tesh --setenv srcdir=C:/projects/simgrid/examples/java --setenv classpath=C:/projects/simgrid/examples/java;C:/projects/simgrid/teshsuite/java;C:/projects/simgrid/simgrid.jar --cd C:/projects/simgrid/examples/java install: # Strawberry perl is the one to work with gcc -- choco install strawberryperl -version 5.20.1.1 +- choco install --limit-output strawberryperl -version 5.20.1.1 - SET PATH=C:\strawberry\c\bin;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin;%PATH% - cpanm --notest --quiet Win32API::File - cpanm --notest --quiet IPC::Run @@ -27,7 +27,7 @@ install: #- choco install lua53 # Basic dependencies: gcc and Cmake (must be placed before Perl in the path) - SET PATH=C:\tools\mingw64\bin;%PATH% -- choco install mingw cmake --limit-output +- choco install --limit-output mingw cmake - rename "C:\Program Files\Git\usr\bin\sh.exe" "sh-ignored.exe" build_script: @@ -76,4 +76,4 @@ artifacts: # https://github.com/polysquare/cmake-unit/blob/master/appveyor.yml # https://github.com/openvswitch/ovs/blob/master/appveyor.yml -# https://github.com/behdad/harfbuzz/pull/112/files \ No newline at end of file +# https://github.com/behdad/harfbuzz/pull/112/files diff --git a/src/mc/ModelChecker.cpp b/src/mc/ModelChecker.cpp index bc69fbe034..6ff138a051 100644 --- a/src/mc/ModelChecker.cpp +++ b/src/mc/ModelChecker.cpp @@ -176,7 +176,7 @@ void ModelChecker::resume(simgrid::mc::Process& process) int res = process.getChannel().send(MC_MESSAGE_CONTINUE); if (res) throw simgrid::xbt::errno_error(res); - process.cache_flags = (mc_process_cache_flags_t) 0; + process.clear_cache(); } static @@ -434,7 +434,7 @@ void ModelChecker::simcall_handle(simgrid::mc::Process& process, unsigned long p m.pid = pid; m.value = value; process.getChannel().send(m); - process.cache_flags = (mc_process_cache_flags_t) 0; + process.clear_cache(); while (process.running()) if (!this->handle_events()) return; diff --git a/src/mc/ModelChecker.hpp b/src/mc/ModelChecker.hpp index 47790fb4ff..1f7665d957 100644 --- a/src/mc/ModelChecker.hpp +++ b/src/mc/ModelChecker.hpp @@ -30,7 +30,7 @@ namespace mc { class ModelChecker { struct pollfd fds_[2]; /** String pool for host names */ - // TODO, use std::unordered_set with heterogeneous comparison lookup (C++14) + // TODO, use std::set with heterogeneous comparison lookup (C++14)? xbt_dict_t /* */ hostnames_; // This is the parent snapshot of the current state: PageStore page_store_; diff --git a/src/mc/Process.cpp b/src/mc/Process.cpp index 3f06a40b42..613eec4f8b 100644 --- a/src/mc/Process.cpp +++ b/src/mc/Process.cpp @@ -227,8 +227,9 @@ void Process::init() this->smx_process_infos.clear(); this->smx_old_process_infos.clear(); this->unw_addr_space = unw_create_addr_space(&mc_unw_accessors , __BYTE_ORDER); - this->unw_underlying_addr_space = unw_create_addr_space(&mc_unw_vmread_accessors, __BYTE_ORDER); - this->unw_underlying_context = _UPT_create(this->pid_); + this->unw_underlying_addr_space = simgrid::unw::create_addr_space(); + this->unw_underlying_context = simgrid::unw::create_context( + this->unw_underlying_addr_space, this->pid_); } Process::~Process() @@ -262,7 +263,7 @@ void Process::refresh_heap() this->heap = std::unique_ptr(new s_xbt_mheap_t()); this->read_bytes(this->heap.get(), sizeof(struct mdesc), remote(this->heap_address), simgrid::mc::ProcessIndexDisabled); - this->cache_flags |= MC_PROCESS_CACHE_FLAG_HEAP; + this->cache_flags_ |= Process::cache_heap; } /** Refresh the information about the process @@ -273,15 +274,15 @@ void Process::refresh_heap() void Process::refresh_malloc_info() { xbt_assert(mc_mode == MC_MODE_SERVER); - if (!(this->cache_flags & MC_PROCESS_CACHE_FLAG_HEAP)) - this->refresh_heap(); // Refresh process->heapinfo: + if (this->cache_flags_ & Process::cache_malloc) + return; size_t count = this->heap->heaplimit + 1; if (this->heap_info.size() < count) this->heap_info.resize(count); this->read_bytes(this->heap_info.data(), count * sizeof(malloc_info), remote(this->heap->heapinfo), simgrid::mc::ProcessIndexDisabled); - this->cache_flags |= MC_PROCESS_CACHE_FLAG_MALLOC_INFO; + this->cache_flags_ |= Process::cache_malloc; } /** @brief Finds the range of the different memory segments and binary paths */ diff --git a/src/mc/Process.hpp b/src/mc/Process.hpp index 36ef9944e3..2b5383783c 100644 --- a/src/mc/Process.hpp +++ b/src/mc/Process.hpp @@ -37,13 +37,6 @@ #include "src/mc/mc_protocol.h" #include "src/mc/ObjectInformation.hpp" -// Those flags are used to track down which cached information -// is still up to date and which information needs to be updated. -typedef int mc_process_cache_flags_t; -#define MC_PROCESS_CACHE_FLAG_NONE 0 -#define MC_PROCESS_CACHE_FLAG_HEAP 1 -#define MC_PROCESS_CACHE_FLAG_MALLOC_INFO 2 -#define MC_PROCESS_CACHE_FLAG_SIMIX_PROCESSES 4 namespace simgrid { namespace mc { @@ -96,6 +89,13 @@ struct IgnoredHeapRegion { * - etc. */ class Process final : public AddressSpace { +private: + // Those flags are used to track down which cached information + // is still up to date and which information needs to be updated. + static constexpr int cache_none = 0; + static constexpr int cache_heap = 1; + static constexpr int cache_malloc = 2; + static constexpr int cache_simix_processes = 4; public: Process(pid_t pid, int sockfd); ~Process(); @@ -135,16 +135,21 @@ public: // Heap access: xbt_mheap_t get_heap() { - if (!(this->cache_flags & MC_PROCESS_CACHE_FLAG_HEAP)) + if (!(this->cache_flags_ & Process::cache_heap)) this->refresh_heap(); return this->heap.get(); } malloc_info* get_malloc_info() { - if (!(this->cache_flags & MC_PROCESS_CACHE_FLAG_MALLOC_INFO)) + if (!(this->cache_flags_ & Process::cache_malloc)) this->refresh_malloc_info(); return this->heap_info.data(); } + + void clear_cache() + { + this->cache_flags_ = Process::cache_none; + } Channel const& getChannel() const { return channel_; } Channel& getChannel() { return channel_; } @@ -251,9 +256,11 @@ public: // Copies of MCed SMX data structures */ std::vector smx_old_process_infos; +private: /** State of the cache (which variables are up to date) */ - mc_process_cache_flags_t cache_flags = MC_PROCESS_CACHE_FLAG_NONE; + int cache_flags_ = Process::cache_none; +public: /** Address of the heap structure in the MCed process. */ void* heap_address; diff --git a/src/mc/Variable.hpp b/src/mc/Variable.hpp index a4f048a4d1..f3b8e0a4bb 100644 --- a/src/mc/Variable.hpp +++ b/src/mc/Variable.hpp @@ -27,15 +27,16 @@ public: unsigned type_id = 0; simgrid::mc::Type* type = nullptr; - /** Address of the variable -if it is fixed) */ + /** Address of the variable (if it is fixed) */ void* address = nullptr; - /** Description of the location of the variable if it's not fixed */ + /** Description of the location of the variable (if it's not fixed) */ simgrid::dwarf::LocationList location_list; /** Offset of validity of the variable (DW_AT_start_scope) * - * This variable is not valid since the beginning of its scope. + * This is an offset from the variable scope beginning. This variable + * is only valid starting from this offset. */ std::size_t start_scope = 0; diff --git a/src/mc/mc_checkpoint.cpp b/src/mc/mc_checkpoint.cpp index 1c0c1cefad..77d6a73854 100644 --- a/src/mc/mc_checkpoint.cpp +++ b/src/mc/mc_checkpoint.cpp @@ -638,7 +638,7 @@ void restore_snapshot(mc_snapshot_t snapshot) if (use_soft_dirty) mc_model_checker->process().reset_soft_dirty(); snapshot_ignore_restore(snapshot); - mc_model_checker->process().cache_flags = 0; + mc_model_checker->process().clear_cache(); if (use_soft_dirty) mc_model_checker->parent_snapshot_ = snapshot; } diff --git a/src/mc/mc_smx.cpp b/src/mc/mc_smx.cpp index 04361857b8..78f86fe596 100644 --- a/src/mc/mc_smx.cpp +++ b/src/mc/mc_smx.cpp @@ -77,7 +77,7 @@ namespace mc { void Process::refresh_simix() { xbt_assert(mc_mode == MC_MODE_SERVER); - if (this->cache_flags & MC_PROCESS_CACHE_FLAG_SIMIX_PROCESSES) + if (this->cache_flags_ & Process::cache_simix_processes) return; // TODO, avoid to reload `&simix_global`, `simix_global`, `*simix_global` @@ -96,7 +96,7 @@ void Process::refresh_simix() MC_process_refresh_simix_process_list( this, this->smx_old_process_infos, simix_global.process_to_destroy); - this->cache_flags |= MC_PROCESS_CACHE_FLAG_SIMIX_PROCESSES; + this->cache_flags_ |= Process::cache_simix_processes; } } diff --git a/src/mc/mc_unw.h b/src/mc/mc_unw.h index 3470bd8580..d27fbd1ce9 100644 --- a/src/mc/mc_unw.h +++ b/src/mc/mc_unw.h @@ -26,29 +26,27 @@ * much here. */ +#include + #include #include -#include "src/mc/Process.hpp" +#include "src/mc/mc_forward.hpp" + +namespace simgrid { +namespace unw { + +XBT_PRIVATE unw_addr_space_t create_addr_space(); +XBT_PRIVATE void* create_context(unw_addr_space_t as, pid_t pid); + +} +} SG_BEGIN_DECL() // ***** Libunwind namespace -/** 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 behaviour (privatisation, snapshots) - * and `ucontext_t`. - * - * It works with `void*` contexts allocated with `_UPT_create(pid)`. - */ -extern XBT_PRIVATE unw_accessors_t mc_unw_vmread_accessors; - /** Virtual table for our `libunwind` implementation * * Stack unwinding on a `simgrid::mc::Process*` (for memory, unwinding information) diff --git a/src/mc/mc_unw_vmread.cpp b/src/mc/mc_unw_vmread.cpp index 29b015be8f..7082dd3849 100644 --- a/src/mc/mc_unw_vmread.cpp +++ b/src/mc/mc_unw_vmread.cpp @@ -11,10 +11,9 @@ #include #include +#include "src/mc/Process.hpp" #include "src/mc/mc_unw.h" -extern "C" { - /** \file * Libunwind namespace implementation using process_vm_readv. *. @@ -23,9 +22,9 @@ extern "C" { /** Partial structure of libunwind-ptrace context in order to get the PID * - * The context type for libunwind-race is an opaque type. We need to get the - * PID which is the first field. This is a hack which might break if the - * libunwind-ptrace structure changes. + * HACK, The context type for libunwind-race is an opaque type. + * We need to get the PID which is the first field. This is a hack + * which might break if the libunwind-ptrace structure changes. */ struct _UPT_info { pid_t pid; @@ -101,16 +100,42 @@ static int access_mem(const unw_addr_space_t as, return _UPT_access_mem(as, addr, valp, write, arg); } -unw_accessors_t mc_unw_vmread_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 - }; +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 behaviour (privatisation, 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() +{ + return unw_create_addr_space(&accessors, __BYTE_ORDER); +} + +void* create_context(unw_addr_space_t as, pid_t pid) +{ + return _UPT_create(pid); +} } +} \ No newline at end of file