From 80caa6cd62fa7c1cf4c2938108a1e9a811798be4 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Wed, 2 Oct 2024 10:57:45 +0200 Subject: [PATCH] ValgrindProcess: Inline setupValgrindProcess Change-Id: I60a15a82dcfccc9fb32e69970e7f84feed3adbfd Reviewed-by: hjk --- src/plugins/valgrind/valgrindprocess.cpp | 65 +++++++++++------------- 1 file changed, 31 insertions(+), 34 deletions(-) diff --git a/src/plugins/valgrind/valgrindprocess.cpp b/src/plugins/valgrind/valgrindprocess.cpp index 4ef1862985f..afb8cc81ca9 100644 --- a/src/plugins/valgrind/valgrindprocess.cpp +++ b/src/plugins/valgrind/valgrindprocess.cpp @@ -70,39 +70,6 @@ public: }); } - void setupValgrindProcess(Process *process, const CommandLine &command) const { - CommandLine cmd = command; - cmd.addArgs(m_valgrindCommand.arguments(), CommandLine::Raw); - - // consider appending our options last so they override any interfering user-supplied - // options -q as suggested by valgrind manual - - if (cmd.executable().osType() == OsTypeMac) { - // May be slower to start but without it we get no filenames for symbols. - cmd.addArg("--dsymutil=yes"); - } - - cmd.addCommandLineAsArgs(m_debuggee.command); - - emit q->appendMessage(cmd.toUserOutput(), NormalMessageFormat); - - process->setCommand(cmd); - process->setWorkingDirectory(m_debuggee.workingDirectory); - process->setEnvironment(m_debuggee.environment); - process->setProcessChannelMode(m_channelMode); - process->setTerminalMode(m_useTerminal ? TerminalMode::Run : TerminalMode::Off); - - connect(process, &Process::started, this, [this, process] { - emit q->valgrindStarted(process->processId()); - }); - connect(process, &Process::readyReadStandardOutput, this, [this, process] { - emit q->appendMessage(process->readAllStandardOutput(), StdOutFormat); - }); - connect(process, &Process::readyReadStandardError, this, [this, process] { - emit q->appendMessage(process->readAllStandardError(), StdErrFormat); - }); - } - Group runRecipe() const; bool run(); @@ -177,7 +144,37 @@ Group ValgrindProcessPrivate::runRecipe() const }; const auto onProcessSetup = [this, storage](Process &process) { - setupValgrindProcess(&process, storage->m_valgrindCommand); + CommandLine cmd = storage->m_valgrindCommand; + cmd.addArgs(m_valgrindCommand.arguments(), CommandLine::Raw); + + // consider appending our options last so they override any interfering user-supplied + // options -q as suggested by valgrind manual + + if (cmd.executable().osType() == OsTypeMac) { + // May be slower to start but without it we get no filenames for symbols. + cmd.addArg("--dsymutil=yes"); + } + + cmd.addCommandLineAsArgs(m_debuggee.command); + + emit q->appendMessage(cmd.toUserOutput(), NormalMessageFormat); + + process.setCommand(cmd); + process.setWorkingDirectory(m_debuggee.workingDirectory); + process.setEnvironment(m_debuggee.environment); + process.setProcessChannelMode(m_channelMode); + process.setTerminalMode(m_useTerminal ? TerminalMode::Run : TerminalMode::Off); + + Process *processPtr = &process; + connect(processPtr, &Process::started, this, [this, processPtr] { + emit q->valgrindStarted(processPtr->processId()); + }); + connect(processPtr, &Process::readyReadStandardOutput, this, [this, processPtr] { + emit q->appendMessage(processPtr->readAllStandardOutput(), StdOutFormat); + }); + connect(processPtr, &Process::readyReadStandardError, this, [this, processPtr] { + emit q->appendMessage(processPtr->readAllStandardError(), StdErrFormat); + }); }; const auto onProcessDone = [this, storage](const Process &process) { emit q->processErrorReceived(process.errorString(), process.error());