Skip to content

Commit 69ca168

Browse files
committed
Add a test to ensure that no SwiftASTContext is initialized for setting a breakpoint.
rdar://81717792
1 parent 4656cc1 commit 69ca168

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
SWIFT_SOURCES := main.swift
2+
include Makefile.rules
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import lldb
2+
from lldbsuite.test.decorators import *
3+
import lldbsuite.test.lldbtest as lldbtest
4+
import lldbsuite.test.lldbutil as lldbutil
5+
import unittest2
6+
7+
class TestSwiftReflectionLoading(lldbtest.TestBase):
8+
mydir = lldbtest.TestBase.compute_mydir(__file__)
9+
10+
@swiftTest
11+
def test(self):
12+
"""Test that no SwiftASTContext is initialized just to stop at a breakpoint"""
13+
self.build()
14+
15+
log = self.getBuildArtifact("types.log")
16+
self.runCmd('log enable lldb types -f "%s"' % log)
17+
18+
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
19+
self, 'Set breakpoint here', lldb.SBFileSpec('main.swift'))
20+
21+
# Scan through the types log.
22+
logfile = open(log, "r")
23+
found_typeref = 0
24+
found_astctx = 0
25+
for line in logfile:
26+
if 'TypeSystemSwiftTypeRef("a.out")::TypeSystemSwiftTypeRef()' in line:
27+
found_typeref += 1
28+
if 'SwiftASTContext' in line:
29+
found_astctx += 1
30+
self.assertEqual(found_typeref, 1)
31+
self.assertEqual(found_astctx, 0)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
class C {
3+
func f() {
4+
{
5+
print("hello from a complicated context") // Set breakpoint here
6+
}()
7+
}
8+
}
9+
10+
let c = C()
11+
c.f()

0 commit comments

Comments
 (0)