2016-01-15 14:57:40 +01:00
|
|
|
/****************************************************************************
|
2012-04-18 20:30:57 +03:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 BogDan Vatra <bog_dan_ro@yahoo.com>
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2012-04-18 20:30:57 +03:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2012-04-18 20:30:57 +03:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2012-04-18 20:30:57 +03:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2012-04-18 20:30:57 +03:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2012-04-18 20:30:57 +03:00
|
|
|
|
|
|
|
|
#include "androiddebugsupport.h"
|
|
|
|
|
|
|
|
|
|
#include "androidglobal.h"
|
|
|
|
|
#include "androidrunner.h"
|
2012-04-24 15:49:09 +02:00
|
|
|
#include "androidmanager.h"
|
2014-06-24 16:47:38 +02:00
|
|
|
#include "androidqtsupport.h"
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
#include <debugger/debuggerkitinformation.h>
|
2013-03-27 13:03:15 +01:00
|
|
|
#include <debugger/debuggerrunconfigurationaspect.h>
|
2014-10-17 13:40:04 +02:00
|
|
|
#include <debugger/debuggerruncontrol.h>
|
2012-04-18 20:30:57 +03:00
|
|
|
#include <debugger/debuggerstartparameters.h>
|
|
|
|
|
|
2014-06-24 16:47:38 +02:00
|
|
|
#include <projectexplorer/buildconfiguration.h>
|
|
|
|
|
#include <projectexplorer/project.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2013-03-25 17:13:18 +01:00
|
|
|
#include <projectexplorer/toolchain.h>
|
2014-06-24 16:47:38 +02:00
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
#include <qtsupport/qtkitinformation.h>
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2016-04-19 14:01:44 +02:00
|
|
|
#include <utils/hostosinfo.h>
|
|
|
|
|
|
2014-06-24 16:47:38 +02:00
|
|
|
#include <QDirIterator>
|
2012-04-18 20:30:57 +03:00
|
|
|
|
|
|
|
|
using namespace Debugger;
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
|
|
|
|
namespace Android {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
static const char * const qMakeVariables[] = {
|
|
|
|
|
"QT_INSTALL_LIBS",
|
|
|
|
|
"QT_INSTALL_PLUGINS",
|
|
|
|
|
"QT_INSTALL_IMPORTS"
|
|
|
|
|
};
|
|
|
|
|
|
2012-08-14 15:52:17 +02:00
|
|
|
static QStringList qtSoPaths(QtSupport::BaseQtVersion *qtVersion)
|
|
|
|
|
{
|
|
|
|
|
if (!qtVersion)
|
|
|
|
|
return QStringList();
|
|
|
|
|
|
|
|
|
|
QSet<QString> paths;
|
|
|
|
|
for (uint i = 0; i < sizeof qMakeVariables / sizeof qMakeVariables[0]; ++i) {
|
|
|
|
|
QString path = qtVersion->qmakeProperty(qMakeVariables[i]);
|
|
|
|
|
if (path.isNull())
|
|
|
|
|
continue;
|
2017-02-07 16:59:21 +01:00
|
|
|
QDirIterator it(path, QStringList("*.so"), QDir::Files, QDirIterator::Subdirectories);
|
2012-08-14 15:52:17 +02:00
|
|
|
while (it.hasNext()) {
|
|
|
|
|
it.next();
|
|
|
|
|
paths.insert(it.fileInfo().absolutePath());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return paths.toList();
|
|
|
|
|
}
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2016-01-16 16:32:28 +02:00
|
|
|
static QStringList uniquePaths(const QStringList &files)
|
|
|
|
|
{
|
|
|
|
|
QSet<QString> paths;
|
|
|
|
|
foreach (const QString &file, files)
|
|
|
|
|
paths<<QFileInfo(file).absolutePath();
|
|
|
|
|
return paths.toList();
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-04 19:12:16 +03:00
|
|
|
static QString toNdkArch(const QString &arch)
|
|
|
|
|
{
|
|
|
|
|
if (arch == QLatin1String("armeabi-v7a") || arch == QLatin1String("armeabi"))
|
|
|
|
|
return QLatin1String("arch-arm");
|
|
|
|
|
if (arch == QLatin1String("arm64-v8a"))
|
|
|
|
|
return QLatin1String("arch-arm64");
|
|
|
|
|
return QLatin1String("arch-") + arch;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-19 14:40:49 +02:00
|
|
|
AndroidDebugSupport::AndroidDebugSupport(RunControl *runControl)
|
|
|
|
|
: Debugger::DebuggerRunTool(runControl)
|
2012-04-18 20:30:57 +03:00
|
|
|
{
|
2017-05-19 14:40:49 +02:00
|
|
|
setDisplayName("AndroidDebugger");
|
|
|
|
|
m_runner = new AndroidRunner(runControl);
|
2017-08-08 14:09:50 +02:00
|
|
|
addStartDependency(m_runner);
|
2017-05-19 14:40:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AndroidDebugSupport::start()
|
|
|
|
|
{
|
|
|
|
|
auto runConfig = runControl()->runConfiguration();
|
2012-08-14 15:52:17 +02:00
|
|
|
Target *target = runConfig->target();
|
2017-05-19 14:40:49 +02:00
|
|
|
Kit *kit = target->kit();
|
2012-08-14 15:52:17 +02:00
|
|
|
|
2012-04-18 20:30:57 +03:00
|
|
|
DebuggerStartParameters params;
|
|
|
|
|
params.startMode = AttachToRemoteServer;
|
2012-08-14 15:52:17 +02:00
|
|
|
params.displayName = AndroidManager::packageName(target);
|
2016-04-29 16:51:50 +02:00
|
|
|
params.useContinueInsteadOfRun = true;
|
2017-05-19 14:40:49 +02:00
|
|
|
params.attachPID = m_runner->pid();
|
2017-05-05 12:26:23 +02:00
|
|
|
if (!Utils::HostOsInfo::isWindowsHost() &&
|
|
|
|
|
AndroidConfigurations::currentConfig().ndkVersion() >= QVersionNumber(11, 0, 0)) {
|
2016-04-19 14:01:44 +02:00
|
|
|
params.useTargetAsync = true;
|
2017-05-05 12:26:23 +02:00
|
|
|
}
|
2012-06-24 19:32:45 -07:00
|
|
|
|
2017-05-19 14:40:49 +02:00
|
|
|
if (isCppDebugging()) {
|
|
|
|
|
Utils::Port gdbServerPort = m_runner->gdbServerPort();
|
|
|
|
|
params.symbolFile = target->activeBuildConfiguration()->buildDirectory().toString() + "/app_process";
|
2015-03-31 07:55:00 +02:00
|
|
|
params.skipExecutableValidation = true;
|
2017-05-19 14:40:49 +02:00
|
|
|
params.useExtendedRemote = true;
|
|
|
|
|
params.remoteChannel = ":" + gdbServerPort.toString();
|
2014-06-24 16:47:38 +02:00
|
|
|
params.solibSearchPath = AndroidManager::androidQtSupport(target)->soLibSearchPath(target);
|
2012-09-03 18:31:44 +02:00
|
|
|
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(kit);
|
2012-06-24 19:32:45 -07:00
|
|
|
params.solibSearchPath.append(qtSoPaths(version));
|
2016-01-16 16:32:28 +02:00
|
|
|
params.solibSearchPath.append(uniquePaths(AndroidManager::androidQtSupport(target)->androidExtraLibs(target)));
|
2017-05-19 14:40:49 +02:00
|
|
|
params.sysRoot = AndroidConfigurations::currentConfig().ndkLocation().appendPath("platforms")
|
|
|
|
|
.appendPath(QString("android-%1").arg(AndroidManager::minimumSDK(target)))
|
2016-09-04 19:12:16 +03:00
|
|
|
.appendPath(toNdkArch(AndroidManager::targetArch(target))).toString();
|
2012-06-24 19:32:45 -07:00
|
|
|
}
|
2017-05-19 14:40:49 +02:00
|
|
|
if (isQmlDebugging()) {
|
|
|
|
|
params.qmlServer.port = m_runner->qmlServerPort();
|
2012-06-24 19:32:45 -07:00
|
|
|
//TODO: Not sure if these are the right paths.
|
2015-04-23 19:05:56 +02:00
|
|
|
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(kit);
|
|
|
|
|
if (version) {
|
2017-01-23 17:40:16 +01:00
|
|
|
const QString qmlQtDir = version->qmakeProperty("QT_INSTALL_QML");
|
2015-04-23 19:05:56 +02:00
|
|
|
params.additionalSearchDirectories = QStringList(qmlQtDir);
|
|
|
|
|
}
|
2012-06-24 19:32:45 -07:00
|
|
|
}
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2017-05-19 14:40:49 +02:00
|
|
|
setStartParameters(params);
|
2013-05-03 12:41:58 +02:00
|
|
|
|
2014-12-12 15:33:16 +01:00
|
|
|
// FIXME: Move signal to base class and generalize handling.
|
2017-04-27 09:53:07 +02:00
|
|
|
connect(this, &DebuggerRunTool::aboutToNotifyInferiorSetupOk,
|
2016-08-05 15:40:33 +02:00
|
|
|
m_runner, &AndroidRunner::remoteDebuggerRunning);
|
2012-04-18 20:30:57 +03:00
|
|
|
|
2017-05-19 14:40:49 +02:00
|
|
|
DebuggerRunTool::start();
|
2013-02-27 15:12:36 +01:00
|
|
|
}
|
|
|
|
|
|
2017-05-19 14:40:49 +02:00
|
|
|
void AndroidDebugSupport::stop()
|
2012-04-18 20:30:57 +03:00
|
|
|
{
|
2017-05-19 14:40:49 +02:00
|
|
|
DebuggerRunTool::stop();
|
2012-04-18 20:30:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
2012-08-09 01:56:51 +02:00
|
|
|
} // namespace Android
|