Skip to content

Commit b73bab4

Browse files
author
git apple-llvm automerger
committed
Merge commit '36bb0744e937' from swift/release/5.3 into swift/master
2 parents 94e7039 + 36bb074 commit b73bab4

File tree

6 files changed

+43
-38
lines changed

6 files changed

+43
-38
lines changed

clang/tools/libclang/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ set(LIBS
5151
clangSerialization
5252
clangTooling
5353
clangToolingRefactor
54+
LLVMOption
5455
LLVMSupport
5556
)
5657

lldb/test/API/macosx/simulator/TestSimulatorPlatform.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,28 @@ def check_debugserver(self, log, expected_platform, expected_version):
2727
"""scan the debugserver packet log"""
2828
logfile = open(log, "r")
2929
dylib_info = None
30-
response = False
30+
process_info_ostype = None
31+
expect_dylib_info_response = False
32+
expect_process_info_response = False
3133
for line in logfile:
32-
if response:
34+
if expect_dylib_info_response:
3335
while line[0] != '$':
3436
line = line[1:]
3537
line = line[1:]
3638
# Unescape '}'.
3739
dylib_info = json.loads(line.replace('}]','}')[:-4])
38-
response = False
40+
expect_dylib_info_response = False
3941
if 'send packet: $jGetLoadedDynamicLibrariesInfos:{' in line:
40-
response = True
41-
42+
expect_dylib_info_response = True
43+
if expect_process_info_response:
44+
for pair in line.split(';'):
45+
keyval = pair.split(':')
46+
if len(keyval) == 2 and keyval[0] == 'ostype':
47+
process_info_ostype = keyval[1]
48+
if 'send packet: $qProcessInfo#' in line:
49+
expect_process_info_response = True
50+
51+
self.assertEquals(process_info_ostype, expected_platform)
4252
self.assertTrue(dylib_info)
4353
aout_info = None
4454
for image in dylib_info['images']:

lldb/tools/debugserver/source/DNB.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1392,7 +1392,10 @@ const char *DNBGetDeploymentInfo(nub_process_t pid,
13921392
uint32_t& patch_version) {
13931393
MachProcessSP procSP;
13941394
if (GetProcessSP(pid, procSP)) {
1395-
// FIXME: This doesn't correct for older ios simulator and macCatalyst.
1395+
// FIXME: This doesn't return the correct result when xctest (a
1396+
// macOS binary) is loaded with the macCatalyst dyld platform
1397+
// override. The image info corrects for this, but qProcessInfo
1398+
// will return what is in the binary.
13961399
auto info = procSP->GetDeploymentInfo(lc, load_command_address);
13971400
major_version = info.major_version;
13981401
minor_version = info.minor_version;

lldb/tools/debugserver/source/MacOSX/MachProcess.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,6 @@ class MachProcess {
236236
operator bool() { return platform > 0; }
237237
/// The Mach-O platform type;
238238
unsigned char platform = 0;
239-
/// Pre-LC_BUILD_VERSION files don't disambiguate between ios and ios
240-
/// simulator.
241-
bool maybe_simulator = false;
242239
uint32_t major_version = 0;
243240
uint32_t minor_version = 0;
244241
uint32_t patch_version = 0;

lldb/tools/debugserver/source/MacOSX/MachProcess.mm

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,28 @@ static bool FBSAddEventDataToOptions(NSMutableDictionary *options,
613613
info.major_version = vers_cmd.version >> 16;
614614
info.minor_version = (vers_cmd.version >> 8) & 0xffu;
615615
info.patch_version = vers_cmd.version & 0xffu;
616-
info.maybe_simulator = true;
616+
617+
// Disambiguate legacy simulator platforms.
618+
#if (defined(__x86_64__) || defined(__i386__))
619+
// If we are running on Intel macOS, it is safe to assume this is
620+
// really a back-deploying simulator binary.
621+
switch (info.platform) {
622+
case PLATFORM_IOS:
623+
info.platform = PLATFORM_IOSSIMULATOR;
624+
break;
625+
case PLATFORM_TVOS:
626+
info.platform = PLATFORM_TVOSSIMULATOR;
627+
break;
628+
case PLATFORM_WATCHOS:
629+
info.platform = PLATFORM_WATCHOSSIMULATOR;
630+
break;
631+
}
632+
#else
633+
// On an Apple Silicon macOS host, there is no ambiguity. The only
634+
// binaries that use legacy load commands are back-deploying
635+
// native iOS binaries. All simulator binaries use the newer,
636+
// unambiguous LC_BUILD_VERSION load commands.
637+
#endif
617638
};
618639
switch (cmd) {
619640
case LC_VERSION_MIN_IPHONEOS:
@@ -774,34 +795,6 @@ static bool FBSAddEventDataToOptions(NSMutableDictionary *options,
774795
uuid_copy(inf.uuid, uuidcmd.uuid);
775796
}
776797
if (DeploymentInfo deployment_info = GetDeploymentInfo(lc, load_cmds_p)) {
777-
// Simulator support. If the platform is ambiguous, use the dyld info.
778-
if (deployment_info.maybe_simulator) {
779-
// If dyld doesn't return a platform, use a heuristic.
780-
#if (defined(__x86_64__) || defined(__i386__))
781-
// If we are running on Intel macOS, it is safe to assume
782-
// this is really a back-deploying simulator binary.
783-
if (deployment_info.maybe_simulator) {
784-
switch (deployment_info.platform) {
785-
case PLATFORM_IOS:
786-
deployment_info.platform = PLATFORM_IOSSIMULATOR;
787-
break;
788-
case PLATFORM_TVOS:
789-
deployment_info.platform = PLATFORM_TVOSSIMULATOR;
790-
break;
791-
case PLATFORM_WATCHOS:
792-
deployment_info.platform = PLATFORM_WATCHOSSIMULATOR;
793-
break;
794-
}
795-
#else
796-
// On an Apple Silicon macOS host, there is no
797-
// ambiguity. The only binaries that use legacy load
798-
// commands are back-deploying native iOS binaries. All
799-
// simulator binaries use the newer, unambiguous
800-
// LC_BUILD_VERSION load commands.
801-
deployment_info.maybe_simulator = false;
802-
#endif
803-
}
804-
}
805798
const char *lc_platform = GetPlatformString(deployment_info.platform);
806799
// macCatalyst support.
807800
//

llvm/lib/LTO/LLVMBuild.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ parent = Libraries
2121
required_libraries =
2222
AggressiveInstCombine
2323
Analysis
24+
BinaryFormat
2425
BitReader
2526
BitWriter
2627
CodeGen

0 commit comments

Comments
 (0)