2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-04-04 14:39:29 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2011-04-04 14:39:29 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-04-04 14:39:29 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2011-04-04 14:39:29 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2011-04-04 14:39:29 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-04-04 14:39:29 +02:00
|
|
|
|
|
|
|
|
#include "callgrindengine.h"
|
|
|
|
|
|
2015-07-01 12:31:27 +02:00
|
|
|
#include "callgrindtool.h"
|
2011-07-12 16:47:32 +02:00
|
|
|
#include "valgrindsettings.h"
|
2011-04-04 14:39:29 +02:00
|
|
|
|
|
|
|
|
#include <valgrind/callgrind/callgrindcontroller.h>
|
|
|
|
|
#include <valgrind/callgrind/callgrindparser.h>
|
|
|
|
|
|
|
|
|
|
#include <analyzerbase/analyzermanager.h>
|
|
|
|
|
|
|
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
|
|
|
|
using namespace Analyzer;
|
2011-05-23 13:50:28 +02:00
|
|
|
using namespace Valgrind;
|
|
|
|
|
using namespace Valgrind::Internal;
|
2011-04-04 14:39:29 +02:00
|
|
|
|
2013-07-30 14:08:01 +02:00
|
|
|
CallgrindRunControl::CallgrindRunControl(const AnalyzerStartParameters &sp,
|
2011-06-30 13:44:22 +02:00
|
|
|
ProjectExplorer::RunConfiguration *runConfiguration)
|
2016-01-06 11:40:52 +01:00
|
|
|
: ValgrindRunControl(sp, runConfiguration, CALLGRIND_RUN_MODE)
|
2011-04-04 14:39:29 +02:00
|
|
|
, m_markAsPaused(false)
|
|
|
|
|
{
|
2015-02-03 23:56:02 +02:00
|
|
|
connect(&m_runner, &Callgrind::CallgrindRunner::finished,
|
2015-01-30 11:02:24 +01:00
|
|
|
this, &CallgrindRunControl::slotFinished);
|
2015-02-06 12:39:07 +02:00
|
|
|
connect(m_runner.parser(), &Callgrind::Parser::parserDataReady,
|
|
|
|
|
this, &CallgrindRunControl::slotFinished);
|
2015-02-03 23:56:02 +02:00
|
|
|
connect(&m_runner, &Callgrind::CallgrindRunner::statusMessage,
|
2015-01-30 11:02:24 +01:00
|
|
|
this, &CallgrindRunControl::showStatusMessage);
|
2011-04-04 14:39:29 +02:00
|
|
|
}
|
|
|
|
|
|
2013-07-30 14:08:01 +02:00
|
|
|
void CallgrindRunControl::showStatusMessage(const QString &msg)
|
2011-06-30 13:44:22 +02:00
|
|
|
{
|
2015-07-01 12:44:45 +02:00
|
|
|
AnalyzerManager::showPermanentStatusMessage(CallgrindToolId, msg);
|
2011-06-30 13:44:22 +02:00
|
|
|
}
|
|
|
|
|
|
2013-07-30 14:08:01 +02:00
|
|
|
QStringList CallgrindRunControl::toolArguments() const
|
2011-04-04 14:39:29 +02:00
|
|
|
{
|
|
|
|
|
QStringList arguments;
|
|
|
|
|
|
2013-08-08 17:37:37 +02:00
|
|
|
QTC_ASSERT(m_settings, return arguments);
|
2011-04-04 14:39:29 +02:00
|
|
|
|
2013-08-08 17:37:37 +02:00
|
|
|
if (m_settings->enableCacheSim())
|
2012-11-26 15:02:17 +02:00
|
|
|
arguments << QLatin1String("--cache-sim=yes");
|
2011-04-04 14:39:29 +02:00
|
|
|
|
2013-08-08 17:37:37 +02:00
|
|
|
if (m_settings->enableBranchSim())
|
2012-11-26 15:02:17 +02:00
|
|
|
arguments << QLatin1String("--branch-sim=yes");
|
2011-04-04 14:39:29 +02:00
|
|
|
|
2013-08-08 17:37:37 +02:00
|
|
|
if (m_settings->collectBusEvents())
|
2012-11-26 15:02:17 +02:00
|
|
|
arguments << QLatin1String("--collect-bus=yes");
|
2011-04-04 14:39:29 +02:00
|
|
|
|
2013-08-08 17:37:37 +02:00
|
|
|
if (m_settings->collectSystime())
|
2012-11-26 15:02:17 +02:00
|
|
|
arguments << QLatin1String("--collect-systime=yes");
|
2011-04-04 14:39:29 +02:00
|
|
|
|
|
|
|
|
if (m_markAsPaused)
|
2012-11-26 15:02:17 +02:00
|
|
|
arguments << QLatin1String("--instr-atstart=no");
|
2011-04-04 14:39:29 +02:00
|
|
|
|
|
|
|
|
// add extra arguments
|
2012-02-02 20:26:12 +01:00
|
|
|
if (!m_argumentForToggleCollect.isEmpty())
|
|
|
|
|
arguments << m_argumentForToggleCollect;
|
2011-04-04 14:39:29 +02:00
|
|
|
|
|
|
|
|
return arguments;
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-30 14:08:01 +02:00
|
|
|
QString CallgrindRunControl::progressTitle() const
|
2011-04-04 14:39:29 +02:00
|
|
|
{
|
|
|
|
|
return tr("Profiling");
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-03 23:56:02 +02:00
|
|
|
ValgrindRunner * CallgrindRunControl::runner()
|
2011-04-04 14:39:29 +02:00
|
|
|
{
|
|
|
|
|
return &m_runner;
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-30 14:08:01 +02:00
|
|
|
bool CallgrindRunControl::startEngine()
|
2011-04-04 14:39:29 +02:00
|
|
|
{
|
2013-10-17 13:48:04 +02:00
|
|
|
appendMessage(tr("Profiling %1").arg(executable()) + QLatin1Char('\n'), Utils::NormalMessageFormat);
|
2013-07-30 14:08:01 +02:00
|
|
|
return ValgrindRunControl::startEngine();
|
2011-04-04 14:39:29 +02:00
|
|
|
}
|
|
|
|
|
|
2013-07-30 14:08:01 +02:00
|
|
|
void CallgrindRunControl::dump()
|
2011-04-04 14:39:29 +02:00
|
|
|
{
|
2015-02-03 23:56:02 +02:00
|
|
|
m_runner.controller()->run(Callgrind::CallgrindController::Dump);
|
2011-04-04 14:39:29 +02:00
|
|
|
}
|
|
|
|
|
|
2013-07-30 14:08:01 +02:00
|
|
|
void CallgrindRunControl::setPaused(bool paused)
|
2011-04-04 14:39:29 +02:00
|
|
|
{
|
|
|
|
|
if (m_markAsPaused == paused)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_markAsPaused = paused;
|
|
|
|
|
|
2011-05-11 16:26:34 +02:00
|
|
|
// call controller only if it is attached to a valgrind process
|
|
|
|
|
if (m_runner.controller()->valgrindProcess()) {
|
|
|
|
|
if (paused)
|
|
|
|
|
pause();
|
|
|
|
|
else
|
|
|
|
|
unpause();
|
|
|
|
|
}
|
2011-04-04 14:39:29 +02:00
|
|
|
}
|
|
|
|
|
|
2013-07-30 14:08:01 +02:00
|
|
|
void CallgrindRunControl::setToggleCollectFunction(const QString &toggleCollectFunction)
|
2011-04-04 14:39:29 +02:00
|
|
|
{
|
|
|
|
|
if (toggleCollectFunction.isEmpty())
|
|
|
|
|
return;
|
|
|
|
|
|
2012-02-02 20:26:12 +01:00
|
|
|
m_argumentForToggleCollect = QLatin1String("--toggle-collect=") + toggleCollectFunction;
|
2011-04-04 14:39:29 +02:00
|
|
|
}
|
|
|
|
|
|
2013-07-30 14:08:01 +02:00
|
|
|
void CallgrindRunControl::reset()
|
2011-04-04 14:39:29 +02:00
|
|
|
{
|
2015-02-03 23:56:02 +02:00
|
|
|
m_runner.controller()->run(Callgrind::CallgrindController::ResetEventCounters);
|
2011-04-04 14:39:29 +02:00
|
|
|
}
|
|
|
|
|
|
2013-07-30 14:08:01 +02:00
|
|
|
void CallgrindRunControl::pause()
|
2011-04-04 14:39:29 +02:00
|
|
|
{
|
2015-02-03 23:56:02 +02:00
|
|
|
m_runner.controller()->run(Callgrind::CallgrindController::Pause);
|
2011-04-04 14:39:29 +02:00
|
|
|
}
|
|
|
|
|
|
2013-07-30 14:08:01 +02:00
|
|
|
void CallgrindRunControl::unpause()
|
2011-04-04 14:39:29 +02:00
|
|
|
{
|
2015-02-03 23:56:02 +02:00
|
|
|
m_runner.controller()->run(Callgrind::CallgrindController::UnPause);
|
2011-04-04 14:39:29 +02:00
|
|
|
}
|
|
|
|
|
|
2015-02-03 23:56:02 +02:00
|
|
|
Callgrind::ParseData *CallgrindRunControl::takeParserData()
|
2011-04-04 14:39:29 +02:00
|
|
|
{
|
|
|
|
|
return m_runner.parser()->takeData();
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-30 14:08:01 +02:00
|
|
|
void CallgrindRunControl::slotFinished()
|
2011-04-04 14:39:29 +02:00
|
|
|
{
|
|
|
|
|
emit parserDataReady(this);
|
|
|
|
|
}
|