Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
A few less global variables.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 26 Feb 2021 13:55:09 +0000 (14:55 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 1 Mar 2021 08:20:44 +0000 (09:20 +0100)
src/instr/instr_config.cpp
src/instr/instr_paje_types.cpp
src/mc/inspect/mc_dwarf.cpp
src/mc/inspect/mc_unw.cpp
src/mc/inspect/mc_unw.hpp
src/mc/inspect/mc_unw_vmread.cpp
src/smpi/internals/smpi_actor.cpp
src/smpi/internals/smpi_global.cpp

index 41d0ca8..65d5a63 100644 (file)
@@ -24,7 +24,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_config, instr, "Configuration");
 
 std::ofstream tracing_file;
 std::map<const simgrid::instr::Container*, std::ofstream*> tracing_files; // TI specific
-double prefix = 0.0;                                 // TI specific
 
 constexpr char OPT_TRACING_BASIC[]             = "tracing/basic";
 constexpr char OPT_TRACING_COMMENT_FILE[]      = "tracing/comment-file";
@@ -269,6 +268,7 @@ static void on_container_creation_ti(const Container& c)
             SIMIX_get_clock());
   // if we are in the mode with only one file
   static std::ofstream* ti_unique_file = nullptr;
+  static double prefix                 = 0.0;
 
   if (tracing_files.empty()) {
     // generate unique run id with time
index 2ee0563..e0f50de 100644 (file)
@@ -9,9 +9,6 @@
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_paje_types, instr, "Paje tracing event system (types)");
 
-// to check if variables were previously set to 0, otherwise paje won't simulate them
-static std::set<std::string, std::less<>> platform_variables;
-
 namespace simgrid {
 namespace instr {
 
@@ -68,6 +65,9 @@ void VariableType::instr_event(double now, double delta, const char* resource, d
    * non-determined value, hence causing analysis problems.
    */
 
+  // to check if variables were previously set to 0, otherwise paje won't simulate them
+  static std::set<std::string, std::less<>> platform_variables;
+
   // create a key considering the resource and variable
   std::string key = std::string(resource) + get_name();
 
index e5e62b6..646ecc1 100644 (file)
@@ -603,8 +603,6 @@ static void MC_dwarf_handle_type_die(simgrid::mc::ObjectInformation* info, Dwarf
     info->full_types_by_name[t.name] = &t;
 }
 
-static int mc_anonymous_variable_index = 0;
-
 static std::unique_ptr<simgrid::mc::Variable> MC_die_to_variable(simgrid::mc::ObjectInformation* info, Dwarf_Die* die,
                                                                  const Dwarf_Die* /*unit*/,
                                                                  const simgrid::mc::Frame* frame, const char* ns)
@@ -694,6 +692,7 @@ static std::unique_ptr<simgrid::mc::Variable> MC_die_to_variable(simgrid::mc::Ob
 
   // The current code needs a variable name,
   // generate a fake one:
+  static int mc_anonymous_variable_index = 0;
   if (variable->name.empty()) {
     variable->name = "@anonymous#" + std::to_string(mc_anonymous_variable_index);
     mc_anonymous_variable_index++;
index 0685ad7..8f37ddb 100644 (file)
@@ -205,22 +205,20 @@ int UnwindContext::get_proc_name(unw_addr_space_t /*as*/, unw_word_t addr, char*
 
 // ***** Init
 
-/** Virtual table for our `libunwind` implementation
- *
- *  Stack unwinding on a `simgrid::mc::Process*` (for memory, unwinding information)
- *  and `ucontext_t` (for processor registers).
- *
- * It works with the `simgrid::mc::UnwindContext` context.
- *
- * Use nullptr as access_fpreg and resume, as we don't need them.
- */
-unw_accessors_t UnwindContext::accessors = {&find_proc_info, &put_unwind_info, &get_dyn_info_list_addr,
-                                            &access_mem,     &access_reg,      nullptr,
-                                            nullptr,         &get_proc_name};
-
 unw_addr_space_t UnwindContext::createUnwindAddressSpace()
 {
-  return unw_create_addr_space(&UnwindContext::accessors, BYTE_ORDER);
+  /** Virtual table for our `libunwind` implementation
+   *
+   *  Stack unwinding on a `simgrid::mc::Process*` (for memory, unwinding information)
+   *  and `ucontext_t` (for processor registers).
+   *
+   * It works with the `simgrid::mc::UnwindContext` context.
+   *
+   * Use nullptr as access_fpreg and resume, as we don't need them.
+   */
+  unw_accessors_t accessors = {&find_proc_info, &put_unwind_info, &get_dyn_info_list_addr, &access_mem, &access_reg,
+                               nullptr,         nullptr,          &get_proc_name};
+  return unw_create_addr_space(&accessors, BYTE_ORDER);
 }
 
 void UnwindContext::initialize(simgrid::mc::RemoteSimulation* process, unw_context_t* c)
index fe0861a..4dc94d6 100644 (file)
@@ -61,7 +61,6 @@ private: // Methods and virtual table for libunwind
   static int access_reg(unw_addr_space_t as, unw_regnum_t regnum, unw_word_t* valp, int write, void* arg) noexcept;
   static int get_proc_name(unw_addr_space_t as, unw_word_t addr, char* bufp, size_t buf_len, unw_word_t* offp,
                            void* arg) noexcept;
-  static unw_accessors_t accessors;
 
 public:
   // Create a libunwind address space:
index ba7fdba..b79000a 100644 (file)
@@ -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);
 }
 
index 1c332e8..0463493 100644 (file)
@@ -12,7 +12,6 @@
 
 #if HAVE_PAPI
 #include "papi.h"
-extern std::string papi_default_config_name;
 #endif
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_process, smpi, "Logging specific to SMPI (kernel)");
@@ -40,7 +39,7 @@ ActorExt::ActorExt(s4u::Actor* actor) : actor_(actor)
     // TODO: Implement host/process/thread based counters. This implementation
     // just always takes the values passed via "default", like this:
     // "default:COUNTER1:COUNTER2:COUNTER3;".
-    auto it = units2papi_setup.find(papi_default_config_name);
+    auto it = units2papi_setup.find("default");
     if (it != units2papi_setup.end()) {
       papi_event_set_    = it->second.event_set;
       papi_counter_data_ = it->second.counter_data;
index ca57aba..7910ac0 100644 (file)
@@ -65,7 +65,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_kernel, smpi, "Logging specific to SMPI (ke
 #endif
 
 #if HAVE_PAPI
-std::string papi_default_config_name = "default";
 std::map</* computation unit name */ std::string, papi_process_data, std::less<>> units2papi_setup;
 #endif