[Lldb-commits] [PATCH] D138638: Report which modules have forcefully completed types in statistics.

2022-11-30 Thread Greg Clayton via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfc743f034a34: Report which modules have forcefully completed 
types in statistics. (authored by clayborg).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138638/new/

https://reviews.llvm.org/D138638

Files:
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/include/lldb/Target/Statistics.h
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Target/Statistics.cpp
  lldb/test/API/commands/statistics/basic/TestStats.py
  lldb/test/API/functionalities/limit-debug-info/TestLimitDebugInfo.py

Index: lldb/test/API/functionalities/limit-debug-info/TestLimitDebugInfo.py
===
--- lldb/test/API/functionalities/limit-debug-info/TestLimitDebugInfo.py
+++ lldb/test/API/functionalities/limit-debug-info/TestLimitDebugInfo.py
@@ -30,6 +30,23 @@
 self._check_type(target, "InheritsFromOne")
 self._check_type(target, "InheritsFromTwo")
 
+# Check that the statistics show that we had incomplete debug info.
+stats = self.get_stats()
+# Find the a.out module info in the stats and verify it has the
+# "debugInfoHadIncompleteTypes" key value pair set to True
+exe_module_found = False
+for module in stats['modules']:
+if module['path'].endswith('a.out'):
+self.assertTrue(module['debugInfoHadIncompleteTypes'])
+exe_module_found = True
+break
+self.assertTrue(exe_module_found)
+# Verify that "totalModuleCountWithIncompleteTypes" at the top level
+# is greater than zero which shows we had incomplete debug info in a
+# module
+self.assertGreater(stats['totalModuleCountWithIncompleteTypes'], 0)
+
+
 def _check_incomplete_frame_variable_output(self):
 # Check that the display of the "frame variable" output identifies the
 # incomplete types. Currently the expression parser will find the real
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
@@ -55,30 +55,6 @@
 self.assertEqual(success_fail_dict['failures'], num_fails,
  'make sure success count')
 
-def get_stats(self, options=None, log_path=None):
-"""
-Get the output of the "statistics dump" with optional extra options
-and return the JSON as a python dictionary.
-"""
-# If log_path is set, open the path and emit the output of the command
-# for debugging purposes.
-if log_path is not None:
-f = open(log_path, 'w')
-else:
-f = None
-return_obj = lldb.SBCommandReturnObject()
-command = "statistics dump "
-if options is not None:
-command += options
-if f:
-f.write('(lldb) %s\n' % (command))
-self.ci.HandleCommand(command, return_obj, False)
-metrics_json = return_obj.GetOutput()
-if f:
-f.write(metrics_json)
-return json.loads(metrics_json)
-
-
 def get_target_stats(self, debug_stats):
 if "targets" in debug_stats:
 return debug_stats["targets"][0]
@@ -509,7 +485,6 @@
 exe_name = 'a.out'
 exe = self.getBuildArtifact(exe_name)
 dsym = self.getBuildArtifact(exe_name + ".dSYM")
-print("carp: dsym = '%s'" % (dsym))
 # Make sure the executable file exists after building.
 self.assertEqual(os.path.exists(exe), True)
 # Make sure the dSYM file doesn't exist after building.
@@ -563,7 +538,6 @@
 exe = self.getBuildArtifact(exe_name)
 dsym = self.getBuildArtifact(exe_name + ".dSYM")
 main_obj = self.getBuildArtifact('main.o')
-print("carp: dsym = '%s'" % (dsym))
 # Make sure the executable file exists after building.
 self.assertEqual(os.path.exists(exe), True)
 # Make sure the dSYM file doesn't exist after building.
Index: lldb/source/Target/Statistics.cpp
===
--- lldb/source/Target/Statistics.cpp
+++ lldb/source/Target/Statistics.cpp
@@ -65,6 +65,8 @@
   module.try_emplace("debugInfoEnabled", debug_info_enabled);
   module.try_emplace("debugInfoHadVariableErrors",
  debug_info_had_variable_errors);
+  module.try_emplace("debugInfoHadIncompleteTypes",
+ debug_info_had_incomplete_types);
   module.try_emplace("symbolTableStripped", symtab_stripped);
   if (!symfile_path.empty())
  

[Lldb-commits] [PATCH] D138638: Report which modules have forcefully completed types in statistics.

2022-11-23 Thread Greg Clayton via Phabricator via lldb-commits
clayborg created this revision.
clayborg added a reviewer: yinghuitan.
Herald added a reviewer: shafik.
Herald added a project: All.
clayborg requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

A previous patch added the ability for us to tell if types were forcefully 
completed. This patch adds the ability to see which modules have forcefully 
completed types and aggregates the number of modules with forcefully completed 
types at the root level.

We add a module specific setting named "debugInfoHadIncompleteTypes" that is a 
boolean value. We also aggregate the number of modules at the root level that 
had incomplete debug info with a key named 
"totalModuleCountWithIncompleteTypes" that is a count of number of modules that 
had incomplete types.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138638

Files:
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/include/lldb/Target/Statistics.h
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Target/Statistics.cpp
  lldb/test/API/commands/statistics/basic/TestStats.py
  lldb/test/API/functionalities/limit-debug-info/TestLimitDebugInfo.py

Index: lldb/test/API/functionalities/limit-debug-info/TestLimitDebugInfo.py
===
--- lldb/test/API/functionalities/limit-debug-info/TestLimitDebugInfo.py
+++ lldb/test/API/functionalities/limit-debug-info/TestLimitDebugInfo.py
@@ -30,6 +30,23 @@
 self._check_type(target, "InheritsFromOne")
 self._check_type(target, "InheritsFromTwo")
 
+# Check that the statistics show that we had incomplete debug info.
+stats = self.get_stats()
+# Find the a.out module info in the stats and verify it has the
+# "debugInfoHadIncompleteTypes" key value pair set to True
+exe_module_found = False
+for module in stats['modules']:
+if module['path'].endswith('a.out'):
+self.assertTrue(module['debugInfoHadIncompleteTypes'])
+exe_module_found = True
+break
+self.assertTrue(exe_module_found)
+# Verify that "totalModuleCountWithIncompleteTypes" at the top level
+# is greater than zero which shows we had incomplete debug info in a
+# module
+self.assertGreater(stats['totalModuleCountWithIncompleteTypes'], 0)
+
+
 def _check_incomplete_frame_variable_output(self):
 # Check that the display of the "frame variable" output identifies the
 # incomplete types. Currently the expression parser will find the real
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
@@ -55,30 +55,6 @@
 self.assertEqual(success_fail_dict['failures'], num_fails,
  'make sure success count')
 
-def get_stats(self, options=None, log_path=None):
-"""
-Get the output of the "statistics dump" with optional extra options
-and return the JSON as a python dictionary.
-"""
-# If log_path is set, open the path and emit the output of the command
-# for debugging purposes.
-if log_path is not None:
-f = open(log_path, 'w')
-else:
-f = None
-return_obj = lldb.SBCommandReturnObject()
-command = "statistics dump "
-if options is not None:
-command += options
-if f:
-f.write('(lldb) %s\n' % (command))
-self.ci.HandleCommand(command, return_obj, False)
-metrics_json = return_obj.GetOutput()
-if f:
-f.write(metrics_json)
-return json.loads(metrics_json)
-
-
 def get_target_stats(self, debug_stats):
 if "targets" in debug_stats:
 return debug_stats["targets"][0]
@@ -509,7 +485,6 @@
 exe_name = 'a.out'
 exe = self.getBuildArtifact(exe_name)
 dsym = self.getBuildArtifact(exe_name + ".dSYM")
-print("carp: dsym = '%s'" % (dsym))
 # Make sure the executable file exists after building.
 self.assertEqual(os.path.exists(exe), True)
 # Make sure the dSYM file doesn't exist after building.
@@ -563,7 +538,6 @@
 exe = self.getBuildArtifact(exe_name)
 dsym = self.getBuildArtifact(exe_name + ".dSYM")
 main_obj = self.getBuildArtifact('main.o')
-print("carp: dsym = '%s'" % (dsym))
 # Make sure the executable file exists after building.
 self.assertEqual(os.path.exists(exe), True)
 # Make sure the dSYM file doesn't exist after building.
Index: