Skip to content

Commit

Permalink
iOS: Fix slow debugger startup on devices
Browse files Browse the repository at this point in the history
We need to pass the path to the device symbols, that Xcode downloaded
for the device's OS version, as the sysroot to the debugger. Otherwise
debugger startup is very slow.

We already tried to do that, but it looks like, depending on the
devices, this path can contain an architecture specific part, e.g.
"iOS DeviceSupport/13.5.1 (17F80) arm64e" instead of just "iOS
DeviceSupport/13.5.1 (17F80)". It can still be just the latter, so we
get the devices architecture information, try the architecture specific
directory first, and fall back to the architecture agnostic name as
before if the former doesn't exist.

Fixes: QTCREATORBUG-21682
Change-Id: I2efdbfda0282f1cf0f8d10bd4e5217a298027fcf
  • Loading branch information
e4z9 committed Jul 9, 2020
1 parent d964e91 commit d978b8c
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 21 deletions.
5 changes: 5 additions & 0 deletions src/plugins/ios/iosdevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ QString IosDevice::osVersion() const
return m_extraInfo.value(QLatin1String("osVersion"));
}

QString IosDevice::cpuArchitecture() const
{
return m_extraInfo.value("cpuArchitecture");
}

Utils::Port IosDevice::nextPort() const
{
// use qrand instead?
Expand Down
1 change: 1 addition & 0 deletions src/plugins/ios/iosdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class IosDevice final : public ProjectExplorer::IDevice
QVariantMap toMap() const override;
QString uniqueDeviceID() const;
QString osVersion() const;
QString cpuArchitecture() const;
Utils::Port nextPort() const;
bool canAutoDetectPorts() const override;

Expand Down
40 changes: 19 additions & 21 deletions src/plugins/ios/iosrunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,28 +436,26 @@ void IosDebugSupport::start()
IosDevice::ConstPtr dev = device().dynamicCast<const IosDevice>();
setStartMode(AttachToRemoteProcess);
setIosPlatform("remote-ios");
QString osVersion = dev->osVersion();
FilePath deviceSdk1 = FilePath::fromString(QDir::homePath()
+ "/Library/Developer/Xcode/iOS DeviceSupport/"
+ osVersion + "/Symbols");
QString deviceSdk;
if (deviceSdk1.isDir()) {
deviceSdk = deviceSdk1.toString();
} else {
const FilePath deviceSdk2 = IosConfigurations::developerPath()
.pathAppended("Platforms/iPhoneOS.platform/DeviceSupport/"
+ osVersion + "/Symbols");
if (deviceSdk2.isDir()) {
deviceSdk = deviceSdk2.toString();
} else {
TaskHub::addTask(DeploymentTask(Task::Warning, tr(
"Could not find device specific debug symbols at %1. "
"Debugging initialization will be slow until you open the Organizer window of "
"Xcode with the device connected to have the symbols generated.")
.arg(deviceSdk1.toUserOutput())));
}
const QString osVersion = dev->osVersion();
const QString cpuArchitecture = dev->cpuArchitecture();
const FilePaths symbolsPathCandidates = {
FilePath::fromString(QDir::homePath() + "/Library/Developer/Xcode/iOS DeviceSupport/"
+ osVersion + " " + cpuArchitecture + "/Symbols"),
FilePath::fromString(QDir::homePath() + "/Library/Developer/Xcode/iOS DeviceSupport/"
+ osVersion + "/Symbols"),
IosConfigurations::developerPath().pathAppended(
"Platforms/iPhoneOS.platform/DeviceSupport/" + osVersion + "/Symbols")};
const FilePath deviceSdk = Utils::findOrDefault(symbolsPathCandidates, &FilePath::isDir);

if (deviceSdk.isEmpty()) {
TaskHub::addTask(DeploymentTask(
Task::Warning,
tr("Could not find device specific debug symbols at %1. "
"Debugging initialization will be slow until you open the Organizer window of "
"Xcode with the device connected to have the symbols generated.")
.arg(symbolsPathCandidates.constFirst().toUserOutput())));
}
setDeviceSymbolsRoot(deviceSdk);
setDeviceSymbolsRoot(deviceSdk.toString());
} else {
setStartMode(AttachExternal);
setIosPlatform("ios-simulator");
Expand Down
13 changes: 13 additions & 0 deletions src/tools/iostool/iosdevicemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1593,6 +1593,7 @@ void DevInfoSession::deviceCallbackReturned()
QString developerStatusKey = QLatin1String("developerStatus");
QString deviceConnectedKey = QLatin1String("deviceConnected");
QString osVersionKey = QLatin1String("osVersion");
QString cpuArchitectureKey = "cpuArchitecture";
bool failure = !device;
if (!failure) {
failure = !connectDevice();
Expand Down Expand Up @@ -1631,6 +1632,18 @@ void DevInfoSession::deviceCallbackReturned()
0,
CFSTR("BuildVersion"));
//CFShow(cfBuildVersion);
CFPropertyListRef cfCpuArchitecture = lib()->deviceCopyValue(device,
0,
CFSTR("CPUArchitecture"));
//CFShow(cfCpuArchitecture);
if (cfCpuArchitecture) {
if (CFGetTypeID(cfCpuArchitecture) == CFStringGetTypeID()) {
res[cpuArchitectureKey] = QString::fromCFString(
reinterpret_cast<CFStringRef>(cfCpuArchitecture));
}
CFRelease(cfCpuArchitecture);
}
//CFShow(cfBuildVersion);
QString versionString;
if (cfProductVersion) {
if (CFGetTypeID(cfProductVersion) == CFStringGetTypeID())
Expand Down

0 comments on commit d978b8c

Please sign in to comment.