From fce872a4f145c997f146ea0d098a77549a47bd0b Mon Sep 17 00:00:00 2001 From: Gabriel Corona Date: Fri, 20 Nov 2015 11:50:37 +0100 Subject: [PATCH] [mc] Remove MCer_ignore_global_variable --- src/mc/ModelChecker.cpp | 4 ++-- src/mc/ObjectInformation.cpp | 39 ++++++++++++++++++++++++++++++++++++ src/mc/ObjectInformation.hpp | 1 + src/mc/Process.hpp | 7 +++++++ src/mc/mcer_ignore.cpp | 30 --------------------------- src/mc/mcer_ignore.h | 1 - 6 files changed, 49 insertions(+), 33 deletions(-) diff --git a/src/mc/ModelChecker.cpp b/src/mc/ModelChecker.cpp index 9ceba066cc..2a870fa8d6 100644 --- a/src/mc/ModelChecker.cpp +++ b/src/mc/ModelChecker.cpp @@ -152,10 +152,10 @@ void ModelChecker::setup_ignore() MC_ignore_local_variable("start_time", "*"); /* Static variable used for tracing */ - MCer_ignore_global_variable("counter"); + this->process().ignore_global_variable("counter"); /* SIMIX */ - MCer_ignore_global_variable("smx_total_comms"); + this->process().ignore_global_variable("smx_total_comms"); } void ModelChecker::shutdown() diff --git a/src/mc/ObjectInformation.cpp b/src/mc/ObjectInformation.cpp index 62b793e827..9889f08665 100644 --- a/src/mc/ObjectInformation.cpp +++ b/src/mc/ObjectInformation.cpp @@ -94,5 +94,44 @@ simgrid::mc::Variable* ObjectInformation::find_variable(const char* name) const return nullptr; } +void ObjectInformation::remove_global_variable(const char* name) +{ + typedef std::vector::size_type size_type; + + if (this->global_variables.empty()) + return; + + // Binary search: + size_type start = 0; + size_type end = this->global_variables.size() - 1; + + while (start <= end) { + size_type cursor = start + (end - start) / 2; + simgrid::mc::Variable& current_var = this->global_variables[cursor]; + int cmp = current_var.name.compare(name); + + if (cmp == 0) { + // Find the whole range: + start = cursor; + while (start != 0 && this->global_variables[start - 1].name == name) + start--; + size_type size = this->global_variables.size(); + end = cursor; + while (end != size - 1 && this->global_variables[end + 1].name == name) + end++; + // Remove the whole range: + this->global_variables.erase( + this->global_variables.begin() + cursor, + this->global_variables.begin() + end + 1); + return; + } else if (cmp < 0) + start = cursor + 1; + else if (cursor != 0) + end = cursor - 1; + else + break; + } +} + } } \ No newline at end of file diff --git a/src/mc/ObjectInformation.hpp b/src/mc/ObjectInformation.hpp index 74c958bce2..1a59340afe 100644 --- a/src/mc/ObjectInformation.hpp +++ b/src/mc/ObjectInformation.hpp @@ -92,6 +92,7 @@ public: simgrid::mc::Frame* find_function(const void *ip) const; simgrid::mc::Variable* find_variable(const char* name) const; + void remove_global_variable(const char* name); }; diff --git a/src/mc/Process.hpp b/src/mc/Process.hpp index 55ba5fdece..7cb054d81c 100644 --- a/src/mc/Process.hpp +++ b/src/mc/Process.hpp @@ -161,6 +161,13 @@ public: } void privatized(bool privatized) { privatized_ = privatized; } + void ignore_global_variable(const char* name) + { + for (std::shared_ptr const& info : + this->object_infos) + info->remove_global_variable(name); + } + private: void init_memory_map_info(); void refresh_heap(); diff --git a/src/mc/mcer_ignore.cpp b/src/mc/mcer_ignore.cpp index ce0478e9d2..bbcef78709 100644 --- a/src/mc/mcer_ignore.cpp +++ b/src/mc/mcer_ignore.cpp @@ -113,36 +113,6 @@ XBT_PRIVATE void MC_heap_region_ignore_remove(void *address, size_t size) } } -// ***** Ignore global variables - -XBT_PRIVATE void MCer_ignore_global_variable(const char *name) -{ - simgrid::mc::Process* process = &mc_model_checker->process(); - xbt_assert(!process->object_infos.empty(), "MC subsystem not initialized"); - - for (std::shared_ptr const& info : process->object_infos) { - - // Binary search: - int start = 0; - int end = info->global_variables.size() - 1; - while (start <= end) { - unsigned int cursor = (start + end) / 2; - simgrid::mc::Variable* current_var = &info->global_variables[cursor]; - int cmp = current_var->name.compare(name); - if (cmp == 0) { - info->global_variables.erase( - info->global_variables.begin() + cursor); - start = 0; - end = info->global_variables.size() - 1; - } else if (cmp < 0) { - start = cursor + 1; - } else { - end = cursor - 1; - } - } - } -} - // ***** Ignore local variables static void mc_ignore_local_variable_in_scope(const char *var_name, diff --git a/src/mc/mcer_ignore.h b/src/mc/mcer_ignore.h index 65f843f951..1961f4bb24 100644 --- a/src/mc/mcer_ignore.h +++ b/src/mc/mcer_ignore.h @@ -16,7 +16,6 @@ SG_BEGIN_DECL(); -XBT_PRIVATE void MCer_ignore_global_variable(const char *var_name); XBT_PRIVATE void MC_heap_region_ignore_insert(mc_heap_ignore_region_t region); XBT_PRIVATE void MC_heap_region_ignore_remove(void *address, size_t size); -- 2.30.2