From f3e92822567ebdb2558d3fe258d6722c87b330f6 Mon Sep 17 00:00:00 2001 From: "Jonathan R. Madsen" Date: Mon, 8 Aug 2022 08:38:04 -0500 Subject: [PATCH] Fix some inconsistencies in debug messages w/in category_region (#135) [ROCm/rocprofiler-systems commit: 49127db414ef04b4d951374ec8abe4128d639adf] --- .../library/components/category_region.hpp | 23 +++++++++++-------- .../source/lib/omnitrace/library/tracing.hpp | 6 ++--- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/projects/rocprofiler-systems/source/lib/omnitrace/library/components/category_region.hpp b/projects/rocprofiler-systems/source/lib/omnitrace/library/components/category_region.hpp index d12529e503..cfdfffd50f 100644 --- a/projects/rocprofiler-systems/source/lib/omnitrace/library/components/category_region.hpp +++ b/projects/rocprofiler-systems/source/lib/omnitrace/library/components/category_region.hpp @@ -101,9 +101,6 @@ category_region::start(std::string_view name, Args&&... args) return; } - OMNITRACE_CONDITIONAL_BASIC_PRINT(tracing::debug_push, "omnitrace_push_region(%s)\n", - name.data()); - // the expectation here is that if the state is not active then the call // to omnitrace_init_tooling_hidden will activate all the appropriate // tooling one time and as it exits set it to active and return true. @@ -111,12 +108,15 @@ category_region::start(std::string_view name, Args&&... args) { static auto _debug = get_debug_env() || get_debug_init(); OMNITRACE_CONDITIONAL_BASIC_PRINT( - _debug, "omnitrace_push_region(%s) ignored :: not active. state = %s\n", - name.data(), std::to_string(get_state()).c_str()); + _debug, "[%s] omnitrace_push_region(%s) ignored :: not active. state = %s\n", + category_name, name.data(), std::to_string(get_state()).c_str()); return; } - OMNITRACE_DEBUG("[%s] omnitrace_push_region(%s)\n", category_name, name.data()); + OMNITRACE_CONDITIONAL_PRINT(tracing::debug_push, + "[%s][PID=%i][state=%s] omnitrace_push_region(%s)\n", + category_name, process::get_id(), + std::to_string(get_state()).c_str(), name.data()); auto _use_timemory = get_use_timemory(); auto _use_perfetto = get_use_perfetto(); @@ -163,11 +163,14 @@ category_region::stop(std::string_view name, Args&&... args) (sizeof...(OptsT) == 0 || tim::is_one_of>::value); + OMNITRACE_CONDITIONAL_PRINT(tracing::debug_pop, + "[%s][PID=%i][state=%s] omnitrace_pop_region(%s)\n", + category_name, process::get_id(), + std::to_string(get_state()).c_str(), name.data()); + // only execute when active if(get_state() == State::Active) { - OMNITRACE_CONDITIONAL_PRINT(tracing::debug_pop || get_debug(), - "omnitrace_pop_region(%s)\n", name.data()); if(get_use_timemory()) { if constexpr(_ct_use_timemory) @@ -188,8 +191,8 @@ category_region::stop(std::string_view name, Args&&... args) { static auto _debug = get_debug_env(); OMNITRACE_CONDITIONAL_BASIC_PRINT( - _debug, "omnitrace_pop_region(%s) ignored :: state = %s\n", name.data(), - std::to_string(get_state()).c_str()); + _debug, "[%s] omnitrace_pop_region(%s) ignored :: state = %s\n", + category_name, name.data(), std::to_string(get_state()).c_str()); } } diff --git a/projects/rocprofiler-systems/source/lib/omnitrace/library/tracing.hpp b/projects/rocprofiler-systems/source/lib/omnitrace/library/tracing.hpp index c7acdce892..9e7678c65d 100644 --- a/projects/rocprofiler-systems/source/lib/omnitrace/library/tracing.hpp +++ b/projects/rocprofiler-systems/source/lib/omnitrace/library/tracing.hpp @@ -52,11 +52,11 @@ get_timemory_hash_aliases(int64_t _tid = threading::get_id()); namespace { bool debug_push = // NOLINT - tim::get_env("OMNITRACE_DEBUG_PUSH", false) && !get_debug_env(); + tim::get_env("OMNITRACE_DEBUG_PUSH", false) || get_debug_env(); bool debug_pop = // NOLINT - tim::get_env("OMNITRACE_DEBUG_POP", false) && !get_debug_env(); + tim::get_env("OMNITRACE_DEBUG_POP", false) || get_debug_env(); bool debug_user = // NOLINT - tim::get_env("OMNITRACE_DEBUG_USER_REGIONS", false) && !get_debug_env(); + tim::get_env("OMNITRACE_DEBUG_USER_REGIONS", false) || get_debug_env(); } // namespace inline auto&