[Lldb-commits] [lldb] [lldb] Add count for number of DWO files loaded in statistics (PR #144424)
via lldb-commits
lldb-commits at lists.llvm.org
Mon Jun 23 11:53:27 PDT 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {darker}-->
:warning: Python code formatter, darker found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
darker --check --diff -r HEAD~1...HEAD lldb/packages/Python/lldbsuite/test/builders/builder.py lldb/test/API/commands/statistics/basic/TestStats.py
``````````
</details>
<details>
<summary>
View the diff from darker here.
</summary>
``````````diff
--- packages/Python/lldbsuite/test/builders/builder.py 2025-06-18 23:14:35.000000 +0000
+++ packages/Python/lldbsuite/test/builders/builder.py 2025-06-23 18:53:00.379948 +0000
@@ -245,28 +245,28 @@
return ["LLDB_OBJ_ROOT={}".format(configuration.lldb_obj_root)]
def _getDebugInfoArgs(self, debug_info):
if debug_info is None:
return []
-
+
debug_options = debug_info if isinstance(debug_info, list) else [debug_info]
option_flags = {
"dwarf": {"MAKE_DSYM": "NO"},
"dwo": {"MAKE_DSYM": "NO", "MAKE_DWO": "YES"},
"gmodules": {"MAKE_DSYM": "NO", "MAKE_GMODULES": "YES"},
"debug_names": {"MAKE_DEBUG_NAMES": "YES"},
"dwp": {"MAKE_DSYM": "NO", "MAKE_DWP": "YES"},
}
-
+
# Collect all flags, with later options overriding earlier ones
flags = {}
-
+
for option in debug_options:
if not option or option not in option_flags:
- return None # Invalid options
+ return None # Invalid options
flags.update(option_flags[option])
-
+
return [f"{key}={value}" for key, value in flags.items()]
def getBuildCommand(
self,
debug_info,
--- test/API/commands/statistics/basic/TestStats.py 2025-06-18 23:14:35.000000 +0000
+++ test/API/commands/statistics/basic/TestStats.py 2025-06-23 18:53:00.691815 +0000
@@ -522,10 +522,11 @@
]
for breakpoint in breakpoints:
self.verify_keys(
breakpoint, 'target_stats["breakpoints"]', bp_keys_exist, None
)
+
def test_non_split_dwarf_has_no_dwo_files(self):
"""
Test "statistics dump" and the dwo file count.
Builds a binary without split-dwarf mode, and then
verifies the dwo file count is zero after running "statistics dump"
@@ -536,34 +537,34 @@
exe = self.getBuildArtifact("a.out")
target = self.createTestTarget(file_path=exe)
debug_stats = self.get_stats()
self.assertIn("totalDwoFileCount", debug_stats)
self.assertIn("totalLoadedDwoFileCount", debug_stats)
-
+
# Verify that the dwo file count is zero
self.assertEqual(debug_stats["totalDwoFileCount"], 0)
self.assertEqual(debug_stats["totalLoadedDwoFileCount"], 0)
-
+
def test_no_debug_names_eager_loads_dwo_files(self):
"""
Test the eager loading behavior of DWO files when debug_names is absent by
building a split-dwarf binary without debug_names and then running "statistics dump".
DWO file loading behavior:
- With debug_names: DebugNamesDWARFIndex allows for lazy loading.
DWO files are loaded on-demand when symbols are actually looked up
- Without debug_names: ManualDWARFIndex uses eager loading.
- All DWO files are loaded upfront during the first symbol lookup to build a manual index.
+ All DWO files are loaded upfront during the first symbol lookup to build a manual index.
"""
da = {"CXX_SOURCES": "third.cpp baz.cpp", "EXE": self.getBuildArtifact("a.out")}
self.build(dictionary=da, debug_info=["dwo"])
self.addTearDownCleanup(dictionary=da)
exe = self.getBuildArtifact("a.out")
target = self.createTestTarget(file_path=exe)
debug_stats = self.get_stats()
self.assertIn("totalDwoFileCount", debug_stats)
self.assertIn("totalLoadedDwoFileCount", debug_stats)
-
+
# Verify that all DWO files are loaded
self.assertEqual(debug_stats["totalDwoFileCount"], 2)
self.assertEqual(debug_stats["totalLoadedDwoFileCount"], 2)
def test_split_dwarf_dwo_file_count(self):
@@ -588,43 +589,43 @@
self.assertEqual(len(debug_stats["modules"]), 1)
self.assertIn("totalLoadedDwoFileCount", debug_stats)
self.assertIn("totalDwoFileCount", debug_stats)
self.assertEqual(debug_stats["totalLoadedDwoFileCount"], 0)
self.assertEqual(debug_stats["totalDwoFileCount"], 2)
-
+
# Since there's only one module, module stats should have the same counts as total counts
self.assertIn("dwoFileCount", debug_stats["modules"][0])
self.assertIn("loadedDwoFileCount", debug_stats["modules"][0])
self.assertEqual(debug_stats["modules"][0]["loadedDwoFileCount"], 0)
self.assertEqual(debug_stats["modules"][0]["dwoFileCount"], 2)
-
+
# 2) Setting breakpoint in main triggers loading of third.dwo (contains main function)
self.runCmd("b main")
debug_stats = self.get_stats()
self.assertEqual(debug_stats["totalLoadedDwoFileCount"], 1)
self.assertEqual(debug_stats["totalDwoFileCount"], 2)
self.assertEqual(debug_stats["modules"][0]["loadedDwoFileCount"], 1)
self.assertEqual(debug_stats["modules"][0]["dwoFileCount"], 2)
-
+
# 3) Type lookup forces loading of baz.dwo (contains struct Baz definition)
self.runCmd("type lookup Baz")
debug_stats = self.get_stats()
self.assertEqual(debug_stats["totalLoadedDwoFileCount"], 2)
self.assertEqual(debug_stats["totalDwoFileCount"], 2)
self.assertEqual(debug_stats["modules"][0]["loadedDwoFileCount"], 2)
self.assertEqual(debug_stats["modules"][0]["dwoFileCount"], 2)
-
+
def test_dwp_dwo_file_count(self):
"""
Test "statistics dump" and the loaded dwo file count.
Builds a binary w/ a separate .dwp file and debug_names, and then
verifies the loaded dwo file count is the expected count after running
various commands.
- We expect the DWO file counters to reflect the number of compile units
+ We expect the DWO file counters to reflect the number of compile units
loaded from the DWP file (each representing what was originally a separate DWO file)
"""
da = {"CXX_SOURCES": "third.cpp baz.cpp", "EXE": self.getBuildArtifact("a.out")}
self.build(dictionary=da, debug_info=["dwp", "debug_names"])
self.addTearDownCleanup(dictionary=da)
@@ -635,23 +636,22 @@
# Initially: 2 DWO files available but none loaded yet
self.assertIn("totalLoadedDwoFileCount", debug_stats)
self.assertIn("totalDwoFileCount", debug_stats)
self.assertEqual(debug_stats["totalLoadedDwoFileCount"], 0)
self.assertEqual(debug_stats["totalDwoFileCount"], 2)
-
+
# Setting breakpoint in main triggers parsing of the CU within a.dwp corresponding to third.dwo (contains main function)
self.runCmd("b main")
debug_stats = self.get_stats()
self.assertEqual(debug_stats["totalLoadedDwoFileCount"], 1)
self.assertEqual(debug_stats["totalDwoFileCount"], 2)
-
+
# Type lookup forces parsing of the CU within a.dwp corresponding to baz.dwo (contains struct Baz definition)
self.runCmd("type lookup Baz")
debug_stats = self.get_stats()
self.assertEqual(debug_stats["totalDwoFileCount"], 2)
self.assertEqual(debug_stats["totalLoadedDwoFileCount"], 2)
-
@skipUnlessDarwin
@no_debug_info_test
def test_dsym_binary_has_symfile_in_stats(self):
"""
``````````
</details>
https://github.com/llvm/llvm-project/pull/144424
More information about the lldb-commits
mailing list