clayborg created this revision. clayborg added reviewers: labath, JDevlieghere, jingham, aadsm, wallace. clayborg requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits.
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. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D113810 Files: lldb/source/Target/Statistics.cpp lldb/test/API/commands/statistics/basic/TestStats.py Index: lldb/test/API/commands/statistics/basic/TestStats.py =================================================================== --- lldb/test/API/commands/statistics/basic/TestStats.py +++ lldb/test/API/commands/statistics/basic/TestStats.py @@ -118,6 +118,12 @@ 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 @@ target = self.createTestTarget() debug_stats = self.get_stats() debug_stat_keys = [ - 'modules', + 'modules', 'targets', 'totalSymbolTableParseTime', 'totalSymbolTableIndexTime', @@ -217,7 +223,7 @@ lldb.SBFileSpec("main.c")) debug_stats = self.get_stats() debug_stat_keys = [ - 'modules', + 'modules', 'targets', 'totalSymbolTableParseTime', 'totalSymbolTableIndexTime', @@ -255,7 +261,7 @@ target = self.createTestTarget(file_path=exe) debug_stats = self.get_stats() debug_stat_keys = [ - 'modules', + 'modules', 'targets', 'totalSymbolTableParseTime', 'totalSymbolTableIndexTime', @@ -315,7 +321,7 @@ "details": {...}, "id": 2, "resolveTime": 4.3632581669999997 - } + } ] } ], @@ -333,7 +339,7 @@ self.runCmd("b a_function") debug_stats = self.get_stats() debug_stat_keys = [ - 'modules', + 'modules', 'targets', 'totalSymbolTableParseTime', 'totalSymbolTableIndexTime', @@ -363,5 +369,5 @@ 'resolveTime' ] for breakpoint in breakpoints: - self.verify_keys(breakpoint, 'target_stats["breakpoints"]', + self.verify_keys(breakpoint, 'target_stats["breakpoints"]', bp_keys_exist, None) Index: lldb/source/Target/Statistics.cpp =================================================================== --- lldb/source/Target/Statistics.cpp +++ lldb/source/Target/Statistics.cpp @@ -103,6 +103,8 @@ 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",
Index: lldb/test/API/commands/statistics/basic/TestStats.py =================================================================== --- lldb/test/API/commands/statistics/basic/TestStats.py +++ lldb/test/API/commands/statistics/basic/TestStats.py @@ -118,6 +118,12 @@ 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 @@ target = self.createTestTarget() debug_stats = self.get_stats() debug_stat_keys = [ - 'modules', + 'modules', 'targets', 'totalSymbolTableParseTime', 'totalSymbolTableIndexTime', @@ -217,7 +223,7 @@ lldb.SBFileSpec("main.c")) debug_stats = self.get_stats() debug_stat_keys = [ - 'modules', + 'modules', 'targets', 'totalSymbolTableParseTime', 'totalSymbolTableIndexTime', @@ -255,7 +261,7 @@ target = self.createTestTarget(file_path=exe) debug_stats = self.get_stats() debug_stat_keys = [ - 'modules', + 'modules', 'targets', 'totalSymbolTableParseTime', 'totalSymbolTableIndexTime', @@ -315,7 +321,7 @@ "details": {...}, "id": 2, "resolveTime": 4.3632581669999997 - } + } ] } ], @@ -333,7 +339,7 @@ self.runCmd("b a_function") debug_stats = self.get_stats() debug_stat_keys = [ - 'modules', + 'modules', 'targets', 'totalSymbolTableParseTime', 'totalSymbolTableIndexTime', @@ -363,5 +369,5 @@ 'resolveTime' ] for breakpoint in breakpoints: - self.verify_keys(breakpoint, 'target_stats["breakpoints"]', + self.verify_keys(breakpoint, 'target_stats["breakpoints"]', bp_keys_exist, None) Index: lldb/source/Target/Statistics.cpp =================================================================== --- lldb/source/Target/Statistics.cpp +++ lldb/source/Target/Statistics.cpp @@ -103,6 +103,8 @@ 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",
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits