Skip to content

Commit ffc2759

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 ffc2759

File tree

6 files changed

+56
-0
lines changed

6 files changed

+56
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
struct M { int j; };
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: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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("frame variable s", substrs=['i = 23'])
23+
self.expect("frame variable m", substrs=['j = 42'])
24+
self.expect("expression s", substrs=['i = 23'])
25+
self.expect("expression m", substrs=['j = 42'])
26+
self.filecheck('platform shell cat "%s"' % log, __file__)
27+
# CHECK: LogConfiguration
28+
# CHECK-NOT: secret
29+
# CHECK: Import
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// A non-modular header.
2+
#include "secret.h"
3+
// A modular header.
4+
#include "M.h"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
func main() {
2+
let s = S(i: 23)
3+
let m = M(j: 42)
4+
print(s) // Set breakpoint here
5+
}
6+
7+
main()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module M { header "M.h" }

0 commit comments

Comments
 (0)