Skip to content

Commit 727373d

Browse files
committed
[LLDB] Prefer serialized bridging headers.
Especially in an explicit modules project, LLDB might not know all the search paths needed to imported the on disk header. rdar://156542351
1 parent b42bc8f commit 727373d

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
SWIFT_SOURCES := main.swift
2+
SWIFT_ENABLE_EXPLICIT_MODULES := Yes
3+
SWIFT_BRIDGING_HEADER := bridging.h
4+
SWIFTFLAGS_EXTRAS = -Xcc -I$(BUILDDIR)/secret
5+
6+
all: secret.h $(EXE)
7+
8+
include Makefile.rules
9+
10+
.PHONY: secret.h
11+
12+
secret.h:
13+
mkdir -p $(BUILDDIR)/secret
14+
echo "struct S { int i; };" > $(BUILDDIR)/secret/secret.h
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import lldb
2+
from lldbsuite.test.decorators import *
3+
import lldbsuite.test.lldbtest as lldbtest
4+
import lldbsuite.test.lldbutil as lldbutil
5+
6+
7+
class TestSwiftExplicitModules(lldbtest.TestBase):
8+
NO_DEBUG_INFO_TESTCASE = True
9+
@swiftTest
10+
def test(self):
11+
"""Test explicit Swift modules with bridging headers"""
12+
self.build()
13+
secret = self.getBuildArtifact("secret")
14+
import shutil
15+
shutil.rmtree(secret)
16+
17+
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
18+
self, 'Set breakpoint here', lldb.SBFileSpec('main.swift'))
19+
log = self.getBuildArtifact("types.log")
20+
self.expect('log enable lldb types -f "%s"' % log)
21+
22+
self.expect("expression s", substrs=['i = 23'])
23+
self.filecheck('platform shell cat "%s"' % log, __file__)
24+
# CHECK: LogConfiguration
25+
# CHECK-NOT: secret
26+
# CHECK: Import
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include "secret.h"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
func main() {
2+
let s = S(i: 23)
3+
print(s) // Set breakpoint here
4+
}
5+
6+
main()

0 commit comments

Comments
 (0)