forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[lldb] Add an expression evaluation test for modules built with ... #9809
Open
augusto2112
wants to merge
2
commits into
swiftlang:stable/20240723
Choose a base branch
from
augusto2112:test-enable-testing
base: stable/20240723
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
SWIFT_SOURCES := main.swift | ||
|
||
all: libPublic.dylib a.out | ||
|
||
include Makefile.rules | ||
LD_EXTRAS = -lPublic -L$(BUILDDIR) | ||
SWIFTFLAGS_EXTRAS = -I$(BUILDDIR) | ||
|
||
libPublic.dylib: Public.swift | ||
"$(MAKE)" MAKE_DSYM=YES CC=$(CC) SWIFTC=$(SWIFTC) \ | ||
ARCH=$(ARCH) DSYMUTIL=$(DSYMUTIL) \ | ||
BASENAME=Public \ | ||
SWIFTFLAGS_EXTRAS="-I$(BUILDDIR) -enable-library-evolution -enable-testing" \ | ||
VPATH=$(SRCDIR) -I $(SRCDIR) \ | ||
DYLIB_ONLY:=YES DYLIB_NAME=Public \ | ||
DYLIB_SWIFT_SOURCES:=Public.swift \ | ||
-f $(MAKEFILE_RULES) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class SomeClass { | ||
let value = 42 | ||
} | ||
|
||
class ClassWithProperty { | ||
private var v = SomeClass() | ||
|
||
func f() { | ||
print("break here") | ||
} | ||
} | ||
|
||
public func entry() { | ||
ClassWithProperty().f() | ||
} |
19 changes: 19 additions & 0 deletions
19
lldb/test/API/lang/swift/enable_testing/TestSwiftEnableTesting.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import lldb | ||
from lldbsuite.test.lldbtest import * | ||
from lldbsuite.test.decorators import * | ||
import lldbsuite.test.lldbutil as lldbutil | ||
|
||
|
||
class TestSwiftEnableTesting(TestBase): | ||
|
||
@skipUnlessDarwin | ||
@swiftTest | ||
def test(self): | ||
"""Test that expression evaluation generates a direct member access to a private property in a module compiled with -enable-library-evolution and -enable-testing""" | ||
|
||
self.build() | ||
target, process, _, _ = lldbutil.run_to_source_breakpoint( | ||
self, "break here", lldb.SBFileSpec("Public.swift"), extra_images=["Public"] | ||
) | ||
|
||
self.expect("expression v", substrs=["Public.SomeClass", "value = 42"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import Public | ||
|
||
entry() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
SWIFT_SOURCES := main.swift | ||
|
||
all: libWithDebInfo.dylib libWithoutDebInfo.dylib a.out | ||
|
||
include Makefile.rules | ||
LD_EXTRAS = -lWithDebInfo -lWithoutDebInfo -L$(BUILDDIR) | ||
SWIFTFLAGS_EXTRAS = -I$(BUILDDIR) | ||
|
||
libWithDebInfo.dylib: WithDebInfo.swift | ||
"$(MAKE)" MAKE_DSYM=YES CC=$(CC) SWIFTC=$(SWIFTC) \ | ||
ARCH=$(ARCH) DSYMUTIL=$(DSYMUTIL) \ | ||
BASENAME=WithDebInfo \ | ||
SWIFTFLAGS_EXTRAS="-I$(BUILDDIR) -enable-library-evolution" \ | ||
VPATH=$(SRCDIR) -I $(SRCDIR) \ | ||
DYLIB_ONLY:=YES DYLIB_NAME=WithDebInfo \ | ||
DYLIB_SWIFT_SOURCES:=WithDebInfo.swift \ | ||
-f $(MAKEFILE_RULES) | ||
|
||
libWithoutDebInfo.dylib: WithoutDebInfo.swift | ||
"$(MAKE)" MAKE_DSYM=YES CC=$(CC) SWIFTC=$(SWIFTC) \ | ||
ARCH=$(ARCH) DSYMUTIL=$(DSYMUTIL) \ | ||
BASENAME=WithoutDebInfo \ | ||
SWIFTFLAGS_EXTRAS="-I$(BUILDDIR) -enable-library-evolution" \ | ||
VPATH=$(SRCDIR) -I $(SRCDIR) \ | ||
DYLIB_ONLY:=YES DYLIB_NAME=WithoutDebInfo \ | ||
DYLIB_SWIFT_SOURCES:=WithoutDebInfo.swift \ | ||
-f $(MAKEFILE_RULES) |
25 changes: 25 additions & 0 deletions
25
lldb/test/API/lang/swift/resilience_other_module/TestSwiftResilienceOtherModule.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import lldb | ||
from lldbsuite.test.lldbtest import * | ||
from lldbsuite.test.decorators import * | ||
import lldbsuite.test.lldbutil as lldbutil | ||
|
||
|
||
class TestSwiftResilienceOtherModule(TestBase): | ||
|
||
@skipUnlessDarwin | ||
@swiftTest | ||
def test_with_debug_info(self): | ||
self.impl('break here with debug info') | ||
|
||
@skipUnlessDarwin | ||
@swiftTest | ||
def test_without_debug_info(self): | ||
self.impl('break here without debug info') | ||
|
||
def impl(self, break_str): | ||
self.build() | ||
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( | ||
self, break_str, lldb.SBFileSpec('main.swift')) | ||
|
||
self.expect("expression s.a", substrs=["Int", "100"]) | ||
self.expect("expression s.b", substrs=["Int", "200"]) |
5 changes: 5 additions & 0 deletions
5
lldb/test/API/lang/swift/resilience_other_module/WithDebInfo.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
public struct S { | ||
public var a = 100 | ||
private var b = 200 | ||
public init() {} | ||
} |
5 changes: 5 additions & 0 deletions
5
lldb/test/API/lang/swift/resilience_other_module/WithoutDebInfo.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
public struct S { | ||
public var a = 100 | ||
private var b = 200 | ||
public init() {} | ||
} |
15 changes: 15 additions & 0 deletions
15
lldb/test/API/lang/swift/resilience_other_module/main.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import WithDebInfo | ||
import WithoutDebInfo | ||
|
||
func withDebugInfo() { | ||
var s = WithDebInfo.S() | ||
print("break here with debug info") | ||
} | ||
|
||
func withoutDebugInfo() { | ||
var s = WithoutDebInfo.S() | ||
print("break here without debug info") | ||
} | ||
|
||
withDebugInfo() | ||
withoutDebugInfo() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
SWIFT_SOURCES := main.swift | ||
SWIFTFLAGS_EXTRAS = -enable-library-evolution | ||
|
||
include Makefile.rules |
15 changes: 15 additions & 0 deletions
15
lldb/test/API/lang/swift/resilience_superclass/TestSwiftResilienceSuperclass.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import lldb | ||
from lldbsuite.test.lldbtest import * | ||
from lldbsuite.test.decorators import * | ||
import lldbsuite.test.lldbutil as lldbutil | ||
|
||
|
||
class TestSwiftResilienceSuperclass(TestBase): | ||
@skipUnlessDarwin | ||
@swiftTest | ||
def test(self): | ||
self.build() | ||
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( | ||
self, 'break here', lldb.SBFileSpec('main.swift')) | ||
|
||
self.expect("expression c.v", substrs=["Int", "42"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import Foundation | ||
|
||
public class SuperClass<T>: NSObject { | ||
var someVar: T | ||
init(_ someVar: T) { | ||
self.someVar = someVar | ||
super.init() | ||
} | ||
} | ||
|
||
class Class<T>: SuperClass<T> { | ||
var v = 42 | ||
|
||
override init(_ t: T) { | ||
super.init(t) | ||
} | ||
} | ||
|
||
|
||
open class OpenSuperClass<T>: NSObject { | ||
var someVar: T | ||
init(_ someVar: T) { | ||
self.someVar = someVar | ||
super.init() | ||
} | ||
} | ||
|
||
class InheritingOpenClass<T>: OpenSuperClass<T> { | ||
var v = 100 | ||
|
||
override init(_ t: T) { | ||
super.init(t) | ||
} | ||
} | ||
|
||
func main() { | ||
let c = Class(true) | ||
let c2 = InheritingOpenClass(true) | ||
print("break here") | ||
} | ||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
SWIFT_SOURCES := main.swift | ||
SWIFTFLAGS_EXTRAS = -enable-library-evolution | ||
|
||
include Makefile.rules |
28 changes: 28 additions & 0 deletions
28
lldb/test/API/lang/swift/resilience_superclass_mod/ModWithClass.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import Foundation | ||
|
||
open class SuperClass<T>: NSObject { | ||
var someVar: T | ||
public init(_ someVar: T) { | ||
self.someVar = someVar | ||
super.init() | ||
} | ||
} | ||
|
||
class Class<T>: SuperClass<T> { | ||
var v = 42 | ||
|
||
override init(_ t: T) { | ||
super.init(t) | ||
} | ||
|
||
func f() -> Int { | ||
let abc = v | ||
return v | ||
} | ||
} | ||
|
||
public func entry() { | ||
let c = Class(true) | ||
print("break here") | ||
} | ||
|
15 changes: 15 additions & 0 deletions
15
lldb/test/API/lang/swift/resilience_superclass_mod/TestSwiftResilienceSuperclassMod.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import lldb | ||
from lldbsuite.test.lldbtest import * | ||
from lldbsuite.test.decorators import * | ||
import lldbsuite.test.lldbutil as lldbutil | ||
|
||
|
||
class TestSwiftResilienceSuperclassMod(TestBase): | ||
@skipUnlessDarwin | ||
@swiftTest | ||
def test(self): | ||
self.build() | ||
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( | ||
self, 'break here', lldb.SBFileSpec('main.swift')) | ||
|
||
self.expect("expression c.v", substrs=["Int", "42"]) |
24 changes: 24 additions & 0 deletions
24
lldb/test/API/lang/swift/resilience_superclass_mod/main.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import Foundation | ||
|
||
public class SuperClass<T>: NSObject { | ||
var someVar: T | ||
init(_ someVar: T) { | ||
self.someVar = someVar | ||
super.init() | ||
} | ||
} | ||
|
||
class Class<T>: SuperClass<T> { | ||
var v = 42 | ||
|
||
override init(_ t: T) { | ||
super.init(t) | ||
} | ||
} | ||
|
||
func main() { | ||
let c = Class(true) | ||
print("break here") | ||
} | ||
|
||
main() |
28 changes: 28 additions & 0 deletions
28
lldb/test/API/lang/swift/resilience_superclass_other_mod/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
SWIFT_SOURCES := main.swift | ||
|
||
all: libModWithClass.dylib libModWithSuper.dylib a.out | ||
|
||
include Makefile.rules | ||
LD_EXTRAS = -lModWithClass -L$(BUILDDIR) | ||
SWIFTFLAGS_EXTRAS = -I$(BUILDDIR) | ||
|
||
libModWithClass.dylib: ModWithClass.swift libModWithSuper.dylib | ||
"$(MAKE)" MAKE_DSYM=YES CC=$(CC) SWIFTC=$(SWIFTC) \ | ||
ARCH=$(ARCH) DSYMUTIL=$(DSYMUTIL) \ | ||
BASENAME=ModWithClass \ | ||
SWIFTFLAGS_EXTRAS="-I$(BUILDDIR) -enable-library-evolution" \ | ||
LD_EXTRAS="-lModWithSuper -L$(BUILDDIR)" \ | ||
VPATH=$(SRCDIR) -I $(SRCDIR) \ | ||
DYLIB_ONLY:=YES DYLIB_NAME=ModWithClass \ | ||
DYLIB_SWIFT_SOURCES:=ModWithClass.swift \ | ||
-f $(MAKEFILE_RULES) | ||
|
||
libModWithSuper.dylib: ModWithSuper.swift | ||
"$(MAKE)" MAKE_DSYM=YES CC=$(CC) SWIFTC=$(SWIFTC) \ | ||
ARCH=$(ARCH) DSYMUTIL=$(DSYMUTIL) \ | ||
BASENAME=ModWithSuper \ | ||
SWIFTFLAGS_EXTRAS="-I$(BUILDDIR) -enable-library-evolution" \ | ||
VPATH=$(SRCDIR) -I $(SRCDIR) \ | ||
DYLIB_ONLY:=YES DYLIB_NAME=ModWithSuper \ | ||
DYLIB_SWIFT_SOURCES:=ModWithSuper.swift \ | ||
-f $(MAKEFILE_RULES) |
20 changes: 20 additions & 0 deletions
20
lldb/test/API/lang/swift/resilience_superclass_other_mod/ModWithClass.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import ModWithSuper | ||
|
||
class Class<T>: SuperClass<T> { | ||
var v = 42 | ||
|
||
override init(_ t: T) { | ||
super.init(t) | ||
} | ||
|
||
func f() -> Int { | ||
let abc = v | ||
return v | ||
} | ||
} | ||
|
||
public func entry() { | ||
let c = Class(true) | ||
print("break here") | ||
} | ||
|
9 changes: 9 additions & 0 deletions
9
lldb/test/API/lang/swift/resilience_superclass_other_mod/ModWithSuper.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Foundation | ||
|
||
open class SuperClass<T>: NSObject { | ||
var someVar: T | ||
public init(_ someVar: T) { | ||
self.someVar = someVar | ||
super.init() | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...t/API/lang/swift/resilience_superclass_other_mod/TestSwiftResilienceSuperclassOtherMod.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import lldb | ||
from lldbsuite.test.lldbtest import * | ||
from lldbsuite.test.decorators import * | ||
import lldbsuite.test.lldbutil as lldbutil | ||
|
||
|
||
class TestSwiftResilienceSuperclassOtherMod(TestBase): | ||
@skipUnlessDarwin | ||
@swiftTest | ||
def test(self): | ||
self.build() | ||
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint( | ||
self, 'break here', lldb.SBFileSpec('ModWithClass.swift')) | ||
|
||
self.expect("expression c.v", substrs=["Int", "42"]) |
3 changes: 3 additions & 0 deletions
3
lldb/test/API/lang/swift/resilience_superclass_other_mod/main.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import ModWithClass | ||
|
||
entry() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.