Skip to content

Commit 10d72fa

Browse files
committed
[lldb] Add an expression evaluation test for modules built with
-enable-testing and -enable-library-evolution -enable-testing affects the visibility of types, which together with -enable-library-evolution may cause the compiler embedded in LLDB to generate incorrect code on expression evaluation.
1 parent 9eb07c4 commit 10d72fa

File tree

4 files changed

+55
-0
lines changed

4 files changed

+55
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
SWIFT_SOURCES := main.swift
2+
3+
all: libPublic.dylib a.out
4+
5+
include Makefile.rules
6+
LD_EXTRAS = -lPublic -L$(BUILDDIR)
7+
SWIFTFLAGS_EXTRAS = -I$(BUILDDIR)
8+
9+
libPublic.dylib: Public.swift
10+
"$(MAKE)" MAKE_DSYM=YES CC=$(CC) SWIFTC=$(SWIFTC) \
11+
ARCH=$(ARCH) DSYMUTIL=$(DSYMUTIL) \
12+
BASENAME=Public \
13+
SWIFTFLAGS_EXTRAS="-I$(BUILDDIR) -enable-library-evolution -enable-testing" \
14+
VPATH=$(SRCDIR) -I $(SRCDIR) \
15+
DYLIB_ONLY:=YES DYLIB_NAME=Public \
16+
DYLIB_SWIFT_SOURCES:=Public.swift \
17+
-f $(MAKEFILE_RULES)
18+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class SomeClass {
2+
let value = 42
3+
}
4+
5+
class ClassWithProperty {
6+
private var v = SomeClass()
7+
8+
func f() {
9+
print("break here")
10+
}
11+
}
12+
13+
public func entry() {
14+
ClassWithProperty().f()
15+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import lldb
2+
from lldbsuite.test.lldbtest import *
3+
from lldbsuite.test.decorators import *
4+
import lldbsuite.test.lldbutil as lldbutil
5+
6+
7+
class TestSwiftEnableTesting(TestBase):
8+
9+
@skipUnlessDarwin
10+
@swiftTest
11+
def test(self):
12+
"""Test that expression evaluation generates a direct member access to a private property in a module compiled with -enable-library-evolution and -enable-testing"""
13+
14+
self.build()
15+
target, process, _, _ = lldbutil.run_to_source_breakpoint(
16+
self, "break here", lldb.SBFileSpec("Public.swift"), extra_images=["Public"]
17+
)
18+
19+
self.expect("expression v", substrs=["Public.SomeClass", "value = 42"])
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import Public
2+
3+
entry()

0 commit comments

Comments
 (0)