forked from qt-creator/qt-creator
Valgrind: Move to Utils::FilePath in some places
Change-Id: I54d03ccda62121055509fd24c5c98a13f7605964 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -81,8 +81,11 @@ void ValgrindToolRunner::start()
|
|||||||
emit outputReceived(tr("Command line arguments: %1").arg(runnable().debuggeeArgs), DebugFormat);
|
emit outputReceived(tr("Command line arguments: %1").arg(runnable().debuggeeArgs), DebugFormat);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_runner.setValgrindExecutable(m_settings->valgrindExecutable());
|
CommandLine valgrind{FilePath::fromString(m_settings->valgrindExecutable())};
|
||||||
m_runner.setValgrindArguments(genericToolArguments() + toolArguments());
|
valgrind.addArgs(genericToolArguments());
|
||||||
|
valgrind.addArgs(toolArguments());
|
||||||
|
|
||||||
|
m_runner.setValgrindCommand(valgrind);
|
||||||
m_runner.setDevice(device());
|
m_runner.setDevice(device());
|
||||||
m_runner.setDebuggee(runnable());
|
m_runner.setDebuggee(runnable());
|
||||||
|
|
||||||
|
|||||||
@@ -477,9 +477,9 @@ void ValgrindMemcheckParserTest::testValgrindGarbage()
|
|||||||
void ValgrindMemcheckParserTest::testParserStop()
|
void ValgrindMemcheckParserTest::testParserStop()
|
||||||
{
|
{
|
||||||
ValgrindRunner runner;
|
ValgrindRunner runner;
|
||||||
runner.setValgrindExecutable(fakeValgrindExecutable());
|
runner.setValgrindCommand({FilePath::fromString(fakeValgrindExecutable()),
|
||||||
runner.setValgrindArguments({QString("--xml-socket=127.0.0.1:%1").arg(m_server->serverPort()),
|
{QString("--xml-socket=127.0.0.1:%1").arg(m_server->serverPort()),
|
||||||
"-i", dataFile("memcheck-output-sample1.xml"), "--wait", "5" });
|
"-i", dataFile("memcheck-output-sample1.xml"), "--wait", "5" }});
|
||||||
runner.setProcessChannelMode(QProcess::ForwardedChannels);
|
runner.setProcessChannelMode(QProcess::ForwardedChannels);
|
||||||
|
|
||||||
runner.setDevice(ProjectExplorer::DeviceManager::instance()->defaultDevice(
|
runner.setDevice(ProjectExplorer::DeviceManager::instance()->defaultDevice(
|
||||||
@@ -502,7 +502,7 @@ void ValgrindMemcheckParserTest::testRealValgrind()
|
|||||||
debuggee.executable = FilePath::fromString(executable);
|
debuggee.executable = FilePath::fromString(executable);
|
||||||
debuggee.environment = sysEnv;
|
debuggee.environment = sysEnv;
|
||||||
ValgrindRunner runner;
|
ValgrindRunner runner;
|
||||||
runner.setValgrindExecutable("valgrind");
|
runner.setValgrindCommand({FilePath::fromString("valgrind"), {}});
|
||||||
runner.setDebuggee(debuggee);
|
runner.setDebuggee(debuggee);
|
||||||
runner.setDevice(ProjectExplorer::DeviceManager::instance()->defaultDevice(
|
runner.setDevice(ProjectExplorer::DeviceManager::instance()->defaultDevice(
|
||||||
ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE));
|
ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE));
|
||||||
@@ -541,8 +541,7 @@ void ValgrindMemcheckParserTest::testValgrindStartError()
|
|||||||
debuggeeExecutable.commandLineArguments = debuggeeArgs;
|
debuggeeExecutable.commandLineArguments = debuggeeArgs;
|
||||||
|
|
||||||
ValgrindRunner runner;
|
ValgrindRunner runner;
|
||||||
runner.setValgrindExecutable(valgrindExe);
|
runner.setValgrindCommand({FilePath::fromString(valgrindExe), valgrindArgs});
|
||||||
runner.setValgrindArguments(valgrindArgs);
|
|
||||||
runner.setDebuggee(debuggeeExecutable);
|
runner.setDebuggee(debuggeeExecutable);
|
||||||
runner.setDevice(ProjectExplorer::DeviceManager::instance()->defaultDevice(
|
runner.setDevice(ProjectExplorer::DeviceManager::instance()->defaultDevice(
|
||||||
ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE));
|
ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE));
|
||||||
|
|||||||
@@ -63,8 +63,7 @@ public:
|
|||||||
|
|
||||||
ApplicationLauncher m_findPID;
|
ApplicationLauncher m_findPID;
|
||||||
|
|
||||||
QString m_valgrindExecutable;
|
CommandLine m_valgrindCommand;
|
||||||
QStringList m_valgrindArguments;
|
|
||||||
|
|
||||||
QHostAddress localServerAddress;
|
QHostAddress localServerAddress;
|
||||||
QProcess::ProcessChannelMode channelMode = QProcess::SeparateChannels;
|
QProcess::ProcessChannelMode channelMode = QProcess::SeparateChannels;
|
||||||
@@ -82,7 +81,7 @@ public:
|
|||||||
|
|
||||||
bool ValgrindRunner::Private::run()
|
bool ValgrindRunner::Private::run()
|
||||||
{
|
{
|
||||||
CommandLine cmd{FilePath::fromString(m_valgrindExecutable)};
|
CommandLine cmd{m_valgrindCommand.executable(), {}};
|
||||||
|
|
||||||
if (!localServerAddress.isNull()) {
|
if (!localServerAddress.isNull()) {
|
||||||
if (!q->startServers())
|
if (!q->startServers())
|
||||||
@@ -112,7 +111,7 @@ bool ValgrindRunner::Private::run()
|
|||||||
if (enableXml)
|
if (enableXml)
|
||||||
cmd.addArg("--xml=yes");
|
cmd.addArg("--xml=yes");
|
||||||
}
|
}
|
||||||
cmd.addArgs(m_valgrindArguments);
|
cmd.addArgs(m_valgrindCommand.arguments(), CommandLine::Raw);
|
||||||
|
|
||||||
m_valgrindProcess.setProcessChannelMode(channelMode);
|
m_valgrindProcess.setProcessChannelMode(channelMode);
|
||||||
// consider appending our options last so they override any interfering user-supplied options
|
// consider appending our options last so they override any interfering user-supplied options
|
||||||
@@ -187,7 +186,8 @@ void ValgrindRunner::Private::remoteProcessStarted()
|
|||||||
// hence we need to do something more complex...
|
// hence we need to do something more complex...
|
||||||
|
|
||||||
// plain path to exe, m_valgrindExe contains e.g. env vars etc. pp.
|
// plain path to exe, m_valgrindExe contains e.g. env vars etc. pp.
|
||||||
const QString proc = m_valgrindExecutable.split(' ').last();
|
// FIXME: Really?
|
||||||
|
const QString proc = m_valgrindCommand.executable().toString().split(' ').last();
|
||||||
|
|
||||||
Runnable findPid;
|
Runnable findPid;
|
||||||
findPid.executable = FilePath::fromString("/bin/sh");
|
findPid.executable = FilePath::fromString("/bin/sh");
|
||||||
@@ -227,7 +227,7 @@ void ValgrindRunner::Private::findPidOutputReceived(const QString &out)
|
|||||||
|
|
||||||
void ValgrindRunner::Private::closed(bool success)
|
void ValgrindRunner::Private::closed(bool success)
|
||||||
{
|
{
|
||||||
Q_UNUSED(success);
|
Q_UNUSED(success)
|
||||||
// QTC_ASSERT(m_remote.m_process, return);
|
// QTC_ASSERT(m_remote.m_process, return);
|
||||||
|
|
||||||
// m_remote.m_errorString = m_remote.m_process->errorString();
|
// m_remote.m_errorString = m_remote.m_process->errorString();
|
||||||
@@ -263,14 +263,9 @@ ValgrindRunner::~ValgrindRunner()
|
|||||||
d = nullptr;
|
d = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ValgrindRunner::setValgrindExecutable(const QString &executable)
|
void ValgrindRunner::setValgrindCommand(const Utils::CommandLine &command)
|
||||||
{
|
{
|
||||||
d->m_valgrindExecutable = executable;
|
d->m_valgrindCommand = command;
|
||||||
}
|
|
||||||
|
|
||||||
void ValgrindRunner::setValgrindArguments(const QStringList &toolArguments)
|
|
||||||
{
|
|
||||||
d->m_valgrindArguments = toolArguments;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ValgrindRunner::setDebuggee(const Runnable &debuggee)
|
void ValgrindRunner::setDebuggee(const Runnable &debuggee)
|
||||||
|
|||||||
@@ -44,8 +44,7 @@ public:
|
|||||||
explicit ValgrindRunner(QObject *parent = nullptr);
|
explicit ValgrindRunner(QObject *parent = nullptr);
|
||||||
~ValgrindRunner() override;
|
~ValgrindRunner() override;
|
||||||
|
|
||||||
void setValgrindExecutable(const QString &executable);
|
void setValgrindCommand(const Utils::CommandLine &command);
|
||||||
void setValgrindArguments(const QStringList &toolArguments);
|
|
||||||
void setDebuggee(const ProjectExplorer::Runnable &debuggee);
|
void setDebuggee(const ProjectExplorer::Runnable &debuggee);
|
||||||
void setProcessChannelMode(QProcess::ProcessChannelMode mode);
|
void setProcessChannelMode(QProcess::ProcessChannelMode mode);
|
||||||
void setLocalServerAddress(const QHostAddress &localServerAddress);
|
void setLocalServerAddress(const QHostAddress &localServerAddress);
|
||||||
|
|||||||
@@ -46,7 +46,9 @@
|
|||||||
|
|
||||||
#define HEADER_LENGTH 25
|
#define HEADER_LENGTH 25
|
||||||
|
|
||||||
|
using namespace ProjectExplorer;
|
||||||
using namespace Valgrind::XmlProtocol;
|
using namespace Valgrind::XmlProtocol;
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Valgrind {
|
namespace Valgrind {
|
||||||
namespace Test {
|
namespace Test {
|
||||||
@@ -77,15 +79,21 @@ QString ValgrindTestRunnerTest::runTestBinary(const QString &binary, const QStri
|
|||||||
const QFileInfo binPathFileInfo(appBinDir, binary);
|
const QFileInfo binPathFileInfo(appBinDir, binary);
|
||||||
if (!binPathFileInfo.isExecutable())
|
if (!binPathFileInfo.isExecutable())
|
||||||
return QString();
|
return QString();
|
||||||
ProjectExplorer::Runnable debuggee;
|
|
||||||
|
Runnable debuggee;
|
||||||
const QString &binPath = binPathFileInfo.canonicalFilePath();
|
const QString &binPath = binPathFileInfo.canonicalFilePath();
|
||||||
debuggee.executable = Utils::FilePath::fromString(binPath);
|
debuggee.executable = Utils::FilePath::fromString(binPath);
|
||||||
debuggee.environment = Utils::Environment::systemEnvironment();
|
debuggee.environment = Utils::Environment::systemEnvironment();
|
||||||
|
|
||||||
|
CommandLine valgrind{FilePath::fromString("valgrind")};
|
||||||
|
valgrind.addArgs({"--num-callers=50", "--track-origins=yes"});
|
||||||
|
valgrind.addArgs(vArgs);
|
||||||
|
|
||||||
m_runner->setLocalServerAddress(QHostAddress::LocalHost);
|
m_runner->setLocalServerAddress(QHostAddress::LocalHost);
|
||||||
m_runner->setValgrindArguments(QStringList() << "--num-callers=50" << "--track-origins=yes" << vArgs);
|
m_runner->setValgrindCommand(valgrind);
|
||||||
m_runner->setDebuggee(debuggee);
|
m_runner->setDebuggee(debuggee);
|
||||||
m_runner->setDevice(ProjectExplorer::DeviceManager::instance()->defaultDevice(
|
m_runner->setDevice(DeviceManager::instance()->defaultDevice(
|
||||||
Core::Id(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE)));
|
ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE));
|
||||||
m_runner->start();
|
m_runner->start();
|
||||||
m_runner->waitForFinished();
|
m_runner->waitForFinished();
|
||||||
return binPath;
|
return binPath;
|
||||||
@@ -131,7 +139,6 @@ void ValgrindTestRunnerTest::init()
|
|||||||
|
|
||||||
Q_ASSERT(!m_runner);
|
Q_ASSERT(!m_runner);
|
||||||
m_runner = new ValgrindRunner;
|
m_runner = new ValgrindRunner;
|
||||||
m_runner->setValgrindExecutable("valgrind");
|
|
||||||
m_runner->setProcessChannelMode(QProcess::ForwardedChannels);
|
m_runner->setProcessChannelMode(QProcess::ForwardedChannels);
|
||||||
connect(m_runner, &ValgrindRunner::logMessageReceived,
|
connect(m_runner, &ValgrindRunner::logMessageReceived,
|
||||||
this, &ValgrindTestRunnerTest::logMessageReceived);
|
this, &ValgrindTestRunnerTest::logMessageReceived);
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ int main(int argc, char *argv[])
|
|||||||
qRegisterMetaType<Error>();
|
qRegisterMetaType<Error>();
|
||||||
|
|
||||||
ValgrindRunner runner;
|
ValgrindRunner runner;
|
||||||
runner.setValgrindExecutable(VALGRIND_FAKE_PATH);
|
runner.setValgrindCommand({Utils::FilePath::fromString(VALGRIND_FAKE_PATH),
|
||||||
runner.setValgrindArguments({"-i", PARSERTESTS_DATA_DIR "/memcheck-output-sample1.xml"});
|
{"-i", PARSERTESTS_DATA_DIR "/memcheck-output-sample1.xml"}});
|
||||||
|
|
||||||
ModelDemo demo(&runner);
|
ModelDemo demo(&runner);
|
||||||
QObject::connect(&runner, &ValgrindRunner::finished,
|
QObject::connect(&runner, &ValgrindRunner::finished,
|
||||||
|
|||||||
Reference in New Issue
Block a user