Skip to content

Commit 1fd0915

Browse files
authored
Merge pull request #9809 from augusto2112/test-enable-testing
[lldb] Add an expression evaluation test for modules built with ...
2 parents 5805166 + e94df26 commit 1fd0915

21 files changed

+339
-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()
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
SWIFT_SOURCES := main.swift
2+
3+
all: libWithDebInfo.dylib libWithoutDebInfo.dylib a.out
4+
5+
include Makefile.rules
6+
LD_EXTRAS = -lWithDebInfo -lWithoutDebInfo -L$(BUILDDIR)
7+
SWIFTFLAGS_EXTRAS = -I$(BUILDDIR)
8+
9+
libWithDebInfo.dylib: WithDebInfo.swift
10+
"$(MAKE)" MAKE_DSYM=YES CC=$(CC) SWIFTC=$(SWIFTC) \
11+
ARCH=$(ARCH) DSYMUTIL=$(DSYMUTIL) \
12+
BASENAME=WithDebInfo \
13+
SWIFTFLAGS_EXTRAS="-I$(BUILDDIR) -enable-library-evolution" \
14+
VPATH=$(SRCDIR) -I $(SRCDIR) \
15+
DYLIB_ONLY:=YES DYLIB_NAME=WithDebInfo \
16+
DYLIB_SWIFT_SOURCES:=WithDebInfo.swift \
17+
-f $(MAKEFILE_RULES)
18+
19+
libWithoutDebInfo.dylib: WithoutDebInfo.swift
20+
"$(MAKE)" MAKE_DSYM=YES CC=$(CC) SWIFTC=$(SWIFTC) \
21+
ARCH=$(ARCH) DSYMUTIL=$(DSYMUTIL) \
22+
BASENAME=WithoutDebInfo \
23+
SWIFTFLAGS_EXTRAS="-I$(BUILDDIR) -enable-library-evolution" \
24+
VPATH=$(SRCDIR) -I $(SRCDIR) \
25+
DYLIB_ONLY:=YES DYLIB_NAME=WithoutDebInfo \
26+
DYLIB_SWIFT_SOURCES:=WithoutDebInfo.swift \
27+
-f $(MAKEFILE_RULES)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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 TestSwiftResilienceOtherModule(TestBase):
8+
9+
@skipUnlessDarwin
10+
@swiftTest
11+
def test_with_debug_info(self):
12+
self.impl('break here with debug info')
13+
14+
@skipUnlessDarwin
15+
@swiftTest
16+
def test_without_debug_info(self):
17+
self.impl('break here without debug info')
18+
19+
def impl(self, break_str):
20+
self.build()
21+
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
22+
self, break_str, lldb.SBFileSpec('main.swift'))
23+
24+
self.expect("expression s.a", substrs=["Int", "100"])
25+
self.expect("expression s.b", substrs=["Int", "200"])
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
public struct S {
2+
public var a = 100
3+
private var b = 200
4+
public init() {}
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
public struct S {
2+
public var a = 100
3+
private var b = 200
4+
public init() {}
5+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import WithDebInfo
2+
import WithoutDebInfo
3+
4+
func withDebugInfo() {
5+
var s = WithDebInfo.S()
6+
print("break here with debug info")
7+
}
8+
9+
func withoutDebugInfo() {
10+
var s = WithoutDebInfo.S()
11+
print("break here without debug info")
12+
}
13+
14+
withDebugInfo()
15+
withoutDebugInfo()
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
SWIFT_SOURCES := main.swift
2+
SWIFTFLAGS_EXTRAS = -enable-library-evolution
3+
4+
include Makefile.rules
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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 TestSwiftResilienceSuperclass(TestBase):
8+
@skipUnlessDarwin
9+
@swiftTest
10+
def test(self):
11+
self.build()
12+
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
13+
self, 'break here', lldb.SBFileSpec('main.swift'))
14+
15+
self.expect("expression c.v", substrs=["Int", "42"])
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import Foundation
2+
3+
public class SuperClass<T>: NSObject {
4+
var someVar: T
5+
init(_ someVar: T) {
6+
self.someVar = someVar
7+
super.init()
8+
}
9+
}
10+
11+
class Class<T>: SuperClass<T> {
12+
var v = 42
13+
14+
override init(_ t: T) {
15+
super.init(t)
16+
}
17+
}
18+
19+
20+
open class OpenSuperClass<T>: NSObject {
21+
var someVar: T
22+
init(_ someVar: T) {
23+
self.someVar = someVar
24+
super.init()
25+
}
26+
}
27+
28+
class InheritingOpenClass<T>: OpenSuperClass<T> {
29+
var v = 100
30+
31+
override init(_ t: T) {
32+
super.init(t)
33+
}
34+
}
35+
36+
func main() {
37+
let c = Class(true)
38+
let c2 = InheritingOpenClass(true)
39+
print("break here")
40+
}
41+
42+
main()
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
SWIFT_SOURCES := main.swift
2+
SWIFTFLAGS_EXTRAS = -enable-library-evolution
3+
4+
include Makefile.rules
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import Foundation
2+
3+
open class SuperClass<T>: NSObject {
4+
var someVar: T
5+
public init(_ someVar: T) {
6+
self.someVar = someVar
7+
super.init()
8+
}
9+
}
10+
11+
class Class<T>: SuperClass<T> {
12+
var v = 42
13+
14+
override init(_ t: T) {
15+
super.init(t)
16+
}
17+
18+
func f() -> Int {
19+
let abc = v
20+
return v
21+
}
22+
}
23+
24+
public func entry() {
25+
let c = Class(true)
26+
print("break here")
27+
}
28+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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 TestSwiftResilienceSuperclassMod(TestBase):
8+
@skipUnlessDarwin
9+
@swiftTest
10+
def test(self):
11+
self.build()
12+
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
13+
self, 'break here', lldb.SBFileSpec('main.swift'))
14+
15+
self.expect("expression c.v", substrs=["Int", "42"])
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import Foundation
2+
3+
public class SuperClass<T>: NSObject {
4+
var someVar: T
5+
init(_ someVar: T) {
6+
self.someVar = someVar
7+
super.init()
8+
}
9+
}
10+
11+
class Class<T>: SuperClass<T> {
12+
var v = 42
13+
14+
override init(_ t: T) {
15+
super.init(t)
16+
}
17+
}
18+
19+
func main() {
20+
let c = Class(true)
21+
print("break here")
22+
}
23+
24+
main()
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
SWIFT_SOURCES := main.swift
2+
3+
all: libModWithClass.dylib libModWithSuper.dylib a.out
4+
5+
include Makefile.rules
6+
LD_EXTRAS = -lModWithClass -L$(BUILDDIR)
7+
SWIFTFLAGS_EXTRAS = -I$(BUILDDIR)
8+
9+
libModWithClass.dylib: ModWithClass.swift libModWithSuper.dylib
10+
"$(MAKE)" MAKE_DSYM=YES CC=$(CC) SWIFTC=$(SWIFTC) \
11+
ARCH=$(ARCH) DSYMUTIL=$(DSYMUTIL) \
12+
BASENAME=ModWithClass \
13+
SWIFTFLAGS_EXTRAS="-I$(BUILDDIR) -enable-library-evolution" \
14+
LD_EXTRAS="-lModWithSuper -L$(BUILDDIR)" \
15+
VPATH=$(SRCDIR) -I $(SRCDIR) \
16+
DYLIB_ONLY:=YES DYLIB_NAME=ModWithClass \
17+
DYLIB_SWIFT_SOURCES:=ModWithClass.swift \
18+
-f $(MAKEFILE_RULES)
19+
20+
libModWithSuper.dylib: ModWithSuper.swift
21+
"$(MAKE)" MAKE_DSYM=YES CC=$(CC) SWIFTC=$(SWIFTC) \
22+
ARCH=$(ARCH) DSYMUTIL=$(DSYMUTIL) \
23+
BASENAME=ModWithSuper \
24+
SWIFTFLAGS_EXTRAS="-I$(BUILDDIR) -enable-library-evolution" \
25+
VPATH=$(SRCDIR) -I $(SRCDIR) \
26+
DYLIB_ONLY:=YES DYLIB_NAME=ModWithSuper \
27+
DYLIB_SWIFT_SOURCES:=ModWithSuper.swift \
28+
-f $(MAKEFILE_RULES)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import ModWithSuper
2+
3+
class Class<T>: SuperClass<T> {
4+
var v = 42
5+
6+
override init(_ t: T) {
7+
super.init(t)
8+
}
9+
10+
func f() -> Int {
11+
let abc = v
12+
return v
13+
}
14+
}
15+
16+
public func entry() {
17+
let c = Class(true)
18+
print("break here")
19+
}
20+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import Foundation
2+
3+
open class SuperClass<T>: NSObject {
4+
var someVar: T
5+
public init(_ someVar: T) {
6+
self.someVar = someVar
7+
super.init()
8+
}
9+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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 TestSwiftResilienceSuperclassOtherMod(TestBase):
8+
@skipUnlessDarwin
9+
@swiftTest
10+
def test(self):
11+
self.build()
12+
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
13+
self, 'break here', lldb.SBFileSpec('ModWithClass.swift'))
14+
15+
self.expect("expression c.v", substrs=["Int", "42"])
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import ModWithClass
2+
3+
entry()

0 commit comments

Comments
 (0)