Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Many const to remove a mutable (TODO--).
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 24 Apr 2019 19:13:07 +0000 (21:13 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 24 Apr 2019 19:14:17 +0000 (21:14 +0200)
src/mc/ObjectInformation.cpp
src/mc/ObjectInformation.hpp
src/mc/remote/RemoteClient.cpp
src/mc/remote/RemoteClient.hpp
teshsuite/mc/dwarf/dwarf.cpp

index 1f5e703..18c2da3 100644 (file)
@@ -81,9 +81,9 @@ simgrid::mc::Frame* ObjectInformation::find_function(const void *ip) const
   return nullptr;
 }
 
-simgrid::mc::Variable* ObjectInformation::find_variable(const char* name) const
+const simgrid::mc::Variable* ObjectInformation::find_variable(const char* name) const
 {
-  for (simgrid::mc::Variable& variable : this->global_variables)
+  for (simgrid::mc::Variable const& variable : this->global_variables)
     if(variable.name == name)
       return &variable;
   return nullptr;
index c59369b..e813af7 100644 (file)
@@ -90,8 +90,7 @@ public:
    */
   std::vector<FunctionIndexEntry> functions_index;
 
-  // TODO, remove the mutable (to remove it we'll have to add a lot of const everywhere)
-  mutable std::vector<simgrid::mc::Variable> global_variables;
+  std::vector<simgrid::mc::Variable> global_variables;
 
   /** Types indexed by DWARF ID */
   std::unordered_map<std::uint64_t, simgrid::mc::Type> types;
@@ -142,7 +141,7 @@ public:
    *  @param name scopes name of the global variable (`myproject::Foo::count`)
    *  @return corresponding variable (if any) or nullptr
    */
-  simgrid::mc::Variable* find_variable(const char* name) const;
+  const simgrid::mc::Variable* find_variable(const char* name) const;
 
   /** Remove a global variable (in order to ignore it)
    *
index 9904e03..4763c9e 100644 (file)
@@ -200,7 +200,7 @@ void RemoteClient::init()
   this->memory_file = fd;
 
   // Read std_heap (is a struct mdesc*):
-  simgrid::mc::Variable* std_heap_var = this->find_variable("__mmalloc_default_mdp");
+  const simgrid::mc::Variable* std_heap_var = this->find_variable("__mmalloc_default_mdp");
   if (not std_heap_var)
     xbt_die("No heap information in the target process");
   if (not std_heap_var->address)
@@ -365,7 +365,7 @@ simgrid::mc::Frame* RemoteClient::find_function(RemotePtr<void> ip) const
 
 /** Find (one occurrence of) the named variable definition
  */
-simgrid::mc::Variable* RemoteClient::find_variable(const char* name) const
+const simgrid::mc::Variable* RemoteClient::find_variable(const char* name) const
 {
   // First lookup the variable in the executable shared object.
   // A global variable used directly by the executable code from a library
@@ -373,13 +373,13 @@ simgrid::mc::Variable* RemoteClient::find_variable(const char* name) const
   // We need to look up the variable in the executable first.
   if (this->binary_info) {
     std::shared_ptr<simgrid::mc::ObjectInformation> const& info = this->binary_info;
-    simgrid::mc::Variable* var                                  = info->find_variable(name);
+    const simgrid::mc::Variable* var                            = info->find_variable(name);
     if (var)
       return var;
   }
 
   for (std::shared_ptr<simgrid::mc::ObjectInformation> const& info : this->object_infos) {
-    simgrid::mc::Variable* var = info->find_variable(name);
+    const simgrid::mc::Variable* var = info->find_variable(name);
     if (var)
       return var;
   }
@@ -389,7 +389,7 @@ simgrid::mc::Variable* RemoteClient::find_variable(const char* name) const
 
 void RemoteClient::read_variable(const char* name, void* target, size_t size) const
 {
-  simgrid::mc::Variable* var = this->find_variable(name);
+  const simgrid::mc::Variable* var = this->find_variable(name);
   xbt_assert(var->address, "No simple location for this variable");
   xbt_assert(var->type->full_type, "Partial type for %s, cannot check size", name);
   xbt_assert((size_t)var->type->full_type->byte_size == size, "Unexpected size for %s (expected %zu, was %zu)", name,
index d2c84c4..f61d481 100644 (file)
@@ -107,7 +107,7 @@ public:
   std::shared_ptr<simgrid::mc::ObjectInformation> find_object_info_exec(RemotePtr<void> addr) const;
   std::shared_ptr<simgrid::mc::ObjectInformation> find_object_info_rw(RemotePtr<void> addr) const;
   simgrid::mc::Frame* find_function(RemotePtr<void> ip) const;
-  simgrid::mc::Variable* find_variable(const char* name) const;
+  const simgrid::mc::Variable* find_variable(const char* name) const;
 
   // Heap access:
   xbt_mheap_t get_heap()
index 0e08c60..27a07ce 100644 (file)
@@ -80,11 +80,11 @@ static void test_local_variable(simgrid::mc::ObjectInformation* info, const char
   xbt_assert(location.address() == address, "Bad resolution of local variable %s of %s", variable, function);
 }
 
-static simgrid::mc::Variable* test_global_variable(simgrid::mc::RemoteClient& process,
-                                                   simgrid::mc::ObjectInformation* info, const char* name,
-                                                   void* address, long byte_size)
+static const simgrid::mc::Variable* test_global_variable(simgrid::mc::RemoteClient& process,
+                                                         simgrid::mc::ObjectInformation* info, const char* name,
+                                                         void* address, long byte_size)
 {
-  simgrid::mc::Variable* variable = info->find_variable(name);
+  const simgrid::mc::Variable* variable = info->find_variable(name);
   xbt_assert(variable, "Global variable %s was not found", name);
   xbt_assert(variable->name == name, "Name mismatch for %s", name);
   xbt_assert(variable->global, "Variable %s is not global", name);
@@ -121,7 +121,7 @@ int main(int argc, char** argv)
 {
   SIMIX_global_init(&argc, argv);
 
-  simgrid::mc::Variable* var;
+  const simgrid::mc::Variable* var;
   simgrid::mc::Type* type;
 
   simgrid::mc::RemoteClient process(getpid(), -1);