Skip to content

Support statistics dump summary only mode #80745

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 7, 2024
Merged

Conversation

kusmour
Copy link
Contributor

@kusmour kusmour commented Feb 5, 2024

Added a new --summary option to statistics dump command so that it is much light weight than the full version.
Also modified the SymbolFileDWARFDwo *GetDwoSymbolFile as suggested in PR #80218

@kusmour kusmour requested a review from JDevlieghere as a code owner February 5, 2024 21:34
@llvmbot llvmbot added the lldb label Feb 5, 2024
@llvmbot
Copy link
Member

llvmbot commented Feb 5, 2024

@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 --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 &target);
+  llvm::json::Value ToJSON(Target &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 &debugger, Target *target);
+  static llvm::json::Value ReportStatistics(Debugger &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<Target>,
   ///
   /// \return
   ///     Returns a JSON value that contains all target metrics.
-  llvm::json::Value ReportStatistics();
+  llvm::json::Value ReportStatistics(bool summary_only = false);
 
   TargetStats &GetStatistics() { 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;
         break;
+      case 's':
+        m_summary_only = true;
+        break;
       default:
         llvm_unreachable("Unimplemented option");
       }
@@ -83,6 +86,7 @@ class CommandObjectStatsDump : public CommandObjectParsed {
 
     void OptionParsingStarting(ExecutionContext *execution_context) override {
       m_all_targets = false;
+      m_summary_only = false;
     }
 
     llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
@@ -90,6 +94,7 @@ class CommandObjectStatsDump : public CommandObjectParsed {
     }
 
     bool m_all_targets = false;
+    bool m_summary_only = false;
   };
 
 public:
@@ -109,7 +114,8 @@ class CommandObjectStatsDump : public CommandObjectParsed {
       target = m_exe_ctx.GetTargetPtr();
 
     result.AppendMessageWithFormatv(
-        "{0:2}", DebuggerStats::ReportStatistics(GetDebugger(), target));
+        "{0:2}", DebuggerStats::ReportStatistics(GetDebugger(), target,
+                                                 m_options.m_summary_only));
     result.SetStatus(eReturnStatusSuccessFinishResult);
   }
 
diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index ed3167727bcd32..dba2e74a33a662 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -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.">;
 }
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index 23e0b8a7f2c06b..4e822742780f8d 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -896,8 +896,9 @@ void DWARFUnit::ComputeAbsolutePath() {
     m_file_spec->MakeAbsolute(GetCompilationDirectory());
 }
 
-SymbolFileDWARFDwo *DWARFUnit::GetDwoSymbolFile() {
-  ExtractUnitDIEIfNeeded();
+SymbolFileDWARFDwo *DWARFUnit::GetDwoSymbolFile(bool load_if_needed) {
+  if (load_if_needed)
+    ExtractUnitDIEIfNeeded();
   if (m_dwo)
     return &llvm::cast<SymbolFileDWARFDwo>(m_dwo->GetSymbolFileDWARF());
   return nullptr;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
index 9f6d127056fa56..815738d8a19330 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -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);
 
   die_iterator_range dies() {
     ExtractDIEsIfNeeded();
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 781f5c5a436778..0918a77f83cf74 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2687,7 +2687,7 @@ uint64_t SymbolFileDWARF::GetDebugInfoSize() {
     if (cu == nullptr)
       continue;
 
-    SymbolFileDWARFDwo *dwo = cu->GetDwoSymbolFile();
+    SymbolFileDWARFDwo *dwo = cu->GetDwoSymbolFile(false);
     if (dwo)
       debug_info_size += dwo->GetDebugInfoSize();
   }
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
index 60baf694b463ec..542624d7ca7b2f 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -186,6 +186,10 @@ class SymbolFileDWARF : public SymbolFileCommon {
   GetMangledNamesForFunction(const std::string &scope_qualified_name,
                              std::vector<ConstString> &mangled_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.
   uint64_t GetDebugInfoSize() override;
 
   void FindTypes(const lldb_private::TypeQuery &match,
diff --git a/lldb/source/Target/Statistics.cpp b/lldb/source/Target/Statistics.cpp
index 4699710035b2d6..0738c2fc68d80c 100644
--- a/lldb/source/Target/Statistics.cpp
+++ b/lldb/source/Target/Statistics.cpp
@@ -12,6 +12,7 @@
 #include "lldb/Core/Module.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Symbol/SymbolFile.h"
+#include "lldb/Target/DynamicLoader.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Target/UnixSignals.h"
@@ -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)
       symfile_ids.emplace_back(symfile_id);
     module.try_emplace("symbolFileModuleIdentifiers", std::move(symfile_ids));
   }
@@ -100,60 +101,91 @@ llvm::json::Value ConstStringStats::ToJSON() const {
   return obj;
 }
 
-json::Value TargetStats::ToJSON(Target &target) {
-  CollectStats(target);
+json::Value TargetStats::ToJSON(Target &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.
+    for (int i = 0; i < 2; ++i) {
+      BreakpointList &breakpoints = target.GetBreakpointList(i == 1);
+      std::unique_lock<std::recursive_mutex> lock;
+      breakpoints.GetListMutex(lock);
+      size_t num_breakpoints = breakpoints.GetSize();
+      for (size_t i = 0; i < num_breakpoints; i++) {
+        Breakpoint *bp = breakpoints.GetBreakpointAtIndex(i).get();
+        breakpoints_array.push_back(bp->GetStatistics());
+        totalBreakpointResolveTime += bp->GetResolveTime().count();
+      }
+    }
+    target_metrics_json.try_emplace("breakpoints",
+                                    std::move(breakpoints_array));
+    target_metrics_json.try_emplace("totalBreakpointResolveTime",
+                                    totalBreakpointResolveTime);
+
+    if (process_sp) {
+      UnixSignalsSP unix_signals_sp = process_sp->GetUnixSignals();
+      if (unix_signals_sp)
+        target_metrics_json.try_emplace(
+            "signals", unix_signals_sp->GetHitCountStatistics());
+    }
   }
-  target_metrics_json.try_emplace("targetCreateTime",
-                                  m_create_time.get().count());
-
-  json::Array breakpoints_array;
-  double totalBreakpointResolveTime = 0.0;
-  // Rport both the normal breakpoint list and the internal breakpoint list.
-  for (int i = 0; i < 2; ++i) {
-    BreakpointList &breakpoints = target.GetBreakpointList(i == 1);
+
+  // Counting "totalSharedLibraryEventHitCount" from breakpoints of kind
+  // "shared-library-event".
+  {
+    uint32_t shared_library_event_breakpoint_hit_count = 0;
+    // The "shared-library-event" is only found in the internal breakpoint list.
+    BreakpointList &breakpoints = target.GetBreakpointList(/* internal */ true);
     std::unique_lock<std::recursive_mutex> lock;
     breakpoints.GetListMutex(lock);
     size_t num_breakpoints = breakpoints.GetSize();
     for (size_t i = 0; i < num_breakpoints; i++) {
       Breakpoint *bp = breakpoints.GetBreakpointAtIndex(i).get();
-      breakpoints_array.push_back(bp->GetStatistics());
-      totalBreakpointResolveTime += bp->GetResolveTime().count();
+      if (strcmp(bp->GetBreakpointKind(), "shared-library-event") == 0)
+        shared_library_event_breakpoint_hit_count += bp->GetHitCount();
     }
+
+    target_metrics_json.try_emplace("totalSharedLibraryEventHitCount",
+                                    shared_library_event_breakpoint_hit_count);
   }
 
-  ProcessSP process_sp = target.GetProcessSP();
   if (process_sp) {
-    UnixSignalsSP unix_signals_sp = process_sp->GetUnixSignals();
-    if (unix_signals_sp)
-      target_metrics_json.try_emplace("signals",
-                                      unix_signals_sp->GetHitCountStatistics());
     uint32_t stop_id = process_sp->GetStopID();
     target_metrics_json.try_emplace("stopCount", stop_id);
-  }
-  target_metrics_json.try_emplace("breakpoints", std::move(breakpoints_array));
-  target_metrics_json.try_emplace("totalBreakpointResolveTime",
-                                  totalBreakpointResolveTime);
-  target_metrics_json.try_emplace("sourceMapDeduceCount", m_source_map_deduce_count);
 
+    llvm::StringRef dyld_plugin_name;
+    if (process_sp->GetDynamicLoader())
+      dyld_plugin_name = process_sp->GetDynamicLoader()->GetPluginName();
+    target_metrics_json.try_emplace("dyldPluginName", dyld_plugin_name);
+  }
+  target_metrics_json.try_emplace("sourceMapDeduceCount",
+                                  m_source_map_deduce_count);
   return target_metrics_json;
 }
 
@@ -185,7 +217,8 @@ void TargetStats::IncreaseSourceMapDeduceCount() {
 bool DebuggerStats::g_collecting_stats = false;
 
 llvm::json::Value DebuggerStats::ReportStatistics(Debugger &debugger,
-                                                  Target *target) {
+                                                  Target *target,
+                                                  bool summary_only) {
   json::Array json_targets;
   json::Array json_modules;
   double symtab_parse_time = 0.0;
@@ -197,12 +230,7 @@ llvm::json::Value DebuggerStats::ReportStatistics(Debugger &debugger,
   uint32_t debug_index_loaded = 0;
   uint32_t debug_index_saved = 0;
   uint64_t debug_info_size = 0;
-  if (target) {
-    json_targets.emplace_back(target->ReportStatistics());
-  } else {
-    for (const auto &target : debugger.GetTargetList().Targets())
-      json_targets.emplace_back(target->ReportStatistics());
-  }
+
   std::vector<ModuleStats> modules;
   std::lock_guard<std::recursive_mutex> guard(
       Module::GetAllocationModuleCollectionMutex());
@@ -215,15 +243,6 @@ llvm::json::Value DebuggerStats::ReportStatistics(Debugger &debugger,
   for (size_t image_idx = 0; image_idx < num_modules; ++image_idx) {
     Module *module = Module::GetAllocatedModuleAtIndex(image_idx);
     ModuleStats module_stat;
-    module_stat.identifier = (intptr_t)module;
-    module_stat.path = module->GetFileSpec().GetPath();
-    if (ConstString object_name = module->GetObjectName()) {
-      module_stat.path.append(1, '(');
-      module_stat.path.append(object_name.GetStringRef().str());
-      module_stat.path.append(1, ')');
-    }
-    module_stat.uuid = module->GetUUID().GetAsString();
-    module_stat.triple = module->GetArchitecture().GetTriple().str();
     module_stat.symtab_parse_time = module->GetSymtabParseTime().get().count();
     module_stat.symtab_index_time = module->GetSymtabIndexTime().get().count();
     Symtab *symtab = module->GetSymtab();
@@ -237,13 +256,14 @@ llvm::json::Value DebuggerStats::ReportStatistics(Debugger &debugger,
     }
     SymbolFile *sym_file = module->GetSymbolFile();
     if (sym_file) {
-
-      if (sym_file->GetObjectFile() != module->GetObjectFile())
-        module_stat.symfile_path =
-            sym_file->GetObjectFile()->GetFileSpec().GetPath();
-      module_stat.debug_index_time = sym_file->GetDebugInfoIndexTime().count();
-      module_stat.debug_parse_time = sym_file->GetDebugInfoParseTime().count();
-      module_stat.debug_info_size = sym_file->GetDebugInfoSize();
+      if (!summary_only) {
+        if (sym_file->GetObjectFile() != module->GetObjectFile())
+          module_stat.symfile_path =
+              sym_file->GetObjectFile()->GetFileSpec().GetPath();
+        ModuleList symbol_modules = sym_file->GetDebugInfoModules();
+        for (const auto &symbol_module : symbol_modules.Modules())
+          module_stat.symfile_modules.push_back((intptr_t)symbol_module.get());
+      }
       module_stat.debug_info_index_loaded_from_cache =
           sym_file->GetDebugInfoIndexWasLoadedFromCache();
       if (module_stat.debug_info_index_loaded_from_cache)
@@ -252,9 +272,9 @@ llvm::json::Value DebuggerStats::ReportStatistics(Debugger &debugger,
           sym_file->GetDebugInfoIndexWasSavedToCache();
       if (module_stat.debug_info_index_saved_to_cache)
         ++debug_index_saved;
-      ModuleList symbol_modules = sym_file->GetDebugInfoModules();
-      for (const auto &symbol_module: symbol_modules.Modules())
-        module_stat.symfile_modules.push_back((intptr_t)symbol_module.get());
+      module_stat.debug_index_time = sym_file->GetDebugInfoIndexTime().count();
+      module_stat.debug_parse_time = sym_file->GetDebugInfoParseTime().count();
+      module_stat.debug_info_size = sym_file->GetDebugInfoSize();
       module_stat.symtab_stripped = module->GetObjectFile()->IsStripped();
       if (module_stat.symtab_stripped)
         ++num_stripped_modules;
@@ -284,9 +304,21 @@ llvm::json::Value DebuggerStats::ReportStatistics(Debugger &debugger,
     if (module_stat.debug_info_had_incomplete_types)
       ++num_modules_with_incomplete_types;
 
-    json_modules.emplace_back(module_stat.ToJSON());
+    if (!summary_only) {
+      module_stat.identifier = (intptr_t)module;
+      module_stat.path = module->GetFileSpec().GetPath();
+      if (ConstString object_name = module->GetObjectName()) {
+        module_stat.path.append(1, '(');
+        module_stat.path.append(object_name.GetStringRef().str());
+        module_stat.path.append(1, ')');
+      }
+      module_stat.uuid = module->GetUUID().GetAsString();
+      module_stat.triple = module->GetArchitecture().GetTriple().str();
+      json_modules.emplace_back(module_stat.ToJSON());
+    }
   }
 
+<<<<<<< HEAD
   ConstStringStats const_string_stats;
   json::Object json_memory{
       {"strings", const_string_stats.ToJSON()},
@@ -299,6 +331,9 @@ llvm::json::Value DebuggerStats::ReportStatistics(Debugger &debugger,
       {"modules", std::move(json_modules)},
       {"memory", std::move(json_memory)},
       {"commands", std::move(cmd_stat...
[truncated]

Copy link

github-actions bot commented Feb 5, 2024

✅ With the latest revision this PR passed the Python code formatter.

Copy link

github-actions bot commented Feb 5, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@kusmour kusmour force-pushed the lldb-statistics branch 3 times, most recently from ec2a332 to 7678d5e Compare February 5, 2024 22:43
Copy link
Contributor

@hawkinsw hawkinsw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

SymbolFileDWARFDwo *dwo = cu->GetDwoSymbolFile();
SymbolFileDWARFDwo *dwo = cu->GetDwoSymbolFile(false);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member

@bulbazord bulbazord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@kusmour kusmour force-pushed the lldb-statistics branch 3 times, most recently from 600ae3d to 54a9ec1 Compare February 6, 2024 20:00
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.
Summary:
We can't take away or change a previously available public API function.
To avoid future changes, intruduce an option class that we can extend without modifying existing APIs.
@kusmour kusmour force-pushed the lldb-statistics branch 2 times, most recently from 6a52893 to 9f07c4b Compare February 6, 2024 22:24
Copy link
Collaborator

@clayborg clayborg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few nits you can fix if you want to.

@kusmour kusmour merged commit 2217837 into llvm:main Feb 7, 2024
@kusmour kusmour deleted the lldb-statistics branch February 7, 2024 00:47
kusmour added a commit that referenced this pull request Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants