llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-lldb Author: Wanyi (kusmour) <details> <summary>Changes</summary> Reverts llvm/llvm-project#<!-- -->80745 Buildbots broke for linux --- Patch is 28.12 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/80915.diff 19 Files Affected: - (modified) lldb/bindings/headers.swig (-1) - (removed) lldb/bindings/interface/SBStatisticsOptionsDocStrings.i (-8) - (modified) lldb/bindings/interfaces.swig (-2) - (modified) lldb/include/lldb/API/LLDB.h (-1) - (modified) lldb/include/lldb/API/SBDefines.h (-1) - (removed) lldb/include/lldb/API/SBStatisticsOptions.h (-36) - (modified) lldb/include/lldb/API/SBTarget.h (-10) - (modified) lldb/include/lldb/Target/Statistics.h (+2-13) - (modified) lldb/include/lldb/Target/Target.h (+1-2) - (modified) lldb/include/lldb/lldb-forward.h (-1) - (modified) lldb/source/API/CMakeLists.txt (-1) - (removed) lldb/source/API/SBStatisticsOptions.cpp (-49) - (modified) lldb/source/API/SBTarget.cpp (+3-10) - (modified) lldb/source/Commands/CommandObjectStats.cpp (+1-9) - (modified) lldb/source/Commands/Options.td (-3) - (modified) lldb/source/Target/Statistics.cpp (+77-123) - (modified) lldb/source/Target/Target.cpp (+1-4) - (modified) lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py (+1-22) - (modified) lldb/test/API/functionalities/stats_api/main.c (+1-1) ``````````diff diff --git a/lldb/bindings/headers.swig b/lldb/bindings/headers.swig index e8d0cda288141c..408db90b925f15 100644 --- a/lldb/bindings/headers.swig +++ b/lldb/bindings/headers.swig @@ -54,7 +54,6 @@ #include "lldb/API/SBScriptObject.h" #include "lldb/API/SBSection.h" #include "lldb/API/SBSourceManager.h" -#include "lldb/API/SBStatisticsOptions.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBStringList.h" #include "lldb/API/SBStructuredData.h" diff --git a/lldb/bindings/interface/SBStatisticsOptionsDocStrings.i b/lldb/bindings/interface/SBStatisticsOptionsDocStrings.i deleted file mode 100644 index f72cf84319e19b..00000000000000 --- a/lldb/bindings/interface/SBStatisticsOptionsDocStrings.i +++ /dev/null @@ -1,8 +0,0 @@ -%feature("docstring", -"A container for options to use when dumping statistics." -) lldb::SBStatisticsOptions; - -%feature("docstring", "Sets whether the statistics should only dump a summary." -) lldb::SBStatisticsOptions::SetSummaryOnly; -%feature("docstring", "Gets whether the statistics only dump a summary." -) lldb::SBStatisticsOptions::GetSummaryOnly; diff --git a/lldb/bindings/interfaces.swig b/lldb/bindings/interfaces.swig index a31a0b4af1eb6c..9ca479218f621c 100644 --- a/lldb/bindings/interfaces.swig +++ b/lldb/bindings/interfaces.swig @@ -56,7 +56,6 @@ %include "./interface/SBReproducerDocstrings.i" %include "./interface/SBSectionDocstrings.i" %include "./interface/SBSourceManagerDocstrings.i" -%include "./interface/SBStatisticsOptionsDocstrings.i" %include "./interface/SBStreamDocstrings.i" %include "./interface/SBStringListDocstrings.i" %include "./interface/SBStructuredDataDocstrings.i" @@ -132,7 +131,6 @@ %include "lldb/API/SBScriptObject.h" %include "lldb/API/SBSection.h" %include "lldb/API/SBSourceManager.h" -%include "lldb/API/SBStatisticsOptions.h" %include "lldb/API/SBStream.h" %include "lldb/API/SBStringList.h" %include "lldb/API/SBStructuredData.h" diff --git a/lldb/include/lldb/API/LLDB.h b/lldb/include/lldb/API/LLDB.h index c83eb92fcfb30a..f5f1b87a046c2a 100644 --- a/lldb/include/lldb/API/LLDB.h +++ b/lldb/include/lldb/API/LLDB.h @@ -56,7 +56,6 @@ #include "lldb/API/SBReproducer.h" #include "lldb/API/SBSection.h" #include "lldb/API/SBSourceManager.h" -#include "lldb/API/SBStatisticsOptions.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBStringList.h" #include "lldb/API/SBStructuredData.h" diff --git a/lldb/include/lldb/API/SBDefines.h b/lldb/include/lldb/API/SBDefines.h index 1181920677b46f..92d823fa1dfe25 100644 --- a/lldb/include/lldb/API/SBDefines.h +++ b/lldb/include/lldb/API/SBDefines.h @@ -99,7 +99,6 @@ class LLDB_API SBReproducer; class LLDB_API SBScriptObject; class LLDB_API SBSection; class LLDB_API SBSourceManager; -class LLDB_API SBStatisticsOptions; class LLDB_API SBStream; class LLDB_API SBStringList; class LLDB_API SBStructuredData; diff --git a/lldb/include/lldb/API/SBStatisticsOptions.h b/lldb/include/lldb/API/SBStatisticsOptions.h deleted file mode 100644 index 8019ed4315ca21..00000000000000 --- a/lldb/include/lldb/API/SBStatisticsOptions.h +++ /dev/null @@ -1,36 +0,0 @@ -//===-- SBStatisticsOptions.h -----------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLDB_API_SBSTATISTICSOPTIONS_H -#define LLDB_API_SBSTATISTICSOPTIONS_H - -#include "lldb/API/SBDefines.h" - -namespace lldb { - -/// This class handles the verbosity when dumping statistics -class LLDB_API SBStatisticsOptions { -public: - SBStatisticsOptions(); - SBStatisticsOptions(const lldb::SBStatisticsOptions &rhs); - ~SBStatisticsOptions(); - - const SBStatisticsOptions &operator=(const lldb::SBStatisticsOptions &rhs); - - void SetSummaryOnly(bool b); - bool GetSummaryOnly(); - -protected: - friend class SBTarget; - const lldb_private::StatisticsOptions &ref() const; - -private: - std::unique_ptr<lldb_private::StatisticsOptions> m_opaque_up; -}; -} // namespace lldb -#endif // LLDB_API_SBSTATISTICSOPTIONS_H diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h index f7bdd3093d2025..83087623088c5b 100644 --- a/lldb/include/lldb/API/SBTarget.h +++ b/lldb/include/lldb/API/SBTarget.h @@ -17,7 +17,6 @@ #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBFileSpecList.h" #include "lldb/API/SBLaunchInfo.h" -#include "lldb/API/SBStatisticsOptions.h" #include "lldb/API/SBSymbolContextList.h" #include "lldb/API/SBType.h" #include "lldb/API/SBValue.h" @@ -91,15 +90,6 @@ class LLDB_API SBTarget { /// A SBStructuredData with the statistics collected. lldb::SBStructuredData GetStatistics(); - /// Returns a dump of the collected statistics. - /// - /// \param[in] options - /// An objects object that contains all options for the statistics dumping. - /// - /// \return - /// A SBStructuredData with the statistics collected. - lldb::SBStructuredData GetStatistics(SBStatisticsOptions options); - /// Return the platform object associated with the target. /// /// After return, the platform object should be checked for diff --git a/lldb/include/lldb/Target/Statistics.h b/lldb/include/lldb/Target/Statistics.h index f838fa17f80c24..f672786f58f84d 100644 --- a/lldb/include/lldb/Target/Statistics.h +++ b/lldb/include/lldb/Target/Statistics.h @@ -130,15 +130,10 @@ struct ConstStringStats { ConstString::MemoryStats stats = ConstString::GetMemoryStats(); }; -struct StatisticsOptions { - bool summary_only = false; -}; - /// A class that represents statistics for a since lldb_private::Target. class TargetStats { public: - llvm::json::Value ToJSON(Target &target, - const lldb_private::StatisticsOptions &options); + llvm::json::Value ToJSON(Target &target); void SetLaunchOrAttachTime(); void SetFirstPrivateStopTime(); @@ -176,15 +171,9 @@ class DebuggerStats { /// The single target to emit statistics for if non NULL, otherwise dump /// statistics only for the specified target. /// - /// \param summary_only - /// If true, only report high level summary statistics without - /// targets/modules/breakpoints etc.. details. - /// /// \return /// Returns a JSON value that contains all target metrics. - static llvm::json::Value - ReportStatistics(Debugger &debugger, Target *target, - const lldb_private::StatisticsOptions &options); + static llvm::json::Value ReportStatistics(Debugger &debugger, Target *target); protected: // Collecting stats can be set to true to collect stats that are expensive diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index 8f57358981d4d2..c37682e2a03859 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -1599,8 +1599,7 @@ class Target : public std::enable_shared_from_this<Target>, /// /// \return /// Returns a JSON value that contains all target metrics. - llvm::json::Value - ReportStatistics(const lldb_private::StatisticsOptions &options); + llvm::json::Value ReportStatistics(); TargetStats &GetStatistics() { return m_stats; } diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h index 10ba921b9dac8c..d89ad21512215f 100644 --- a/lldb/include/lldb/lldb-forward.h +++ b/lldb/include/lldb/lldb-forward.h @@ -298,7 +298,6 @@ struct CompilerContext; struct LineEntry; struct PropertyDefinition; struct ScriptSummaryFormat; -struct StatisticsOptions; struct StringSummaryFormat; template <unsigned N> class StreamBuffer; diff --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt index 57cc44f7646753..7d478ecc7f599e 100644 --- a/lldb/source/API/CMakeLists.txt +++ b/lldb/source/API/CMakeLists.txt @@ -69,7 +69,6 @@ add_lldb_library(liblldb SHARED ${option_framework} SBScriptObject.cpp SBSection.cpp SBSourceManager.cpp - SBStatisticsOptions.cpp SBStream.cpp SBStringList.cpp SBStructuredData.cpp diff --git a/lldb/source/API/SBStatisticsOptions.cpp b/lldb/source/API/SBStatisticsOptions.cpp deleted file mode 100644 index 77a7e26a6bd4b5..00000000000000 --- a/lldb/source/API/SBStatisticsOptions.cpp +++ /dev/null @@ -1,49 +0,0 @@ -//===-- SBStatisticsOptions.cpp -------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include "lldb/API/SBStatisticsOptions.h" -#include "lldb/Target/Statistics.h" -#include "lldb/Utility/Instrumentation.h" - -#include "Utils.h" - -using namespace lldb; -using namespace lldb_private; - -SBStatisticsOptions::SBStatisticsOptions() - : m_opaque_up(new StatisticsOptions()) { - LLDB_INSTRUMENT_VA(this); - m_opaque_up->summary_only = false; -} - -SBStatisticsOptions::SBStatisticsOptions(const SBStatisticsOptions &rhs) { - LLDB_INSTRUMENT_VA(this, rhs); - - m_opaque_up = clone(rhs.m_opaque_up); -} - -SBStatisticsOptions::~SBStatisticsOptions() = default; - -const SBStatisticsOptions & -SBStatisticsOptions::operator=(const SBStatisticsOptions &rhs) { - LLDB_INSTRUMENT_VA(this, rhs); - - if (this != &rhs) - m_opaque_up = clone(rhs.m_opaque_up); - return *this; -} - -void SBStatisticsOptions::SetSummaryOnly(bool b) { - m_opaque_up->summary_only = b; -} - -bool SBStatisticsOptions::GetSummaryOnly() { return m_opaque_up->summary_only; } - -const lldb_private::StatisticsOptions &SBStatisticsOptions::ref() const { - return *m_opaque_up; -} diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index cc9f1fdd76afaa..8e616afbcb4e8d 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -199,22 +199,15 @@ SBDebugger SBTarget::GetDebugger() const { SBStructuredData SBTarget::GetStatistics() { LLDB_INSTRUMENT_VA(this); - SBStatisticsOptions options; - return GetStatistics(options); -} - -SBStructuredData SBTarget::GetStatistics(SBStatisticsOptions options) { - LLDB_INSTRUMENT_VA(this); SBStructuredData data; TargetSP target_sp(GetSP()); if (!target_sp) return data; std::string json_str = - llvm::formatv("{0:2}", DebuggerStats::ReportStatistics( - target_sp->GetDebugger(), target_sp.get(), - options.ref())) - .str(); + llvm::formatv("{0:2}", + DebuggerStats::ReportStatistics(target_sp->GetDebugger(), + target_sp.get())).str(); data.m_impl_up->SetObjectSP(StructuredData::ParseJSON(json_str)); return data; } diff --git a/lldb/source/Commands/CommandObjectStats.cpp b/lldb/source/Commands/CommandObjectStats.cpp index b23b7024c82176..262de0bda144a6 100644 --- a/lldb/source/Commands/CommandObjectStats.cpp +++ b/lldb/source/Commands/CommandObjectStats.cpp @@ -75,9 +75,6 @@ class CommandObjectStatsDump : public CommandObjectParsed { case 'a': m_all_targets = true; break; - case 's': - m_stats_options.summary_only = true; - break; default: llvm_unreachable("Unimplemented option"); } @@ -86,17 +83,13 @@ class CommandObjectStatsDump : public CommandObjectParsed { void OptionParsingStarting(ExecutionContext *execution_context) override { m_all_targets = false; - m_stats_options = StatisticsOptions(); } llvm::ArrayRef<OptionDefinition> GetDefinitions() override { return llvm::ArrayRef(g_statistics_dump_options); } - const StatisticsOptions &GetStatisticsOptions() { return m_stats_options; } - bool m_all_targets = false; - StatisticsOptions m_stats_options = StatisticsOptions(); }; public: @@ -116,8 +109,7 @@ class CommandObjectStatsDump : public CommandObjectParsed { target = m_exe_ctx.GetTargetPtr(); result.AppendMessageWithFormatv( - "{0:2}", DebuggerStats::ReportStatistics( - GetDebugger(), target, m_options.GetStatisticsOptions())); + "{0:2}", DebuggerStats::ReportStatistics(GetDebugger(), target)); result.SetStatus(eReturnStatusSuccessFinishResult); } diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td index a87f457105aac0..ed3167727bcd32 100644 --- a/lldb/source/Commands/Options.td +++ b/lldb/source/Commands/Options.td @@ -1412,7 +1412,4 @@ let Command = "trace schema" in { let Command = "statistics dump" in { def statistics_dump_all: Option<"all-targets", "a">, Group<1>, Desc<"Include statistics for all targets.">; - def statistics_dump_summary: Option<"summary", "s">, Group<1>, - Desc<"Dump only high-level summary statistics." - "Exclude targets, modules, breakpoints etc... details.">; } diff --git a/lldb/source/Target/Statistics.cpp b/lldb/source/Target/Statistics.cpp index ec0a4c84692dea..4699710035b2d6 100644 --- a/lldb/source/Target/Statistics.cpp +++ b/lldb/source/Target/Statistics.cpp @@ -12,7 +12,6 @@ #include "lldb/Core/Module.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Symbol/SymbolFile.h" -#include "lldb/Target/DynamicLoader.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Target/UnixSignals.h" @@ -101,94 +100,60 @@ llvm::json::Value ConstStringStats::ToJSON() const { return obj; } -json::Value -TargetStats::ToJSON(Target &target, - const lldb_private::StatisticsOptions &options) { - json::Object target_metrics_json; - ProcessSP process_sp = target.GetProcessSP(); - const bool summary_only = options.summary_only; - if (!summary_only) { - CollectStats(target); - - json::Array json_module_uuid_array; - for (auto module_identifier : m_module_identifiers) - json_module_uuid_array.emplace_back(module_identifier); - - target_metrics_json.try_emplace(m_expr_eval.name, m_expr_eval.ToJSON()); - target_metrics_json.try_emplace(m_frame_var.name, m_frame_var.ToJSON()); - target_metrics_json.try_emplace("moduleIdentifiers", - std::move(json_module_uuid_array)); +json::Value TargetStats::ToJSON(Target &target) { + CollectStats(target); - if (m_launch_or_attach_time && m_first_private_stop_time) { - double elapsed_time = - elapsed(*m_launch_or_attach_time, *m_first_private_stop_time); - target_metrics_json.try_emplace("launchOrAttachTime", elapsed_time); - } - if (m_launch_or_attach_time && m_first_public_stop_time) { - double elapsed_time = - elapsed(*m_launch_or_attach_time, *m_first_public_stop_time); - target_metrics_json.try_emplace("firstStopTime", elapsed_time); - } - target_metrics_json.try_emplace("targetCreateTime", - m_create_time.get().count()); + json::Array json_module_uuid_array; + for (auto module_identifier : m_module_identifiers) + json_module_uuid_array.emplace_back(module_identifier); - json::Array breakpoints_array; - double totalBreakpointResolveTime = 0.0; - // Report both the normal breakpoint list and the internal breakpoint list. - for (int i = 0; i < 2; ++i) { - BreakpointList &breakpoints = target.GetBreakpointList(i == 1); - std::unique_lock<std::recursive_mutex> lock; - breakpoints.GetListMutex(lock); - size_t num_breakpoints = breakpoints.GetSize(); - for (size_t i = 0; i < num_breakpoints; i++) { - Breakpoint *bp = breakpoints.GetBreakpointAtIndex(i).get(); - breakpoints_array.push_back(bp->GetStatistics()); - totalBreakpointResolveTime += bp->GetResolveTime().count(); - } - } - target_metrics_json.try_emplace("breakpoints", - std::move(breakpoints_array)); - target_metrics_json.try_emplace("totalBreakpointResolveTime", - totalBreakpointResolveTime); + json::Object target_metrics_json{ + {m_expr_eval.name, m_expr_eval.ToJSON()}, + {m_frame_var.name, m_frame_var.ToJSON()}, + {"moduleIdentifiers", std::move(json_module_uuid_array)}}; - if (process_sp) { - UnixSignalsSP unix_signals_sp = process_sp->GetUnixSignals(); - if (unix_signals_sp) - target_metrics_json.try_emplace( - "signals", unix_signals_sp->GetHitCountStatistics()); - } + if (m_launch_or_attach_time && m_first_private_stop_time) { + double elapsed_time = + elapsed(*m_launch_or_attach_time, *m_first_private_stop_time); + target_metrics_json.try_emplace("launchOrAttachTime", elapsed_time); } - - // Counting "totalSharedLibraryEventHitCount" from breakpoints of kind - // "shared-library-event". - { - uint32_t shared_library_event_breakpoint_hit_count = 0; - // The "shared-library-event" is only found in the internal breakpoint list. - BreakpointList &breakpoints = target.GetBreakpointList(/* internal */ true); + if (m_launch_or_attach_time && m_first_public_stop_time) { + double elapsed_time = + elapsed(*m_launch_or_attach_time, *m_first_public_stop_time); + target_metrics_json.try_emplace("firstStopTime", elapsed_time); + } + target_metrics_json.try_emplace("targetCreateTime", + m_create_time.get().count()); + + json::Array breakpoints_array; + double totalBreakpointResolveTime = 0.0; + // Rport both the normal breakpoint list and the internal breakpoint list. + for (int i = 0; i < 2; ++i) { + BreakpointList &breakpoints = target.GetBreakpointList(i == 1); std::unique_lock<std::recursive_mutex> lock; breakpoints.GetListMutex(lock); size_t num_breakpoints = breakpoints.GetSize(); for (size_t i = 0; i < num_breakpoints; i++) { Breakpoint *bp = breakpoints.GetBreakpointAtIndex(i).get(); - if (strcmp(bp->GetBreakpointKind(), "shared-library-event") == 0) - shared_library_event_breakpoint_hit_count += bp->GetHitCount(); + breakpoints_array.push_back(bp->GetStatistics()); + totalBreakpointResolveTime += bp->GetResolveTime().count(); } - - target_metrics_json.try_emplace("totalSharedLibraryEventHitCount", - shared_library_event_breakpoint_hit_count); } + ProcessSP process_sp = target.GetProcessSP(); if (process_sp) { + UnixSignalsSP unix_signals_sp = process_sp->GetUnixSignals(); + if (unix_signals_sp) + target_metrics_json.try_emplace("signals", + unix_signals_sp->GetHitCountStatistics()); uint32_t stop_id = process_sp->GetStopID(); target_metrics_json.try_emplace("stopCount", stop_id); - - llvm::StringRef dyld_plugin_name; - if (process_sp->GetDynamicLoader()) - dyld_plugin_name = process_sp->GetDynamicLoader()->GetPluginName(); - target_metrics_json.try_emplace("dyldPluginName", dyld_plugin_name); } - target_metrics_json.try_emplace("sourceMapDeduceCount", - m_source_map_deduce_count); + target_metrics_json.try_emplace("breakpoints", std::move(breakpoints_array)); + target_metrics_json.try_emplace("totalBreakpointResolveTime", + totalBreakpointResolveTime); + target_metrics_json.try_emplace("sourceMapDeduceCount", m_source_map_deduce_count); + return target_metrics_json; } @@ -219,12 +184,8 @@ void TargetStats::IncreaseSourceMapDeduceCount() { bool DebuggerStats::g_collecting_stats = false; -llvm::json::Value DebuggerStats::ReportStatistics( - Debugger &debugger, Target *target, - const lldb_private::StatisticsOptions &options) { - - const bool summary_only = options.summary_only; - +llvm::json::Value DebuggerStats::ReportStatistics(Debugger &debugger, + Target *target) { json::Array json_targets; json::Array json_modules; double symtab_parse_time = 0.0; @@ -236,7 +197,12 @@ llvm::json::Value DebuggerStats::ReportStatistics( uint32_t debug_index_loaded = 0; uint32_t debug_index_saved = 0; uint64_t debug_info_size = 0; - + if (target) { + json_targets.emplace_ba... [truncated] `````````` </details> https://github.com/llvm/llvm-project/pull/80915 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits