[Lldb-commits] [lldb] 5be12e1 - [LLDB] Run API tests with PDB too (#149305)
via lldb-commits
lldb-commits at lists.llvm.org
Tue Nov 4 11:23:38 PST 2025
Author: nerix
Date: 2025-11-04T20:23:33+01:00
New Revision: 5be12e1c95e897a9da713d49255868eea7ad60fa
URL: https://github.com/llvm/llvm-project/commit/5be12e1c95e897a9da713d49255868eea7ad60fa
DIFF: https://github.com/llvm/llvm-project/commit/5be12e1c95e897a9da713d49255868eea7ad60fa.diff
LOG: [LLDB] Run API tests with PDB too (#149305)
From
https://github.com/llvm/llvm-project/pull/148554#issuecomment-3083261858
- this adds an option for API tests to be run with the both PDB readers
on Windows. As there are a lot of failures with PDB, this is an opt-in
per test.
To get PDB, `-g -gcodeview` has to be used on Clang. `-gcodeview` alone
isn't enough, because it won't cause clang to pass `-debug` to the
linker.
#149498 tracks the (currently) failing tests.
Added:
lldb/test/API/test_utils/pdb/Makefile
lldb/test/API/test_utils/pdb/TestPdb.py
lldb/test/API/test_utils/pdb/main.cpp
Modified:
lldb/packages/Python/lldbsuite/test/builders/builder.py
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/packages/Python/lldbsuite/test/make/Makefile.rules
lldb/packages/Python/lldbsuite/test/test_categories.py
Removed:
################################################################################
diff --git a/lldb/packages/Python/lldbsuite/test/builders/builder.py b/lldb/packages/Python/lldbsuite/test/builders/builder.py
index 96c7b3987d8a1..024c9f1c7e435 100644
--- a/lldb/packages/Python/lldbsuite/test/builders/builder.py
+++ b/lldb/packages/Python/lldbsuite/test/builders/builder.py
@@ -258,6 +258,7 @@ def _getDebugInfoArgs(self, debug_info):
"gmodules": {"MAKE_DSYM": "NO", "MAKE_GMODULES": "YES"},
"debug_names": {"MAKE_DEBUG_NAMES": "YES"},
"dwp": {"MAKE_DSYM": "NO", "MAKE_DWP": "YES"},
+ "pdb": {"MAKE_PDB": "YES"},
}
# Collect all flags, with later options overriding earlier ones
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index b92de941c4124..8c1eea97620e2 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1791,6 +1791,11 @@ def no_reason(_):
if can_replicate
]
+ # PDB is off by default, because it has a lot of failures right now.
+ # See llvm.org/pr149498
+ if original_testcase.TEST_WITH_PDB_DEBUG_INFO:
+ dbginfo_categories.append("pdb")
+
xfail_for_debug_info_cat_fn = getattr(
attrvalue, "__xfail_for_debug_info_cat_fn__", no_reason
)
@@ -1878,6 +1883,13 @@ class TestBase(Base, metaclass=LLDBTestCaseFactory):
# test multiple times with various debug info types.
NO_DEBUG_INFO_TESTCASE = False
+ TEST_WITH_PDB_DEBUG_INFO = False
+ """
+ Subclasses can set this to True to test with PDB in addition to the other debug info
+ types. This id off by default because many tests will fail due to missing functionality in PDB.
+ See llvm.org/pr149498.
+ """
+
def generateSource(self, source):
template = source + ".template"
temp = os.path.join(self.getSourceDir(), template)
diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index 28cae54776ac8..b3822db162a0b 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -249,6 +249,10 @@ ifeq ($(CC_TYPE), clang)
MODULE_DEBUG_INFO_FLAGS += -gmodules
endif
+ifeq "$(MAKE_PDB)" "YES"
+ DEBUG_INFO_FLAG ?= -g -gcodeview
+endif
+
# If the OS is Windows, we need to pass -gdwarf to clang, otherwise it will build
# with codeview by default but all the tests rely on dwarf.
ifeq "$(OS)" "Windows_NT"
diff --git a/lldb/packages/Python/lldbsuite/test/test_categories.py b/lldb/packages/Python/lldbsuite/test/test_categories.py
index 1f6e8a78e0c0d..b8a764fb3349a 100644
--- a/lldb/packages/Python/lldbsuite/test/test_categories.py
+++ b/lldb/packages/Python/lldbsuite/test/test_categories.py
@@ -12,7 +12,13 @@
# Key: Category name
# Value: should be used in lldbtest's debug-info replication
-debug_info_categories = {"dwarf": True, "dwo": True, "dsym": True, "gmodules": False}
+debug_info_categories = {
+ "dwarf": True,
+ "dwo": True,
+ "dsym": True,
+ "pdb": False,
+ "gmodules": False,
+}
all_categories = {
"basic_process": "Basic process execution sniff tests.",
@@ -34,6 +40,7 @@
"lldb-dap": "Tests for the Debug Adapter Protocol with lldb-dap",
"llgs": "Tests for the gdb-server functionality of lldb-server",
"msvcstl": "Test for MSVC STL data formatters",
+ "pdb": "Tests that can be run with PDB debug information",
"pexpect": "Tests requiring the pexpect library to be available",
"objc": "Tests related to the Objective-C programming language support",
"pyapi": "Tests related to the Python API",
@@ -65,6 +72,8 @@ def is_supported_on_platform(category, platform, compiler_path):
if platform not in ["darwin", "macosx", "ios", "watchos", "tvos", "bridgeos"]:
return False
return gmodules.is_compiler_clang_with_gmodules(compiler_path)
+ elif category == "pdb":
+ return platform == "windows"
return True
diff --git a/lldb/test/API/test_utils/pdb/Makefile b/lldb/test/API/test_utils/pdb/Makefile
new file mode 100644
index 0000000000000..99998b20bcb05
--- /dev/null
+++ b/lldb/test/API/test_utils/pdb/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
diff --git a/lldb/test/API/test_utils/pdb/TestPdb.py b/lldb/test/API/test_utils/pdb/TestPdb.py
new file mode 100644
index 0000000000000..bd3a9d0c34ab3
--- /dev/null
+++ b/lldb/test/API/test_utils/pdb/TestPdb.py
@@ -0,0 +1,18 @@
+"""
+Test PDB enabled tests
+"""
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+
+class TestBuildMethod(TestBase):
+ TEST_WITH_PDB_DEBUG_INFO = True
+
+ def test(self):
+ self.build()
+ self.assertTrue(self.dbg.CreateTarget(self.getBuildArtifact()))
+ if self.getDebugInfo() == "pdb":
+ self.expect(
+ "target modules dump symfile", patterns=["SymbolFile (native-)?pdb"]
+ )
diff --git a/lldb/test/API/test_utils/pdb/main.cpp b/lldb/test/API/test_utils/pdb/main.cpp
new file mode 100644
index 0000000000000..76e8197013aab
--- /dev/null
+++ b/lldb/test/API/test_utils/pdb/main.cpp
@@ -0,0 +1 @@
+int main() { return 0; }
More information about the lldb-commits
mailing list