From: Arnaud Giersch Date: Sat, 28 Dec 2019 13:11:19 +0000 (+0100) Subject: [sonar] Constify pointer and reference parameters in src/mc/. X-Git-Tag: v3.25~198 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/ac9197eec3a25524040ce2f55021ba590788c3a3 [sonar] Constify pointer and reference parameters in src/mc/. --- diff --git a/src/include/mc/mc.h b/src/include/mc/mc.h index c662db508f..90349ab3c4 100644 --- a/src/include/mc/mc.h +++ b/src/include/mc/mc.h @@ -26,8 +26,6 @@ SG_BEGIN_DECL /********************************* Global *************************************/ XBT_ATTRIB_NORETURN XBT_PUBLIC void MC_run(); -XBT_PUBLIC void MC_process_clock_add(smx_actor_t, double); -XBT_PUBLIC double MC_process_clock_get(smx_actor_t); XBT_PRIVATE void MC_automaton_load(const char *file); /********************************* Memory *************************************/ @@ -35,4 +33,9 @@ XBT_PUBLIC void MC_memory_init(); /* Initialize the memory subsystem */ SG_END_DECL +#ifdef __cplusplus +XBT_PUBLIC void MC_process_clock_add(const simgrid::kernel::actor::ActorImpl*, double); +XBT_PUBLIC double MC_process_clock_get(const simgrid::kernel::actor::ActorImpl*); +#endif + #endif diff --git a/src/mc/ModelChecker.cpp b/src/mc/ModelChecker.cpp index f5ef3b49cb..42d42f665d 100644 --- a/src/mc/ModelChecker.cpp +++ b/src/mc/ModelChecker.cpp @@ -161,7 +161,7 @@ static void MC_report_assertion_error() session->log_state(); } -bool ModelChecker::handle_message(char* buffer, ssize_t size) +bool ModelChecker::handle_message(const char* buffer, ssize_t size) { s_mc_message_t base_message; xbt_assert(size >= (ssize_t)sizeof(base_message), "Broken message"); diff --git a/src/mc/ModelChecker.hpp b/src/mc/ModelChecker.hpp index fcbff13718..52d068fa50 100644 --- a/src/mc/ModelChecker.hpp +++ b/src/mc/ModelChecker.hpp @@ -65,7 +65,7 @@ public: private: void setup_ignore(); - bool handle_message(char* buffer, ssize_t size); + bool handle_message(const char* buffer, ssize_t size); void handle_waitpid(); void on_signal(int signo); diff --git a/src/mc/VisitedState.cpp b/src/mc/VisitedState.cpp index 5b8919be6e..55d40b63e9 100644 --- a/src/mc/VisitedState.cpp +++ b/src/mc/VisitedState.cpp @@ -33,10 +33,9 @@ void VisitedStates::prune() { while (states_.size() > (std::size_t)_sg_mc_max_visited_states) { XBT_DEBUG("Try to remove visited state (maximum number of stored states reached)"); - auto min_element = boost::range::min_element(states_, - [](std::unique_ptr& a, std::unique_ptr& b) { - return a->num < b->num; - }); + auto min_element = boost::range::min_element( + states_, [](const std::unique_ptr& a, + const std::unique_ptr& b) { return a->num < b->num; }); xbt_assert(min_element != states_.end()); // and drop it: states_.erase(min_element); diff --git a/src/mc/checker/CommunicationDeterminismChecker.cpp b/src/mc/checker/CommunicationDeterminismChecker.cpp index db14ae1fad..a6a41270b1 100644 --- a/src/mc/checker/CommunicationDeterminismChecker.cpp +++ b/src/mc/checker/CommunicationDeterminismChecker.cpp @@ -29,8 +29,8 @@ std::vector> incomplete_communic /********** Static functions ***********/ -static e_mc_comm_pattern_difference_t compare_comm_pattern(simgrid::mc::PatternCommunication* comm1, - simgrid::mc::PatternCommunication* comm2) +static e_mc_comm_pattern_difference_t compare_comm_pattern(const simgrid::mc::PatternCommunication* comm1, + const simgrid::mc::PatternCommunication* comm2) { if(comm1->type != comm2->type) return TYPE_DIFF; @@ -50,7 +50,7 @@ static e_mc_comm_pattern_difference_t compare_comm_pattern(simgrid::mc::PatternC } static char* print_determinism_result(e_mc_comm_pattern_difference_t diff, int process, - simgrid::mc::PatternCommunication* comm, unsigned int cursor) + const simgrid::mc::PatternCommunication* comm, unsigned int cursor) { char* type; char* res; @@ -116,7 +116,7 @@ static void update_comm_pattern(simgrid::mc::PatternCommunication* comm_pattern, namespace simgrid { namespace mc { -void CommunicationDeterminismChecker::deterministic_comm_pattern(int process, PatternCommunication* comm, +void CommunicationDeterminismChecker::deterministic_comm_pattern(int process, const PatternCommunication* comm, int backtracking) { if (not backtracking) { @@ -253,7 +253,7 @@ void CommunicationDeterminismChecker::complete_comm_pattern(RemotePtr& incomplete_pattern = incomplete_communications_pattern[issuer]; auto current_comm_pattern = std::find_if(begin(incomplete_pattern), end(incomplete_pattern), - [&comm_addr](PatternCommunication* comm) { return remote(comm->comm_addr) == comm_addr; }); + [&comm_addr](const PatternCommunication* comm) { return remote(comm->comm_addr) == comm_addr; }); if (current_comm_pattern == std::end(incomplete_pattern)) xbt_die("Corresponding communication not found!"); diff --git a/src/mc/checker/CommunicationDeterminismChecker.hpp b/src/mc/checker/CommunicationDeterminismChecker.hpp index c10d60f0ec..6e132c8ff7 100644 --- a/src/mc/checker/CommunicationDeterminismChecker.hpp +++ b/src/mc/checker/CommunicationDeterminismChecker.hpp @@ -28,7 +28,7 @@ private: void prepare(); void real_run(); void log_state() override; - void deterministic_comm_pattern(int process, simgrid::mc::PatternCommunication* comm, int backtracking); + void deterministic_comm_pattern(int process, const simgrid::mc::PatternCommunication* comm, int backtracking); void restoreState(); public: // These are used by functions which should be moved in CommunicationDeterminismChecker: diff --git a/src/mc/checker/LivenessChecker.cpp b/src/mc/checker/LivenessChecker.cpp index 7f5a9d6ec8..75a630736d 100644 --- a/src/mc/checker/LivenessChecker.cpp +++ b/src/mc/checker/LivenessChecker.cpp @@ -39,7 +39,7 @@ VisitedPair::VisitedPair(int pair_num, xbt_automaton_state_t automaton_state, this->atomic_propositions = std::move(atomic_propositions); } -static bool evaluate_label(xbt_automaton_exp_label_t l, std::vector const& values) +static bool evaluate_label(const xbt_automaton_exp_label* l, std::vector const& values) { switch (l->type) { case xbt_automaton_exp_label::AUT_OR: @@ -260,7 +260,7 @@ std::vector LivenessChecker::get_textual_trace() // override return trace; } -std::shared_ptr LivenessChecker::create_pair(Pair* current_pair, xbt_automaton_state_t state, +std::shared_ptr LivenessChecker::create_pair(const Pair* current_pair, xbt_automaton_state_t state, std::shared_ptr> propositions) { expanded_pairs_count_++; diff --git a/src/mc/checker/LivenessChecker.hpp b/src/mc/checker/LivenessChecker.hpp index 3867a9e8ff..d050fa80d0 100644 --- a/src/mc/checker/LivenessChecker.hpp +++ b/src/mc/checker/LivenessChecker.hpp @@ -71,7 +71,7 @@ private: void remove_acceptance_pair(int pair_num); void purge_visited_pairs(); void backtrack(); - std::shared_ptr create_pair(Pair* pair, xbt_automaton_state_t state, + std::shared_ptr create_pair(const Pair* pair, xbt_automaton_state_t state, std::shared_ptr> propositions); // A stack of (application_state, automaton_state) pairs for DFS exploration: diff --git a/src/mc/checker/SafetyChecker.cpp b/src/mc/checker/SafetyChecker.cpp index bb45a97b66..e4859a27b7 100644 --- a/src/mc/checker/SafetyChecker.cpp +++ b/src/mc/checker/SafetyChecker.cpp @@ -31,7 +31,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_safety, mc, "Logging specific to MC safety ve namespace simgrid { namespace mc { -void SafetyChecker::check_non_termination(State* current_state) +void SafetyChecker::check_non_termination(const State* current_state) { for (auto state = stack_.rbegin(); state != stack_.rend(); ++state) if (snapshot_equal((*state)->system_state_.get(), current_state->system_state_.get())) { diff --git a/src/mc/checker/SafetyChecker.hpp b/src/mc/checker/SafetyChecker.hpp index 1377934919..8fb5df2a5f 100644 --- a/src/mc/checker/SafetyChecker.hpp +++ b/src/mc/checker/SafetyChecker.hpp @@ -30,7 +30,7 @@ public: void log_state() override; private: - void check_non_termination(simgrid::mc::State* current_state); + void check_non_termination(const State* current_state); void backtrack(); void restore_state(); diff --git a/src/mc/compare.cpp b/src/mc/compare.cpp index a93c6d1139..9e93e1a58d 100644 --- a/src/mc/compare.cpp +++ b/src/mc/compare.cpp @@ -60,7 +60,7 @@ public: std::vector types; std::size_t heapsize = 0; - void initHeapInformation(xbt_mheap_t heap, const std::vector& i); + void initHeapInformation(const s_xbt_mheap_t* heap, const std::vector& i); }; class StateComparator { @@ -77,8 +77,8 @@ public: compared_pointers.clear(); } - int initHeapInformation(xbt_mheap_t heap1, xbt_mheap_t heap2, const std::vector& i1, - const std::vector& i2); + int initHeapInformation(const s_xbt_mheap_t* heap1, const s_xbt_mheap_t* heap2, + const std::vector& i1, const std::vector& i2); template HeapArea& equals_to_(std::size_t i, std::size_t j) { @@ -123,7 +123,7 @@ public: this->equals_to_<2>(b2, f2).block_ == b1 && this->equals_to_<2>(b2, f2).fragment_ == f1; } - void match_equals(HeapLocationPairs* list); + void match_equals(const HeapLocationPairs* list); }; } // namespace mc @@ -171,7 +171,7 @@ static bool is_block_stack(int block) namespace simgrid { namespace mc { -void StateComparator::match_equals(HeapLocationPairs* list) +void StateComparator::match_equals(const HeapLocationPairs* list) { for (auto const& pair : *list) { if (pair[0].fragment_ != -1) { @@ -184,7 +184,7 @@ void StateComparator::match_equals(HeapLocationPairs* list) } } -void ProcessComparisonState::initHeapInformation(xbt_mheap_t heap, const std::vector& i) +void ProcessComparisonState::initHeapInformation(const s_xbt_mheap_t* heap, const std::vector& i) { auto heaplimit = heap->heaplimit; this->heapsize = heap->heapsize; @@ -193,7 +193,8 @@ void ProcessComparisonState::initHeapInformation(xbt_mheap_t heap, const std::ve this->types.assign(heaplimit * MAX_FRAGMENT_PER_BLOCK, nullptr); } -int StateComparator::initHeapInformation(xbt_mheap_t heap1, xbt_mheap_t heap2, const std::vector& i1, +int StateComparator::initHeapInformation(const s_xbt_mheap_t* heap1, const s_xbt_mheap_t* heap2, + const std::vector& i1, const std::vector& i2) { if ((heap1->heaplimit != heap2->heaplimit) || (heap1->heapsize != heap2->heapsize)) @@ -228,8 +229,8 @@ static bool mmalloc_heap_differ(StateComparator& state, const Snapshot& snapshot malloc_info heapinfo_temp2; malloc_info heapinfo_temp2b; - Region* heap_region1 = MC_get_heap_region(snapshot1); - Region* heap_region2 = MC_get_heap_region(snapshot2); + const Region* heap_region1 = MC_get_heap_region(snapshot1); + const Region* heap_region2 = MC_get_heap_region(snapshot2); // This is the address of std_heap->heapinfo in the application process: void* heapinfo_address = &((xbt_mheap_t)process.heap_address)->heapinfo; @@ -448,8 +449,8 @@ static bool heap_area_differ_without_type(StateComparator& state, const void* re HeapLocationPairs* previous, int size, int check_ignore) { const RemoteClient& process = mc_model_checker->process(); - Region* heap_region1 = MC_get_heap_region(snapshot1); - Region* heap_region2 = MC_get_heap_region(snapshot2); + const Region* heap_region1 = MC_get_heap_region(snapshot1); + const Region* heap_region2 = MC_get_heap_region(snapshot2); for (int i = 0; i < size; ) { if (check_ignore > 0) { @@ -509,7 +510,7 @@ static bool heap_area_differ_without_type(StateComparator& state, const void* re */ static bool heap_area_differ_with_type(StateComparator& state, const void* real_area1, const void* real_area2, const Snapshot& snapshot1, const Snapshot& snapshot2, - HeapLocationPairs* previous, Type* type, int area_size, int check_ignore, + HeapLocationPairs* previous, const Type* type, int area_size, int check_ignore, int pointer_level) { // HACK: This should not happen but in practice, there are some @@ -536,8 +537,8 @@ static bool heap_area_differ_with_type(StateComparator& state, const void* real_ const void* addr_pointed1; const void* addr_pointed2; - Region* heap_region1 = MC_get_heap_region(snapshot1); - Region* heap_region2 = MC_get_heap_region(snapshot2); + const Region* heap_region1 = MC_get_heap_region(snapshot1); + const Region* heap_region2 = MC_get_heap_region(snapshot2); switch (type->type) { case DW_TAG_unspecified_type: @@ -652,7 +653,7 @@ static bool heap_area_differ_with_type(StateComparator& state, const void* real_ return true; } } else { - for (simgrid::mc::Member& member : type->members) { + for (const simgrid::mc::Member& member : type->members) { // TODO, optimize this? (for the offset case) const void* real_member1 = dwarf::resolve_member(real_area1, type, &member, &snapshot1); const void* real_member2 = dwarf::resolve_member(real_area2, type, &member, &snapshot2); @@ -700,7 +701,7 @@ static Type* get_offset_type(void* real_base_address, Type* type, int offset, in return nullptr; } - for (simgrid::mc::Member& member : type->members) { + for (const simgrid::mc::Member& member : type->members) { if (member.has_offset_location()) { // We have the offset, use it directly (shortcut): if (member.offset() == offset) @@ -806,8 +807,8 @@ static bool heap_area_differ(StateComparator& state, const void* area1, const vo type_size = type->byte_size; } - simgrid::mc::Region* heap_region1 = MC_get_heap_region(snapshot1); - simgrid::mc::Region* heap_region2 = MC_get_heap_region(snapshot2); + const Region* heap_region1 = MC_get_heap_region(snapshot1); + const Region* heap_region2 = MC_get_heap_region(snapshot2); const malloc_info* heapinfo1 = (const malloc_info*)heap_region1->read(&heapinfo_temp1, &heapinfos1[block1], sizeof(malloc_info)); @@ -1009,7 +1010,7 @@ static bool heap_area_differ(StateComparator& state, const void* area1, const vo static bool areas_differ_with_type(simgrid::mc::StateComparator& state, const void* real_area1, const simgrid::mc::Snapshot& snapshot1, simgrid::mc::Region* region1, const void* real_area2, const simgrid::mc::Snapshot& snapshot2, - simgrid::mc::Region* region2, simgrid::mc::Type* type, int pointer_level) + simgrid::mc::Region* region2, const simgrid::mc::Type* type, int pointer_level) { const simgrid::mc::Type* subtype; const simgrid::mc::Type* subsubtype; @@ -1113,7 +1114,7 @@ static bool areas_differ_with_type(simgrid::mc::StateComparator& state, const vo } case DW_TAG_structure_type: case DW_TAG_class_type: - for (simgrid::mc::Member& member : type->members) { + for (const simgrid::mc::Member& member : type->members) { const void* member1 = simgrid::dwarf::resolve_member(real_area1, type, &member, &snapshot1); const void* member2 = simgrid::dwarf::resolve_member(real_area2, type, &member, &snapshot2); simgrid::mc::Region* subregion1 = snapshot1.get_region(member1, region1); // region1 is hinted @@ -1133,9 +1134,10 @@ static bool areas_differ_with_type(simgrid::mc::StateComparator& state, const vo return false; } -static bool global_variables_differ(simgrid::mc::StateComparator& state, simgrid::mc::ObjectInformation* object_info, - simgrid::mc::Region* r1, simgrid::mc::Region* r2, - const simgrid::mc::Snapshot& snapshot1, const simgrid::mc::Snapshot& snapshot2) +static bool global_variables_differ(simgrid::mc::StateComparator& state, + const simgrid::mc::ObjectInformation* object_info, simgrid::mc::Region* r1, + simgrid::mc::Region* r2, const simgrid::mc::Snapshot& snapshot1, + const simgrid::mc::Snapshot& snapshot2) { xbt_assert(r1 && r2, "Missing region."); diff --git a/src/mc/inspect/LocationList.cpp b/src/mc/inspect/LocationList.cpp index cc701965ee..a370ac7c57 100644 --- a/src/mc/inspect/LocationList.cpp +++ b/src/mc/inspect/LocationList.cpp @@ -20,7 +20,7 @@ namespace dwarf { /** Resolve a location expression */ Location resolve(simgrid::dwarf::DwarfExpression const& expression, simgrid::mc::ObjectInformation* object_info, - unw_cursor_t* c, void* frame_pointer_address, simgrid::mc::AddressSpace* address_space) + unw_cursor_t* c, void* frame_pointer_address, const simgrid::mc::AddressSpace* address_space) { simgrid::dwarf::ExpressionContext context; context.frame_base = frame_pointer_address; @@ -50,7 +50,7 @@ static simgrid::dwarf::DwarfExpression const* find_expression(simgrid::dwarf::Lo } Location resolve(simgrid::dwarf::LocationList const& locations, simgrid::mc::ObjectInformation* object_info, - unw_cursor_t* c, void* frame_pointer_address, simgrid::mc::AddressSpace* address_space) + unw_cursor_t* c, void* frame_pointer_address, const simgrid::mc::AddressSpace* address_space) { unw_word_t ip = 0; if (c && unw_get_reg(c, UNW_REG_IP, &ip)) @@ -61,7 +61,7 @@ Location resolve(simgrid::dwarf::LocationList const& locations, simgrid::mc::Obj return simgrid::dwarf::resolve(*expression, object_info, c, frame_pointer_address, address_space); } -LocationList location_list(simgrid::mc::ObjectInformation& info, Dwarf_Attribute& attr) +LocationList location_list(const simgrid::mc::ObjectInformation& info, Dwarf_Attribute& attr) { LocationList locations; std::ptrdiff_t offset = 0; diff --git a/src/mc/inspect/LocationList.hpp b/src/mc/inspect/LocationList.hpp index adb4b4e90b..46f50db99c 100644 --- a/src/mc/inspect/LocationList.hpp +++ b/src/mc/inspect/LocationList.hpp @@ -66,13 +66,13 @@ public: XBT_PRIVATE Location resolve(simgrid::dwarf::DwarfExpression const& expression, simgrid::mc::ObjectInformation* object_info, - unw_cursor_t* c, void* frame_pointer_address, simgrid::mc::AddressSpace* address_space); + unw_cursor_t* c, void* frame_pointer_address, const simgrid::mc::AddressSpace* address_space); Location resolve(simgrid::dwarf::LocationList const& locations, simgrid::mc::ObjectInformation* object_info, - unw_cursor_t* c, void* frame_pointer_address, simgrid::mc::AddressSpace* address_space); + unw_cursor_t* c, void* frame_pointer_address, const simgrid::mc::AddressSpace* address_space); XBT_PRIVATE -simgrid::dwarf::LocationList location_list(simgrid::mc::ObjectInformation& info, Dwarf_Attribute& attr); +simgrid::dwarf::LocationList location_list(const simgrid::mc::ObjectInformation& info, Dwarf_Attribute& attr); } // namespace dwarf } // namespace simgrid diff --git a/src/mc/inspect/ObjectInformation.hpp b/src/mc/inspect/ObjectInformation.hpp index 0e3a3941f0..6928513aeb 100644 --- a/src/mc/inspect/ObjectInformation.hpp +++ b/src/mc/inspect/ObjectInformation.hpp @@ -157,7 +157,8 @@ XBT_PRIVATE std::shared_ptr createObjectInformation(std::vect const char* name); /** Augment the current module with informations about the other ones */ -XBT_PRIVATE void postProcessObjectInformation(simgrid::mc::RemoteClient* process, simgrid::mc::ObjectInformation* info); +XBT_PRIVATE void postProcessObjectInformation(const simgrid::mc::RemoteClient* process, + simgrid::mc::ObjectInformation* info); } // namespace mc } // namespace simgrid diff --git a/src/mc/inspect/mc_dwarf.cpp b/src/mc/inspect/mc_dwarf.cpp index c6085b088d..6bc7aaf5d0 100644 --- a/src/mc/inspect/mc_dwarf.cpp +++ b/src/mc/inspect/mc_dwarf.cpp @@ -89,7 +89,7 @@ static void MC_dwarf_handle_children(simgrid::mc::ObjectInformation* info, Dwarf * @param unit the DIE of the compile unit of the current DIE * @param frame containing frame if any */ -static void MC_dwarf_handle_variable_die(simgrid::mc::ObjectInformation* info, Dwarf_Die* die, Dwarf_Die* unit, +static void MC_dwarf_handle_variable_die(simgrid::mc::ObjectInformation* info, Dwarf_Die* die, const Dwarf_Die* unit, simgrid::mc::Frame* frame, const char* ns); /** @brief Get the DW_TAG_type of the DIE @@ -431,7 +431,7 @@ static bool MC_compare_variable(simgrid::mc::Variable const& a, simgrid::mc::Var * @param member the member of the type * @param child DIE of the member (DW_TAG_member) */ -static void MC_dwarf_fill_member_location(simgrid::mc::Type* type, simgrid::mc::Member* member, Dwarf_Die* child) +static void MC_dwarf_fill_member_location(const simgrid::mc::Type* type, simgrid::mc::Member* member, Dwarf_Die* child) { xbt_assert(not dwarf_hasattr(child, DW_AT_data_bit_offset), "Can't groke DW_AT_data_bit_offset."); @@ -484,8 +484,8 @@ static void MC_dwarf_fill_member_location(simgrid::mc::Type* type, simgrid::mc:: * @param unit DIE of the compilation unit containing the type DIE * @param type the type */ -static void MC_dwarf_add_members(simgrid::mc::ObjectInformation* /*info*/, Dwarf_Die* die, Dwarf_Die* /*unit*/, - simgrid::mc::Type* type) +static void MC_dwarf_add_members(const simgrid::mc::ObjectInformation* /*info*/, Dwarf_Die* die, + const Dwarf_Die* /*unit*/, simgrid::mc::Type* type) { int res; Dwarf_Die child; @@ -644,8 +644,8 @@ static void MC_dwarf_handle_type_die(simgrid::mc::ObjectInformation* info, Dwarf static int mc_anonymous_variable_index = 0; static std::unique_ptr MC_die_to_variable(simgrid::mc::ObjectInformation* info, Dwarf_Die* die, - Dwarf_Die* /*unit*/, simgrid::mc::Frame* frame, - const char* ns) + const Dwarf_Die* /*unit*/, + const simgrid::mc::Frame* frame, const char* ns) { // Skip declarations: if (MC_dwarf_attr_flag(die, DW_AT_declaration, false)) @@ -739,7 +739,7 @@ static std::unique_ptr MC_die_to_variable(simgrid::mc::Ob return variable; } -static void MC_dwarf_handle_variable_die(simgrid::mc::ObjectInformation* info, Dwarf_Die* die, Dwarf_Die* unit, +static void MC_dwarf_handle_variable_die(simgrid::mc::ObjectInformation* info, Dwarf_Die* die, const Dwarf_Die* unit, simgrid::mc::Frame* frame, const char* ns) { std::unique_ptr variable = MC_die_to_variable(info, die, unit, frame, ns); @@ -1207,7 +1207,7 @@ std::shared_ptr createObjectInformation(std::vectortypes) { Type* type = &(t.second); diff --git a/src/mc/inspect/mc_dwarf.hpp b/src/mc/inspect/mc_dwarf.hpp index d24ebe97d1..8ee9ab53b1 100644 --- a/src/mc/inspect/mc_dwarf.hpp +++ b/src/mc/inspect/mc_dwarf.hpp @@ -16,7 +16,7 @@ namespace dwarf { XBT_PRIVATE const char* attrname(int attr); XBT_PRIVATE const char* tagname(int tag); -XBT_PRIVATE void* resolve_member(const void* base, simgrid::mc::Type* type, simgrid::mc::Member* member, +XBT_PRIVATE void* resolve_member(const void* base, const simgrid::mc::Type* type, const simgrid::mc::Member* member, const simgrid::mc::AddressSpace* snapshot); XBT_PRIVATE diff --git a/src/mc/inspect/mc_member.cpp b/src/mc/inspect/mc_member.cpp index 1bd5ad49bf..fbc7054c71 100644 --- a/src/mc/inspect/mc_member.cpp +++ b/src/mc/inspect/mc_member.cpp @@ -18,7 +18,7 @@ namespace dwarf { * @param snapshot Snapshot (or nullptr) * @return Process address of the given member of the 'object' struct/class */ -void* resolve_member(const void* base, simgrid::mc::Type* /*type*/, simgrid::mc::Member* member, +void* resolve_member(const void* base, const simgrid::mc::Type* /*type*/, const simgrid::mc::Member* member, const simgrid::mc::AddressSpace* address_space) { ExpressionContext state; diff --git a/src/mc/mc_base.cpp b/src/mc/mc_base.cpp index 10c8ec915d..e574258faa 100644 --- a/src/mc/mc_base.cpp +++ b/src/mc/mc_base.cpp @@ -42,7 +42,7 @@ void wait_for_requests() while (not simix_global->actors_to_run.empty()) { simix_global->run_all_actors(); for (smx_actor_t const& process : simix_global->actors_that_ran) { - smx_simcall_t req = &process->simcall; + const s_smx_simcall* req = &process->simcall; if (req->call_ != SIMCALL_NONE && not simgrid::mc::request_is_visible(req)) process->simcall_handle(0); } @@ -148,7 +148,7 @@ bool actor_is_enabled(smx_actor_t actor) /* This is the list of requests that are visible from the checker algorithm. * Any other requests are handled right away on the application side. */ -bool request_is_visible(smx_simcall_t req) +bool request_is_visible(const s_smx_simcall* req) { #if SIMGRID_HAVE_MC xbt_assert(mc_model_checker == nullptr, "This should be called from the client side"); diff --git a/src/mc/mc_base.h b/src/mc/mc_base.h index a1160d0c6e..48cbdde8ee 100644 --- a/src/mc/mc_base.h +++ b/src/mc/mc_base.h @@ -40,8 +40,7 @@ XBT_PRIVATE void handle_simcall(smx_simcall_t req, int req_num); XBT_PRIVATE bool actor_is_enabled(smx_actor_t process); /** Check if the given simcall is visible */ -XBT_PRIVATE bool request_is_visible(smx_simcall_t req); - +XBT_PRIVATE bool request_is_visible(const s_smx_simcall* req); } } diff --git a/src/mc/mc_comm_pattern.hpp b/src/mc/mc_comm_pattern.hpp index 9d55a88136..6b0e4a7c14 100644 --- a/src/mc/mc_comm_pattern.hpp +++ b/src/mc/mc_comm_pattern.hpp @@ -43,7 +43,7 @@ enum e_mc_comm_pattern_difference_t { DATA_DIFF, }; -static inline e_mc_call_type_t MC_get_call_type(smx_simcall_t req) +static inline e_mc_call_type_t MC_get_call_type(const s_smx_simcall* req) { switch (req->call_) { case SIMCALL_COMM_ISEND: diff --git a/src/mc/mc_global.cpp b/src/mc/mc_global.cpp index 975d079063..4c57cd7e92 100644 --- a/src/mc/mc_global.cpp +++ b/src/mc/mc_global.cpp @@ -136,7 +136,7 @@ void dumpStack(FILE* file, unw_cursor_t&& cursor) } #endif -double MC_process_clock_get(smx_actor_t process) +double MC_process_clock_get(const simgrid::kernel::actor::ActorImpl* process) { if (simgrid::mc::processes_time.empty()) return 0; @@ -145,7 +145,7 @@ double MC_process_clock_get(smx_actor_t process) return -1; } -void MC_process_clock_add(smx_actor_t process, double amount) +void MC_process_clock_add(const simgrid::kernel::actor::ActorImpl* process, double amount) { simgrid::mc::processes_time[process->get_pid()] += amount; } diff --git a/src/mc/mc_record.cpp b/src/mc/mc_record.cpp index 4c7f441c1c..53a3acc2e7 100644 --- a/src/mc/mc_record.cpp +++ b/src/mc/mc_record.cpp @@ -34,7 +34,7 @@ void replay(RecordTrace const& trace) smx_actor_t process = SIMIX_process_from_PID(transition.pid_); if (not process) xbt_die("Unexpected process (pid:%d).", transition.pid_); - smx_simcall_t simcall = &(process->simcall); + const s_smx_simcall* simcall = &(process->simcall); if (simcall == nullptr || simcall->call_ == SIMCALL_NONE) xbt_die("No simcall for process %d.", transition.pid_); if (not simgrid::mc::request_is_visible(simcall) || not simgrid::mc::actor_is_enabled(process)) diff --git a/src/mc/mc_smx.cpp b/src/mc/mc_smx.cpp index e6ffc00e83..606a5237aa 100644 --- a/src/mc/mc_smx.cpp +++ b/src/mc/mc_smx.cpp @@ -31,7 +31,7 @@ static inline simgrid::mc::ActorInformation* actor_info_cast(smx_actor_t actor) * @param target Local vector (to be filled with copies of `s_smx_actor_t`) * @param remote_dynar Address of the process dynar in the remote list */ -static void MC_process_refresh_simix_actor_dynar(simgrid::mc::RemoteClient* process, +static void MC_process_refresh_simix_actor_dynar(const simgrid::mc::RemoteClient* process, std::vector& target, simgrid::mc::RemotePtr remote_dynar) { diff --git a/src/mc/mc_state.hpp b/src/mc/mc_state.hpp index 9e70190507..586b5a04a6 100644 --- a/src/mc/mc_state.hpp +++ b/src/mc/mc_state.hpp @@ -124,7 +124,10 @@ public: explicit State(unsigned long state_number); std::size_t interleave_size() const; - void add_interleaving_set(smx_actor_t actor) { this->actor_states_[actor->get_pid()].consider(); } + void add_interleaving_set(const simgrid::kernel::actor::ActorImpl* actor) + { + this->actor_states_[actor->get_pid()].consider(); + } Transition get_transition() const; }; } diff --git a/src/mc/remote/Client.cpp b/src/mc/remote/Client.cpp index a1c92425e1..b5fd0a0470 100644 --- a/src/mc/remote/Client.cpp +++ b/src/mc/remote/Client.cpp @@ -72,7 +72,7 @@ Client* Client::initialize() return instance_.get(); } -void Client::handle_deadlock_check(s_mc_message_t*) +void Client::handle_deadlock_check(const s_mc_message_t*) { bool deadlock = false; if (not simix_global->process_list.empty()) { @@ -88,11 +88,11 @@ void Client::handle_deadlock_check(s_mc_message_t*) s_mc_message_int_t answer{MC_MESSAGE_DEADLOCK_CHECK_REPLY, deadlock}; xbt_assert(channel_.send(answer) == 0, "Could not send response"); } -void Client::handle_continue(s_mc_message_t*) +void Client::handle_continue(const s_mc_message_t*) { /* Nothing to do */ } -void Client::handle_simcall(s_mc_message_simcall_handle_t* message) +void Client::handle_simcall(const s_mc_message_simcall_handle_t* message) { smx_actor_t process = SIMIX_process_from_PID(message->pid); if (not process) @@ -102,7 +102,7 @@ void Client::handle_simcall(s_mc_message_simcall_handle_t* message) xbt_die("Could not send MESSAGE_WAITING to model-checker"); } -void Client::handle_actor_enabled(s_mc_message_actor_enabled_t* msg) +void Client::handle_actor_enabled(const s_mc_message_actor_enabled_t* msg) { bool res = simgrid::mc::actor_is_enabled(SIMIX_process_from_PID(msg->aid)); s_mc_message_int_t answer{MC_MESSAGE_ACTOR_ENABLED_REPLY, res}; @@ -120,7 +120,7 @@ void Client::handle_messages() if (received_size < 0) xbt_die("Could not receive commands from the model-checker"); - s_mc_message_t* message = (s_mc_message_t*)message_buffer; + const s_mc_message_t* message = (s_mc_message_t*)message_buffer; switch (message->type) { case MC_MESSAGE_DEADLOCK_CHECK: xbt_assert(received_size == sizeof(s_mc_message_t), "Unexpected size for DEADLOCK_CHECK (%zd != %zu)", diff --git a/src/mc/remote/Client.hpp b/src/mc/remote/Client.hpp index b26207ed80..e0ce493292 100644 --- a/src/mc/remote/Client.hpp +++ b/src/mc/remote/Client.hpp @@ -28,10 +28,10 @@ public: void handle_messages(); private: - void handle_deadlock_check(s_mc_message_t* msg); - void handle_continue(s_mc_message_t* msg); - void handle_simcall(s_mc_message_simcall_handle_t* message); - void handle_actor_enabled(s_mc_message_actor_enabled_t* msg); + void handle_deadlock_check(const s_mc_message_t* msg); + void handle_continue(const s_mc_message_t* msg); + void handle_simcall(const s_mc_message_simcall_handle_t* message); + void handle_actor_enabled(const s_mc_message_actor_enabled_t* msg); public: Channel const& get_channel() const { return channel_; } diff --git a/src/mc/sosp/ChunkedData.cpp b/src/mc/sosp/ChunkedData.cpp index 14796c4120..c51891ca92 100644 --- a/src/mc/sosp/ChunkedData.cpp +++ b/src/mc/sosp/ChunkedData.cpp @@ -15,7 +15,7 @@ namespace mc { * @param page_count Number of pages of the region * @return Snapshot page numbers of this new snapshot */ -ChunkedData::ChunkedData(PageStore& store, AddressSpace& as, RemotePtr addr, std::size_t page_count) +ChunkedData::ChunkedData(PageStore& store, const AddressSpace& as, RemotePtr addr, std::size_t page_count) : store_(&store) { this->pagenos_.resize(page_count); diff --git a/src/mc/sosp/ChunkedData.hpp b/src/mc/sosp/ChunkedData.hpp index 8d5f1baa06..a7f2903194 100644 --- a/src/mc/sosp/ChunkedData.hpp +++ b/src/mc/sosp/ChunkedData.hpp @@ -84,7 +84,7 @@ public: /** Get a a pointer to a chunk */ void* page(std::size_t i) const { return store_->get_page(pagenos_[i]); } - ChunkedData(PageStore& store, AddressSpace& as, RemotePtr addr, std::size_t page_count); + ChunkedData(PageStore& store, const AddressSpace& as, RemotePtr addr, std::size_t page_count); }; } // namespace mc diff --git a/src/mc/sosp/PageStore.cpp b/src/mc/sosp/PageStore.cpp index 149e36dc0b..e96f0b67d7 100644 --- a/src/mc/sosp/PageStore.cpp +++ b/src/mc/sosp/PageStore.cpp @@ -142,7 +142,7 @@ void PageStore::remove_page(std::size_t pageno) } /** Store a page in memory */ -std::size_t PageStore::store_page(void* page) +std::size_t PageStore::store_page(const void* page) { xbt_assert(top_index_ <= this->capacity_, "top_index is not consistent"); diff --git a/src/mc/sosp/PageStore.hpp b/src/mc/sosp/PageStore.hpp index 0853b6d905..0bc896f160 100644 --- a/src/mc/sosp/PageStore.hpp +++ b/src/mc/sosp/PageStore.hpp @@ -134,7 +134,7 @@ public: void ref_page(size_t pageno); /** @brief Store a page in the page store */ - std::size_t store_page(void* page); + std::size_t store_page(const void* page); /** @brief Get a page from its page number * diff --git a/src/mc/sosp/Region.cpp b/src/mc/sosp/Region.cpp index 41c8b1ba93..1cc01058c2 100644 --- a/src/mc/sosp/Region.cpp +++ b/src/mc/sosp/Region.cpp @@ -44,7 +44,7 @@ void Region::restore() } } -static XBT_ALWAYS_INLINE void* mc_translate_address_region(uintptr_t addr, simgrid::mc::Region* region) +static XBT_ALWAYS_INLINE void* mc_translate_address_region(uintptr_t addr, const simgrid::mc::Region* region) { auto split = simgrid::mc::mmu::split(addr - region->start().address()); auto pageno = split.first; @@ -53,7 +53,7 @@ static XBT_ALWAYS_INLINE void* mc_translate_address_region(uintptr_t addr, simgr return (char*)snapshot_page + offset; } -void* Region::read(void* target, const void* addr, std::size_t size) +void* Region::read(void* target, const void* addr, std::size_t size) const { xbt_assert(contain(simgrid::mc::remote(addr)), "Trying to read out of the region boundary."); @@ -103,8 +103,8 @@ void* Region::read(void* target, const void* addr, std::size_t size) * @param region2 Region of the address in the second snapshot * @return same semantic as memcmp */ -int MC_snapshot_region_memcmp(const void* addr1, simgrid::mc::Region* region1, const void* addr2, - simgrid::mc::Region* region2, size_t size) +int MC_snapshot_region_memcmp(const void* addr1, const simgrid::mc::Region* region1, const void* addr2, + const simgrid::mc::Region* region2, size_t size) { // Using alloca() for large allocations may trigger stack overflow: // use malloc if the buffer is too big. diff --git a/src/mc/sosp/Region.hpp b/src/mc/sosp/Region.hpp index 4985c61c1d..f75a345e3d 100644 --- a/src/mc/sosp/Region.hpp +++ b/src/mc/sosp/Region.hpp @@ -69,16 +69,16 @@ public: * @param size Size of the data to read in bytes * @return Pointer where the data is located (either target buffer or original location) */ - void* read(void* target, const void* addr, std::size_t size); + void* read(void* target, const void* addr, std::size_t size) const; }; } // namespace mc } // namespace simgrid -int MC_snapshot_region_memcmp(const void* addr1, simgrid::mc::Region* region1, const void* addr2, - simgrid::mc::Region* region2, std::size_t size); +int MC_snapshot_region_memcmp(const void* addr1, const simgrid::mc::Region* region1, const void* addr2, + const simgrid::mc::Region* region2, std::size_t size); -static XBT_ALWAYS_INLINE void* MC_region_read_pointer(simgrid::mc::Region* region, const void* addr) +static XBT_ALWAYS_INLINE void* MC_region_read_pointer(const simgrid::mc::Region* region, const void* addr) { void* res; return *(void**)region->read(&res, addr, sizeof(void*)); diff --git a/src/mc/sosp/Snapshot.cpp b/src/mc/sosp/Snapshot.cpp index fb8e06f1a1..db553bc47e 100644 --- a/src/mc/sosp/Snapshot.cpp +++ b/src/mc/sosp/Snapshot.cpp @@ -40,7 +40,7 @@ void Snapshot::snapshot_regions(RemoteClient* process) * @param ip Instruction pointer * @return true if the variable is valid * */ -static bool valid_variable(simgrid::mc::Variable* var, simgrid::mc::Frame* scope, const void* ip) +static bool valid_variable(const simgrid::mc::Variable* var, simgrid::mc::Frame* scope, const void* ip) { // The variable is not yet valid: if (scope->range.begin() + var->start_scope > (std::uint64_t)ip) @@ -55,7 +55,7 @@ static void fill_local_variables_values(mc_stack_frame_t stack_frame, Frame* sco if (not scope || not scope->range.contain(stack_frame->ip)) return; - for (Variable& current_variable : scope->variables) { + for (const Variable& current_variable : scope->variables) { if (not valid_variable(¤t_variable, scope, (void*)stack_frame->ip)) continue; @@ -191,7 +191,7 @@ static void snapshot_handle_ignore(Snapshot* snapshot) snapshot->process()->clear_bytes(remote(region.addr), region.size); } -static void snapshot_ignore_restore(simgrid::mc::Snapshot* snapshot) +static void snapshot_ignore_restore(const simgrid::mc::Snapshot* snapshot) { for (auto const& ignored_data : snapshot->ignored_data_) snapshot->process()->write_bytes(ignored_data.data.data(), ignored_data.data.size(), remote(ignored_data.start)); @@ -233,7 +233,7 @@ void Snapshot::add_region(RegionType type, ObjectInformation* object_info, void* void* Snapshot::read_bytes(void* buffer, std::size_t size, RemotePtr address, ReadOptions options) const { - Region* region = this->get_region((void*)address.address()); + const Region* region = this->get_region((void*)address.address()); if (region) { void* res = region->read(buffer, (void*)address.address(), size); if (buffer == res || options & ReadOptions::lazy())