github-actions[bot] wrote: <!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning: <details> <summary> You can test this locally with the following command: </summary> ``````````bash git-clang-format --diff a3ccaed3b9f6a1fe9b7f2ef019259f88072639b2 ad4b20d2074203fce9e4c47fd6045699b1528d86 --extensions h,cpp -- lldb/include/lldb/Target/Statistics.h lldb/include/lldb/Target/Target.h lldb/source/Core/ValueObject.cpp lldb/source/Target/Statistics.cpp lldb/source/Target/Target.cpp lldb/test/API/commands/statistics/basic/main.cpp `````````` </details> <details> <summary> View the diff from clang-format here. </summary> ``````````diff diff --git a/lldb/include/lldb/Target/Statistics.h b/lldb/include/lldb/Target/Statistics.h index 06ca5c7923..a8c3f84d9d 100644 --- a/lldb/include/lldb/Target/Statistics.h +++ b/lldb/include/lldb/Target/Statistics.h @@ -180,49 +180,44 @@ private: class SummaryStatistics { public: SummaryStatistics() = default; - SummaryStatistics(lldb_private::ConstString name) : - m_total_time(), m_name(name), m_summary_count(0) {} + SummaryStatistics(lldb_private::ConstString name) + : m_total_time(), m_name(name), m_summary_count(0) {} SummaryStatistics(const SummaryStatistics &&rhs) - : m_total_time(), m_name(rhs.m_name), m_summary_count(rhs.m_summary_count.load(std::memory_order_relaxed)) {} + : m_total_time(), m_name(rhs.m_name), + m_summary_count(rhs.m_summary_count.load(std::memory_order_relaxed)) {} lldb_private::ConstString GetName() const { return m_name; }; double GetAverageTime() const { - return m_total_time.get().count() / m_summary_count.load(std::memory_order_relaxed); + return m_total_time.get().count() / + m_summary_count.load(std::memory_order_relaxed); } - double GetTotalTime() const { - return m_total_time.get().count(); - } + double GetTotalTime() const { return m_total_time.get().count(); } uint64_t GetSummaryCount() const { return m_summary_count.load(std::memory_order_relaxed); } - StatsDuration& GetDurationReference() { - return m_total_time; - } + StatsDuration &GetDurationReference() { return m_total_time; } llvm::json::Value ToJSON() const; // Basic RAII class to increment the summary count when the call is complete. - // In the future this can be extended to collect information about the + // In the future this can be extended to collect information about the // elapsed time for a single request. class SummaryInvocation { public: SummaryInvocation(SummaryStatistics &summary) : m_summary(summary) {} - ~SummaryInvocation() { - m_summary.OnInvoked(); - } + ~SummaryInvocation() { m_summary.OnInvoked(); } + private: SummaryStatistics &m_summary; }; private: /// Called when Summary Invocation is destructed. - void OnInvoked() { - m_summary_count.fetch_add(1, std::memory_order_relaxed); - } + void OnInvoked() { m_summary_count.fetch_add(1, std::memory_order_relaxed); } lldb_private::StatsDuration m_total_time; lldb_private::ConstString m_name; @@ -235,13 +230,16 @@ public: SummaryStatisticsCache() = default; /// Get the SummaryStatistics object for a given provider name, or insert /// if statistics for that provider is not in the map. - lldb_private::SummaryStatistics &GetSummaryStatisticsForProviderName(lldb_private::ConstString summary_provider_name) { + lldb_private::SummaryStatistics &GetSummaryStatisticsForProviderName( + lldb_private::ConstString summary_provider_name) { m_map_mutex.lock(); if (m_summary_stats_map.count(summary_provider_name) == 0) { - m_summary_stats_map.emplace(summary_provider_name, SummaryStatistics(summary_provider_name)); + m_summary_stats_map.emplace(summary_provider_name, + SummaryStatistics(summary_provider_name)); } - SummaryStatistics &summary_stats = m_summary_stats_map.at(summary_provider_name); + SummaryStatistics &summary_stats = + m_summary_stats_map.at(summary_provider_name); m_map_mutex.unlock(); return summary_stats; } @@ -249,7 +247,8 @@ public: llvm::json::Value ToJSON(); private: - std::map<lldb_private::ConstString, lldb_private::SummaryStatistics> m_summary_stats_map; + std::map<lldb_private::ConstString, lldb_private::SummaryStatistics> + m_summary_stats_map; std::mutex m_map_mutex; }; diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index ae1ea43c01..7e53670c39 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -258,7 +258,6 @@ public: bool GetDebugUtilityExpression() const; - private: std::optional<bool> GetExperimentalPropertyValue(size_t prop_idx, @@ -1222,8 +1221,9 @@ public: void ClearAllLoadedSections(); - lldb_private::SummaryStatistics& GetSummaryStatisticsForProvider(lldb_private::ConstString summary_provider_name); - lldb_private::SummaryStatisticsCache& GetSummaryStatisticsCache(); + lldb_private::SummaryStatistics &GetSummaryStatisticsForProvider( + lldb_private::ConstString summary_provider_name); + lldb_private::SummaryStatisticsCache &GetSummaryStatisticsCache(); /// Set the \a Trace object containing processor trace information of this /// target. diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index 8e6ff41c08..08d3dd5e0f 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -615,10 +615,11 @@ bool ValueObject::GetSummaryAsCString(TypeSummaryImpl *summary_ptr, m_synthetic_value->UpdateValueIfNeeded(); // the summary might depend on // the synthetic children being // up-to-date (e.g. ${svar%#}) - SummaryStatistics &summary_stats = GetExecutionContextRef() - .GetProcessSP() - ->GetTarget() - .GetSummaryStatisticsForProvider(GetTypeName()); + SummaryStatistics &summary_stats = + GetExecutionContextRef() + .GetProcessSP() + ->GetTarget() + .GetSummaryStatisticsForProvider(GetTypeName()); /// Construct RAII types to time and collect data on summary creation. SummaryStatistics::SummaryInvocation summary_inv(summary_stats); { diff --git a/lldb/source/Target/Statistics.cpp b/lldb/source/Target/Statistics.cpp index bcb8fdbca4..5c36fd7bb2 100644 --- a/lldb/source/Target/Statistics.cpp +++ b/lldb/source/Target/Statistics.cpp @@ -192,7 +192,7 @@ TargetStats::ToJSON(Target &target, } target_metrics_json.try_emplace("sourceMapDeduceCount", m_source_map_deduce_count); - target_metrics_json.try_emplace("summaryProviderStatistics", + target_metrics_json.try_emplace("summaryProviderStatistics", target.GetSummaryStatisticsCache().ToJSON()); return target_metrics_json; } @@ -412,21 +412,18 @@ llvm::json::Value DebuggerStats::ReportStatistics( } llvm::json::Value SummaryStatistics::ToJSON() const { - json::Object body {{ - {"invocationCount", GetSummaryCount()}, - {"totalTime", GetTotalTime()}, - {"averageTime", GetAverageTime()} - }}; + json::Object body{{{"invocationCount", GetSummaryCount()}, + {"totalTime", GetTotalTime()}, + {"averageTime", GetAverageTime()}}}; return json::Object{{GetName().AsCString(), std::move(body)}}; } - json::Value SummaryStatisticsCache::ToJSON() { m_map_mutex.lock(); json::Array json_summary_stats; for (const auto &summary_stat : m_summary_stats_map) json_summary_stats.emplace_back(summary_stat.second.ToJSON()); - + m_map_mutex.unlock(); return json_summary_stats; } diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 834d48763b..d40da36443 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -3193,11 +3193,13 @@ bool Target::SetSectionUnloaded(const lldb::SectionSP §ion_sp, void Target::ClearAllLoadedSections() { m_section_load_history.Clear(); } -lldb_private::SummaryStatistics& Target::GetSummaryStatisticsForProvider(lldb_private::ConstString summary_provider_name) { - return m_summary_statistics_cache.GetSummaryStatisticsForProviderName(summary_provider_name); +lldb_private::SummaryStatistics &Target::GetSummaryStatisticsForProvider( + lldb_private::ConstString summary_provider_name) { + return m_summary_statistics_cache.GetSummaryStatisticsForProviderName( + summary_provider_name); } -lldb_private::SummaryStatisticsCache& Target::GetSummaryStatisticsCache() { +lldb_private::SummaryStatisticsCache &Target::GetSummaryStatisticsCache() { return m_summary_statistics_cache; } `````````` </details> https://github.com/llvm/llvm-project/pull/102708 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits