Skip to content

Commit 07d34d0

Browse files
authored
Merge pull request #47 from adrian-prantl/56280346-5.1
Avoid adding any framework paths in /System/Library in process_one_mo…
2 parents 5bdc08a + cfcf3c2 commit 07d34d0

File tree

4 files changed

+51
-1
lines changed

4 files changed

+51
-1
lines changed
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
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")
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

+4-1
Original file line numberDiff line numberDiff line change
@@ -2124,7 +2124,10 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(lldb::LanguageType language,
21242124
std::string parent_path =
21252125
module_path.substr(0, framework_offset);
21262126

2127-
if (!StringRef(parent_path).equals("/System/Library") &&
2127+
// Never add framework paths pointing into the
2128+
// system. These modules must be imported from the
2129+
// SDK instead.
2130+
if (!StringRef(parent_path).startswith("/System/Library") &&
21282131
!IsDeviceSupport(parent_path.c_str()))
21292132
framework_search_paths.push_back(
21302133
{std::move(parent_path), /*system*/ false});

0 commit comments

Comments
 (0)