forked from qt-creator/qt-creator
Android: Move part of start setup into AndroidDebugSupport's c'tor
Task-number: QTCREATORBUG-29168 Change-Id: I948c52e8fbd197591ca19e15b928f6a26642ceac Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -89,6 +89,75 @@ public:
|
|||||||
setLldbPlatform("remote-android");
|
setLldbPlatform("remote-android");
|
||||||
m_runner = new AndroidRunner(runControl);
|
m_runner = new AndroidRunner(runControl);
|
||||||
addStartDependency(m_runner);
|
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<AndroidQtVersion *>(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;
|
void start() override;
|
||||||
@@ -99,51 +168,10 @@ private:
|
|||||||
|
|
||||||
void AndroidDebugSupport::start()
|
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());
|
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()) {
|
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) {
|
if (cppEngineType() == LldbEngineType) {
|
||||||
QString deviceSerialNumber = Internal::deviceSerialNumber(target);
|
QString deviceSerialNumber = Internal::deviceSerialNumber(runControl()->target());
|
||||||
const int colonPos = deviceSerialNumber.indexOf(QLatin1Char(':'));
|
const int colonPos = deviceSerialNumber.indexOf(QLatin1Char(':'));
|
||||||
if (colonPos > 0) {
|
if (colonPos > 0) {
|
||||||
// When wireless debugging is used then the device serial number will include a port number
|
// 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());
|
debugServer.setHost(QHostAddress(QHostAddress::LocalHost).toString());
|
||||||
setRemoteChannel(debugServer);
|
setRemoteChannel(debugServer);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto qt = static_cast<AndroidQtVersion *>(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()) {
|
if (isQmlDebugging())
|
||||||
qCDebug(androidDebugSupportLog) << "QML debugging enabled. QML server: "
|
|
||||||
<< qmlChannel().toDisplayString();
|
|
||||||
setQmlServer(qmlChannel());
|
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();
|
DebuggerRunTool::start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user