Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Declare functions "const" in src/mc/.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 2 Jul 2020 15:30:56 +0000 (17:30 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 2 Jul 2020 15:30:56 +0000 (17:30 +0200)
15 files changed:
src/mc/Session.cpp
src/mc/Session.hpp
src/mc/checker/LivenessChecker.cpp
src/mc/checker/LivenessChecker.hpp
src/mc/mc_hash.cpp
src/mc/mc_private.hpp
src/mc/remote/AppSide.cpp
src/mc/remote/AppSide.hpp
src/mc/remote/RemoteSimulation.cpp
src/mc/remote/RemoteSimulation.hpp
src/mc/sosp/PageStore.hpp
src/mc/sosp/Region.cpp
src/mc/sosp/Region.hpp
src/mc/sosp/Snapshot.cpp
src/mc/sosp/Snapshot.hpp

index 2ace38c..71b28fc 100644 (file)
@@ -105,18 +105,18 @@ void Session::initialize()
   initial_snapshot_ = std::make_shared<simgrid::mc::Snapshot>(0);
 }
 
-void Session::execute(Transition const& transition)
+void Session::execute(Transition const& transition) const
 {
   model_checker_->handle_simcall(transition);
   model_checker_->wait_for_requests();
 }
 
-void Session::restore_initial_state()
+void Session::restore_initial_state() const
 {
   this->initial_snapshot_->restore(&model_checker_->get_remote_simulation());
 }
 
-void Session::log_state()
+void Session::log_state() const
 {
   model_checker_->getChecker()->log_state();
 
@@ -141,7 +141,7 @@ void Session::close()
   }
 }
 
-bool Session::actor_is_enabled(aid_t pid)
+bool Session::actor_is_enabled(aid_t pid) const
 {
   s_mc_message_actor_enabled_t msg{MC_MESSAGE_ACTOR_ENABLED, pid};
   model_checker_->channel().send(msg);
index 9f07bad..7934ec0 100644 (file)
@@ -45,11 +45,11 @@ public:
   void close();
 
   void initialize();
-  void execute(Transition const& transition);
-  void log_state();
+  void execute(Transition const& transition) const;
+  void log_state() const;
 
-  void restore_initial_state();
-  bool actor_is_enabled(aid_t pid);
+  void restore_initial_state() const;
+  bool actor_is_enabled(aid_t pid) const;
 };
 
 // Temporary :)
index 3598ae0..e22741d 100644 (file)
@@ -70,7 +70,7 @@ static bool evaluate_label(const xbt_automaton_exp_label* l, std::vector<int> co
 Pair::Pair(unsigned long expanded_pairs) : num(expanded_pairs)
 {}
 
-std::shared_ptr<const std::vector<int>> LivenessChecker::get_proposition_values()
+std::shared_ptr<const std::vector<int>> LivenessChecker::get_proposition_values() const
 {
   std::vector<int> values;
   unsigned int cursor = 0;
index 3ce6200..d471da9 100644 (file)
@@ -61,7 +61,7 @@ public:
   void log_state() override;
 
 private:
-  std::shared_ptr<const std::vector<int>> get_proposition_values();
+  std::shared_ptr<const std::vector<int>> get_proposition_values() const;
   std::shared_ptr<VisitedPair> insert_acceptance_pair(Pair* pair);
   int insert_visited_pair(std::shared_ptr<VisitedPair> visited_pair, Pair* pair);
   void show_acceptance_cycle(std::size_t depth);
index 7ae53cb..7b86d7f 100644 (file)
@@ -30,10 +30,7 @@ public:
   {
     state_ = (state_ << 5) + state_ + x;
   }
-  hash_type value()
-  {
-    return state_;
-  }
+  hash_type value() const { return state_; }
 };
 
 }
index 3feeed9..c89997c 100644 (file)
@@ -16,7 +16,7 @@ namespace simgrid {
 namespace mc {
 
 struct DerefAndCompareByActorsCountAndUsedHeap {
-  template <class X, class Y> bool operator()(X const& a, Y const& b)
+  template <class X, class Y> bool operator()(X const& a, Y const& b) const
   {
     return std::make_pair(a->actors_count, a->heap_bytes_used) < std::make_pair(b->actors_count, b->heap_bytes_used);
   }
index af8d7c0..0c7ff0d 100644 (file)
@@ -66,7 +66,7 @@ AppSide* AppSide::initialize()
   return instance_.get();
 }
 
-void AppSide::handle_deadlock_check(const s_mc_message_t*)
+void AppSide::handle_deadlock_check(const s_mc_message_t*) const
 {
   bool deadlock = false;
   if (not simix_global->process_list.empty()) {
@@ -82,11 +82,11 @@ void AppSide::handle_deadlock_check(const 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 AppSide::handle_continue(const s_mc_message_t*)
+void AppSide::handle_continue(const s_mc_message_t*) const
 {
   /* Nothing to do */
 }
-void AppSide::handle_simcall(const s_mc_message_simcall_handle_t* message)
+void AppSide::handle_simcall(const s_mc_message_simcall_handle_t* message) const
 {
   smx_actor_t process = SIMIX_process_from_PID(message->pid);
   xbt_assert(process != nullptr, "Invalid pid %lu", message->pid);
@@ -95,7 +95,7 @@ void AppSide::handle_simcall(const s_mc_message_simcall_handle_t* message)
     xbt_die("Could not send MESSAGE_WAITING to model-checker");
 }
 
-void AppSide::handle_actor_enabled(const s_mc_message_actor_enabled_t* msg)
+void AppSide::handle_actor_enabled(const s_mc_message_actor_enabled_t* msg) const
 {
   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};
@@ -161,7 +161,7 @@ void AppSide::report_assertion_failure()
   this->handle_messages();
 }
 
-void AppSide::ignore_memory(void* addr, std::size_t size)
+void AppSide::ignore_memory(void* addr, std::size_t size) const
 {
   s_mc_message_ignore_memory_t message;
   message.type = MC_MESSAGE_IGNORE_MEMORY;
@@ -171,7 +171,7 @@ void AppSide::ignore_memory(void* addr, std::size_t size)
     xbt_die("Could not send IGNORE_MEMORY message to model-checker");
 }
 
-void AppSide::ignore_heap(void* address, std::size_t size)
+void AppSide::ignore_heap(void* address, std::size_t size) const
 {
   const s_xbt_mheap_t* heap = mmalloc_get_current_heap();
 
@@ -192,7 +192,7 @@ void AppSide::ignore_heap(void* address, std::size_t size)
     xbt_die("Could not send ignored region to MCer");
 }
 
-void AppSide::unignore_heap(void* address, std::size_t size)
+void AppSide::unignore_heap(void* address, std::size_t size) const
 {
   s_mc_message_ignore_memory_t message;
   message.type = MC_MESSAGE_UNIGNORE_HEAP;
@@ -202,7 +202,7 @@ void AppSide::unignore_heap(void* address, std::size_t size)
     xbt_die("Could not send IGNORE_HEAP message to model-checker");
 }
 
-void AppSide::declare_symbol(const char* name, int* value)
+void AppSide::declare_symbol(const char* name, int* value) const
 {
   s_mc_message_register_symbol_t message;
   message.type = MC_MESSAGE_REGISTER_SYMBOL;
@@ -215,7 +215,7 @@ void AppSide::declare_symbol(const char* name, int* value)
     xbt_die("Could send REGISTER_SYMBOL message to model-checker");
 }
 
-void AppSide::declare_stack(void* stack, size_t size, ucontext_t* context)
+void AppSide::declare_stack(void* stack, size_t size, ucontext_t* context) const
 {
   const s_xbt_mheap_t* heap = mmalloc_get_current_heap();
 
index b1cd172..0c96f35 100644 (file)
@@ -30,22 +30,22 @@ public:
   void handle_messages();
 
 private:
-  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);
+  void handle_deadlock_check(const s_mc_message_t* msg) const;
+  void handle_continue(const s_mc_message_t* msg) const;
+  void handle_simcall(const s_mc_message_simcall_handle_t* message) const;
+  void handle_actor_enabled(const s_mc_message_actor_enabled_t* msg) const;
 
 public:
   Channel const& get_channel() const { return channel_; }
   Channel& get_channel() { return channel_; }
   XBT_ATTRIB_NORETURN void main_loop();
   void report_assertion_failure();
-  void ignore_memory(void* addr, std::size_t size);
-  void ignore_heap(void* addr, std::size_t size);
-  void unignore_heap(void* addr, std::size_t size);
-  void declare_symbol(const char* name, int* value);
+  void ignore_memory(void* addr, std::size_t size) const;
+  void ignore_heap(void* addr, std::size_t size) const;
+  void unignore_heap(void* addr, std::size_t size) const;
+  void declare_symbol(const char* name, int* value) const;
 #if HAVE_UCONTEXT_H
-  void declare_stack(void* stack, size_t size, ucontext_t* context);
+  void declare_stack(void* stack, size_t size, ucontext_t* context) const;
 #endif
 
   // Singleton :/
index 290c765..34d1f27 100644 (file)
@@ -454,13 +454,13 @@ void* RemoteSimulation::read_bytes(void* buffer, std::size_t size, RemotePtr<voi
  *  @param len      data size
  *  @param address  target process memory address (target)
  */
-void RemoteSimulation::write_bytes(const void* buffer, size_t len, RemotePtr<void> address)
+void RemoteSimulation::write_bytes(const void* buffer, size_t len, RemotePtr<void> address) const
 {
   if (pwrite_whole(this->memory_file, buffer, len, (size_t)address.address()) < 0)
     xbt_die("Write to process %lli failed", (long long)this->pid_);
 }
 
-void RemoteSimulation::clear_bytes(RemotePtr<void> address, size_t len)
+void RemoteSimulation::clear_bytes(RemotePtr<void> address, size_t len) const
 {
   pthread_once(&zero_buffer_flag, zero_buffer_init);
   while (len) {
@@ -575,7 +575,7 @@ void RemoteSimulation::unignore_heap(void* address, size_t size)
   }
 }
 
-void RemoteSimulation::ignore_local_variable(const char* var_name, const char* frame_name)
+void RemoteSimulation::ignore_local_variable(const char* var_name, const char* frame_name) const
 {
   if (frame_name != nullptr && strcmp(frame_name, "*") == 0)
     frame_name = nullptr;
@@ -595,7 +595,7 @@ std::vector<simgrid::mc::ActorInformation>& RemoteSimulation::dead_actors()
   return smx_dead_actors_infos;
 }
 
-void RemoteSimulation::dump_stack()
+void RemoteSimulation::dump_stack() const
 {
   unw_addr_space_t as = unw_create_addr_space(&_UPT_accessors, BYTE_ORDER);
   if (as == nullptr) {
index 55f3f97..3bd73c2 100644 (file)
@@ -102,8 +102,8 @@ public:
   using AddressSpace::read_string;
 
   // Write memory:
-  void write_bytes(const void* buffer, size_t len, RemotePtr<void> address);
-  void clear_bytes(RemotePtr<void> address, size_t len);
+  void write_bytes(const void* buffer, size_t len, RemotePtr<void> address) const;
+  void clear_bytes(RemotePtr<void> address, size_t len) const;
 
   // Debug information:
   std::shared_ptr<ObjectInformation> find_object_info(RemotePtr<void> addr) const;
@@ -142,7 +142,7 @@ public:
 
   void terminate() { running_ = false; }
 
-  void ignore_global_variable(const char* name)
+  void ignore_global_variable(const char* name) const
   {
     for (std::shared_ptr<ObjectInformation> const& info : this->object_infos)
       info->remove_global_variable(name);
@@ -155,7 +155,7 @@ public:
   void ignore_heap(IgnoredHeapRegion const& region);
   void unignore_heap(void* address, size_t size);
 
-  void ignore_local_variable(const char* var_name, const char* frame_name);
+  void ignore_local_variable(const char* var_name, const char* frame_name) const;
   std::vector<ActorInformation>& actors();
   std::vector<ActorInformation>& dead_actors();
 
@@ -185,7 +185,7 @@ public:
       return nullptr;
   }
 
-  void dump_stack();
+  void dump_stack() const;
 
 private:
   void init_memory_map_info();
index 934a325..702fc15 100644 (file)
@@ -146,16 +146,16 @@ public:
   // Debug/test methods
 
   /** @brief Get the number of references for a page */
-  std::size_t get_ref(std::size_t pageno);
+  std::size_t get_ref(std::size_t pageno) const;
 
   /** @brief Get the number of used pages */
-  std::size_t size();
+  std::size_t size() const;
 
   /** @brief Get the capacity of the page store
    *
    *  The capacity is expanded by a system call (mremap).
    * */
-  std::size_t capacity();
+  std::size_t capacity() const;
 };
 
 XBT_ALWAYS_INLINE void PageStore::unref_page(std::size_t pageno)
@@ -174,17 +174,17 @@ XBT_ALWAYS_INLINE void* PageStore::get_page(std::size_t pageno) const
   return (void*)simgrid::mc::mmu::join(pageno, (std::uintptr_t)this->memory_);
 }
 
-XBT_ALWAYS_INLINE std::size_t PageStore::get_ref(std::size_t pageno)
+XBT_ALWAYS_INLINE std::size_t PageStore::get_ref(std::size_t pageno) const
 {
   return this->page_counts_[pageno];
 }
 
-XBT_ALWAYS_INLINE std::size_t PageStore::size()
+XBT_ALWAYS_INLINE std::size_t PageStore::size() const
 {
   return this->top_index_ - this->free_pages_.size();
 }
 
-XBT_ALWAYS_INLINE std::size_t PageStore::capacity()
+XBT_ALWAYS_INLINE std::size_t PageStore::capacity() const
 {
   return this->capacity_;
 }
index a770cd3..653586c 100644 (file)
@@ -32,7 +32,7 @@ Region::Region(RegionType region_type, void* start_addr, size_t size)
  *
  *  @param region     Target region
  */
-void Region::restore()
+void Region::restore() const
 {
   xbt_assert(((start().address()) & (xbt_pagesize - 1)) == 0, "Not at the beginning of a page");
   xbt_assert(simgrid::mc::mmu::chunk_count(size()) == get_chunks().page_count());
index 0131713..62d13c3 100644 (file)
@@ -60,7 +60,7 @@ public:
   bool contain(RemotePtr<void> p) const { return p >= start() && p < end(); }
 
   /** @brief Restore a region from a snapshot */
-  void restore();
+  void restore() const;
 
   /** @brief Read memory that was snapshotted in this region
    *
index 6646082..7e79989 100644 (file)
@@ -273,7 +273,7 @@ Region* Snapshot::get_region(const void* addr, Region* hinted_region) const
     return get_region(addr);
 }
 
-void Snapshot::restore(RemoteSimulation* process)
+void Snapshot::restore(RemoteSimulation* process) const
 {
   XBT_DEBUG("Restore snapshot %i", num_state_);
 
index d232d0b..ac6b434 100644 (file)
@@ -74,7 +74,7 @@ public:
                    ReadOptions options = ReadOptions::none()) const override;
   Region* get_region(const void* addr) const;
   Region* get_region(const void* addr, Region* hinted_region) const;
-  void restore(RemoteSimulation* get_remote_simulation);
+  void restore(RemoteSimulation* get_remote_simulation) const;
 
   // To be private
   int num_state_;