[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-06 Thread via lldb-commits


@@ -2687,7 +2687,7 @@ uint64_t SymbolFileDWARF::GetDebugInfoSize() {
 if (cu == nullptr)
   continue;
 
-SymbolFileDWARFDwo *dwo = cu->GetDwoSymbolFile();
+SymbolFileDWARFDwo *dwo = cu->GetDwoSymbolFile(false);

kusmour wrote:

Will put a new PR to address this

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-06 Thread via lldb-commits

https://github.com/kusmour closed 
https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-06 Thread via lldb-commits

https://github.com/kusmour updated 
https://github.com/llvm/llvm-project/pull/80745

>From e5902abd4cd401f5e6a132d1fa5d0b2197512494 Mon Sep 17 00:00:00 2001
From: Wanyi Ye 
Date: Fri, 2 Feb 2024 15:42:01 -0800
Subject: [PATCH 1/5] Support statistics dump summary only mode

Summary:
Added a new --summary option to statistics dump command so that it is much 
light weight than the full version.
With this change, statistics dump --summary can now be included in lldb command 
line telemetry without slowing down lldb exiting.
---
 lldb/include/lldb/API/SBTarget.h  |   6 +-
 lldb/include/lldb/Target/Statistics.h |   9 +-
 lldb/include/lldb/Target/Target.h |   2 +-
 lldb/source/API/SBTarget.cpp  |   9 +-
 lldb/source/Commands/CommandObjectStats.cpp   |   8 +-
 lldb/source/Commands/Options.td   |   3 +
 lldb/source/Target/Statistics.cpp | 194 +++---
 lldb/source/Target/Target.cpp |   4 +-
 .../stats_api/TestStatisticsAPI.py|  15 ++
 9 files changed, 163 insertions(+), 87 deletions(-)

diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 83087623088c5..72b8997afd270 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -86,9 +86,13 @@ class LLDB_API SBTarget {
 
   /// Returns a dump of the collected statistics.
   ///
+  /// \param[in] summary_only
+  ///   If true, only report high level summary statistics without
+  ///   targets/modules/breakpoints etc.. details.
+  ///
   /// \return
   /// A SBStructuredData with the statistics collected.
-  lldb::SBStructuredData GetStatistics();
+  lldb::SBStructuredData GetStatistics(bool summary_only = false);
 
   /// Return the platform object associated with the target.
   ///
diff --git a/lldb/include/lldb/Target/Statistics.h 
b/lldb/include/lldb/Target/Statistics.h
index f672786f58f84..98658ba0cac31 100644
--- a/lldb/include/lldb/Target/Statistics.h
+++ b/lldb/include/lldb/Target/Statistics.h
@@ -133,7 +133,7 @@ struct ConstStringStats {
 /// A class that represents statistics for a since lldb_private::Target.
 class TargetStats {
 public:
-  llvm::json::Value ToJSON(Target );
+  llvm::json::Value ToJSON(Target , bool summary_only = false);
 
   void SetLaunchOrAttachTime();
   void SetFirstPrivateStopTime();
@@ -171,9 +171,14 @@ 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 , Target 
*target);
+  static llvm::json::Value ReportStatistics(Debugger , Target *target,
+bool summary_only = false);
 
 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 c37682e2a0385..4bf6c123dc1dd 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -1599,7 +1599,7 @@ class Target : public 
std::enable_shared_from_this,
   ///
   /// \return
   /// Returns a JSON value that contains all target metrics.
-  llvm::json::Value ReportStatistics();
+  llvm::json::Value ReportStatistics(bool summary_only = false);
 
   TargetStats () { return m_stats; }
 
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 8e616afbcb4e8..615a00ceeaee1 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -197,7 +197,7 @@ SBDebugger SBTarget::GetDebugger() const {
   return debugger;
 }
 
-SBStructuredData SBTarget::GetStatistics() {
+SBStructuredData SBTarget::GetStatistics(bool summary_only) {
   LLDB_INSTRUMENT_VA(this);
 
   SBStructuredData data;
@@ -205,9 +205,10 @@ SBStructuredData SBTarget::GetStatistics() {
   if (!target_sp)
 return data;
   std::string json_str =
-  llvm::formatv("{0:2}",
-  DebuggerStats::ReportStatistics(target_sp->GetDebugger(),
-  target_sp.get())).str();
+  llvm::formatv(
+  "{0:2}", DebuggerStats::ReportStatistics(
+   target_sp->GetDebugger(), target_sp.get(), 
summary_only))
+  .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 262de0bda144a..781b90794dc37 100644
--- a/lldb/source/Commands/CommandObjectStats.cpp
+++ b/lldb/source/Commands/CommandObjectStats.cpp
@@ -75,6 +75,9 @@ class CommandObjectStatsDump : public CommandObjectParsed {
   case 'a':
 m_all_targets = true;
 

[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-06 Thread Greg Clayton via lldb-commits


@@ -184,8 +219,12 @@ void TargetStats::IncreaseSourceMapDeduceCount() {
 
 bool DebuggerStats::g_collecting_stats = false;
 
-llvm::json::Value DebuggerStats::ReportStatistics(Debugger ,
-  Target *target) {
+llvm::json::Value DebuggerStats::ReportStatistics(
+Debugger , Target *target,
+const lldb_private::StatisticsOptions ) {
+
+  bool summary_only = options.summary_only;

clayborg wrote:

`const bool ...`

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-06 Thread Greg Clayton via lldb-commits


@@ -100,60 +101,94 @@ llvm::json::Value ConstStringStats::ToJSON() const {
   return obj;
 }
 
-json::Value TargetStats::ToJSON(Target ) {
-  CollectStats(target);
+json::Value
+TargetStats::ToJSON(Target ,
+const lldb_private::StatisticsOptions ) {
+  json::Object target_metrics_json;
+  ProcessSP process_sp = target.GetProcessSP();
+  bool summary_only = options.summary_only;

clayborg wrote:

`const bool ...`

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-06 Thread Greg Clayton via lldb-commits


@@ -83,13 +86,17 @@ class CommandObjectStatsDump : public CommandObjectParsed {
 
 void OptionParsingStarting(ExecutionContext *execution_context) override {
   m_all_targets = false;
+  m_stats_options = StatisticsOptions();
 }
 
 llvm::ArrayRef GetDefinitions() override {
   return llvm::ArrayRef(g_statistics_dump_options);
 }
 
+StatisticsOptions GetStatisticsOptions() { return m_stats_options; }

clayborg wrote:

return a `const StatisticsOptions&` if you want to. The struct isn't big now, 
so no big deal.

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-06 Thread Greg Clayton via lldb-commits

https://github.com/clayborg edited 
https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-06 Thread Greg Clayton via lldb-commits

https://github.com/clayborg approved this pull request.

A few nits you can fix if you want to.

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-06 Thread via lldb-commits

https://github.com/kusmour updated 
https://github.com/llvm/llvm-project/pull/80745

>From e5902abd4cd401f5e6a132d1fa5d0b2197512494 Mon Sep 17 00:00:00 2001
From: Wanyi Ye 
Date: Fri, 2 Feb 2024 15:42:01 -0800
Subject: [PATCH 1/4] Support statistics dump summary only mode

Summary:
Added a new --summary option to statistics dump command so that it is much 
light weight than the full version.
With this change, statistics dump --summary can now be included in lldb command 
line telemetry without slowing down lldb exiting.
---
 lldb/include/lldb/API/SBTarget.h  |   6 +-
 lldb/include/lldb/Target/Statistics.h |   9 +-
 lldb/include/lldb/Target/Target.h |   2 +-
 lldb/source/API/SBTarget.cpp  |   9 +-
 lldb/source/Commands/CommandObjectStats.cpp   |   8 +-
 lldb/source/Commands/Options.td   |   3 +
 lldb/source/Target/Statistics.cpp | 194 +++---
 lldb/source/Target/Target.cpp |   4 +-
 .../stats_api/TestStatisticsAPI.py|  15 ++
 9 files changed, 163 insertions(+), 87 deletions(-)

diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 83087623088c5b..72b8997afd2704 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -86,9 +86,13 @@ class LLDB_API SBTarget {
 
   /// Returns a dump of the collected statistics.
   ///
+  /// \param[in] summary_only
+  ///   If true, only report high level summary statistics without
+  ///   targets/modules/breakpoints etc.. details.
+  ///
   /// \return
   /// A SBStructuredData with the statistics collected.
-  lldb::SBStructuredData GetStatistics();
+  lldb::SBStructuredData GetStatistics(bool summary_only = false);
 
   /// Return the platform object associated with the target.
   ///
diff --git a/lldb/include/lldb/Target/Statistics.h 
b/lldb/include/lldb/Target/Statistics.h
index f672786f58f84d..98658ba0cac317 100644
--- a/lldb/include/lldb/Target/Statistics.h
+++ b/lldb/include/lldb/Target/Statistics.h
@@ -133,7 +133,7 @@ struct ConstStringStats {
 /// A class that represents statistics for a since lldb_private::Target.
 class TargetStats {
 public:
-  llvm::json::Value ToJSON(Target );
+  llvm::json::Value ToJSON(Target , bool summary_only = false);
 
   void SetLaunchOrAttachTime();
   void SetFirstPrivateStopTime();
@@ -171,9 +171,14 @@ 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 , Target 
*target);
+  static llvm::json::Value ReportStatistics(Debugger , Target *target,
+bool summary_only = false);
 
 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 c37682e2a03859..4bf6c123dc1ddc 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -1599,7 +1599,7 @@ class Target : public 
std::enable_shared_from_this,
   ///
   /// \return
   /// Returns a JSON value that contains all target metrics.
-  llvm::json::Value ReportStatistics();
+  llvm::json::Value ReportStatistics(bool summary_only = false);
 
   TargetStats () { return m_stats; }
 
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 8e616afbcb4e8d..615a00ceeaee16 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -197,7 +197,7 @@ SBDebugger SBTarget::GetDebugger() const {
   return debugger;
 }
 
-SBStructuredData SBTarget::GetStatistics() {
+SBStructuredData SBTarget::GetStatistics(bool summary_only) {
   LLDB_INSTRUMENT_VA(this);
 
   SBStructuredData data;
@@ -205,9 +205,10 @@ SBStructuredData SBTarget::GetStatistics() {
   if (!target_sp)
 return data;
   std::string json_str =
-  llvm::formatv("{0:2}",
-  DebuggerStats::ReportStatistics(target_sp->GetDebugger(),
-  target_sp.get())).str();
+  llvm::formatv(
+  "{0:2}", DebuggerStats::ReportStatistics(
+   target_sp->GetDebugger(), target_sp.get(), 
summary_only))
+  .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 262de0bda144a6..781b90794dc377 100644
--- a/lldb/source/Commands/CommandObjectStats.cpp
+++ b/lldb/source/Commands/CommandObjectStats.cpp
@@ -75,6 +75,9 @@ class CommandObjectStatsDump : public CommandObjectParsed {
   case 'a':
 m_all_targets = true;
   

[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-06 Thread via lldb-commits


@@ -2687,7 +2687,7 @@ uint64_t SymbolFileDWARF::GetDebugInfoSize() {
 if (cu == nullptr)
   continue;
 
-SymbolFileDWARFDwo *dwo = cu->GetDwoSymbolFile();
+SymbolFileDWARFDwo *dwo = cu->GetDwoSymbolFile(false);

kusmour wrote:

In that case I will leave this commit out of this PR and start a separate one :)

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-06 Thread via lldb-commits

https://github.com/kusmour updated 
https://github.com/llvm/llvm-project/pull/80745

>From e5902abd4cd401f5e6a132d1fa5d0b2197512494 Mon Sep 17 00:00:00 2001
From: Wanyi Ye 
Date: Fri, 2 Feb 2024 15:42:01 -0800
Subject: [PATCH 1/5] Support statistics dump summary only mode

Summary:
Added a new --summary option to statistics dump command so that it is much 
light weight than the full version.
With this change, statistics dump --summary can now be included in lldb command 
line telemetry without slowing down lldb exiting.
---
 lldb/include/lldb/API/SBTarget.h  |   6 +-
 lldb/include/lldb/Target/Statistics.h |   9 +-
 lldb/include/lldb/Target/Target.h |   2 +-
 lldb/source/API/SBTarget.cpp  |   9 +-
 lldb/source/Commands/CommandObjectStats.cpp   |   8 +-
 lldb/source/Commands/Options.td   |   3 +
 lldb/source/Target/Statistics.cpp | 194 +++---
 lldb/source/Target/Target.cpp |   4 +-
 .../stats_api/TestStatisticsAPI.py|  15 ++
 9 files changed, 163 insertions(+), 87 deletions(-)

diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 83087623088c5b..72b8997afd2704 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -86,9 +86,13 @@ class LLDB_API SBTarget {
 
   /// Returns a dump of the collected statistics.
   ///
+  /// \param[in] summary_only
+  ///   If true, only report high level summary statistics without
+  ///   targets/modules/breakpoints etc.. details.
+  ///
   /// \return
   /// A SBStructuredData with the statistics collected.
-  lldb::SBStructuredData GetStatistics();
+  lldb::SBStructuredData GetStatistics(bool summary_only = false);
 
   /// Return the platform object associated with the target.
   ///
diff --git a/lldb/include/lldb/Target/Statistics.h 
b/lldb/include/lldb/Target/Statistics.h
index f672786f58f84d..98658ba0cac317 100644
--- a/lldb/include/lldb/Target/Statistics.h
+++ b/lldb/include/lldb/Target/Statistics.h
@@ -133,7 +133,7 @@ struct ConstStringStats {
 /// A class that represents statistics for a since lldb_private::Target.
 class TargetStats {
 public:
-  llvm::json::Value ToJSON(Target );
+  llvm::json::Value ToJSON(Target , bool summary_only = false);
 
   void SetLaunchOrAttachTime();
   void SetFirstPrivateStopTime();
@@ -171,9 +171,14 @@ 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 , Target 
*target);
+  static llvm::json::Value ReportStatistics(Debugger , Target *target,
+bool summary_only = false);
 
 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 c37682e2a03859..4bf6c123dc1ddc 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -1599,7 +1599,7 @@ class Target : public 
std::enable_shared_from_this,
   ///
   /// \return
   /// Returns a JSON value that contains all target metrics.
-  llvm::json::Value ReportStatistics();
+  llvm::json::Value ReportStatistics(bool summary_only = false);
 
   TargetStats () { return m_stats; }
 
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 8e616afbcb4e8d..615a00ceeaee16 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -197,7 +197,7 @@ SBDebugger SBTarget::GetDebugger() const {
   return debugger;
 }
 
-SBStructuredData SBTarget::GetStatistics() {
+SBStructuredData SBTarget::GetStatistics(bool summary_only) {
   LLDB_INSTRUMENT_VA(this);
 
   SBStructuredData data;
@@ -205,9 +205,10 @@ SBStructuredData SBTarget::GetStatistics() {
   if (!target_sp)
 return data;
   std::string json_str =
-  llvm::formatv("{0:2}",
-  DebuggerStats::ReportStatistics(target_sp->GetDebugger(),
-  target_sp.get())).str();
+  llvm::formatv(
+  "{0:2}", DebuggerStats::ReportStatistics(
+   target_sp->GetDebugger(), target_sp.get(), 
summary_only))
+  .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 262de0bda144a6..781b90794dc377 100644
--- a/lldb/source/Commands/CommandObjectStats.cpp
+++ b/lldb/source/Commands/CommandObjectStats.cpp
@@ -75,6 +75,9 @@ class CommandObjectStatsDump : public CommandObjectParsed {
   case 'a':
 m_all_targets = true;
   

[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-06 Thread via lldb-commits

https://github.com/kusmour updated 
https://github.com/llvm/llvm-project/pull/80745

>From e5902abd4cd401f5e6a132d1fa5d0b2197512494 Mon Sep 17 00:00:00 2001
From: Wanyi Ye 
Date: Fri, 2 Feb 2024 15:42:01 -0800
Subject: [PATCH 1/5] Support statistics dump summary only mode

Summary:
Added a new --summary option to statistics dump command so that it is much 
light weight than the full version.
With this change, statistics dump --summary can now be included in lldb command 
line telemetry without slowing down lldb exiting.
---
 lldb/include/lldb/API/SBTarget.h  |   6 +-
 lldb/include/lldb/Target/Statistics.h |   9 +-
 lldb/include/lldb/Target/Target.h |   2 +-
 lldb/source/API/SBTarget.cpp  |   9 +-
 lldb/source/Commands/CommandObjectStats.cpp   |   8 +-
 lldb/source/Commands/Options.td   |   3 +
 lldb/source/Target/Statistics.cpp | 194 +++---
 lldb/source/Target/Target.cpp |   4 +-
 .../stats_api/TestStatisticsAPI.py|  15 ++
 9 files changed, 163 insertions(+), 87 deletions(-)

diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 83087623088c5b..72b8997afd2704 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -86,9 +86,13 @@ class LLDB_API SBTarget {
 
   /// Returns a dump of the collected statistics.
   ///
+  /// \param[in] summary_only
+  ///   If true, only report high level summary statistics without
+  ///   targets/modules/breakpoints etc.. details.
+  ///
   /// \return
   /// A SBStructuredData with the statistics collected.
-  lldb::SBStructuredData GetStatistics();
+  lldb::SBStructuredData GetStatistics(bool summary_only = false);
 
   /// Return the platform object associated with the target.
   ///
diff --git a/lldb/include/lldb/Target/Statistics.h 
b/lldb/include/lldb/Target/Statistics.h
index f672786f58f84d..98658ba0cac317 100644
--- a/lldb/include/lldb/Target/Statistics.h
+++ b/lldb/include/lldb/Target/Statistics.h
@@ -133,7 +133,7 @@ struct ConstStringStats {
 /// A class that represents statistics for a since lldb_private::Target.
 class TargetStats {
 public:
-  llvm::json::Value ToJSON(Target );
+  llvm::json::Value ToJSON(Target , bool summary_only = false);
 
   void SetLaunchOrAttachTime();
   void SetFirstPrivateStopTime();
@@ -171,9 +171,14 @@ 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 , Target 
*target);
+  static llvm::json::Value ReportStatistics(Debugger , Target *target,
+bool summary_only = false);
 
 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 c37682e2a03859..4bf6c123dc1ddc 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -1599,7 +1599,7 @@ class Target : public 
std::enable_shared_from_this,
   ///
   /// \return
   /// Returns a JSON value that contains all target metrics.
-  llvm::json::Value ReportStatistics();
+  llvm::json::Value ReportStatistics(bool summary_only = false);
 
   TargetStats () { return m_stats; }
 
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 8e616afbcb4e8d..615a00ceeaee16 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -197,7 +197,7 @@ SBDebugger SBTarget::GetDebugger() const {
   return debugger;
 }
 
-SBStructuredData SBTarget::GetStatistics() {
+SBStructuredData SBTarget::GetStatistics(bool summary_only) {
   LLDB_INSTRUMENT_VA(this);
 
   SBStructuredData data;
@@ -205,9 +205,10 @@ SBStructuredData SBTarget::GetStatistics() {
   if (!target_sp)
 return data;
   std::string json_str =
-  llvm::formatv("{0:2}",
-  DebuggerStats::ReportStatistics(target_sp->GetDebugger(),
-  target_sp.get())).str();
+  llvm::formatv(
+  "{0:2}", DebuggerStats::ReportStatistics(
+   target_sp->GetDebugger(), target_sp.get(), 
summary_only))
+  .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 262de0bda144a6..781b90794dc377 100644
--- a/lldb/source/Commands/CommandObjectStats.cpp
+++ b/lldb/source/Commands/CommandObjectStats.cpp
@@ -75,6 +75,9 @@ class CommandObjectStatsDump : public CommandObjectParsed {
   case 'a':
 m_all_targets = true;
   

[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-06 Thread via lldb-commits

https://github.com/kusmour updated 
https://github.com/llvm/llvm-project/pull/80745

>From c79b3daa3e2a5ed2a571d93871bc527b651c0403 Mon Sep 17 00:00:00 2001
From: Wanyi Ye 
Date: Fri, 2 Feb 2024 15:42:01 -0800
Subject: [PATCH 1/4] Support statistics dump summary only mode

Summary:
Added a new --summary option to statistics dump command so that it is much 
light weight than the full version.
With this change, statistics dump --summary can now be included in lldb command 
line telemetry without slowing down lldb exiting.
---
 lldb/include/lldb/API/SBTarget.h  |   6 +-
 lldb/include/lldb/Target/Statistics.h |   9 +-
 lldb/include/lldb/Target/Target.h |   2 +-
 lldb/source/API/SBTarget.cpp  |   9 +-
 lldb/source/Commands/CommandObjectStats.cpp   |   8 +-
 lldb/source/Commands/Options.td   |   3 +
 lldb/source/Target/Statistics.cpp | 194 +++---
 lldb/source/Target/Target.cpp |   4 +-
 .../stats_api/TestStatisticsAPI.py|  15 ++
 9 files changed, 163 insertions(+), 87 deletions(-)

diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 83087623088c5b..72b8997afd2704 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -86,9 +86,13 @@ class LLDB_API SBTarget {
 
   /// Returns a dump of the collected statistics.
   ///
+  /// \param[in] summary_only
+  ///   If true, only report high level summary statistics without
+  ///   targets/modules/breakpoints etc.. details.
+  ///
   /// \return
   /// A SBStructuredData with the statistics collected.
-  lldb::SBStructuredData GetStatistics();
+  lldb::SBStructuredData GetStatistics(bool summary_only = false);
 
   /// Return the platform object associated with the target.
   ///
diff --git a/lldb/include/lldb/Target/Statistics.h 
b/lldb/include/lldb/Target/Statistics.h
index f672786f58f84d..98658ba0cac317 100644
--- a/lldb/include/lldb/Target/Statistics.h
+++ b/lldb/include/lldb/Target/Statistics.h
@@ -133,7 +133,7 @@ struct ConstStringStats {
 /// A class that represents statistics for a since lldb_private::Target.
 class TargetStats {
 public:
-  llvm::json::Value ToJSON(Target );
+  llvm::json::Value ToJSON(Target , bool summary_only = false);
 
   void SetLaunchOrAttachTime();
   void SetFirstPrivateStopTime();
@@ -171,9 +171,14 @@ 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 , Target 
*target);
+  static llvm::json::Value ReportStatistics(Debugger , Target *target,
+bool summary_only = false);
 
 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 c37682e2a03859..4bf6c123dc1ddc 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -1599,7 +1599,7 @@ class Target : public 
std::enable_shared_from_this,
   ///
   /// \return
   /// Returns a JSON value that contains all target metrics.
-  llvm::json::Value ReportStatistics();
+  llvm::json::Value ReportStatistics(bool summary_only = false);
 
   TargetStats () { return m_stats; }
 
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 8e616afbcb4e8d..615a00ceeaee16 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -197,7 +197,7 @@ SBDebugger SBTarget::GetDebugger() const {
   return debugger;
 }
 
-SBStructuredData SBTarget::GetStatistics() {
+SBStructuredData SBTarget::GetStatistics(bool summary_only) {
   LLDB_INSTRUMENT_VA(this);
 
   SBStructuredData data;
@@ -205,9 +205,10 @@ SBStructuredData SBTarget::GetStatistics() {
   if (!target_sp)
 return data;
   std::string json_str =
-  llvm::formatv("{0:2}",
-  DebuggerStats::ReportStatistics(target_sp->GetDebugger(),
-  target_sp.get())).str();
+  llvm::formatv(
+  "{0:2}", DebuggerStats::ReportStatistics(
+   target_sp->GetDebugger(), target_sp.get(), 
summary_only))
+  .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 262de0bda144a6..781b90794dc377 100644
--- a/lldb/source/Commands/CommandObjectStats.cpp
+++ b/lldb/source/Commands/CommandObjectStats.cpp
@@ -75,6 +75,9 @@ class CommandObjectStatsDump : public CommandObjectParsed {
   case 'a':
 m_all_targets = true;
   

[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-06 Thread via lldb-commits

https://github.com/kusmour updated 
https://github.com/llvm/llvm-project/pull/80745

>From be36537cfc647735a823b685ab89ca68d1ae9803 Mon Sep 17 00:00:00 2001
From: Wanyi Ye 
Date: Fri, 2 Feb 2024 15:42:01 -0800
Subject: [PATCH 1/4] Support statistics dump summary only mode

Summary:
Added a new --summary option to statistics dump command so that it is much 
light weight than the full version.
With this change, statistics dump --summary can now be included in lldb command 
line telemetry without slowing down lldb exiting.
---
 lldb/include/lldb/API/SBTarget.h  |   6 +-
 lldb/include/lldb/Target/Statistics.h |   9 +-
 lldb/include/lldb/Target/Target.h |   2 +-
 lldb/source/API/SBTarget.cpp  |   9 +-
 lldb/source/Commands/CommandObjectStats.cpp   |   8 +-
 lldb/source/Commands/Options.td   |   3 +
 lldb/source/Target/Statistics.cpp | 194 +++---
 lldb/source/Target/Target.cpp |   4 +-
 .../stats_api/TestStatisticsAPI.py|  15 ++
 9 files changed, 163 insertions(+), 87 deletions(-)

diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 83087623088c5..72b8997afd270 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -86,9 +86,13 @@ class LLDB_API SBTarget {
 
   /// Returns a dump of the collected statistics.
   ///
+  /// \param[in] summary_only
+  ///   If true, only report high level summary statistics without
+  ///   targets/modules/breakpoints etc.. details.
+  ///
   /// \return
   /// A SBStructuredData with the statistics collected.
-  lldb::SBStructuredData GetStatistics();
+  lldb::SBStructuredData GetStatistics(bool summary_only = false);
 
   /// Return the platform object associated with the target.
   ///
diff --git a/lldb/include/lldb/Target/Statistics.h 
b/lldb/include/lldb/Target/Statistics.h
index f672786f58f84..98658ba0cac31 100644
--- a/lldb/include/lldb/Target/Statistics.h
+++ b/lldb/include/lldb/Target/Statistics.h
@@ -133,7 +133,7 @@ struct ConstStringStats {
 /// A class that represents statistics for a since lldb_private::Target.
 class TargetStats {
 public:
-  llvm::json::Value ToJSON(Target );
+  llvm::json::Value ToJSON(Target , bool summary_only = false);
 
   void SetLaunchOrAttachTime();
   void SetFirstPrivateStopTime();
@@ -171,9 +171,14 @@ 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 , Target 
*target);
+  static llvm::json::Value ReportStatistics(Debugger , Target *target,
+bool summary_only = false);
 
 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 c37682e2a0385..4bf6c123dc1dd 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -1599,7 +1599,7 @@ class Target : public 
std::enable_shared_from_this,
   ///
   /// \return
   /// Returns a JSON value that contains all target metrics.
-  llvm::json::Value ReportStatistics();
+  llvm::json::Value ReportStatistics(bool summary_only = false);
 
   TargetStats () { return m_stats; }
 
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 8e616afbcb4e8..615a00ceeaee1 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -197,7 +197,7 @@ SBDebugger SBTarget::GetDebugger() const {
   return debugger;
 }
 
-SBStructuredData SBTarget::GetStatistics() {
+SBStructuredData SBTarget::GetStatistics(bool summary_only) {
   LLDB_INSTRUMENT_VA(this);
 
   SBStructuredData data;
@@ -205,9 +205,10 @@ SBStructuredData SBTarget::GetStatistics() {
   if (!target_sp)
 return data;
   std::string json_str =
-  llvm::formatv("{0:2}",
-  DebuggerStats::ReportStatistics(target_sp->GetDebugger(),
-  target_sp.get())).str();
+  llvm::formatv(
+  "{0:2}", DebuggerStats::ReportStatistics(
+   target_sp->GetDebugger(), target_sp.get(), 
summary_only))
+  .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 262de0bda144a..781b90794dc37 100644
--- a/lldb/source/Commands/CommandObjectStats.cpp
+++ b/lldb/source/Commands/CommandObjectStats.cpp
@@ -75,6 +75,9 @@ class CommandObjectStatsDump : public CommandObjectParsed {
   case 'a':
 m_all_targets = true;
 

[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-06 Thread via lldb-commits

https://github.com/kusmour updated 
https://github.com/llvm/llvm-project/pull/80745

>From 4e06a3ebcf12de413f0906b1f4f6aaca40bedcff Mon Sep 17 00:00:00 2001
From: Wanyi Ye 
Date: Fri, 2 Feb 2024 15:42:01 -0800
Subject: [PATCH 1/4] Support statistics dump summary only mode

Summary:
Added a new --summary option to statistics dump command so that it is much 
light weight than the full version.
With this change, statistics dump --summary can now be included in lldb command 
line telemetry without slowing down lldb exiting.
---
 lldb/include/lldb/API/SBTarget.h  |   8 +-
 lldb/include/lldb/Target/Statistics.h |   9 +-
 lldb/include/lldb/Target/Target.h |   2 +-
 lldb/source/API/SBTarget.cpp  |   9 +-
 lldb/source/Commands/CommandObjectStats.cpp   |   8 +-
 lldb/source/Commands/Options.td   |   3 +
 lldb/source/Target/Statistics.cpp | 194 +++---
 lldb/source/Target/Target.cpp |   4 +-
 .../stats_api/TestStatisticsAPI.py|  15 ++
 9 files changed, 164 insertions(+), 88 deletions(-)

diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 83087623088c5..7fd888cf7014e 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -86,9 +86,13 @@ class LLDB_API SBTarget {
 
   /// Returns a dump of the collected statistics.
   ///
+  /// \param[in] summary_only
+  ///   If true, only report high level summary statistics without
+  ///   targets/modules/breakpoints etc.. details.
+  ///
   /// \return
   /// A SBStructuredData with the statistics collected.
-  lldb::SBStructuredData GetStatistics();
+  lldb::SBStructuredData GetStatistics(bool summary_only = false);
 
   /// Return the platform object associated with the target.
   ///
@@ -326,7 +330,7 @@ class LLDB_API SBTarget {
   uint32_t GetAddressByteSize();
 
   const char *GetTriple();
-  
+
   const char *GetABIName();
 
   const char *GetLabel() const;
diff --git a/lldb/include/lldb/Target/Statistics.h 
b/lldb/include/lldb/Target/Statistics.h
index f672786f58f84..98658ba0cac31 100644
--- a/lldb/include/lldb/Target/Statistics.h
+++ b/lldb/include/lldb/Target/Statistics.h
@@ -133,7 +133,7 @@ struct ConstStringStats {
 /// A class that represents statistics for a since lldb_private::Target.
 class TargetStats {
 public:
-  llvm::json::Value ToJSON(Target );
+  llvm::json::Value ToJSON(Target , bool summary_only = false);
 
   void SetLaunchOrAttachTime();
   void SetFirstPrivateStopTime();
@@ -171,9 +171,14 @@ 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 , Target 
*target);
+  static llvm::json::Value ReportStatistics(Debugger , Target *target,
+bool summary_only = false);
 
 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 c37682e2a0385..4bf6c123dc1dd 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -1599,7 +1599,7 @@ class Target : public 
std::enable_shared_from_this,
   ///
   /// \return
   /// Returns a JSON value that contains all target metrics.
-  llvm::json::Value ReportStatistics();
+  llvm::json::Value ReportStatistics(bool summary_only = false);
 
   TargetStats () { return m_stats; }
 
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 8e616afbcb4e8..615a00ceeaee1 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -197,7 +197,7 @@ SBDebugger SBTarget::GetDebugger() const {
   return debugger;
 }
 
-SBStructuredData SBTarget::GetStatistics() {
+SBStructuredData SBTarget::GetStatistics(bool summary_only) {
   LLDB_INSTRUMENT_VA(this);
 
   SBStructuredData data;
@@ -205,9 +205,10 @@ SBStructuredData SBTarget::GetStatistics() {
   if (!target_sp)
 return data;
   std::string json_str =
-  llvm::formatv("{0:2}",
-  DebuggerStats::ReportStatistics(target_sp->GetDebugger(),
-  target_sp.get())).str();
+  llvm::formatv(
+  "{0:2}", DebuggerStats::ReportStatistics(
+   target_sp->GetDebugger(), target_sp.get(), 
summary_only))
+  .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 262de0bda144a..781b90794dc37 100644
--- a/lldb/source/Commands/CommandObjectStats.cpp
+++ 

[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Greg Clayton via lldb-commits


@@ -0,0 +1,31 @@
+//===-- 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 {
+
+class LLDB_API SBStatisticsOptions {

clayborg wrote:

Would be good to get some header documentation on this simple class and explain 
which function it is for.

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Greg Clayton via lldb-commits


@@ -75,6 +75,9 @@ class CommandObjectStatsDump : public CommandObjectParsed {
   case 'a':
 m_all_targets = true;
 break;
+  case 's':
+m_summary_only = true;

clayborg wrote:

See comment about storing a different ivar below, then this becomes:
```
m_stats_options.summary_only = true;
```


https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Greg Clayton via lldb-commits


@@ -198,16 +198,24 @@ SBDebugger SBTarget::GetDebugger() const {
 }
 
 SBStructuredData SBTarget::GetStatistics() {
+   LLDB_INSTRUMENT_VA(this);
+  SBStatisticsOptions options;
+  options.SetSummaryOnly(false);
+  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())).str();
+  llvm::formatv(
+  "{0:2}", DebuggerStats::ReportStatistics(
+   target_sp->GetDebugger(), target_sp.get(), 
options.GetStatisticsOptions()))

clayborg wrote:

```
target_sp->GetDebugger(), target_sp.get(), options.ref()))
```

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Greg Clayton via lldb-commits


@@ -83,13 +86,21 @@ class CommandObjectStatsDump : public CommandObjectParsed {
 
 void OptionParsingStarting(ExecutionContext *execution_context) override {
   m_all_targets = false;
+  m_summary_only = false;
 }
 
 llvm::ArrayRef GetDefinitions() override {
   return llvm::ArrayRef(g_statistics_dump_options);
 }
 
+StatisticsOptions GetStatisticsOptions() {
+  StatisticsOptions options;
+  options.summary_only = m_summary_only;
+  return options;

clayborg wrote:

See my ivar comment below, then this becomes:
```
return m_stats_options;
```


https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Greg Clayton via lldb-commits


@@ -0,0 +1,31 @@
+//===-- 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 {
+
+class LLDB_API SBStatisticsOptions {
+public:
+  SBStatisticsOptions();
+  SBStatisticsOptions(const lldb::SBStatisticsOptions );
+  ~SBStatisticsOptions();
+
+  const SBStatisticsOptions =(const lldb::SBStatisticsOptions );
+
+  void SetSummaryOnly(bool b);
+  lldb_private::StatisticsOptions GetStatisticsOptions();

clayborg wrote:

We don't want this function to be public, it should be protected, and not 
return an instance of `lldb_private::StatisticsOptions`, cause if we do this, 
then we need to include the header file that defines this data structure and it 
should be opaque. In a class like SBAddress, we do something like this:
```
class SBStatisticsOptions {
  ...
protected:
  friend class SBTarget;
  const lldb_private::StatisticsOptions () const;
}
```
If this is a `lldb_private::StatisticsOptions &`, then we don't need to include 
the header file that defines this structure in this file since the size of a 
references is just a pointer size.

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Greg Clayton via lldb-commits


@@ -0,0 +1,46 @@
+//===-- 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);
+}
+
+SBStatisticsOptions::SBStatisticsOptions(const SBStatisticsOptions ) {
+  LLDB_INSTRUMENT_VA(this, rhs);
+
+  m_opaque_up = clone(rhs.m_opaque_up);
+}
+
+SBStatisticsOptions::~SBStatisticsOptions() = default;
+
+const SBStatisticsOptions &
+SBStatisticsOptions::operator=(const SBStatisticsOptions ) {
+  LLDB_INSTRUMENT_VA(this, rhs);
+
+  if (this != )
+m_opaque_up = clone(rhs.m_opaque_up);
+  return *this;
+}
+
+void SBStatisticsOptions::SetSummaryOnly(bool b) {
+  m_opaque_up->summary_only = b;
+}
+
+lldb_private::StatisticsOptions SBStatisticsOptions::GetStatisticsOptions() {
+  return *m_opaque_up;
+}

clayborg wrote:

```
const lldb_private::StatisticsOptions *SBStatisticsOptions::ref() {
  return *m_opaque_up;
}
```

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Greg Clayton via lldb-commits


@@ -83,13 +86,21 @@ class CommandObjectStatsDump : public CommandObjectParsed {
 
 void OptionParsingStarting(ExecutionContext *execution_context) override {
   m_all_targets = false;
+  m_summary_only = false;
 }
 
 llvm::ArrayRef GetDefinitions() override {
   return llvm::ArrayRef(g_statistics_dump_options);
 }
 
+StatisticsOptions GetStatisticsOptions() {
+  StatisticsOptions options;
+  options.summary_only = m_summary_only;
+  return options;
+}
+
 bool m_all_targets = false;
+bool m_summary_only = false;

clayborg wrote:

Change this ivar from:
```
bool summary_only = false;
```
to:
```
lldb_private::StatisticsOptions m_stats_options;
```
And fill things into this struct when parsing the options.

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Greg Clayton via lldb-commits


@@ -100,60 +101,91 @@ llvm::json::Value ConstStringStats::ToJSON() const {
   return obj;
 }
 
-json::Value TargetStats::ToJSON(Target ) {
-  CollectStats(target);
+json::Value TargetStats::ToJSON(Target , bool summary_only) {

clayborg wrote:

This function seems to still take a "bool summary_only"?

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Greg Clayton via lldb-commits


@@ -198,16 +198,24 @@ SBDebugger SBTarget::GetDebugger() const {
 }
 
 SBStructuredData SBTarget::GetStatistics() {
+   LLDB_INSTRUMENT_VA(this);
+  SBStatisticsOptions options;
+  options.SetSummaryOnly(false);

clayborg wrote:

This defaults to false right? I would make sure the default 
`SBStatisticsOptions` constructor sets everything to good defaults and we can 
remove this line.

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Greg Clayton via lldb-commits

https://github.com/clayborg requested changes to this pull request.


https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Greg Clayton via lldb-commits

https://github.com/clayborg edited 
https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Greg Clayton via lldb-commits


@@ -130,10 +130,14 @@ 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 );
+  llvm::json::Value ToJSON(Target , bool summary_only = false);

clayborg wrote:

We should still pass in a "const StatisticsOptions options = 
StatisticsOptions()" instead of a boolean here. If we add more options in the 
future, we should avoid changing this API that way.

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread via lldb-commits


@@ -83,13 +86,15 @@ class CommandObjectStatsDump : public CommandObjectParsed {
 
 void OptionParsingStarting(ExecutionContext *execution_context) override {
   m_all_targets = false;
+  m_summary_only = false;
 }
 
 llvm::ArrayRef GetDefinitions() override {
   return llvm::ArrayRef(g_statistics_dump_options);
 }
 
 bool m_all_targets = false;
+bool m_summary_only = false;

kusmour wrote:

> We should probably also move `m_all_targets` into 
> `lldb_private::StatisticsOptions`

I can do that but notice the `m_all_targets` was not used anywhere outside of 
the command object. The target is decided with the current execution context.

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Alex Langford via lldb-commits


@@ -241,7 +241,7 @@ class DWARFUnit : public UserID {
   FileSpec GetFile(size_t file_idx);
   FileSpec::Style GetPathStyle();
 
-  SymbolFileDWARFDwo *GetDwoSymbolFile();
+  SymbolFileDWARFDwo *GetDwoSymbolFile(bool load_if_needed = true);

bulbazord wrote:

Instead of having a bool here, you could make this an enum with 2 values. 
Something like this:
```
enum LoadMode : bool { eDoNotForceLoad, eForceLoad };
```

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Alex Langford via lldb-commits


@@ -86,9 +86,13 @@ class LLDB_API SBTarget {
 
   /// Returns a dump of the collected statistics.
   ///
+  /// \param[in] summary_only
+  ///   If true, only report high level summary statistics without
+  ///   targets/modules/breakpoints etc.. details.
+  ///
   /// \return
   /// A SBStructuredData with the statistics collected.
-  lldb::SBStructuredData GetStatistics();

bulbazord wrote:

This is an ABI-breaking change. You'll want to add a new method entirely.

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Alex Langford via lldb-commits


@@ -186,6 +186,10 @@ class SymbolFileDWARF : public SymbolFileCommon {
   GetMangledNamesForFunction(const std::string _qualified_name,
  std::vector _names) override;
 
+  // Return total currently loaded debug info.
+  // For cases like .dwo files, the debug info = skeleton debug info + all dwo
+  // debug info where .dwo files might not be loaded yet. Calling this function
+  // will not force the loading of any .dwo files.

bulbazord wrote:

Could you make this into a proper doxygen comment? With `///` instead of `//`

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Alex Langford via lldb-commits

https://github.com/bulbazord edited 
https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Alex Langford via lldb-commits

https://github.com/bulbazord requested changes to this pull request.

Haven't looked over everything yet but this has an ABI-breaking change. Please 
revert the existing changes to SBTarget.

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Greg Clayton via lldb-commits


@@ -83,13 +86,15 @@ class CommandObjectStatsDump : public CommandObjectParsed {
 
 void OptionParsingStarting(ExecutionContext *execution_context) override {
   m_all_targets = false;
+  m_summary_only = false;
 }
 
 llvm::ArrayRef GetDefinitions() override {
   return llvm::ArrayRef(g_statistics_dump_options);
 }
 
 bool m_all_targets = false;

clayborg wrote:

This should get moved into `lldb_private::StatisticsOptions` as an option. Add 
accessor to `SBStatisticsOptions` so we can get/set this as well.

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Greg Clayton via lldb-commits


@@ -2687,7 +2687,7 @@ uint64_t SymbolFileDWARF::GetDebugInfoSize() {
 if (cu == nullptr)
   continue;
 
-SymbolFileDWARFDwo *dwo = cu->GetDwoSymbolFile();
+SymbolFileDWARFDwo *dwo = cu->GetDwoSymbolFile(false);

clayborg wrote:

This bool might need to be a bool in the "SymbolFile::GetDebugInfoSize()" 
virtual function. Users might want the know the rigtht answer (exactly how much 
total debug info they have if `load_if_needed == true` or just what is loaded 
currently `load_if_needed == false`

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Greg Clayton via lldb-commits


@@ -326,7 +330,7 @@ class LLDB_API SBTarget {
   uint32_t GetAddressByteSize();
 
   const char *GetTriple();
-  
+

clayborg wrote:

revert whitespace only changes

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Greg Clayton via lldb-commits


@@ -100,60 +101,91 @@ llvm::json::Value ConstStringStats::ToJSON() const {
   return obj;
 }
 
-json::Value TargetStats::ToJSON(Target ) {
-  CollectStats(target);
+json::Value TargetStats::ToJSON(Target , bool summary_only) {

clayborg wrote:

Pass in "const lldb_private::StatisticsOptions " here insetead of bool

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Greg Clayton via lldb-commits


@@ -197,17 +197,18 @@ SBDebugger SBTarget::GetDebugger() const {
   return debugger;
 }
 
-SBStructuredData SBTarget::GetStatistics() {
+SBStructuredData SBTarget::GetStatistics(bool summary_only) {

clayborg wrote:

pass in const `SBStatisticsOptions options` instead of bool

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Greg Clayton via lldb-commits


@@ -4962,4 +4962,6 @@ std::recursive_mutex ::GetAPIMutex() {
 }
 
 /// Get metrics associated with this target in JSON format.
-llvm::json::Value Target::ReportStatistics() { return m_stats.ToJSON(*this); }
+llvm::json::Value Target::ReportStatistics(bool summary_only) {

clayborg wrote:

pass in "const lldb_private::StatisticsOptions " here instead of bool

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Greg Clayton via lldb-commits


@@ -83,13 +86,15 @@ class CommandObjectStatsDump : public CommandObjectParsed {
 
 void OptionParsingStarting(ExecutionContext *execution_context) override {
   m_all_targets = false;
+  m_summary_only = false;
 }
 
 llvm::ArrayRef GetDefinitions() override {
   return llvm::ArrayRef(g_statistics_dump_options);
 }
 
 bool m_all_targets = false;
+bool m_summary_only = false;

clayborg wrote:

Change this to:
```
lldb_private::StatisticsOptions m_options;
```
We should probably also move `m_all_targets` into 
`lldb_private::StatisticsOptions`.

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Greg Clayton via lldb-commits


@@ -86,9 +86,13 @@ class LLDB_API SBTarget {
 
   /// Returns a dump of the collected statistics.
   ///
+  /// \param[in] summary_only
+  ///   If true, only report high level summary statistics without
+  ///   targets/modules/breakpoints etc.. details.
+  ///
   /// \return
   /// A SBStructuredData with the statistics collected.
-  lldb::SBStructuredData GetStatistics();
+  lldb::SBStructuredData GetStatistics(bool summary_only = false);

clayborg wrote:

This violates our public API policy where we can't take away or change a 
previously available public API function. So we must:
- keep the old function around
- add a new function with extra parameters

If we are going to possibly add more options to GetStatistics in the future, we 
don't want to have to keep overloading this function with new values since we 
would need to keep adding overloads. The way we fix this in the API is to 
create a SBStatisticsOptions class that has accessors. This way we can keep 
adding more features in the future as it is ok to add new methods to any 
existing classes. So this code should look like:
```
  /// Returns a dump of the collected statistics.
  ///
  /// \return
  /// 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);
```
Then we need to create a simple public API class for `SBStatisticsOptions`:
```
class SBStatisticsOptions {
public:
  SBStatisticsOptions();
  bool GetSummaryOnly();
  void SetSummaryOnly(bool b);
};
```
And if later we might want to add another bool option, we can just add the new 
methods to this class. Lets say later we want to only emit target stats for a 
specific target, instead of all targets, we could add new functions to 
`SBStatisticsOptions`:
```
class SBStatisticsOptions {
public:
  SBStatisticsOptions();
  bool GetSummaryOnly();
  void SetSummaryOnly(bool b);
  /// Limit statistics data for only 1 target instead of all targets
  void SetTarget(SBTarget target);
};
```
And we can still use our `lldb::SBStructuredData 
GetStatistics(SBStatisticsOptions options);` function because the signature 
didn't change!

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Greg Clayton via lldb-commits


@@ -1599,7 +1599,7 @@ class Target : public 
std::enable_shared_from_this,
   ///
   /// \return
   /// Returns a JSON value that contains all target metrics.
-  llvm::json::Value ReportStatistics();
+  llvm::json::Value ReportStatistics(bool summary_only = false);

clayborg wrote:

pass in `const lldb_private::StatisticsOptions ` instead of bool

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Greg Clayton via lldb-commits


@@ -133,7 +133,7 @@ struct ConstStringStats {
 /// A class that represents statistics for a since lldb_private::Target.
 class TargetStats {
 public:
-  llvm::json::Value ToJSON(Target );
+  llvm::json::Value ToJSON(Target , bool summary_only = false);

clayborg wrote:

We probably want a lldb_private::StatisticsOptions class that contains all 
options:
```
struct StatisticsOptions {
  bool summary_only = false;
};
```
Then when you create the SBStatisticsOptions class, it should contain a 
`std::unique_ptr m_opaque_up;` member, just 
like all other public API classes. And the methods on `SBStatisticsOptions` 
will modify the contained `lldb_private::StatisticsOptions` object 
appropriately. The reason we need the `SBStatisticsOptions` class to have a 
single member that is a unique pointer is so if we add extra things to 
`lldb_private::StatisticsOptions`, it won't change the size of the 
`SBStatisticsOptions` class since it just has a 
`unique_ptr` as its only member variable, 
which makes it suitable for use in the public API. We can't change the size of 
our objects if we want to maintain a stable public API.


https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Greg Clayton via lldb-commits


@@ -171,9 +171,14 @@ 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 , Target 
*target);
+  static llvm::json::Value ReportStatistics(Debugger , Target *target,
+bool summary_only = false);

clayborg wrote:

pass in const `lldb_private::StatisticsOptions ` instead of bool



https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Greg Clayton via lldb-commits

https://github.com/clayborg requested changes to this pull request.


https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Greg Clayton via lldb-commits

https://github.com/clayborg edited 
https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread via lldb-commits


@@ -2687,7 +2687,7 @@ uint64_t SymbolFileDWARF::GetDebugInfoSize() {
 if (cu == nullptr)
   continue;
 
-SymbolFileDWARFDwo *dwo = cu->GetDwoSymbolFile();
+SymbolFileDWARFDwo *dwo = cu->GetDwoSymbolFile(false);

jeffreytan81 wrote:

Instead of hard-coding `false` here, I think it should the caller of 
`SymbolFileDWARF::GetDebugInfoSize` caller (statistics.cpp in this case) making 
this decision. 

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread via lldb-commits

https://github.com/kusmour updated 
https://github.com/llvm/llvm-project/pull/80745

>From 36c84ce56e9ea288d64833aa1f927a7f97fd904c Mon Sep 17 00:00:00 2001
From: Wanyi Ye 
Date: Fri, 2 Feb 2024 15:42:01 -0800
Subject: [PATCH 1/3] Support statistics dump summary only mode

Summary:
Added a new --summary option to statistics dump command so that it is much 
light weight than the full version.
With this change, statistics dump --summary can now be included in lldb command 
line telemetry without slowing down lldb exiting.
---
 lldb/include/lldb/API/SBTarget.h  |   8 +-
 lldb/include/lldb/Target/Statistics.h |   9 +-
 lldb/include/lldb/Target/Target.h |   2 +-
 lldb/source/API/SBTarget.cpp  |   9 +-
 lldb/source/Commands/CommandObjectStats.cpp   |   8 +-
 lldb/source/Commands/Options.td   |   3 +
 lldb/source/Target/Statistics.cpp | 194 +++---
 lldb/source/Target/Target.cpp |   4 +-
 .../stats_api/TestStatisticsAPI.py|  15 ++
 9 files changed, 164 insertions(+), 88 deletions(-)

diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 83087623088c5b..7fd888cf7014e3 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -86,9 +86,13 @@ class LLDB_API SBTarget {
 
   /// Returns a dump of the collected statistics.
   ///
+  /// \param[in] summary_only
+  ///   If true, only report high level summary statistics without
+  ///   targets/modules/breakpoints etc.. details.
+  ///
   /// \return
   /// A SBStructuredData with the statistics collected.
-  lldb::SBStructuredData GetStatistics();
+  lldb::SBStructuredData GetStatistics(bool summary_only = false);
 
   /// Return the platform object associated with the target.
   ///
@@ -326,7 +330,7 @@ class LLDB_API SBTarget {
   uint32_t GetAddressByteSize();
 
   const char *GetTriple();
-  
+
   const char *GetABIName();
 
   const char *GetLabel() const;
diff --git a/lldb/include/lldb/Target/Statistics.h 
b/lldb/include/lldb/Target/Statistics.h
index f672786f58f84d..98658ba0cac317 100644
--- a/lldb/include/lldb/Target/Statistics.h
+++ b/lldb/include/lldb/Target/Statistics.h
@@ -133,7 +133,7 @@ struct ConstStringStats {
 /// A class that represents statistics for a since lldb_private::Target.
 class TargetStats {
 public:
-  llvm::json::Value ToJSON(Target );
+  llvm::json::Value ToJSON(Target , bool summary_only = false);
 
   void SetLaunchOrAttachTime();
   void SetFirstPrivateStopTime();
@@ -171,9 +171,14 @@ 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 , Target 
*target);
+  static llvm::json::Value ReportStatistics(Debugger , Target *target,
+bool summary_only = false);
 
 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 c37682e2a03859..4bf6c123dc1ddc 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -1599,7 +1599,7 @@ class Target : public 
std::enable_shared_from_this,
   ///
   /// \return
   /// Returns a JSON value that contains all target metrics.
-  llvm::json::Value ReportStatistics();
+  llvm::json::Value ReportStatistics(bool summary_only = false);
 
   TargetStats () { return m_stats; }
 
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 8e616afbcb4e8d..615a00ceeaee16 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -197,7 +197,7 @@ SBDebugger SBTarget::GetDebugger() const {
   return debugger;
 }
 
-SBStructuredData SBTarget::GetStatistics() {
+SBStructuredData SBTarget::GetStatistics(bool summary_only) {
   LLDB_INSTRUMENT_VA(this);
 
   SBStructuredData data;
@@ -205,9 +205,10 @@ SBStructuredData SBTarget::GetStatistics() {
   if (!target_sp)
 return data;
   std::string json_str =
-  llvm::formatv("{0:2}",
-  DebuggerStats::ReportStatistics(target_sp->GetDebugger(),
-  target_sp.get())).str();
+  llvm::formatv(
+  "{0:2}", DebuggerStats::ReportStatistics(
+   target_sp->GetDebugger(), target_sp.get(), 
summary_only))
+  .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 262de0bda144a6..781b90794dc377 100644
--- 

[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread via lldb-commits


@@ -74,7 +75,7 @@ json::Value ModuleStats::ToJSON() const {
 
   if (!symfile_modules.empty()) {
 json::Array symfile_ids;
-for (const auto symfile_id: symfile_modules)
+for (const auto symfile_id : symfile_modules)

kusmour wrote:

Yes I can revert that, probs a formatting on save that I didn't notice. 

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Will Hawkins via lldb-commits


@@ -74,7 +75,7 @@ json::Value ModuleStats::ToJSON() const {
 
   if (!symfile_modules.empty()) {
 json::Array symfile_ids;
-for (const auto symfile_id: symfile_modules)
+for (const auto symfile_id : symfile_modules)

hawkinsw wrote:

Is this just a whitespace change? 

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Will Hawkins via lldb-commits


@@ -100,60 +101,91 @@ llvm::json::Value ConstStringStats::ToJSON() const {
   return obj;
 }
 
-json::Value TargetStats::ToJSON(Target ) {
-  CollectStats(target);
+json::Value TargetStats::ToJSON(Target , bool summary_only) {
+  json::Object target_metrics_json;
+  ProcessSP process_sp = target.GetProcessSP();
+  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);
+json::Array json_module_uuid_array;
+for (auto module_identifier : m_module_identifiers)
+  json_module_uuid_array.emplace_back(module_identifier);
 
-  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)}};
+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));
 
-  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);
+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 breakpoints_array;
+double totalBreakpointResolveTime = 0.0;
+// Rport both the normal breakpoint list and the internal breakpoint list.

hawkinsw wrote:

```suggestion
// Report both the normal breakpoint list and the internal breakpoint list.
```

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Will Hawkins via lldb-commits


@@ -186,6 +186,10 @@ class SymbolFileDWARF : public SymbolFileCommon {
   GetMangledNamesForFunction(const std::string _qualified_name,
  std::vector _names) override;
 
+  // Return total currently loaded debug info

hawkinsw wrote:

```suggestion
  // Return total currently loaded debug info.
```

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Will Hawkins via lldb-commits


@@ -1412,4 +1412,7 @@ 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."

hawkinsw wrote:

```suggestion
Desc<"Dump only high-level summary statistics."
```

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Will Hawkins via lldb-commits


@@ -1412,4 +1412,7 @@ 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.">;

hawkinsw wrote:

```suggestion
 "Exclude targets, modules, breakpoints etc... details.">;
```

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Will Hawkins via lldb-commits

https://github.com/hawkinsw commented:

Thank you for doing this! I hope that these little nits are helpful!

https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread Will Hawkins via lldb-commits

https://github.com/hawkinsw edited 
https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread via lldb-commits

https://github.com/kusmour updated 
https://github.com/llvm/llvm-project/pull/80745

>From 36c84ce56e9ea288d64833aa1f927a7f97fd904c Mon Sep 17 00:00:00 2001
From: Wanyi Ye 
Date: Fri, 2 Feb 2024 15:42:01 -0800
Subject: [PATCH 1/2] Support statistics dump summary only mode

Summary:
Added a new --summary option to statistics dump command so that it is much 
light weight than the full version.
With this change, statistics dump --summary can now be included in lldb command 
line telemetry without slowing down lldb exiting.
---
 lldb/include/lldb/API/SBTarget.h  |   8 +-
 lldb/include/lldb/Target/Statistics.h |   9 +-
 lldb/include/lldb/Target/Target.h |   2 +-
 lldb/source/API/SBTarget.cpp  |   9 +-
 lldb/source/Commands/CommandObjectStats.cpp   |   8 +-
 lldb/source/Commands/Options.td   |   3 +
 lldb/source/Target/Statistics.cpp | 194 +++---
 lldb/source/Target/Target.cpp |   4 +-
 .../stats_api/TestStatisticsAPI.py|  15 ++
 9 files changed, 164 insertions(+), 88 deletions(-)

diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 83087623088c5b..7fd888cf7014e3 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -86,9 +86,13 @@ class LLDB_API SBTarget {
 
   /// Returns a dump of the collected statistics.
   ///
+  /// \param[in] summary_only
+  ///   If true, only report high level summary statistics without
+  ///   targets/modules/breakpoints etc.. details.
+  ///
   /// \return
   /// A SBStructuredData with the statistics collected.
-  lldb::SBStructuredData GetStatistics();
+  lldb::SBStructuredData GetStatistics(bool summary_only = false);
 
   /// Return the platform object associated with the target.
   ///
@@ -326,7 +330,7 @@ class LLDB_API SBTarget {
   uint32_t GetAddressByteSize();
 
   const char *GetTriple();
-  
+
   const char *GetABIName();
 
   const char *GetLabel() const;
diff --git a/lldb/include/lldb/Target/Statistics.h 
b/lldb/include/lldb/Target/Statistics.h
index f672786f58f84d..98658ba0cac317 100644
--- a/lldb/include/lldb/Target/Statistics.h
+++ b/lldb/include/lldb/Target/Statistics.h
@@ -133,7 +133,7 @@ struct ConstStringStats {
 /// A class that represents statistics for a since lldb_private::Target.
 class TargetStats {
 public:
-  llvm::json::Value ToJSON(Target );
+  llvm::json::Value ToJSON(Target , bool summary_only = false);
 
   void SetLaunchOrAttachTime();
   void SetFirstPrivateStopTime();
@@ -171,9 +171,14 @@ 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 , Target 
*target);
+  static llvm::json::Value ReportStatistics(Debugger , Target *target,
+bool summary_only = false);
 
 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 c37682e2a03859..4bf6c123dc1ddc 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -1599,7 +1599,7 @@ class Target : public 
std::enable_shared_from_this,
   ///
   /// \return
   /// Returns a JSON value that contains all target metrics.
-  llvm::json::Value ReportStatistics();
+  llvm::json::Value ReportStatistics(bool summary_only = false);
 
   TargetStats () { return m_stats; }
 
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 8e616afbcb4e8d..615a00ceeaee16 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -197,7 +197,7 @@ SBDebugger SBTarget::GetDebugger() const {
   return debugger;
 }
 
-SBStructuredData SBTarget::GetStatistics() {
+SBStructuredData SBTarget::GetStatistics(bool summary_only) {
   LLDB_INSTRUMENT_VA(this);
 
   SBStructuredData data;
@@ -205,9 +205,10 @@ SBStructuredData SBTarget::GetStatistics() {
   if (!target_sp)
 return data;
   std::string json_str =
-  llvm::formatv("{0:2}",
-  DebuggerStats::ReportStatistics(target_sp->GetDebugger(),
-  target_sp.get())).str();
+  llvm::formatv(
+  "{0:2}", DebuggerStats::ReportStatistics(
+   target_sp->GetDebugger(), target_sp.get(), 
summary_only))
+  .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 262de0bda144a6..781b90794dc377 100644
--- 

[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread via lldb-commits

https://github.com/kusmour updated 
https://github.com/llvm/llvm-project/pull/80745

>From 30d723ba9808c7a8109b11dd0f20b4d8808e9ad5 Mon Sep 17 00:00:00 2001
From: Wanyi Ye 
Date: Fri, 2 Feb 2024 15:42:01 -0800
Subject: [PATCH 1/2] Support statistics dump summary only mode

Summary:
Added a new --summary option to statistics dump command so that it is much 
light weight than the full version.
With this change, statistics dump --summary can now be included in lldb command 
line telemetry without slowing down lldb exiting.
---
 lldb/include/lldb/API/SBTarget.h  |   8 +-
 lldb/include/lldb/Target/Statistics.h |   9 +-
 lldb/include/lldb/Target/Target.h |   2 +-
 lldb/source/API/SBTarget.cpp  |   9 +-
 lldb/source/Commands/CommandObjectStats.cpp   |   8 +-
 lldb/source/Commands/Options.td   |   3 +
 lldb/source/Target/Statistics.cpp | 194 +++---
 lldb/source/Target/Target.cpp |   4 +-
 .../stats_api/TestStatisticsAPI.py|  15 ++
 9 files changed, 164 insertions(+), 88 deletions(-)

diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 83087623088c5b..7fd888cf7014e3 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -86,9 +86,13 @@ class LLDB_API SBTarget {
 
   /// Returns a dump of the collected statistics.
   ///
+  /// \param[in] summary_only
+  ///   If true, only report high level summary statistics without
+  ///   targets/modules/breakpoints etc.. details.
+  ///
   /// \return
   /// A SBStructuredData with the statistics collected.
-  lldb::SBStructuredData GetStatistics();
+  lldb::SBStructuredData GetStatistics(bool summary_only = false);
 
   /// Return the platform object associated with the target.
   ///
@@ -326,7 +330,7 @@ class LLDB_API SBTarget {
   uint32_t GetAddressByteSize();
 
   const char *GetTriple();
-  
+
   const char *GetABIName();
 
   const char *GetLabel() const;
diff --git a/lldb/include/lldb/Target/Statistics.h 
b/lldb/include/lldb/Target/Statistics.h
index f672786f58f84d..98658ba0cac317 100644
--- a/lldb/include/lldb/Target/Statistics.h
+++ b/lldb/include/lldb/Target/Statistics.h
@@ -133,7 +133,7 @@ struct ConstStringStats {
 /// A class that represents statistics for a since lldb_private::Target.
 class TargetStats {
 public:
-  llvm::json::Value ToJSON(Target );
+  llvm::json::Value ToJSON(Target , bool summary_only = false);
 
   void SetLaunchOrAttachTime();
   void SetFirstPrivateStopTime();
@@ -171,9 +171,14 @@ 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 , Target 
*target);
+  static llvm::json::Value ReportStatistics(Debugger , Target *target,
+bool summary_only = false);
 
 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 c37682e2a03859..4bf6c123dc1ddc 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -1599,7 +1599,7 @@ class Target : public 
std::enable_shared_from_this,
   ///
   /// \return
   /// Returns a JSON value that contains all target metrics.
-  llvm::json::Value ReportStatistics();
+  llvm::json::Value ReportStatistics(bool summary_only = false);
 
   TargetStats () { return m_stats; }
 
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 8e616afbcb4e8d..615a00ceeaee16 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -197,7 +197,7 @@ SBDebugger SBTarget::GetDebugger() const {
   return debugger;
 }
 
-SBStructuredData SBTarget::GetStatistics() {
+SBStructuredData SBTarget::GetStatistics(bool summary_only) {
   LLDB_INSTRUMENT_VA(this);
 
   SBStructuredData data;
@@ -205,9 +205,10 @@ SBStructuredData SBTarget::GetStatistics() {
   if (!target_sp)
 return data;
   std::string json_str =
-  llvm::formatv("{0:2}",
-  DebuggerStats::ReportStatistics(target_sp->GetDebugger(),
-  target_sp.get())).str();
+  llvm::formatv(
+  "{0:2}", DebuggerStats::ReportStatistics(
+   target_sp->GetDebugger(), target_sp.get(), 
summary_only))
+  .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 262de0bda144a6..781b90794dc377 100644
--- 

[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread via lldb-commits

https://github.com/kusmour updated 
https://github.com/llvm/llvm-project/pull/80745

>From 429a44aa6332440e879f7c5f91037741814d1a17 Mon Sep 17 00:00:00 2001
From: Wanyi Ye 
Date: Fri, 2 Feb 2024 15:42:01 -0800
Subject: [PATCH 1/2] Support statistics dump summary only mode

Summary:
Added a new --summary option to statistics dump command so that it is much 
light weight than the full version.
With this change, statistics dump --summary can now be included in lldb command 
line telemetry without slowing down lldb exiting.
---
 lldb/include/lldb/API/SBTarget.h  |   8 +-
 lldb/include/lldb/Target/Statistics.h |   9 +-
 lldb/include/lldb/Target/Target.h |   2 +-
 lldb/source/API/SBTarget.cpp  |   9 +-
 lldb/source/Commands/CommandObjectStats.cpp   |   8 +-
 lldb/source/Commands/Options.td   |   3 +
 lldb/source/Target/Statistics.cpp | 187 +++---
 lldb/source/Target/Target.cpp |   4 +-
 .../stats_api/TestStatisticsAPI.py|  15 ++
 9 files changed, 168 insertions(+), 77 deletions(-)

diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 83087623088c5..7fd888cf7014e 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -86,9 +86,13 @@ class LLDB_API SBTarget {
 
   /// Returns a dump of the collected statistics.
   ///
+  /// \param[in] summary_only
+  ///   If true, only report high level summary statistics without
+  ///   targets/modules/breakpoints etc.. details.
+  ///
   /// \return
   /// A SBStructuredData with the statistics collected.
-  lldb::SBStructuredData GetStatistics();
+  lldb::SBStructuredData GetStatistics(bool summary_only = false);
 
   /// Return the platform object associated with the target.
   ///
@@ -326,7 +330,7 @@ class LLDB_API SBTarget {
   uint32_t GetAddressByteSize();
 
   const char *GetTriple();
-  
+
   const char *GetABIName();
 
   const char *GetLabel() const;
diff --git a/lldb/include/lldb/Target/Statistics.h 
b/lldb/include/lldb/Target/Statistics.h
index f672786f58f84..98658ba0cac31 100644
--- a/lldb/include/lldb/Target/Statistics.h
+++ b/lldb/include/lldb/Target/Statistics.h
@@ -133,7 +133,7 @@ struct ConstStringStats {
 /// A class that represents statistics for a since lldb_private::Target.
 class TargetStats {
 public:
-  llvm::json::Value ToJSON(Target );
+  llvm::json::Value ToJSON(Target , bool summary_only = false);
 
   void SetLaunchOrAttachTime();
   void SetFirstPrivateStopTime();
@@ -171,9 +171,14 @@ 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 , Target 
*target);
+  static llvm::json::Value ReportStatistics(Debugger , Target *target,
+bool summary_only = false);
 
 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 c37682e2a0385..4bf6c123dc1dd 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -1599,7 +1599,7 @@ class Target : public 
std::enable_shared_from_this,
   ///
   /// \return
   /// Returns a JSON value that contains all target metrics.
-  llvm::json::Value ReportStatistics();
+  llvm::json::Value ReportStatistics(bool summary_only = false);
 
   TargetStats () { return m_stats; }
 
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 8e616afbcb4e8..615a00ceeaee1 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -197,7 +197,7 @@ SBDebugger SBTarget::GetDebugger() const {
   return debugger;
 }
 
-SBStructuredData SBTarget::GetStatistics() {
+SBStructuredData SBTarget::GetStatistics(bool summary_only) {
   LLDB_INSTRUMENT_VA(this);
 
   SBStructuredData data;
@@ -205,9 +205,10 @@ SBStructuredData SBTarget::GetStatistics() {
   if (!target_sp)
 return data;
   std::string json_str =
-  llvm::formatv("{0:2}",
-  DebuggerStats::ReportStatistics(target_sp->GetDebugger(),
-  target_sp.get())).str();
+  llvm::formatv(
+  "{0:2}", DebuggerStats::ReportStatistics(
+   target_sp->GetDebugger(), target_sp.get(), 
summary_only))
+  .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 262de0bda144a..781b90794dc37 100644
--- a/lldb/source/Commands/CommandObjectStats.cpp
+++ 

[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread via lldb-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 76706090c2f672ae933798292bfa889f9e3dac3d 
ebf4db52352c39f33e483affa2bcee88298b353a -- lldb/include/lldb/API/SBTarget.h 
lldb/include/lldb/Target/Statistics.h lldb/include/lldb/Target/Target.h 
lldb/source/API/SBTarget.cpp lldb/source/Commands/CommandObjectStats.cpp 
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp 
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h 
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h 
lldb/source/Target/Statistics.cpp lldb/source/Target/Target.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Target/Statistics.cpp 
b/lldb/source/Target/Statistics.cpp
index 0738c2fc68..8189f87c3d 100644
--- a/lldb/source/Target/Statistics.cpp
+++ b/lldb/source/Target/Statistics.cpp
@@ -327,29 +327,28 @@ llvm::json::Value 
DebuggerStats::ReportStatistics(Debugger ,
   json::Value cmd_stats = debugger.GetCommandInterpreter().GetStatistics();
 
   json::Object global_stats{
-  {"targets", std::move(json_targets)},
-  {"modules", std::move(json_modules)},
-  {"memory", std::move(json_memory)},
-  {"commands", std::move(cmd_stats)},
+{"targets", std::move(json_targets)}, {"modules", std::move(json_modules)},
+{"memory", std::move(json_memory)}, {"commands", std::move(cmd_stats)},
 ===
   json::Object global_stats{
 >>> a018d51da52f (Support statistics dump summary only mode)
-  {"totalSymbolTableParseTime", symtab_parse_time},
-  {"totalSymbolTableIndexTime", symtab_index_time},
-  {"totalSymbolTablesLoadedFromCache", symtabs_loaded},
-  {"totalSymbolTablesSavedToCache", symtabs_saved},
-  {"totalDebugInfoParseTime", debug_parse_time},
-  {"totalDebugInfoIndexTime", debug_index_time},
-  {"totalDebugInfoIndexLoadedFromCache", debug_index_loaded},
-  {"totalDebugInfoIndexSavedToCache", debug_index_saved},
-  {"totalDebugInfoByteSize", debug_info_size},
-  {"totalModuleCount", num_modules},
-  {"totalModuleCountHasDebugInfo", num_modules_has_debug_info},
-  {"totalModuleCountWithVariableErrors", num_modules_with_variable_errors},
-  {"totalModuleCountWithIncompleteTypes",
-   num_modules_with_incomplete_types},
-  {"totalDebugInfoEnabled", num_debug_info_enabled_modules},
-  {"totalSymbolTableStripped", num_stripped_modules},
+{"totalSymbolTableParseTime", symtab_parse_time},
+{"totalSymbolTableIndexTime", symtab_index_time},
+{"totalSymbolTablesLoadedFromCache", symtabs_loaded},
+{"totalSymbolTablesSavedToCache", symtabs_saved},
+{"totalDebugInfoParseTime", debug_parse_time},
+{"totalDebugInfoIndexTime", debug_index_time},
+{"totalDebugInfoIndexLoadedFromCache", debug_index_loaded},
+{"totalDebugInfoIndexSavedToCache", debug_index_saved},
+{"totalDebugInfoByteSize", debug_info_size},
+{"totalModuleCount", num_modules},
+{"totalModuleCountHasDebugInfo", num_modules_has_debug_info},
+{"totalModuleCountWithVariableErrors",
+ num_modules_with_variable_errors},
+{"totalModuleCountWithIncompleteTypes",
+ num_modules_with_incomplete_types},
+{"totalDebugInfoEnabled", num_debug_info_enabled_modules},
+{"totalSymbolTableStripped", num_stripped_modules},
   };
 
   if (target) {

``




https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread via lldb-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r 
76706090c2f672ae933798292bfa889f9e3dac3d...ebf4db52352c39f33e483affa2bcee88298b353a
 lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py
``





View the diff from darker here.


``diff
--- TestStatisticsAPI.py2024-02-05 21:30:06.00 +
+++ TestStatisticsAPI.py2024-02-05 21:36:35.135968 +
@@ -77,18 +77,18 @@
 # Test statistics summary.
 stats_summary = target.GetStatistics(True)
 stream_summary = lldb.SBStream()
 res = stats_summary.GetAsJSON(stream_summary)
 debug_stats_summary = json.loads(stream_summary.GetData())
-self.assertNotIn('modules', debug_stats_summary)
-self.assertNotIn('memory', debug_stats_summary)
-self.assertNotIn('commands', debug_stats_summary)
+self.assertNotIn("modules", debug_stats_summary)
+self.assertNotIn("memory", debug_stats_summary)
+self.assertNotIn("commands", debug_stats_summary)
 
 # Summary values should be the same as in full statistics.
 for key, value in debug_stats_summary.items():
 self.assertIn(key, debug_stats)
-if key != 'targets':
+if key != "targets":
 self.assertEqual(debug_stats[key], value)
 
 def test_command_stats_api(self):
 """
 Test GetCommandInterpreter::GetStatistics() API.

``




https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread via lldb-commits

https://github.com/kusmour edited 
https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread via lldb-commits

https://github.com/kusmour edited 
https://github.com/llvm/llvm-project/pull/80745
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Wanyi (kusmour)


Changes

Added a new --summary option to statistics dump command so that it is much 
light weight than the full version.
Per my benchmark against AdFinder, full statistics dump takes 20 ~ 30 
seconds to complete while statisitics dump --summary completes immediately. 
This makes sense because the bottleneck is in JSON construction/serialization 
instead of module enumeration.
With this change, statistics dump --summary can now be included in lldb 
command line telemetry without slowing down lldb exiting.

---

Patch is 23.00 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/80745.diff


13 Files Affected:

- (modified) lldb/include/lldb/API/SBTarget.h (+6-2) 
- (modified) lldb/include/lldb/Target/Statistics.h (+7-2) 
- (modified) lldb/include/lldb/Target/Target.h (+1-1) 
- (modified) lldb/source/API/SBTarget.cpp (+5-4) 
- (modified) lldb/source/Commands/CommandObjectStats.cpp (+7-1) 
- (modified) lldb/source/Commands/Options.td (+3) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp (+3-2) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h (+1-1) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (+1-1) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (+4) 
- (modified) lldb/source/Target/Statistics.cpp (+121-66) 
- (modified) lldb/source/Target/Target.cpp (+3-1) 
- (modified) lldb/test/API/functionalities/stats_api/TestStatisticsAPI.py (+15) 


``diff
diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 83087623088c5b..7fd888cf7014e3 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -86,9 +86,13 @@ class LLDB_API SBTarget {
 
   /// Returns a dump of the collected statistics.
   ///
+  /// \param[in] summary_only
+  ///   If true, only report high level summary statistics without
+  ///   targets/modules/breakpoints etc.. details.
+  ///
   /// \return
   /// A SBStructuredData with the statistics collected.
-  lldb::SBStructuredData GetStatistics();
+  lldb::SBStructuredData GetStatistics(bool summary_only = false);
 
   /// Return the platform object associated with the target.
   ///
@@ -326,7 +330,7 @@ class LLDB_API SBTarget {
   uint32_t GetAddressByteSize();
 
   const char *GetTriple();
-  
+
   const char *GetABIName();
 
   const char *GetLabel() const;
diff --git a/lldb/include/lldb/Target/Statistics.h 
b/lldb/include/lldb/Target/Statistics.h
index f672786f58f84d..98658ba0cac317 100644
--- a/lldb/include/lldb/Target/Statistics.h
+++ b/lldb/include/lldb/Target/Statistics.h
@@ -133,7 +133,7 @@ struct ConstStringStats {
 /// A class that represents statistics for a since lldb_private::Target.
 class TargetStats {
 public:
-  llvm::json::Value ToJSON(Target );
+  llvm::json::Value ToJSON(Target , bool summary_only = false);
 
   void SetLaunchOrAttachTime();
   void SetFirstPrivateStopTime();
@@ -171,9 +171,14 @@ 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 , Target 
*target);
+  static llvm::json::Value ReportStatistics(Debugger , Target *target,
+bool summary_only = false);
 
 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 c37682e2a03859..4bf6c123dc1ddc 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -1599,7 +1599,7 @@ class Target : public 
std::enable_shared_from_this,
   ///
   /// \return
   /// Returns a JSON value that contains all target metrics.
-  llvm::json::Value ReportStatistics();
+  llvm::json::Value ReportStatistics(bool summary_only = false);
 
   TargetStats () { return m_stats; }
 
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 8e616afbcb4e8d..615a00ceeaee16 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -197,7 +197,7 @@ SBDebugger SBTarget::GetDebugger() const {
   return debugger;
 }
 
-SBStructuredData SBTarget::GetStatistics() {
+SBStructuredData SBTarget::GetStatistics(bool summary_only) {
   LLDB_INSTRUMENT_VA(this);
 
   SBStructuredData data;
@@ -205,9 +205,10 @@ SBStructuredData SBTarget::GetStatistics() {
   if (!target_sp)
 return data;
   std::string json_str =
-  llvm::formatv("{0:2}",
-  DebuggerStats::ReportStatistics(target_sp->GetDebugger(),
-  

[Lldb-commits] [lldb] Support statistics dump summary only mode (PR #80745)

2024-02-05 Thread via lldb-commits

https://github.com/kusmour created 
https://github.com/llvm/llvm-project/pull/80745

Added a new --summary option to statistics dump command so that it is much 
light weight than the full version.
Per my benchmark against AdFinder, full statistics dump takes 20 ~ 30 
seconds to complete while statisitics dump --summary completes immediately. 
This makes sense because the bottleneck is in JSON construction/serialization 
instead of module enumeration.
With this change, statistics dump --summary can now be included in lldb 
command line telemetry without slowing down lldb exiting.

>From db568e0a5194cdb48f65972c71c707a5a015a7c2 Mon Sep 17 00:00:00 2001
From: Wanyi Ye 
Date: Fri, 2 Feb 2024 15:42:01 -0800
Subject: [PATCH 1/2] Support statistics dump summary only mode

Summary:
Added a new --summary option to statistics dump command so that it is much 
light weight than the full version.
Per my benchmark against AdFinder, full statistics dump takes 20 ~ 30 seconds 
to complete while statisitics dump --summary completes immediately. This makes 
sense because the bottleneck is in JSON construction/serialization instead of 
module enumeration.
With this change, statistics dump --summary can now be included in lldb command 
line telemetry without slowing down lldb exiting.
Need this change so that we can capture some important telemetry for coredump 
debugging -- how many coredump sessions are using upcoming new NT_FILE dynamic 
loader instead of old Posix dynamic loader (A new dyldPluginName field is added 
into the output). I will upstream this change later.
---
 lldb/include/lldb/API/SBTarget.h  |   8 +-
 lldb/include/lldb/Target/Statistics.h |   9 +-
 lldb/include/lldb/Target/Target.h |   2 +-
 lldb/source/API/SBTarget.cpp  |   9 +-
 lldb/source/Commands/CommandObjectStats.cpp   |   8 +-
 lldb/source/Commands/Options.td   |   3 +
 lldb/source/Target/Statistics.cpp | 187 +++---
 lldb/source/Target/Target.cpp |   4 +-
 .../stats_api/TestStatisticsAPI.py|  15 ++
 9 files changed, 168 insertions(+), 77 deletions(-)

diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 83087623088c5..7fd888cf7014e 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -86,9 +86,13 @@ class LLDB_API SBTarget {
 
   /// Returns a dump of the collected statistics.
   ///
+  /// \param[in] summary_only
+  ///   If true, only report high level summary statistics without
+  ///   targets/modules/breakpoints etc.. details.
+  ///
   /// \return
   /// A SBStructuredData with the statistics collected.
-  lldb::SBStructuredData GetStatistics();
+  lldb::SBStructuredData GetStatistics(bool summary_only = false);
 
   /// Return the platform object associated with the target.
   ///
@@ -326,7 +330,7 @@ class LLDB_API SBTarget {
   uint32_t GetAddressByteSize();
 
   const char *GetTriple();
-  
+
   const char *GetABIName();
 
   const char *GetLabel() const;
diff --git a/lldb/include/lldb/Target/Statistics.h 
b/lldb/include/lldb/Target/Statistics.h
index f672786f58f84..98658ba0cac31 100644
--- a/lldb/include/lldb/Target/Statistics.h
+++ b/lldb/include/lldb/Target/Statistics.h
@@ -133,7 +133,7 @@ struct ConstStringStats {
 /// A class that represents statistics for a since lldb_private::Target.
 class TargetStats {
 public:
-  llvm::json::Value ToJSON(Target );
+  llvm::json::Value ToJSON(Target , bool summary_only = false);
 
   void SetLaunchOrAttachTime();
   void SetFirstPrivateStopTime();
@@ -171,9 +171,14 @@ 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 , Target 
*target);
+  static llvm::json::Value ReportStatistics(Debugger , Target *target,
+bool summary_only = false);
 
 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 c37682e2a0385..4bf6c123dc1dd 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -1599,7 +1599,7 @@ class Target : public 
std::enable_shared_from_this,
   ///
   /// \return
   /// Returns a JSON value that contains all target metrics.
-  llvm::json::Value ReportStatistics();
+  llvm::json::Value ReportStatistics(bool summary_only = false);
 
   TargetStats () { return m_stats; }
 
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 8e616afbcb4e8..615a00ceeaee1 100644
---