Skip to content

Commit 5be12e1

Browse files
authored
[LLDB] Run API tests with PDB too (#149305)
From #148554 (comment) - 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.
1 parent e5f191e commit 5be12e1

File tree

7 files changed

+49
-1
lines changed

7 files changed

+49
-1
lines changed

lldb/packages/Python/lldbsuite/test/builders/builder.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ def _getDebugInfoArgs(self, debug_info):
258258
"gmodules": {"MAKE_DSYM": "NO", "MAKE_GMODULES": "YES"},
259259
"debug_names": {"MAKE_DEBUG_NAMES": "YES"},
260260
"dwp": {"MAKE_DSYM": "NO", "MAKE_DWP": "YES"},
261+
"pdb": {"MAKE_PDB": "YES"},
261262
}
262263

263264
# Collect all flags, with later options overriding earlier ones

lldb/packages/Python/lldbsuite/test/lldbtest.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,6 +1791,11 @@ def no_reason(_):
17911791
if can_replicate
17921792
]
17931793

1794+
# PDB is off by default, because it has a lot of failures right now.
1795+
# See llvm.org/pr149498
1796+
if original_testcase.TEST_WITH_PDB_DEBUG_INFO:
1797+
dbginfo_categories.append("pdb")
1798+
17941799
xfail_for_debug_info_cat_fn = getattr(
17951800
attrvalue, "__xfail_for_debug_info_cat_fn__", no_reason
17961801
)
@@ -1878,6 +1883,13 @@ class TestBase(Base, metaclass=LLDBTestCaseFactory):
18781883
# test multiple times with various debug info types.
18791884
NO_DEBUG_INFO_TESTCASE = False
18801885

1886+
TEST_WITH_PDB_DEBUG_INFO = False
1887+
"""
1888+
Subclasses can set this to True to test with PDB in addition to the other debug info
1889+
types. This id off by default because many tests will fail due to missing functionality in PDB.
1890+
See llvm.org/pr149498.
1891+
"""
1892+
18811893
def generateSource(self, source):
18821894
template = source + ".template"
18831895
temp = os.path.join(self.getSourceDir(), template)

lldb/packages/Python/lldbsuite/test/make/Makefile.rules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,10 @@ ifeq ($(CC_TYPE), clang)
249249
MODULE_DEBUG_INFO_FLAGS += -gmodules
250250
endif
251251

252+
ifeq "$(MAKE_PDB)" "YES"
253+
DEBUG_INFO_FLAG ?= -g -gcodeview
254+
endif
255+
252256
# If the OS is Windows, we need to pass -gdwarf to clang, otherwise it will build
253257
# with codeview by default but all the tests rely on dwarf.
254258
ifeq "$(OS)" "Windows_NT"

lldb/packages/Python/lldbsuite/test/test_categories.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@
1212

1313
# Key: Category name
1414
# Value: should be used in lldbtest's debug-info replication
15-
debug_info_categories = {"dwarf": True, "dwo": True, "dsym": True, "gmodules": False}
15+
debug_info_categories = {
16+
"dwarf": True,
17+
"dwo": True,
18+
"dsym": True,
19+
"pdb": False,
20+
"gmodules": False,
21+
}
1622

1723
all_categories = {
1824
"basic_process": "Basic process execution sniff tests.",
@@ -34,6 +40,7 @@
3440
"lldb-dap": "Tests for the Debug Adapter Protocol with lldb-dap",
3541
"llgs": "Tests for the gdb-server functionality of lldb-server",
3642
"msvcstl": "Test for MSVC STL data formatters",
43+
"pdb": "Tests that can be run with PDB debug information",
3744
"pexpect": "Tests requiring the pexpect library to be available",
3845
"objc": "Tests related to the Objective-C programming language support",
3946
"pyapi": "Tests related to the Python API",
@@ -65,6 +72,8 @@ def is_supported_on_platform(category, platform, compiler_path):
6572
if platform not in ["darwin", "macosx", "ios", "watchos", "tvos", "bridgeos"]:
6673
return False
6774
return gmodules.is_compiler_clang_with_gmodules(compiler_path)
75+
elif category == "pdb":
76+
return platform == "windows"
6877
return True
6978

7079

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CXX_SOURCES := main.cpp
2+
3+
include Makefile.rules
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"""
2+
Test PDB enabled tests
3+
"""
4+
5+
from lldbsuite.test.decorators import *
6+
from lldbsuite.test.lldbtest import *
7+
8+
9+
class TestBuildMethod(TestBase):
10+
TEST_WITH_PDB_DEBUG_INFO = True
11+
12+
def test(self):
13+
self.build()
14+
self.assertTrue(self.dbg.CreateTarget(self.getBuildArtifact()))
15+
if self.getDebugInfo() == "pdb":
16+
self.expect(
17+
"target modules dump symfile", patterns=["SymbolFile (native-)?pdb"]
18+
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
int main() { return 0; }

0 commit comments

Comments
 (0)