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

Will Hawkins via lldb-commits lldb-commits at lists.llvm.org
Mon Feb 5 14:52:01 PST 2024


================
@@ -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.
----------------
hawkinsw wrote:

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

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


More information about the lldb-commits mailing list