summaryrefslogtreecommitdiff
path: root/src/plugins/valgrind/valgrindprocess.cpp
diff options
context:
space:
mode:
authorhjk <hjk@theqtcompany.com>2016-01-25 17:15:54 +0100
committerhjk <hjk@theqtcompany.com>2016-01-26 14:27:00 +0000
commit9a3b340c00bb8a78ea492201ffe1392c0d4a3790 (patch)
tree62a2deab9681c2c99c6306d0c2df4b3a837e927d /src/plugins/valgrind/valgrindprocess.cpp
parent96a9f1011f072db2b876cb75c25585a191ee5824 (diff)
downloadqt-creator-9a3b340c00bb8a78ea492201ffe1392c0d4a3790.tar.gz
Valgrind: Use StandardRunnable in ValgrindRunner and ValgrindProcess
Change-Id: I17def50bbf6887b63d676fdb245064f1df2003de Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
Diffstat (limited to 'src/plugins/valgrind/valgrindprocess.cpp')
-rw-r--r--src/plugins/valgrind/valgrindprocess.cpp70
1 files changed, 20 insertions, 50 deletions
diff --git a/src/plugins/valgrind/valgrindprocess.cpp b/src/plugins/valgrind/valgrindprocess.cpp
index 952fd51e17..5604fbb408 100644
--- a/src/plugins/valgrind/valgrindprocess.cpp
+++ b/src/plugins/valgrind/valgrindprocess.cpp
@@ -40,8 +40,7 @@ namespace Valgrind {
ValgrindProcess::ValgrindProcess(bool isLocal, const QSsh::SshConnectionParameters &sshParams,
QSsh::SshConnection *connection, QObject *parent)
: QObject(parent),
- m_isLocal(isLocal),
- m_localRunMode(ApplicationLauncher::Gui)
+ m_isLocal(isLocal)
{
m_remote.m_params = sshParams;
m_remote.m_connection = connection;
@@ -56,20 +55,9 @@ void ValgrindProcess::setProcessChannelMode(QProcess::ProcessChannelMode mode)
///TODO: remote support this by handling the mode internally
}
-void ValgrindProcess::setWorkingDirectory(const QString &path)
-{
- if (isLocal())
- m_localProcess.setWorkingDirectory(path);
- else
- m_remote.m_workingDir = path;
-}
-
QString ValgrindProcess::workingDirectory() const
{
- if (isLocal())
- return m_localProcess.workingDirectory();
- else
- return m_remote.m_workingDir;
+ return m_debuggee.workingDirectory;
}
bool ValgrindProcess::isRunning() const
@@ -85,31 +73,19 @@ void ValgrindProcess::setValgrindExecutable(const QString &valgrindExecutable)
m_valgrindExecutable = valgrindExecutable;
}
-void ValgrindProcess::setValgrindArguments(const QStringList &valgrindArguments)
-{
- m_valgrindArguments = valgrindArguments;
-}
-
-void ValgrindProcess::setDebuggeeExecutable(const QString &debuggeeExecutable)
-{
- m_debuggeeExecutable = debuggeeExecutable;
-}
-
-void ValgrindProcess::setDebugeeArguments(const QString &debuggeeArguments)
+void ValgrindProcess::setDebuggee(const StandardRunnable &debuggee)
{
- m_debuggeeArguments = debuggeeArguments;
-}
-
-void ValgrindProcess::setEnvironment(const Utils::Environment &environment)
-{
- if (isLocal())
- m_localProcess.setEnvironment(environment);
- ///TODO: remote anything that should/could be done here?
+ m_debuggee = debuggee;
+ if (isLocal()) {
+ m_localProcess.setWorkingDirectory(m_debuggee.workingDirectory);
+ m_localProcess.setEnvironment(m_debuggee.environment);
+ ///TODO: remote anything that should/could be done here?
+ }
}
-void ValgrindProcess::setLocalRunMode(ApplicationLauncher::Mode localRunMode)
+void ValgrindProcess::setValgrindArguments(const QStringList &valgrindArguments)
{
- m_localRunMode = localRunMode;
+ m_valgrindArguments = valgrindArguments;
}
void ValgrindProcess::close()
@@ -146,13 +122,10 @@ void ValgrindProcess::run()
connect(&m_localProcess, &ApplicationLauncher::appendMessage,
this, &ValgrindProcess::processOutput);
- m_localProcess.start(m_localRunMode, m_valgrindExecutable,
+ m_localProcess.start(m_debuggee.runMode, m_valgrindExecutable,
argumentString(Utils::HostOsInfo::hostOs()));
} else {
- m_remote.m_valgrindExe = m_valgrindExecutable;
- m_remote.m_debuggee = m_debuggeeExecutable;
-
// connect to host and wait for connection
if (!m_remote.m_connection)
m_remote.m_connection = new QSsh::SshConnection(m_remote.m_params, this);
@@ -231,10 +204,10 @@ void ValgrindProcess::connected()
// connected, run command
QString cmd;
- if (!m_remote.m_workingDir.isEmpty())
- cmd += QString::fromLatin1("cd '%1' && ").arg(m_remote.m_workingDir);
+ if (!m_debuggee.workingDirectory.isEmpty())
+ cmd += QString::fromLatin1("cd '%1' && ").arg(m_debuggee.workingDirectory);
- cmd += m_remote.m_valgrindExe + QLatin1Char(' ') + argumentString(Utils::OsTypeLinux);
+ cmd += m_valgrindExecutable + QLatin1Char(' ') + argumentString(Utils::OsTypeLinux);
m_remote.m_process = m_remote.m_connection->createRemoteProcess(cmd.toUtf8());
connect(m_remote.m_process.data(), &QSsh::SshRemoteProcess::readyReadStandardError,
@@ -272,7 +245,7 @@ void ValgrindProcess::remoteProcessStarted()
// hence we need to do something more complex...
// plain path to exe, m_valgrindExe contains e.g. env vars etc. pp.
- const QString proc = m_remote.m_valgrindExe.split(QLatin1Char(' ')).last();
+ const QString proc = m_valgrindExecutable.split(QLatin1Char(' ')).last();
// sleep required since otherwise we might only match "bash -c..."
// and not the actual valgrind run
const QString cmd = QString::fromLatin1("sleep 1; ps ax" // list all processes with aliased name
@@ -280,7 +253,7 @@ void ValgrindProcess::remoteProcessStarted()
" | tail -n 1" // limit to single process
// we pick the last one, first would be "bash -c ..."
" | awk '{print $1;}'" // get pid
- ).arg(proc, Utils::FileName::fromString(m_remote.m_debuggee).fileName());
+ ).arg(proc, Utils::FileName::fromString(m_debuggee.executable).fileName());
m_remote.m_findPID = m_remote.m_connection->createRemoteProcess(cmd.toUtf8());
connect(m_remote.m_findPID.data(), &QSsh::SshRemoteProcess::readyReadStandardError,
@@ -308,15 +281,12 @@ void ValgrindProcess::findPIDOutputReceived()
QString ValgrindProcess::argumentString(Utils::OsType osType) const
{
QString arguments = Utils::QtcProcess::joinArgs(m_valgrindArguments, osType);
- if (!m_debuggeeExecutable.isEmpty())
- Utils::QtcProcess::addArg(&arguments, m_debuggeeExecutable, osType);
- Utils::QtcProcess::addArgs(&arguments, m_debuggeeArguments);
+ if (!m_debuggee.executable.isEmpty())
+ Utils::QtcProcess::addArg(&arguments, m_debuggee.executable, osType);
+ Utils::QtcProcess::addArgs(&arguments, m_debuggee.commandLineArguments);
return arguments;
}
-
-///////////
-
void ValgrindProcess::closed(int status)
{
QTC_ASSERT(m_remote.m_process, return);