[Lldb-commits] [lldb] dbd36e1 - Add the stop count to "statistics dump" in each target's dictionary.

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Mon Nov 15 18:59:16 PST 2021


Author: Greg Clayton
Date: 2021-11-15T18:59:09-08:00
New Revision: dbd36e1e9f16059f1be1d15f8549a6e538906679

URL: https://github.com/llvm/llvm-project/commit/dbd36e1e9f16059f1be1d15f8549a6e538906679
DIFF: https://github.com/llvm/llvm-project/commit/dbd36e1e9f16059f1be1d15f8549a6e538906679.diff

LOG: Add the stop count to "statistics dump" in each target's dictionary.

It is great to know how many times the target has stopped over its lifetime as each time the target stops, and possibly resumes without the user seeing it for things like shared library loading and signals that are not notified and auto continued, to help explain why a debug session might be slow. This is now included as "stopCount" inside each target JSON.

Differential Revision: https://reviews.llvm.org/D113810

Added: 
    

Modified: 
    lldb/source/Target/Statistics.cpp
    lldb/test/API/commands/statistics/basic/TestStats.py

Removed: 
    


################################################################################
diff  --git a/lldb/source/Target/Statistics.cpp b/lldb/source/Target/Statistics.cpp
index 41639264a949b..1b205c533519e 100644
--- a/lldb/source/Target/Statistics.cpp
+++ b/lldb/source/Target/Statistics.cpp
@@ -103,6 +103,8 @@ json::Value TargetStats::ToJSON(Target &target) {
     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",

diff  --git a/lldb/test/API/commands/statistics/basic/TestStats.py b/lldb/test/API/commands/statistics/basic/TestStats.py
index 9c57ea12a801b..e2d62e181a525 100644
--- a/lldb/test/API/commands/statistics/basic/TestStats.py
+++ b/lldb/test/API/commands/statistics/basic/TestStats.py
@@ -118,6 +118,12 @@ def test_expressions_frame_var_counts(self):
         stats = self.get_target_stats(self.get_stats())
         self.verify_success_fail_count(stats, 'frameVariable', 1, 0)
 
+        # Test that "stopCount" is available when the process has run
+        self.assertEqual('stopCount' in stats, True,
+                         'ensure "stopCount" is in target JSON')
+        self.assertGreater(stats['stopCount'], 0,
+                           'make sure "stopCount" is greater than zero')
+
     def test_default_no_run(self):
         """Test "statistics dump" without running the target.
 
@@ -154,7 +160,7 @@ def test_default_no_run(self):
         target = self.createTestTarget()
         debug_stats = self.get_stats()
         debug_stat_keys = [
-            'modules', 
+            'modules',
             'targets',
             'totalSymbolTableParseTime',
             'totalSymbolTableIndexTime',
@@ -217,7 +223,7 @@ def test_default_with_run(self):
                                           lldb.SBFileSpec("main.c"))
         debug_stats = self.get_stats()
         debug_stat_keys = [
-            'modules', 
+            'modules',
             'targets',
             'totalSymbolTableParseTime',
             'totalSymbolTableIndexTime',
@@ -255,7 +261,7 @@ def test_modules(self):
         target = self.createTestTarget(file_path=exe)
         debug_stats = self.get_stats()
         debug_stat_keys = [
-            'modules', 
+            'modules',
             'targets',
             'totalSymbolTableParseTime',
             'totalSymbolTableIndexTime',
@@ -315,7 +321,7 @@ def test_breakpoints(self):
                             "details": {...},
                             "id": 2,
                             "resolveTime": 4.3632581669999997
-                        }                        
+                        }
                     ]
                 }
             ],
@@ -333,7 +339,7 @@ def test_breakpoints(self):
         self.runCmd("b a_function")
         debug_stats = self.get_stats()
         debug_stat_keys = [
-            'modules', 
+            'modules',
             'targets',
             'totalSymbolTableParseTime',
             'totalSymbolTableIndexTime',
@@ -363,5 +369,5 @@ def test_breakpoints(self):
             'resolveTime'
         ]
         for breakpoint in breakpoints:
-            self.verify_keys(breakpoint, 'target_stats["breakpoints"]', 
+            self.verify_keys(breakpoint, 'target_stats["breakpoints"]',
                              bp_keys_exist, None)


        


More information about the lldb-commits mailing list