From: Arnaud Giersch Date: Fri, 26 Feb 2021 13:55:09 +0000 (+0100) Subject: A few less global variables. X-Git-Tag: v3.27~301 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/6d822b05d062d8be5858745ee8bdba4208f42d00 A few less global variables. --- diff --git a/src/instr/instr_config.cpp b/src/instr/instr_config.cpp index 41d0ca88d4..65d5a634d5 100644 --- a/src/instr/instr_config.cpp +++ b/src/instr/instr_config.cpp @@ -24,7 +24,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_config, instr, "Configuration"); std::ofstream tracing_file; std::map 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 diff --git a/src/instr/instr_paje_types.cpp b/src/instr/instr_paje_types.cpp index 2ee05635c0..e0f50de708 100644 --- a/src/instr/instr_paje_types.cpp +++ b/src/instr/instr_paje_types.cpp @@ -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> 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> platform_variables; + // create a key considering the resource and variable std::string key = std::string(resource) + get_name(); diff --git a/src/mc/inspect/mc_dwarf.cpp b/src/mc/inspect/mc_dwarf.cpp index e5e62b623e..646ecc1305 100644 --- a/src/mc/inspect/mc_dwarf.cpp +++ b/src/mc/inspect/mc_dwarf.cpp @@ -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 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 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++; diff --git a/src/mc/inspect/mc_unw.cpp b/src/mc/inspect/mc_unw.cpp index 0685ad78ac..8f37ddb5e1 100644 --- a/src/mc/inspect/mc_unw.cpp +++ b/src/mc/inspect/mc_unw.cpp @@ -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) diff --git a/src/mc/inspect/mc_unw.hpp b/src/mc/inspect/mc_unw.hpp index fe0861a648..4dc94d6625 100644 --- a/src/mc/inspect/mc_unw.hpp +++ b/src/mc/inspect/mc_unw.hpp @@ -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: diff --git a/src/mc/inspect/mc_unw_vmread.cpp b/src/mc/inspect/mc_unw_vmread.cpp index ba7fdbab4c..b79000aa58 100644 --- a/src/mc/inspect/mc_unw_vmread.cpp +++ b/src/mc/inspect/mc_unw_vmread.cpp @@ -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); } diff --git a/src/smpi/internals/smpi_actor.cpp b/src/smpi/internals/smpi_actor.cpp index 1c332e8643..0463493c9f 100644 --- a/src/smpi/internals/smpi_actor.cpp +++ b/src/smpi/internals/smpi_actor.cpp @@ -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; diff --git a/src/smpi/internals/smpi_global.cpp b/src/smpi/internals/smpi_global.cpp index ca57aba514..7910ac00f1 100644 --- a/src/smpi/internals/smpi_global.cpp +++ b/src/smpi/internals/smpi_global.cpp @@ -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> units2papi_setup; #endif