From dbd36e1e9f16059f1be1d15f8549a6e538906679 Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Fri, 12 Nov 2021 15:26:27 -0800 Subject: [PATCH] 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 --- lldb/source/Target/Statistics.cpp | 2 ++ lldb/test/API/commands/statistics/basic/TestStats.py | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lldb/source/Target/Statistics.cpp b/lldb/source/Target/Statistics.cpp index 4163926..1b205c5 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 9c57ea1..e2d62e1 100644 --- a/lldb/test/API/commands/statistics/basic/TestStats.py +++ b/lldb/test/API/commands/statistics/basic/TestStats.py @@ -118,6 +118,12 @@ class TestCase(TestBase): 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 @@ class TestCase(TestBase): target = self.createTestTarget() debug_stats = self.get_stats() debug_stat_keys = [ - 'modules', + 'modules', 'targets', 'totalSymbolTableParseTime', 'totalSymbolTableIndexTime', @@ -217,7 +223,7 @@ class TestCase(TestBase): lldb.SBFileSpec("main.c")) debug_stats = self.get_stats() debug_stat_keys = [ - 'modules', + 'modules', 'targets', 'totalSymbolTableParseTime', 'totalSymbolTableIndexTime', @@ -255,7 +261,7 @@ class TestCase(TestBase): target = self.createTestTarget(file_path=exe) debug_stats = self.get_stats() debug_stat_keys = [ - 'modules', + 'modules', 'targets', 'totalSymbolTableParseTime', 'totalSymbolTableIndexTime', @@ -315,7 +321,7 @@ class TestCase(TestBase): "details": {...}, "id": 2, "resolveTime": 4.3632581669999997 - } + } ] } ], @@ -333,7 +339,7 @@ class TestCase(TestBase): self.runCmd("b a_function") debug_stats = self.get_stats() debug_stat_keys = [ - 'modules', + 'modules', 'targets', 'totalSymbolTableParseTime', 'totalSymbolTableIndexTime', @@ -363,5 +369,5 @@ class TestCase(TestBase): 'resolveTime' ] for breakpoint in breakpoints: - self.verify_keys(breakpoint, 'target_stats["breakpoints"]', + self.verify_keys(breakpoint, 'target_stats["breakpoints"]', bp_keys_exist, None) -- 2.7.4