Skip to content

Commit e9e842b

Browse files
committed
Avoid adding any framework paths in /System/Library in process_one_module.
The merit of process_one_module can be debated, but these are definitely wrong, system modules must be imported from the SDK instead. <rdar://problem/56280346>
1 parent c951307 commit e9e842b

File tree

4 files changed

+51
-1
lines changed

4 files changed

+51
-1
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
LEVEL = ../../../make
2+
3+
SWIFT_SOURCES := main.swift
4+
5+
SWIFT_FLAGS_EXTRAS := -framwork CoreGraphics
6+
7+
include $(LEVEL)/Makefile.rules
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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 os
6+
import unittest2
7+
8+
9+
class TestSwiftAnyType(lldbtest.TestBase):
10+
11+
mydir = lldbtest.TestBase.compute_mydir(__file__)
12+
13+
@swiftTest
14+
def test_system_framework(self):
15+
"""Make sure no framework paths into /System/Library are added"""
16+
self.build()
17+
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
18+
self, 'break here', lldb.SBFileSpec('main.swift'))
19+
20+
log = self.getBuildArtifact("types.log")
21+
self.runCmd('log enable lldb types -f "%s"' % log)
22+
self.expect("settings set target.use-all-compiler-flags true")
23+
self.expect("expression -- 0")
24+
pos = 0
25+
neg = 0
26+
with open(log, "r") as logfile:
27+
for line in logfile:
28+
if "process_one_module rejecting framework path" in line:
29+
pos += 1
30+
elif "/System/Library/Frameworks" in line:
31+
neg += 1
32+
33+
self.assertGreater(pos, 0, "sanity check failed")
34+
self.assertEqual(neg, 0, "found /System/Library/Frameworks in log")
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import ApplicationServices
2+
3+
func stop() {}
4+
5+
let a = ATSFSSpec()
6+
stop() // break here

lldb/source/Symbol/SwiftASTContext.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2089,7 +2089,10 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(lldb::LanguageType language,
20892089
std::string parent_path =
20902090
module_path.substr(0, framework_offset);
20912091

2092-
if (!StringRef(parent_path).equals("/System/Library") &&
2092+
// Never add framework paths pointing into the
2093+
// system. These modules must be imported from the
2094+
// SDK instead.
2095+
if (!StringRef(parent_path).startswith("/System/Library") &&
20932096
!IsDeviceSupport(parent_path.c_str()))
20942097
framework_search_paths.push_back(
20952098
{std::move(parent_path), /*system*/ false});

0 commit comments

Comments
 (0)