From aac1c3b15aae7a13f6861c6a58729d68d2f1eab0 Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Sun, 20 Nov 2022 09:40:23 -0800 Subject: [PATCH] Add a new top level statistic that tracks how many modules have variable errors. We have a statistic on each module named "debugInfoHadVariableErrors" which tracks when we have debug info, but an error prevented the variables from being displayed. This patch adds a new top level statistic named "totalModuleCountWithVariableErrors" which is a count of the modules that have "debugInfoHadVariableErrors" set to true. Differential Revision: https://reviews.llvm.org/D138383 --- lldb/source/Target/Statistics.cpp | 4 ++++ lldb/test/API/commands/statistics/basic/TestStats.py | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lldb/source/Target/Statistics.cpp b/lldb/source/Target/Statistics.cpp index e0ac00e..e542f90 100644 --- a/lldb/source/Target/Statistics.cpp +++ b/lldb/source/Target/Statistics.cpp @@ -206,6 +206,7 @@ llvm::json::Value DebuggerStats::ReportStatistics(Debugger &debugger, const uint64_t num_modules = Module::GetNumberAllocatedModules(); uint32_t num_debug_info_enabled_modules = 0; uint32_t num_modules_has_debug_info = 0; + uint32_t num_modules_with_variable_errors = 0; uint32_t num_stripped_modules = 0; for (size_t image_idx = 0; image_idx < num_modules; ++image_idx) { Module *module = Module::GetAllocatedModuleAtIndex(image_idx); @@ -261,6 +262,8 @@ llvm::json::Value DebuggerStats::ReportStatistics(Debugger &debugger, ++num_debug_info_enabled_modules; if (module_stat.debug_info_size > 0) ++num_modules_has_debug_info; + if (module_stat.debug_info_had_variable_errors) + ++num_modules_with_variable_errors; } symtab_parse_time += module_stat.symtab_parse_time; symtab_index_time += module_stat.symtab_index_time; @@ -295,6 +298,7 @@ llvm::json::Value DebuggerStats::ReportStatistics(Debugger &debugger, {"totalDebugInfoByteSize", debug_info_size}, {"totalModuleCount", num_modules}, {"totalModuleCountHasDebugInfo", num_modules_has_debug_info}, + {"totalModuleCountWithVariableErrors", num_modules_with_variable_errors}, {"totalDebugInfoEnabled", num_debug_info_enabled_modules}, {"totalSymbolTableStripped", num_stripped_modules}, }; diff --git a/lldb/test/API/commands/statistics/basic/TestStats.py b/lldb/test/API/commands/statistics/basic/TestStats.py index 92c2016..5a8aa99 100644 --- a/lldb/test/API/commands/statistics/basic/TestStats.py +++ b/lldb/test/API/commands/statistics/basic/TestStats.py @@ -578,13 +578,18 @@ class TestCase(TestBase): (target, process, thread, bkpt) = lldbutil.run_to_name_breakpoint(self, 'main') # Get stats and verify we had errors. - exe_stats = self.find_module_in_metrics(exe, self.get_stats()) + stats = self.get_stats() + exe_stats = self.find_module_in_metrics(exe, stats) self.assertTrue(exe_stats is not None) # Make sure we have "debugInfoHadVariableErrors" variable that is set to # false before failing to get local variables due to missing .o file. self.assertEqual(exe_stats['debugInfoHadVariableErrors'], False) + # Verify that the top level statistic that aggregates the number of + # modules with debugInfoHadVariableErrors is zero + self.assertEqual(stats['totalModuleCountWithVariableErrors'], 0) + # Try and fail to get variables vars = thread.GetFrameAtIndex(0).GetVariables(True, True, False, True) @@ -593,9 +598,14 @@ class TestCase(TestBase): self.assertTrue(vars.GetError().Fail()) # Get stats and verify we had errors. - exe_stats = self.find_module_in_metrics(exe, self.get_stats()) + stats = self.get_stats() + exe_stats = self.find_module_in_metrics(exe, stats) self.assertTrue(exe_stats is not None) # Make sure we have "hadFrameVariableErrors" variable that is set to # true after failing to get local variables due to missing .o file. self.assertEqual(exe_stats['debugInfoHadVariableErrors'], True) + + # Verify that the top level statistic that aggregates the number of + # modules with debugInfoHadVariableErrors is greater than zero + self.assertGreater(stats['totalModuleCountWithVariableErrors'], 0) -- 2.7.4