forked from qt-creator/qt-creator
Valgrind: Fix parsing of remote pid
Before we have matched actually "grep valgrind" process pid and the intention was to match valgrind process pid itself. Change-Id: I87576aa6fcf4ac302feb28f046421f7c21c1bcb4 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -192,19 +192,19 @@ void ValgrindRunner::Private::remoteProcessStarted()
|
|||||||
// 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.
|
||||||
// FIXME: Really?
|
// FIXME: Really?
|
||||||
const QString proc = m_valgrindCommand.executable().toString().split(' ').last();
|
const QString proc = m_valgrindCommand.executable().toString().split(' ').last();
|
||||||
|
QString procEscaped = proc;
|
||||||
|
procEscaped.replace("/", "\\\\/");
|
||||||
|
|
||||||
Runnable findPid;
|
Runnable findPid;
|
||||||
// sleep required since otherwise we might only match "bash -c..."
|
// sleep required since otherwise we might only match "bash -c..." and not the actual
|
||||||
// and not the actual valgrind run
|
// valgrind run
|
||||||
findPid.command.setExecutable("/bin/sh");
|
findPid.command.setExecutable("/bin/sh");
|
||||||
findPid.command.setArguments(QString("-c \""
|
findPid.command.setArguments(QString("-c \""
|
||||||
"sleep 1; ps ax" // list all processes with aliased name
|
"sleep 1; ps ax" // list all processes with aliased name
|
||||||
" | grep '\\b%1.*%2'" // find valgrind process
|
" | grep '%1.*%2'" // find valgrind process that runs with our exec
|
||||||
" | tail -n 1" // limit to single process
|
" | awk '\\$5 ~ /^%3/" // 5th column must start with valgrind process
|
||||||
// we pick the last one, first would be "bash -c ..."
|
" {print \\$1;}'" // print 1st then (with PID)
|
||||||
" | awk '{print $1;}'" // get pid
|
"\"").arg(proc, m_debuggee.command.executable().fileName(), procEscaped));
|
||||||
"\""
|
|
||||||
).arg(proc, m_debuggee.command.executable().fileName()));
|
|
||||||
|
|
||||||
// m_remote.m_findPID = m_remote.m_connection->createRemoteProcess(cmd.toUtf8());
|
// m_remote.m_findPID = m_remote.m_connection->createRemoteProcess(cmd.toUtf8());
|
||||||
connect(&m_findPID, &ApplicationLauncher::remoteStderr,
|
connect(&m_findPID, &ApplicationLauncher::remoteStderr,
|
||||||
|
Reference in New Issue
Block a user