Valgrind: Clean up a bit after class merge

Change-Id: I1df02a93ebca318424461c3e48b9bb51133eec8d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
hjk
2022-05-31 13:43:14 +02:00
parent 72aa77ced7
commit 16aaf8c59c
2 changed files with 16 additions and 69 deletions

View File

@@ -62,18 +62,18 @@ CallgrindToolRunner::CallgrindToolRunner(RunControl *runControl)
connect(&m_parser, &Callgrind::Parser::parserDataReady, connect(&m_parser, &Callgrind::Parser::parserDataReady,
this, &CallgrindToolRunner::slotFinished); this, &CallgrindToolRunner::slotFinished);
connect(&m_runner, &ValgrindRunner::valgrindStarted, connect(&m_runner, &ValgrindRunner::valgrindStarted, this, [this](qint64 pid) {
this, &CallgrindToolRunner::setValgrindPid); m_pid = pid;
});
connect(&m_runner, &ValgrindRunner::extraProcessFinished, this, [this] { connect(&m_runner, &ValgrindRunner::extraProcessFinished, this, [this] {
triggerParse(); triggerParse();
}); });
setValgrindRunnable(runControl->runnable()); m_valgrindRunnable = runControl->runnable();
static int fileCount = 100; static int fileCount = 100;
m_valgrindOutputFile = runControl->workingDirectory() / QString("callgrind.out.f%1").arg(++fileCount); m_valgrindOutputFile = runControl->workingDirectory() / QString("callgrind.out.f%1").arg(++fileCount);
setValgrindOutputFile(m_valgrindOutputFile);
setupCallgrindRunner(this); setupCallgrindRunner(this);
} }
@@ -125,11 +125,6 @@ void CallgrindToolRunner::start()
return ValgrindToolRunner::start(); return ValgrindToolRunner::start();
} }
void CallgrindToolRunner::dump()
{
run(Dump);
}
void CallgrindToolRunner::setPaused(bool paused) void CallgrindToolRunner::setPaused(bool paused)
{ {
if (m_markAsPaused == paused) if (m_markAsPaused == paused)
@@ -152,21 +147,6 @@ void CallgrindToolRunner::setToggleCollectFunction(const QString &toggleCollectF
m_argumentForToggleCollect = "--toggle-collect=" + toggleCollectFunction; m_argumentForToggleCollect = "--toggle-collect=" + toggleCollectFunction;
} }
void CallgrindToolRunner::reset()
{
run(ResetEventCounters);
}
void CallgrindToolRunner::pause()
{
run(Pause);
}
void CallgrindToolRunner::unpause()
{
run(UnPause);
}
Callgrind::ParseData *CallgrindToolRunner::takeParserData() Callgrind::ParseData *CallgrindToolRunner::takeParserData()
{ {
return m_parser.takeData(); return m_parser.takeData();
@@ -182,12 +162,6 @@ void CallgrindToolRunner::showStatusMessage(const QString &message)
Debugger::showPermanentStatusMessage(message); Debugger::showPermanentStatusMessage(message);
} }
void CallgrindToolRunner::triggerParse()
{
getLocalDataFile();
}
static QString toOptionString(CallgrindToolRunner::Option option) static QString toOptionString(CallgrindToolRunner::Option option)
{ {
/* callgrind_control help from v3.9.0 /* callgrind_control help from v3.9.0
@@ -261,11 +235,6 @@ void CallgrindToolRunner::run(Option option)
m_controllerProcess->start(); m_controllerProcess->start();
} }
void CallgrindToolRunner::setValgrindPid(qint64 pid)
{
m_pid = pid;
}
void CallgrindToolRunner::controllerProcessDone() void CallgrindToolRunner::controllerProcessDone()
{ {
const QString error = m_controllerProcess->errorString(); const QString error = m_controllerProcess->errorString();
@@ -286,36 +255,24 @@ void CallgrindToolRunner::controllerProcessDone()
run(Dump); run(Dump);
return; return;
case Pause: case Pause:
m_paused = true;
break; break;
case Dump: case Dump:
showStatusMessage(tr("Callgrind dumped profiling info")); showStatusMessage(tr("Callgrind dumped profiling info"));
triggerParse();
break; break;
case UnPause: case UnPause:
m_paused = false;
showStatusMessage(tr("Callgrind unpaused.")); showStatusMessage(tr("Callgrind unpaused."));
break; break;
default: default:
break; break;
} }
switch (m_lastOption)
{
case Pause:
m_paused = true;
break;
case UnPause:
m_paused = false;
break;
case Dump:
triggerParse();
break;
default:
break; // do nothing
}
m_lastOption = Unknown; m_lastOption = Unknown;
} }
void CallgrindToolRunner::getLocalDataFile() void CallgrindToolRunner::triggerParse()
{ {
cleanupTempFile(); cleanupTempFile();
{ {
@@ -341,10 +298,5 @@ void CallgrindToolRunner::cleanupTempFile()
m_hostOutputFile.clear(); m_hostOutputFile.clear();
} }
void CallgrindToolRunner::setValgrindRunnable(const Runnable &runnable)
{
m_valgrindRunnable = runnable;
}
} // Internal } // Internal
} // Valgrind } // Valgrind

View File

@@ -48,10 +48,10 @@ public:
Valgrind::Callgrind::ParseData *takeParserData(); Valgrind::Callgrind::ParseData *takeParserData();
/// controller actions /// controller actions
void dump(); void dump() { run(Dump); }
void reset(); void reset() { run(ResetEventCounters); }
void pause(); void pause() { run(Pause); }
void unpause(); void unpause() { run(UnPause); }
/// marks the callgrind process as paused /// marks the callgrind process as paused
/// calls pause() and unpause() if there's an active run /// calls pause() and unpause() if there's an active run
@@ -80,21 +80,16 @@ private:
void slotFinished(); void slotFinished();
void showStatusMessage(const QString &message); void showStatusMessage(const QString &message);
void triggerParse();
void controllerFinished(Option option);
void run(Option option);
/** /**
* Make data file available locally, triggers @c localParseDataAvailable. * Make data file available locally, triggers @c localParseDataAvailable.
* *
* If the valgrind process was run remotely, this transparently * If the valgrind process was run remotely, this transparently
* downloads the data file first and returns a local path. * downloads the data file first and returns a local path.
*/ */
void getLocalDataFile(); void triggerParse();
void setValgrindPid(qint64 pid); void controllerFinished(Option option);
void setValgrindRunnable(const ProjectExplorer::Runnable &runnable);
void setValgrindOutputFile(const Utils::FilePath &output) { m_valgrindOutputFile = output; } void run(Option option);
void cleanupTempFile(); void cleanupTempFile();
void controllerProcessDone(); void controllerProcessDone();