From 8be96606a051358ca1b0e8269f5150a7e3d53cab Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Sat, 21 Jul 2018 14:34:27 +0200 Subject: [PATCH] stringify tracing category --- include/simgrid/kernel/resource/Action.hpp | 6 +++--- src/instr/instr_private.hpp | 2 +- src/instr/instr_resource_utilization.cpp | 6 +++--- src/kernel/resource/Action.cpp | 7 ------- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/include/simgrid/kernel/resource/Action.hpp b/include/simgrid/kernel/resource/Action.hpp index 0881e68dc1..955db666ed 100644 --- a/include/simgrid/kernel/resource/Action.hpp +++ b/include/simgrid/kernel/resource/Action.hpp @@ -178,9 +178,9 @@ public: virtual void set_max_duration(double duration); /** @brief Get the tracing category associated to the current action */ - char* get_category() const { return category_; } + std::string get_category() const { return category_; } /** @brief Set the tracing category of the current Action */ - void set_category(const char* category); + void set_category(std::string category) { category_ = category; } /** @brief Get the priority of the current Action */ double get_priority() const { return sharing_priority_; }; @@ -203,7 +203,7 @@ private: double remains_; /**< How much of that cost remains to be done in the currently running task */ double start_time_; /**< start time */ double finish_time_ = -1; /**< finish time (may fluctuate until the task is completed) */ - char* category_ = nullptr; /**< tracing category for categorized resource utilization monitoring */ + std::string category_; /**< tracing category for categorized resource utilization monitoring */ double cost_; simgrid::kernel::resource::Model* model_; diff --git a/src/instr/instr_private.hpp b/src/instr/instr_private.hpp index 1fc86dbc29..31b08e7986 100644 --- a/src/instr/instr_private.hpp +++ b/src/instr/instr_private.hpp @@ -258,7 +258,7 @@ XBT_PUBLIC bool TRACE_smpi_is_sleeping(); XBT_PUBLIC bool TRACE_smpi_view_internals(); XBT_PRIVATE void TRACE_surf_resource_set_utilization(const char* type, const char* name, const char* resource, - const char* category, double value, double now, double delta); + std::string category, double value, double now, double delta); /* instr_paje.c */ extern XBT_PRIVATE std::set trivaNodeTypes; diff --git a/src/instr/instr_resource_utilization.cpp b/src/instr/instr_resource_utilization.cpp index ace1ff0bd0..d9d96fc8f7 100644 --- a/src/instr/instr_resource_utilization.cpp +++ b/src/instr/instr_resource_utilization.cpp @@ -9,7 +9,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_resource, instr, "tracing (un)-categorized resource utilization"); -void TRACE_surf_resource_set_utilization(const char* type, const char* name, const char* resource, const char* category, +void TRACE_surf_resource_set_utilization(const char* type, const char* name, const char* resource, std::string category, double value, double now, double delta) { // only trace resource utilization if resource is known by tracing mechanism @@ -24,8 +24,8 @@ void TRACE_surf_resource_set_utilization(const char* type, const char* name, con } // trace categorized resource utilization - if (TRACE_categorized() && category) { - std::string category_type = name[0] + std::string(category); + if (TRACE_categorized() && !category.empty()) { + std::string category_type = name[0] + category; XBT_DEBUG("CAT %s [%f - %f] %s %s %f", type, now, now + delta, resource, category_type.c_str(), value); container->get_variable(name)->instr_event(now, delta, resource, value); } diff --git a/src/kernel/resource/Action.cpp b/src/kernel/resource/Action.cpp index 1752c19d54..7f6fa06dd4 100644 --- a/src/kernel/resource/Action.cpp +++ b/src/kernel/resource/Action.cpp @@ -42,8 +42,6 @@ Action::~Action() get_model()->get_action_heap().remove(this); if (modified_set_hook_.is_linked()) simgrid::xbt::intrusive_erase(*get_model()->get_modified_set(), *this); - - xbt_free(category_); } void Action::finish(Action::State state) @@ -111,11 +109,6 @@ void Action::set_bound(double bound) XBT_OUT(); } -void Action::set_category(const char* category) -{ - category_ = xbt_strdup(category); -} - void Action::ref() { refcount_++; -- 2.20.1