2013-07-19 16:08:54 +02:00
|
|
|
/****************************************************************************
|
2011-12-27 22:41:31 +01:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 Kläralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
|
|
|
|
|
** Contact: http://www.qt.io/licensing
|
2011-12-27 22:41:31 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-12-27 22:41:31 +01: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
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2011-12-27 22:41:31 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2011-12-27 22:41:31 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-12-27 22:41:31 +01:00
|
|
|
|
2013-07-19 16:08:54 +02:00
|
|
|
#include "valgrindruncontrolfactory.h"
|
2016-01-06 11:40:52 +01:00
|
|
|
|
|
|
|
|
#include "valgrindengine.h"
|
2013-08-08 17:37:37 +02:00
|
|
|
#include "valgrindsettings.h"
|
|
|
|
|
#include "valgrindplugin.h"
|
2015-06-29 10:36:29 +03:00
|
|
|
#include "callgrindtool.h"
|
|
|
|
|
#include "memchecktool.h"
|
2011-12-27 22:41:31 +01:00
|
|
|
|
2013-07-19 16:08:54 +02:00
|
|
|
#include <analyzerbase/ianalyzertool.h>
|
|
|
|
|
#include <analyzerbase/analyzermanager.h>
|
|
|
|
|
#include <analyzerbase/analyzerstartparameters.h>
|
|
|
|
|
#include <analyzerbase/analyzerruncontrol.h>
|
2013-08-12 17:04:10 +02:00
|
|
|
#include <analyzerbase/analyzerrunconfigwidget.h>
|
2011-12-27 22:41:31 +01:00
|
|
|
|
2014-04-08 11:07:42 +02:00
|
|
|
#include <remotelinux/abstractremotelinuxrunconfiguration.h>
|
2013-07-30 11:33:03 +02:00
|
|
|
|
|
|
|
|
#include <debugger/debuggerrunconfigurationaspect.h>
|
|
|
|
|
#include <projectexplorer/environmentaspect.h>
|
|
|
|
|
#include <projectexplorer/localapplicationrunconfiguration.h>
|
|
|
|
|
#include <projectexplorer/kitinformation.h>
|
|
|
|
|
#include <projectexplorer/projectexplorer.h>
|
|
|
|
|
#include <projectexplorer/target.h>
|
|
|
|
|
|
2013-07-19 16:08:54 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2011-12-27 22:41:31 +01:00
|
|
|
|
2013-07-30 11:33:03 +02:00
|
|
|
#include <QTcpServer>
|
|
|
|
|
|
2013-07-19 16:08:54 +02:00
|
|
|
using namespace Analyzer;
|
2011-12-27 22:41:31 +01:00
|
|
|
using namespace ProjectExplorer;
|
2016-01-06 11:40:52 +01:00
|
|
|
using namespace Utils;
|
2011-12-27 22:41:31 +01:00
|
|
|
|
2013-07-19 16:08:54 +02:00
|
|
|
namespace Valgrind {
|
2011-12-27 22:41:31 +01:00
|
|
|
namespace Internal {
|
|
|
|
|
|
2013-07-19 16:08:54 +02:00
|
|
|
ValgrindRunControlFactory::ValgrindRunControlFactory(QObject *parent) :
|
2011-12-27 22:41:31 +01:00
|
|
|
IRunControlFactory(parent)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-29 10:36:29 +03:00
|
|
|
bool ValgrindRunControlFactory::canRun(RunConfiguration *runConfiguration, Core::Id mode) const
|
2011-12-27 22:41:31 +01:00
|
|
|
{
|
2013-07-31 08:54:45 +02:00
|
|
|
Q_UNUSED(runConfiguration);
|
2015-06-29 10:36:29 +03:00
|
|
|
return mode == CALLGRIND_RUN_MODE || mode == MEMCHECK_RUN_MODE || mode == MEMCHECK_WITH_GDB_RUN_MODE;
|
2011-12-27 22:41:31 +01:00
|
|
|
}
|
|
|
|
|
|
2015-06-29 10:36:29 +03:00
|
|
|
RunControl *ValgrindRunControlFactory::create(RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage)
|
2013-07-30 11:33:03 +02:00
|
|
|
{
|
2013-08-02 14:39:33 +02:00
|
|
|
Q_UNUSED(errorMessage);
|
|
|
|
|
|
2016-01-06 11:40:52 +01:00
|
|
|
ApplicationLauncher::Mode localRunMode = ApplicationLauncher::Gui;
|
|
|
|
|
Utils::Environment environment;
|
2013-08-02 14:39:33 +02:00
|
|
|
AnalyzerStartParameters sp;
|
2016-01-06 11:40:52 +01:00
|
|
|
QString workingDirectory;
|
|
|
|
|
if (auto rc1 = qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration)) {
|
2013-07-30 11:33:03 +02:00
|
|
|
EnvironmentAspect *aspect = runConfiguration->extraAspect<EnvironmentAspect>();
|
|
|
|
|
if (aspect)
|
2016-01-06 11:40:52 +01:00
|
|
|
environment = aspect->environment();
|
|
|
|
|
workingDirectory = rc1->workingDirectory();
|
2013-07-30 11:33:03 +02:00
|
|
|
sp.debuggee = rc1->executable();
|
|
|
|
|
sp.debuggeeArgs = rc1->commandLineArguments();
|
|
|
|
|
const IDevice::ConstPtr device =
|
|
|
|
|
DeviceKitInformation::device(runConfiguration->target()->kit());
|
2013-08-02 14:39:33 +02:00
|
|
|
QTC_ASSERT(device, return 0);
|
|
|
|
|
QTC_ASSERT(device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE, return 0);
|
2013-07-30 11:33:03 +02:00
|
|
|
QTcpServer server;
|
|
|
|
|
if (!server.listen(QHostAddress::LocalHost) && !server.listen(QHostAddress::LocalHostIPv6)) {
|
|
|
|
|
qWarning() << "Cannot open port on host for profiling.";
|
2013-08-02 14:39:33 +02:00
|
|
|
return 0;
|
2013-07-30 11:33:03 +02:00
|
|
|
}
|
|
|
|
|
sp.connParams.host = server.serverAddress().toString();
|
|
|
|
|
sp.connParams.port = server.serverPort();
|
2016-01-06 11:40:52 +01:00
|
|
|
localRunMode = rc1->runMode();
|
2014-04-08 11:07:42 +02:00
|
|
|
} else if (RemoteLinux::AbstractRemoteLinuxRunConfiguration *rc2 =
|
|
|
|
|
qobject_cast<RemoteLinux::AbstractRemoteLinuxRunConfiguration *>(runConfiguration)) {
|
2013-07-30 11:33:03 +02:00
|
|
|
sp.debuggee = rc2->remoteExecutableFilePath();
|
|
|
|
|
sp.connParams = DeviceKitInformation::device(rc2->target()->kit())->sshParameters();
|
2014-08-23 01:19:53 +02:00
|
|
|
sp.debuggeeArgs = rc2->arguments().join(QLatin1Char(' '));
|
2013-07-30 11:33:03 +02:00
|
|
|
} else {
|
2013-08-02 14:39:33 +02:00
|
|
|
QTC_ASSERT(false, return 0);
|
2013-07-30 11:33:03 +02:00
|
|
|
}
|
|
|
|
|
|
2016-01-06 11:40:52 +01:00
|
|
|
auto analyzerRunControl = AnalyzerManager::createRunControl(sp, runConfiguration, mode);
|
|
|
|
|
if (auto valgrindRunControl = qobject_cast<ValgrindRunControl *>(analyzerRunControl)) {
|
|
|
|
|
valgrindRunControl->setLocalRunMode(localRunMode);
|
|
|
|
|
valgrindRunControl->setEnvironment(environment);
|
|
|
|
|
valgrindRunControl->setWorkingDirectory(workingDirectory);
|
|
|
|
|
}
|
|
|
|
|
return analyzerRunControl;
|
2011-12-27 22:41:31 +01:00
|
|
|
}
|
|
|
|
|
|
2013-08-12 17:04:10 +02:00
|
|
|
|
|
|
|
|
class ValgrindRunConfigurationAspect : public IRunConfigurationAspect
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
ValgrindRunConfigurationAspect(RunConfiguration *parent)
|
|
|
|
|
: IRunConfigurationAspect(parent)
|
|
|
|
|
{
|
|
|
|
|
setProjectSettings(new ValgrindProjectSettings());
|
|
|
|
|
setGlobalSettings(ValgrindPlugin::globalSettings());
|
|
|
|
|
setId(ANALYZER_VALGRIND_SETTINGS);
|
2013-08-23 16:25:16 +02:00
|
|
|
setDisplayName(QCoreApplication::translate("Valgrind::Internal::ValgrindRunConfigurationAspect", "Valgrind Settings"));
|
2013-09-06 12:20:48 +02:00
|
|
|
setUsingGlobalSettings(true);
|
2013-09-06 12:08:34 +02:00
|
|
|
resetProjectToGlobalSettings();
|
2013-08-12 17:04:10 +02:00
|
|
|
}
|
|
|
|
|
|
2015-05-13 15:15:33 +02:00
|
|
|
ValgrindRunConfigurationAspect *create(RunConfiguration *parent) const override
|
2013-08-12 17:04:10 +02:00
|
|
|
{
|
|
|
|
|
return new ValgrindRunConfigurationAspect(parent);
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-13 15:15:33 +02:00
|
|
|
RunConfigWidget *createConfigurationWidget() override
|
2013-08-12 17:04:10 +02:00
|
|
|
{
|
2015-02-03 23:56:02 +02:00
|
|
|
return new AnalyzerRunConfigWidget(this);
|
2013-08-12 17:04:10 +02:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2013-07-19 16:08:54 +02:00
|
|
|
IRunConfigurationAspect *ValgrindRunControlFactory::createRunConfigurationAspect(RunConfiguration *rc)
|
2011-12-27 22:41:31 +01:00
|
|
|
{
|
2013-08-12 17:04:10 +02:00
|
|
|
return new ValgrindRunConfigurationAspect(rc);
|
2011-12-27 22:41:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
2013-07-19 16:08:54 +02:00
|
|
|
} // namespace Valgrind
|