aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/valgrind
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2021-09-15 14:02:16 +0200
committerJarek Kobus <jaroslaw.kobus@qt.io>2021-09-15 13:04:33 +0000
commit844cfe70b7eea4508e9b33dad19e5f113ae52a5b (patch)
tree77411df527c3754ddfcf2384fd6a57eb9215a1a3 /src/plugins/valgrind
parent464f665735d62b110ad47026801ca33a67b55d3f (diff)
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>
Diffstat (limited to 'src/plugins/valgrind')
-rw-r--r--src/plugins/valgrind/valgrindrunner.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/plugins/valgrind/valgrindrunner.cpp b/src/plugins/valgrind/valgrindrunner.cpp
index 7ac0d506205..a1ca7a2c120 100644
--- a/src/plugins/valgrind/valgrindrunner.cpp
+++ b/src/plugins/valgrind/valgrindrunner.cpp
@@ -192,19 +192,19 @@ void ValgrindRunner::Private::remoteProcessStarted()
// plain path to exe, m_valgrindExe contains e.g. env vars etc. pp.
// FIXME: Really?
const QString proc = m_valgrindCommand.executable().toString().split(' ').last();
+ QString procEscaped = proc;
+ procEscaped.replace("/", "\\\\/");
Runnable findPid;
- // sleep required since otherwise we might only match "bash -c..."
- // and not the actual valgrind run
+ // sleep required since otherwise we might only match "bash -c..." and not the actual
+ // valgrind run
findPid.command.setExecutable("/bin/sh");
findPid.command.setArguments(QString("-c \""
- "sleep 1; ps ax" // list all processes with aliased name
- " | grep '\\b%1.*%2'" // find valgrind process
- " | tail -n 1" // limit to single process
- // we pick the last one, first would be "bash -c ..."
- " | awk '{print $1;}'" // get pid
- "\""
- ).arg(proc, m_debuggee.command.executable().fileName()));
+ "sleep 1; ps ax" // list all processes with aliased name
+ " | grep '%1.*%2'" // find valgrind process that runs with our exec
+ " | awk '\\$5 ~ /^%3/" // 5th column must start with valgrind process
+ " {print \\$1;}'" // print 1st then (with PID)
+ "\"").arg(proc, m_debuggee.command.executable().fileName(), procEscaped));
// m_remote.m_findPID = m_remote.m_connection->createRemoteProcess(cmd.toUtf8());
connect(&m_findPID, &ApplicationLauncher::remoteStderr,