Skip to content

Commit aac1c3b

Browse files
committed
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
1 parent 3888913 commit aac1c3b

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lldb/source/Target/Statistics.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ llvm::json::Value DebuggerStats::ReportStatistics(Debugger &debugger,
206206
const uint64_t num_modules = Module::GetNumberAllocatedModules();
207207
uint32_t num_debug_info_enabled_modules = 0;
208208
uint32_t num_modules_has_debug_info = 0;
209+
uint32_t num_modules_with_variable_errors = 0;
209210
uint32_t num_stripped_modules = 0;
210211
for (size_t image_idx = 0; image_idx < num_modules; ++image_idx) {
211212
Module *module = Module::GetAllocatedModuleAtIndex(image_idx);
@@ -261,6 +262,8 @@ llvm::json::Value DebuggerStats::ReportStatistics(Debugger &debugger,
261262
++num_debug_info_enabled_modules;
262263
if (module_stat.debug_info_size > 0)
263264
++num_modules_has_debug_info;
265+
if (module_stat.debug_info_had_variable_errors)
266+
++num_modules_with_variable_errors;
264267
}
265268
symtab_parse_time += module_stat.symtab_parse_time;
266269
symtab_index_time += module_stat.symtab_index_time;
@@ -295,6 +298,7 @@ llvm::json::Value DebuggerStats::ReportStatistics(Debugger &debugger,
295298
{"totalDebugInfoByteSize", debug_info_size},
296299
{"totalModuleCount", num_modules},
297300
{"totalModuleCountHasDebugInfo", num_modules_has_debug_info},
301+
{"totalModuleCountWithVariableErrors", num_modules_with_variable_errors},
298302
{"totalDebugInfoEnabled", num_debug_info_enabled_modules},
299303
{"totalSymbolTableStripped", num_stripped_modules},
300304
};

lldb/test/API/commands/statistics/basic/TestStats.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -578,13 +578,18 @@ def test_had_frame_variable_errors(self):
578578
(target, process, thread, bkpt) = lldbutil.run_to_name_breakpoint(self, 'main')
579579

580580
# Get stats and verify we had errors.
581-
exe_stats = self.find_module_in_metrics(exe, self.get_stats())
581+
stats = self.get_stats()
582+
exe_stats = self.find_module_in_metrics(exe, stats)
582583
self.assertTrue(exe_stats is not None)
583584

584585
# Make sure we have "debugInfoHadVariableErrors" variable that is set to
585586
# false before failing to get local variables due to missing .o file.
586587
self.assertEqual(exe_stats['debugInfoHadVariableErrors'], False)
587588

589+
# Verify that the top level statistic that aggregates the number of
590+
# modules with debugInfoHadVariableErrors is zero
591+
self.assertEqual(stats['totalModuleCountWithVariableErrors'], 0)
592+
588593
# Try and fail to get variables
589594
vars = thread.GetFrameAtIndex(0).GetVariables(True, True, False, True)
590595

@@ -593,9 +598,14 @@ def test_had_frame_variable_errors(self):
593598
self.assertTrue(vars.GetError().Fail())
594599

595600
# Get stats and verify we had errors.
596-
exe_stats = self.find_module_in_metrics(exe, self.get_stats())
601+
stats = self.get_stats()
602+
exe_stats = self.find_module_in_metrics(exe, stats)
597603
self.assertTrue(exe_stats is not None)
598604

599605
# Make sure we have "hadFrameVariableErrors" variable that is set to
600606
# true after failing to get local variables due to missing .o file.
601607
self.assertEqual(exe_stats['debugInfoHadVariableErrors'], True)
608+
609+
# Verify that the top level statistic that aggregates the number of
610+
# modules with debugInfoHadVariableErrors is greater than zero
611+
self.assertGreater(stats['totalModuleCountWithVariableErrors'], 0)

0 commit comments

Comments
 (0)