diff --git a/src/plugins/android/androiddebugsupport.cpp b/src/plugins/android/androiddebugsupport.cpp index 2d432a6b643..00f821b3c11 100644 --- a/src/plugins/android/androiddebugsupport.cpp +++ b/src/plugins/android/androiddebugsupport.cpp @@ -89,6 +89,75 @@ public: setLldbPlatform("remote-android"); m_runner = new AndroidRunner(runControl); addStartDependency(m_runner); + + Target *target = runControl->target(); + Kit *kit = target->kit(); + setStartMode(AttachToRemoteServer); + const QString packageName = Internal::packageName(target); + setRunControlName(packageName); + setUseContinueInsteadOfRun(true); + + QtSupport::QtVersion *qtVersion = QtSupport::QtKitAspect::qtVersion(kit); + if (!HostOsInfo::isWindowsHost() + && (qtVersion && AndroidConfig::ndkVersion(qtVersion) >= QVersionNumber(11, 0, 0))) { + qCDebug(androidDebugSupportLog) << "UseTargetAsync: " << true; + setUseTargetAsync(true); + } + + if (isCppDebugging()) { + qCDebug(androidDebugSupportLog) << "C++ debugging enabled"; + const ProjectNode *node = target->project()->findNodeForBuildKey(runControl->buildKey()); + FilePaths solibSearchPath = getSoLibSearchPath(node); + if (qtVersion) + solibSearchPath.append(qtVersion->qtSoPaths()); + const FilePaths extraLibs = getExtraLibs(node); + solibSearchPath.append(extraLibs); + + FilePath buildDir = Internal::buildDirectory(target); + const RunConfiguration *activeRunConfig = target->activeRunConfiguration(); + if (activeRunConfig) + solibSearchPath.append(activeRunConfig->buildTargetInfo().workingDirectory); + solibSearchPath.append(buildDir); + const FilePath androidLibsPath = androidBuildDirectory(target) + .pathAppended("libs") + .pathAppended(apkDevicePreferredAbi(target)); + solibSearchPath.append(androidLibsPath); + FilePath::removeDuplicates(solibSearchPath); + setSolibSearchPath(solibSearchPath); + qCDebug(androidDebugSupportLog).noquote() << "SoLibSearchPath: " << solibSearchPath; + setSymbolFile(androidAppProcessDir(target).pathAppended("app_process")); + setSkipExecutableValidation(true); + setUseExtendedRemote(true); + QString devicePreferredAbi = apkDevicePreferredAbi(target); + setAbi(androidAbi2Abi(devicePreferredAbi)); + + auto qt = static_cast(qtVersion); + const int minimumNdk = qt ? qt->minimumNDK() : 0; + + int sdkVersion = qMax(Internal::minimumSDK(kit), minimumNdk); + if (qtVersion) { + const FilePath ndkLocation = AndroidConfig::ndkLocation(qtVersion); + FilePath sysRoot = ndkLocation + / "platforms" + / QString("android-%1").arg(sdkVersion) + / devicePreferredAbi; // Legacy Ndk structure + if (!sysRoot.exists()) + sysRoot = AndroidConfig::toolchainPathFromNdk(ndkLocation) / "sysroot"; + setSysRoot(sysRoot); + qCDebug(androidDebugSupportLog).noquote() << "Sysroot: " << sysRoot.toUserOutput(); + } + } + if (isQmlDebugging()) { + qCDebug(androidDebugSupportLog) << "QML debugging enabled. QML server: " + << qmlChannel().toDisplayString(); + //TODO: Not sure if these are the right paths. + if (qtVersion) + addSearchDirectory(qtVersion->qmlPath()); + } + connect(this, &RunWorker::started, this, [this, packageName] { + qCDebug(androidDebugSupportLog) << "Starting debugger - package name: " << packageName + << ", PID: " << m_runner->pid().pid(); + }); } void start() override; @@ -99,51 +168,10 @@ private: void AndroidDebugSupport::start() { - Target *target = runControl()->target(); - Kit *kit = target->kit(); - - setStartMode(AttachToRemoteServer); - const QString packageName = Internal::packageName(target); - setRunControlName(packageName); - setUseContinueInsteadOfRun(true); setAttachPid(m_runner->pid()); - - QtSupport::QtVersion *qtVersion = QtSupport::QtKitAspect::qtVersion(kit); - if (!HostOsInfo::isWindowsHost() - && (qtVersion && AndroidConfig::ndkVersion(qtVersion) >= QVersionNumber(11, 0, 0))) { - qCDebug(androidDebugSupportLog) << "UseTargetAsync: " << true; - setUseTargetAsync(true); - } - if (isCppDebugging()) { - qCDebug(androidDebugSupportLog) << "C++ debugging enabled"; - const ProjectNode *node = target->project()->findNodeForBuildKey(runControl()->buildKey()); - FilePaths solibSearchPath = getSoLibSearchPath(node); - if (qtVersion) - solibSearchPath.append(qtVersion->qtSoPaths()); - const FilePaths extraLibs = getExtraLibs(node); - solibSearchPath.append(extraLibs); - - FilePath buildDir = Internal::buildDirectory(target); - const RunConfiguration *activeRunConfig = target->activeRunConfiguration(); - if (activeRunConfig) - solibSearchPath.append(activeRunConfig->buildTargetInfo().workingDirectory); - solibSearchPath.append(buildDir); - const FilePath androidLibsPath = androidBuildDirectory(target) - .pathAppended("libs") - .pathAppended(apkDevicePreferredAbi(target)); - solibSearchPath.append(androidLibsPath); - FilePath::removeDuplicates(solibSearchPath); - setSolibSearchPath(solibSearchPath); - qCDebug(androidDebugSupportLog).noquote() << "SoLibSearchPath: " << solibSearchPath; - setSymbolFile(androidAppProcessDir(target).pathAppended("app_process")); - setSkipExecutableValidation(true); - setUseExtendedRemote(true); - QString devicePreferredAbi = apkDevicePreferredAbi(target); - setAbi(androidAbi2Abi(devicePreferredAbi)); - if (cppEngineType() == LldbEngineType) { - QString deviceSerialNumber = Internal::deviceSerialNumber(target); + QString deviceSerialNumber = Internal::deviceSerialNumber(runControl()->target()); const int colonPos = deviceSerialNumber.indexOf(QLatin1Char(':')); if (colonPos > 0) { // When wireless debugging is used then the device serial number will include a port number @@ -158,34 +186,9 @@ void AndroidDebugSupport::start() debugServer.setHost(QHostAddress(QHostAddress::LocalHost).toString()); setRemoteChannel(debugServer); } - - auto qt = static_cast(qtVersion); - const int minimumNdk = qt ? qt->minimumNDK() : 0; - - int sdkVersion = qMax(Internal::minimumSDK(kit), minimumNdk); - if (qtVersion) { - const FilePath ndkLocation = AndroidConfig::ndkLocation(qtVersion); - FilePath sysRoot = ndkLocation - / "platforms" - / QString("android-%1").arg(sdkVersion) - / devicePreferredAbi; // Legacy Ndk structure - if (!sysRoot.exists()) - sysRoot = AndroidConfig::toolchainPathFromNdk(ndkLocation) / "sysroot"; - setSysRoot(sysRoot); - qCDebug(androidDebugSupportLog).noquote() << "Sysroot: " << sysRoot.toUserOutput(); - } } - if (isQmlDebugging()) { - qCDebug(androidDebugSupportLog) << "QML debugging enabled. QML server: " - << qmlChannel().toDisplayString(); + if (isQmlDebugging()) setQmlServer(qmlChannel()); - //TODO: Not sure if these are the right paths. - if (qtVersion) - addSearchDirectory(qtVersion->qmlPath()); - } - - qCDebug(androidDebugSupportLog) << "Starting debugger - package name: " << packageName - << ", PID: " << m_runner->pid().pid(); DebuggerRunTool::start(); }