Fixes for valgrind-callgrind feedback by Nokia

Most changes include style fixes and UI changes for better usability.

Merge-request: 324
Reviewed-by: hjk <qtc-committer@nokia.com>
This commit is contained in:
Kevin Funk
2011-05-11 16:26:34 +02:00
committed by hjk
parent f5601d7b1b
commit bf1f5c2b02
44 changed files with 429 additions and 234 deletions

View File

@@ -208,11 +208,21 @@ QVariant CallModel::data(const QModelIndex &index, int role) const
QVariant CallModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Vertical || role != Qt::DisplayRole)
if (orientation == Qt::Vertical || (role != Qt::DisplayRole && role != Qt::ToolTipRole))
return QVariant();
QTC_ASSERT(section >= 0 && section < columnCount(), return QVariant());
if (role == Qt::ToolTipRole) {
if (section == CostColumn) {
if (!d->m_data)
return QVariant();
return ParseData::prettyStringForEvent(d->m_data->events().at(d->m_event));
}
return QVariant();
}
if (section == CalleeColumn)
return tr("Callee");
else if (section == CallerColumn)

View File

@@ -36,7 +36,6 @@
#include <QObject>
#include <qprocess.h>
#include <qmetatype.h>
#include <utils/ssh/sshconnection.h>
#include <utils/ssh/sshremoteprocess.h>
@@ -69,6 +68,7 @@ public:
void run(Valgrind::Callgrind::CallgrindController::Option option);
void setValgrindProcess(ValgrindProcess *process);
inline ValgrindProcess *valgrindProcess() { return m_valgrindProc; }
/**
* Make data file available locally, triggers @c localParseDataAvailable.
@@ -96,7 +96,7 @@ private Q_SLOTS:
private:
void cleanupTempFile();
// callgrind_controll process
// callgrind_control process
Valgrind::ValgrindProcess *m_process;
// valgrind process
Valgrind::ValgrindProcess *m_valgrindProc;

View File

@@ -65,6 +65,7 @@ public:
Private()
: m_data(0)
, m_event(0)
, m_verboseToolTips(true)
, m_cycleDetection(false)
{
}
@@ -77,6 +78,7 @@ public:
const ParseData *m_data;
int m_event;
bool m_verboseToolTips;
bool m_cycleDetection;
QVector<const Function *> m_functions;
};
@@ -128,6 +130,16 @@ void DataModel::setParseData(const ParseData *data)
endResetModel();
}
void DataModel::setVerboseToolTipsEnabled(bool enabled)
{
d->m_verboseToolTips = enabled;
}
bool DataModel::verboseToolTipsEnabled() const
{
return d->m_verboseToolTips;
}
const ParseData *DataModel::parseData() const
{
return d->m_data;
@@ -254,6 +266,9 @@ QVariant DataModel::data(const QModelIndex &index, int role) const
else if (index.column() == InclusiveCostColumn)
return inclusiveCost;
} else if (role == Qt::ToolTipRole) {
if (!d->m_verboseToolTips)
return data(index, Qt::DisplayRole);
QString ret = "<html><head><style>\
dt { font-weight: bold; }\
dd { font-family: monospace; }\
@@ -311,11 +326,24 @@ QVariant DataModel::data(const QModelIndex &index, int role) const
QVariant DataModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Vertical || role != Qt::DisplayRole)
if (orientation == Qt::Vertical || (role != Qt::DisplayRole && role != Qt::ToolTipRole))
return QVariant();
QTC_ASSERT(section >= 0 && section < columnCount(), return QVariant());
if (role == Qt::ToolTipRole) {
if (!d->m_data)
return QVariant();
const QString prettyCostStr = ParseData::prettyStringForEvent(d->m_data->events().at(d->m_event));
if (section == SelfCostColumn) {
return tr("%1 cost spent in a given function excluding costs from called functions.").arg(prettyCostStr);
} else if (section == InclusiveCostColumn) {
return tr("%1 cost spent in a given function including costs from called functions.").arg(prettyCostStr);
}
return QVariant();
}
if (section == NameColumn)
return tr("Function");
else if (section == LocationColumn)

View File

@@ -56,6 +56,9 @@ public:
virtual void setParseData(const ParseData *data);
virtual const ParseData *parseData() const;
void setVerboseToolTipsEnabled(bool enabled);
bool verboseToolTipsEnabled() const;
/// Only one cost event column will be shown, this decides which one it is.
/// By default it is the first event in the @c ParseData, i.e. 0.
virtual int costEvent() const;

View File

@@ -38,6 +38,8 @@
#include <QtCore/QEventLoop>
#include <QtCore/QFileInfo>
#include <utils/qtcassert.h>
namespace Valgrind {
ValgrindProcess::ValgrindProcess(QObject *parent)
@@ -204,6 +206,8 @@ void RemoteValgrindProcess::run(const QString &valgrindExecutable, const QString
void RemoteValgrindProcess::connected()
{
QTC_ASSERT(m_connection->state() == Utils::SshConnection::Connected, return);
// connected, run command
QString cmd;
@@ -235,6 +239,8 @@ Utils::SshConnection::Ptr RemoteValgrindProcess::connection() const
void RemoteValgrindProcess::processStarted()
{
QTC_ASSERT(m_connection->state() == Utils::SshConnection::Connected, return);
// find out what PID our process has
// NOTE: valgrind cloaks its name,
@@ -293,9 +299,8 @@ void RemoteValgrindProcess::error(Utils::SshError error)
void RemoteValgrindProcess::close()
{
QTC_ASSERT(m_connection->state() == Utils::SshConnection::Connected, return);
if (m_process) {
m_process->closeChannel();
if (m_pid) {
const QString killTemplate = QString("kill -%2 %1" // kill
).arg(m_pid);
@@ -304,14 +309,16 @@ void RemoteValgrindProcess::close()
const QString brutalKill = killTemplate.arg("SIGKILL");
const QString remoteCall = niceKill + QLatin1String("; sleep 1; ") + brutalKill;
m_cleanup = m_connection->createRemoteProcess(remoteCall.toUtf8());
m_cleanup->start();
Utils::SshRemoteProcess::Ptr cleanup = m_connection->createRemoteProcess(remoteCall.toUtf8());
cleanup->start();
}
}
}
void RemoteValgrindProcess::closed(int status)
{
QTC_ASSERT(m_process, return);
m_errorString = m_process->errorString();
if (status == Utils::SshRemoteProcess::FailedToStart) {
m_error = QProcess::FailedToStart;

View File

@@ -156,7 +156,6 @@ private:
Utils::SshConnectionParameters m_params;
Utils::SshConnection::Ptr m_connection;
Utils::SshRemoteProcess::Ptr m_process;
Utils::SshRemoteProcess::Ptr m_cleanup;
QString m_workingDir;
QString m_valgrindExe;
QStringList m_valgrindArgs;

View File

@@ -210,6 +210,7 @@ public:
AnalyzerRunControlFactory *m_runControlFactory;
ProjectExplorer::RunControl *m_currentRunControl;
Utils::FancyMainWindow *m_mainWindow;
IAnalyzerTool *m_currentTool;
QList<IAnalyzerTool *> m_tools;
QActionGroup *m_toolGroup;
QAction *m_startAction;
@@ -232,7 +233,6 @@ public:
bool m_restartOnStop;
bool m_initialized;
IAnalyzerTool *m_currentTool;
};
AnalyzerManager::AnalyzerManagerPrivate::AnalyzerManagerPrivate(AnalyzerManager *qq):
@@ -242,6 +242,7 @@ AnalyzerManager::AnalyzerManagerPrivate::AnalyzerManagerPrivate(AnalyzerManager
m_runControlFactory(0),
m_currentRunControl(0),
m_mainWindow(0),
m_currentTool(0),
m_toolGroup(0),
m_startAction(0),
m_startRemoteAction(0),
@@ -253,8 +254,7 @@ AnalyzerManager::AnalyzerManagerPrivate::AnalyzerManagerPrivate(AnalyzerManager
m_statusLabel(new Utils::StatusLabel),
m_resizeEventFilter(new DockWidgetEventFilter(qq)),
m_restartOnStop(false),
m_initialized(false),
m_currentTool(0)
m_initialized(false)
{
m_toolBox->setObjectName(QLatin1String("AnalyzerManagerToolBox"));
m_runControlFactory = new AnalyzerRunControlFactory();
@@ -541,7 +541,7 @@ void AnalyzerManager::AnalyzerManagerPrivate::startTool()
const QString msg = tr("<html><head/><body><center><i>%1</i> is still running. You have to quit the Analyzer before being able to run another instance.<center/>"
"<center>Force it to quit?</center></body></html>").arg(m_currentRunControl->displayName());
bool stopRequested = showPromptDialog(tr("Analyzer Still Running"), msg,
tr("Stop active run"), tr("Keep Running"));
tr("Stop Active Run"), tr("Keep Running"));
if (!stopRequested)
return; // no restart, keep it running, do nothing
@@ -657,7 +657,6 @@ void AnalyzerManager::toolSelected(int idx)
return;
selectingTool = true;
if (oldTool != 0) {
saveToolSettings(oldTool);

View File

@@ -68,6 +68,24 @@ CallgrindConfigWidget::CallgrindConfigWidget(AbstractCallgrindSettings *settings
m_settings, SLOT(setCollectBusEvents(bool)));
connect(m_settings, SIGNAL(collectBusEventsChanged(bool)),
m_ui->collectBusEvents, SLOT(setChecked(bool)));
m_ui->enableEventToolTips->setChecked(m_settings->enableEventToolTips());
connect(m_ui->enableEventToolTips, SIGNAL(toggled(bool)),
m_settings, SLOT(setEnableEventToolTips(bool)));
connect(m_settings, SIGNAL(enableEventToolTipsChanged(bool)),
m_ui->enableEventToolTips, SLOT(setChecked(bool)));
m_ui->minimumInclusiveCostRatio->setValue(m_settings->minimumInclusiveCostRatio());
connect(m_ui->minimumInclusiveCostRatio, SIGNAL(valueChanged(double)),
m_settings, SLOT(setMinimumInclusiveCostRatio(double)));
connect(m_settings, SIGNAL(minimumInclusiveCostRatioChanged(double)),
m_ui->minimumInclusiveCostRatio, SLOT(setValue(double)));
m_ui->visualisationMinimumInclusiveCostRatio->setValue(m_settings->visualisationMinimumInclusiveCostRatio());
connect(m_ui->visualisationMinimumInclusiveCostRatio, SIGNAL(valueChanged(double)),
m_settings, SLOT(setVisualisationMinimumInclusiveCostRatio(double)));
connect(m_settings, SIGNAL(visualisationMinimumInclusiveCostRatioChanged(double)),
m_ui->visualisationMinimumInclusiveCostRatio, SLOT(setValue(double)));
}
CallgrindConfigWidget::~CallgrindConfigWidget()

View File

@@ -10,8 +10,8 @@
<height>565</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<widget class="QGroupBox" name="memcheckOptions">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
@@ -22,21 +22,46 @@
<property name="title">
<string>Profiling Options</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="4" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="minimumInclusiveCostRatioLabel">
<property name="toolTip">
<string>This option limits the amount of results the profiler will give you. A lower limit will likely increase performance.</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
<property name="text">
<string>Result view: Show events with inclusive costs higher than:</string>
</property>
</spacer>
<property name="buddy">
<cstring>minimumInclusiveCostRatio</cstring>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="minimumInclusiveCostRatio">
<property name="suffix">
<string>%</string>
</property>
<property name="decimals">
<number>2</number>
</property>
<property name="maximum">
<double>10.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QGroupBox" name="enableEventToolTips">
<property name="title">
<string>Show additional information for events in tooltips</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QCheckBox" name="enableCacheSim">
<property name="toolTip">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
@@ -96,13 +121,52 @@ p, li { white-space: pre-wrap; }
<string>This specifies whether the number of global bus events executed should be collected. The event type &quot;Ge&quot; is used for these events.</string>
</property>
<property name="text">
<string>Collect global bus events</string>
<string>Collect global bus events:</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="visualisationMinimumInclusiveCostRatioLabel">
<property name="text">
<string>Visualisation: Show events with inclusive costs higher than:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="visualisationMinimumInclusiveCostRatio">
<property name="prefix">
<string/>
</property>
<property name="suffix">
<string>%</string>
</property>
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>50.000000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>

View File

@@ -126,12 +126,14 @@ void CallgrindEngine::setPaused(bool paused)
m_markAsPaused = paused;
// call controller
// call controller only if it is attached to a valgrind process
if (m_runner.controller()->valgrindProcess()) {
if (paused)
pause();
else
unpause();
}
}
void CallgrindEngine::setToggleCollectFunction(const QString &toggleCollectFunction)
{

View File

@@ -60,7 +60,10 @@ public slots:
void pause();
void unpause();
/// marks the callgrind process as paused
/// calls pause() and unpause() if there's an active run
void setPaused(bool paused);
void setToggleCollectFunction(const QString &toggleCollectFunction);
protected:

View File

@@ -44,10 +44,12 @@ static const char callgrindEnableCacheSimC[] = "Analyzer.Valgrind.Callgrind.Enab
static const char callgrindEnableBranchSimC[] = "Analyzer.Valgrind.Callgrind.EnableBranchSim";
static const char callgrindCollectSystimeC[] = "Analyzer.Valgrind.Callgrind.CollectSystime";
static const char callgrindCollectBusEventsC[] = "Analyzer.Valgrind.Callgrind.CollectBusEvents";
static const char callgrindEnableEventToolTipsC[] = "Analyzer.Valgrind.Callgrind.EnableEventToolTips";
static const char callgrindMinimumCostRatioC[] = "Analyzer.Valgrind.Callgrind.MinimumCostRatio";
static const char callgrindVisualisationMinimumCostRatioC[] = "Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio";
static const char callgrindCycleDetectionC[] = "Analyzer.Valgrind.Callgrind.CycleDetection";
static const char callgrindCostFormatC[] = "Analyzer.Valgrind.Callgrind.CostFormat";
static const char callgrindMinimumCostRatioC[] = "Analyzer.Valgrind.Callgrind.MinimumCostRatio";
AbstractCallgrindSettings::AbstractCallgrindSettings(QObject *parent)
: AbstractAnalyzerSubConfig(parent)
@@ -96,6 +98,35 @@ void AbstractCallgrindSettings::setCollectBusEvents(bool collect)
emit collectBusEventsChanged(collect);
}
void AbstractCallgrindSettings::setEnableEventToolTips(bool enable)
{
if (m_enableEventToolTips == enable)
return;
m_enableEventToolTips = enable;
emit enableEventToolTipsChanged(enable);
}
void AbstractCallgrindSettings::setMinimumInclusiveCostRatio(
double minimumInclusiveCostRatio)
{
if (m_minimumInclusiveCostRatio == minimumInclusiveCostRatio)
return;
m_minimumInclusiveCostRatio = qBound(0.0, minimumInclusiveCostRatio, 100.0);
emit minimumInclusiveCostRatioChanged(minimumInclusiveCostRatio);
}
void AbstractCallgrindSettings::setVisualisationMinimumInclusiveCostRatio(
double minimumInclusiveCostRatio)
{
if (m_visualisationMinimumInclusiveCostRatio == minimumInclusiveCostRatio)
return;
m_visualisationMinimumInclusiveCostRatio = qBound(0.0, minimumInclusiveCostRatio, 100.0);
emit visualisationMinimumInclusiveCostRatioChanged(minimumInclusiveCostRatio);
}
QVariantMap AbstractCallgrindSettings::defaults() const
{
QVariantMap map;
@@ -103,6 +134,9 @@ QVariantMap AbstractCallgrindSettings::defaults() const
map.insert(QLatin1String(callgrindEnableBranchSimC), false);
map.insert(QLatin1String(callgrindCollectSystimeC), false);
map.insert(QLatin1String(callgrindCollectBusEventsC), false);
map.insert(QLatin1String(callgrindEnableEventToolTipsC), true);
map.insert(QLatin1String(callgrindMinimumCostRatioC), 0.01);
map.insert(QLatin1String(callgrindVisualisationMinimumCostRatioC), 10.0);
return map;
}
@@ -112,6 +146,10 @@ bool AbstractCallgrindSettings::fromMap(const QVariantMap &map)
setIfPresent(map, QLatin1String(callgrindEnableBranchSimC), &m_enableBranchSim);
setIfPresent(map, QLatin1String(callgrindCollectSystimeC), &m_collectSystime);
setIfPresent(map, QLatin1String(callgrindCollectBusEventsC), &m_collectBusEvents);
setIfPresent(map, QLatin1String(callgrindEnableEventToolTipsC), &m_enableEventToolTips);
setIfPresent(map, QLatin1String(callgrindMinimumCostRatioC), &m_minimumInclusiveCostRatio);
setIfPresent(map, QLatin1String(callgrindVisualisationMinimumCostRatioC),
&m_visualisationMinimumInclusiveCostRatio);
return true;
}
@@ -122,7 +160,10 @@ QVariantMap AbstractCallgrindSettings::toMap() const
map.insert(QLatin1String(callgrindEnableBranchSimC), m_enableBranchSim);
map.insert(QLatin1String(callgrindCollectSystimeC), m_collectSystime);
map.insert(QLatin1String(callgrindCollectBusEventsC), m_collectBusEvents);
map.insert(QLatin1String(callgrindEnableEventToolTipsC), m_enableEventToolTips);
map.insert(QLatin1String(callgrindMinimumCostRatioC), m_minimumInclusiveCostRatio);
map.insert(QLatin1String(callgrindVisualisationMinimumCostRatioC),
m_visualisationMinimumInclusiveCostRatio);
return map;
}
@@ -158,7 +199,6 @@ QVariantMap CallgrindGlobalSettings::defaults() const
QVariantMap map = AbstractCallgrindSettings::defaults();
map.insert(QLatin1String(callgrindCostFormatC), CostDelegate::FormatRelative);
map.insert(QLatin1String(callgrindCycleDetectionC), true);
map.insert(QLatin1String(callgrindMinimumCostRatioC), 0.0001);
return map;
}
@@ -170,7 +210,6 @@ bool CallgrindGlobalSettings::fromMap(const QVariantMap &map)
m_costFormat = static_cast<CostDelegate::CostFormat>(map.value(QLatin1String(callgrindCostFormatC)).toInt());
}
setIfPresent(map, QLatin1String(callgrindCycleDetectionC), &m_detectCycles);
setIfPresent(map, QLatin1String(callgrindMinimumCostRatioC), &m_minimumInclusiveCostRatio);
return true;
}
@@ -179,7 +218,6 @@ QVariantMap CallgrindGlobalSettings::toMap() const
QVariantMap map = AbstractCallgrindSettings::toMap();
map.insert(QLatin1String(callgrindCostFormatC), m_costFormat);
map.insert(QLatin1String(callgrindCycleDetectionC), m_detectCycles);
map.insert(QLatin1String(callgrindMinimumCostRatioC), m_minimumInclusiveCostRatio);
return map;
}
@@ -205,17 +243,6 @@ void CallgrindGlobalSettings::setDetectCycles(bool detect)
AnalyzerGlobalSettings::instance()->writeSettings();
}
double CallgrindGlobalSettings::minimumInclusiveCostRatio() const
{
return m_minimumInclusiveCostRatio;
}
void CallgrindGlobalSettings::setMinimumInclusiveCostRatio(double minimumInclusiveCost)
{
m_minimumInclusiveCostRatio = minimumInclusiveCost;
AnalyzerGlobalSettings::instance()->writeSettings();
}
CallgrindProjectSettings::CallgrindProjectSettings(QObject *parent)
: AbstractCallgrindSettings(parent)
{

View File

@@ -56,6 +56,13 @@ public:
inline bool enableBranchSim() const { return m_enableBranchSim; }
inline bool collectSystime() const { return m_collectSystime; }
inline bool collectBusEvents() const { return m_collectBusEvents; }
inline bool enableEventToolTips() const { return m_enableEventToolTips; }
/// \return Minimum cost ratio, range [0.0..100.0]
inline double minimumInclusiveCostRatio() const { return m_minimumInclusiveCostRatio; }
/// \return Minimum cost ratio, range [0.0..100.0]
inline double visualisationMinimumInclusiveCostRatio() const { return m_visualisationMinimumInclusiveCostRatio; }
// abstract virtual methods from base class
virtual bool fromMap(const QVariantMap &map);
@@ -71,12 +78,22 @@ public Q_SLOTS:
void setEnableBranchSim(bool enable);
void setCollectSystime(bool collect);
void setCollectBusEvents(bool collect);
void setEnableEventToolTips(bool enable);
/// \param minimumInclusiveCostRatio Minimum inclusive cost ratio, valid values are [0.0..100.0]
void setMinimumInclusiveCostRatio(double minimumInclusiveCostRatio);
/// \param minimumInclusiveCostRatio Minimum inclusive cost ratio, valid values are [0.0..100.0]
void setVisualisationMinimumInclusiveCostRatio(double minimumInclusiveCostRatio);
Q_SIGNALS:
void enableCacheSimChanged(bool);
void enableBranchSimChanged(bool);
void collectSystimeChanged(bool);
void collectBusEventsChanged(bool);
void enableEventToolTipsChanged(bool);
void minimumInclusiveCostRatioChanged(double);
void visualisationMinimumInclusiveCostRatioChanged(double);
protected:
virtual QVariantMap toMap() const;
@@ -86,6 +103,9 @@ private:
bool m_collectSystime;
bool m_collectBusEvents;
bool m_enableBranchSim;
bool m_enableEventToolTips;
double m_minimumInclusiveCostRatio;
double m_visualisationMinimumInclusiveCostRatio;
};
/**
@@ -104,12 +124,10 @@ public:
CostDelegate::CostFormat costFormat() const;
bool detectCycles() const;
double minimumInclusiveCostRatio() const;
public slots:
void setCostFormat(Callgrind::Internal::CostDelegate::CostFormat format);
void setDetectCycles(bool detect);
void setMinimumInclusiveCostRatio(double minimumInclusiveCost);
protected:
virtual QVariantMap toMap() const;
@@ -117,7 +135,6 @@ protected:
private:
CostDelegate::CostFormat m_costFormat;
bool m_detectCycles;
double m_minimumInclusiveCostRatio;
};
/**

View File

@@ -208,7 +208,7 @@ void CallgrindTool::extensionsInitialized()
analyzerContext);
editorContextMenu->addAction(cmd);
action = new QAction(tr("Profile costs of this function and its callees"), this);
action = new QAction(tr("Profile Costs of this Function and its Callees"), this);
action->setIcon(QIcon(Analyzer::Constants::ANALYZER_CONTROL_START_ICON));
connect(action, SIGNAL(triggered()), SLOT(handleShowCostsOfFunction()));
cmd = actionManager->registerAction(action, Callgrind::Constants::A_SHOWCOSTSOFFUNCTION,
@@ -245,6 +245,15 @@ IAnalyzerEngine *CallgrindTool::createEngine(const AnalyzerStartParameters &sp,
AnalyzerManager::instance()->showStatusMessage(AnalyzerManager::msgToolStarted(displayName()));
// apply project settings
AnalyzerProjectSettings *analyzerSettings = runConfiguration->extraAspect<AnalyzerProjectSettings>();
CallgrindProjectSettings *settings = analyzerSettings->subConfig<CallgrindProjectSettings>();
QTC_ASSERT(settings, return engine)
m_callgrindWidgetHandler->visualisation()->setMinimumInclusiveCostRatio(settings->visualisationMinimumInclusiveCostRatio() / 100.0);
m_callgrindWidgetHandler->proxyModel()->setMinimumInclusiveCostRatio(settings->minimumInclusiveCostRatio() / 100.0);
m_callgrindWidgetHandler->dataModel()->setVerboseToolTipsEnabled(settings->enableEventToolTips());
return engine;
}
@@ -313,9 +322,6 @@ QWidget *CallgrindTool::createPaneToolBarWidget()
connect(m_callgrindWidgetHandler, SIGNAL(cycleDetectionEnabled(bool)),
settings, SLOT(setDetectCycles(bool)));
// performance: add a minimum cost index so that we are not flooded by the results
m_callgrindWidgetHandler->proxyModel()->setMinimumInclusiveCostRatio(settings->minimumInclusiveCostRatio());
return toolbarWidget;
}
@@ -397,7 +403,7 @@ void CallgrindTool::requestContextMenu(TextEditor::ITextEditor *editor, int line
return; // no callgrind text mark under cursor, return
// add our action to the context menu
QAction *action = new QAction(tr("Select this function in the analyzer output"), menu);
QAction *action = new QAction(tr("Select this Function in the Analyzer Output"), menu);
connect(action, SIGNAL(triggered()), this, SLOT(handleShowCostsAction()));
action->setData(QVariant::fromValue<const Function *>(func));
menu->addAction(action);
@@ -435,7 +441,7 @@ void CallgrindTool::handleShowCostsOfFunction()
void CallgrindTool::slotRequestDump()
{
m_callgrindWidgetHandler->visualisation()->setText(tr("Populating..."));
m_callgrindWidgetHandler->slotRequestDump();
emit dumpRequested();
}

View File

@@ -73,13 +73,9 @@ public:
const QStyleOptionGraphicsItem *option, QWidget *widget);
virtual QRectF boundingRect() const;
void setRotateText(bool rotate);
private:
QString m_text;
QStaticText m_staticText;
bool m_rotateText;
QColor m_textColor;
qreal m_previousViewportDimension;
};
@@ -105,7 +101,6 @@ FunctionGraphicsTextItem::FunctionGraphicsTextItem(const QString &text,
QGraphicsItem *parent)
: QAbstractGraphicsShapeItem(parent)
, m_text(text)
, m_rotateText(true)
, m_previousViewportDimension(0)
{
setFlag(QGraphicsItem::ItemIgnoresTransformations);
@@ -113,11 +108,6 @@ FunctionGraphicsTextItem::FunctionGraphicsTextItem(const QString &text,
setToolTip(text);
}
void FunctionGraphicsTextItem::setRotateText(bool rotate)
{
m_rotateText = rotate;
}
void FunctionGraphicsTextItem::paint(QPainter *painter,
const QStyleOptionGraphicsItem *,
QWidget *widget)
@@ -135,30 +125,17 @@ void FunctionGraphicsTextItem::paint(QPainter *painter,
* parentItem()->boundingRect().height()
/ scene()->sceneRect().height();
qreal textMaxHeight;
qreal textMaxWidth;
qreal viewportDim;
if (m_rotateText) {
viewportDim = viewportRect.height();
textMaxHeight = maxWidth;
textMaxWidth = maxHeight;
} else {
viewportDim = viewportRect.width();
textMaxHeight = maxHeight;
textMaxWidth = maxWidth;
}
if (textHeight > textMaxHeight)
if (textHeight > maxHeight)
return;
if (viewportDim != m_previousViewportDimension) {
if (viewportRect.width() != m_previousViewportDimension) {
const QString &elidedText =
painter->fontMetrics().elidedText(m_text, Qt::ElideRight,
textMaxWidth);
maxWidth);
m_staticText.setText(elidedText);
m_staticText.prepare();
m_previousViewportDimension = viewportDim;
m_previousViewportDimension = viewportRect.width();
}
#if VISUALISATION_DEBUG
@@ -169,16 +146,9 @@ void FunctionGraphicsTextItem::paint(QPainter *painter,
painter->save();
int textLeft = 0;
int textTop = 0;
if (m_rotateText) {
painter->rotate(90);
textLeft = 2;
textTop = -textHeight/2;
}
else {
const int textWidth = painter->fontMetrics().width(m_staticText.text());
textLeft = -textWidth/2;
textTop = (maxHeight - textHeight)/2;
}
painter->drawStaticText(textLeft, textTop, m_staticText);
painter->restore();
@@ -218,9 +188,10 @@ void FunctionGraphicsItem::paint(QPainter *painter,
QRectF rect = this->rect();
const QColor &color = brush().color();
if (option->state & QStyle::State_Selected) {
QLinearGradient gradient(0, 0, rect.width(), rect.height());
gradient.setColorAt(0, color.lighter(250));
gradient.setColorAt(1, color.darker());
QLinearGradient gradient(0, 0, rect.width(), 0);
gradient.setColorAt(0, color.darker(100));
gradient.setColorAt(0.5, color.lighter(200));
gradient.setColorAt(1, color.darker(100));
painter->setBrush(gradient);
}
else {
@@ -256,13 +227,11 @@ public:
Visualisation *q;
DataProxyModel *m_model;
QGraphicsScene m_scene;
int m_modelColumn;
};
Visualisation::Private::Private(Visualisation *qq)
: q(qq)
, m_model(new DataProxyModel(qq))
, m_modelColumn(-1)
{
// setup scene
m_scene.setObjectName("Visualisation Scene");
@@ -359,6 +328,11 @@ const Function *Visualisation::function() const
return d->m_model->filterFunction();
}
void Visualisation::setMinimumInclusiveCostRatio(double ratio)
{
d->m_model->setMinimumInclusiveCostRatio(ratio);
}
void Visualisation::setModel(DataModel *model)
{
QTC_ASSERT(!d->m_model->sourceModel() && model, return); // only set once!
@@ -450,28 +424,26 @@ void Visualisation::populateScene()
const QColor background = CallgrindHelper::colorForString(text);
item->setBrush(background);
item->setData(FunctionGraphicsItem::FunctionCallKey, QVariant::fromValue(d->m_model->filterFunction()));
item->textItem()->setRotateText(false);
// NOTE: workaround wrong tooltip being show, no idea why...
item->setZValue(-1);
d->m_scene.addItem(item);
}
// add the canvas elements to the scene
qreal used = 0;
qreal used = sceneHeight * 0.1;
foreach (const Pair &cost, costs)
{
const QModelIndex &index = cost.first;
const QString text = index.data().toString();
const qreal width = (sceneWidth * cost.second) / total;
const qreal height = sceneHeight * 0.9;
const qreal height = (sceneHeight * 0.9 * cost.second) / total;
FunctionGraphicsItem *item = new FunctionGraphicsItem(text, used, sceneHeight - height, width, height);
FunctionGraphicsItem *item = new FunctionGraphicsItem(text, 0, used, sceneWidth, height);
const QColor background = CallgrindHelper::colorForString(text);
item->setBrush(background);
item->setData(FunctionGraphicsItem::FunctionCallKey, index.data(DataModel::FunctionRole));
d->m_scene.addItem(item);
used += width;
used += height;
}
}

View File

@@ -66,6 +66,8 @@ public:
void setFunction(const Valgrind::Callgrind::Function *function);
const Valgrind::Callgrind::Function *function() const;
void setMinimumInclusiveCostRatio(double ratio);
public slots:
void setText(const QString &message);

View File

@@ -36,10 +36,6 @@
#include "callgrindengine.h"
#include "callgrindvisualisation.h"
#ifndef DISABLE_CALLGRIND_WORKAROUNDS
#include "workarounds.h"
#endif
#include <analyzerbase/analyzerconstants.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/icore.h>
@@ -129,6 +125,7 @@ void CallgrindWidgetHandler::ensureDockWidgets()
return;
QWidget *parenWidget = qobject_cast<QWidget *>(parent());
m_visualisation = new Visualisation(parenWidget);
m_visualisation->setFrameStyle(QFrame::NoFrame);
m_visualisation->setObjectName("Valgrind.CallgrindWidgetHandler.Visualisation");
m_visualisation->setModel(m_dataModel);
connect(m_visualisation, SIGNAL(functionActivated(const Valgrind::Callgrind::Function*)),
@@ -137,6 +134,7 @@ void CallgrindWidgetHandler::ensureDockWidgets()
m_callersView = new CostView(parenWidget);
m_callersView->sortByColumn(CallModel::CostColumn);
m_callersView->setObjectName("Valgrind.CallgrindWidgetHandler.CallersView");
m_callersView->setFrameStyle(QFrame::NoFrame);
// enable sorting
QSortFilterProxyModel *callerProxy = new QSortFilterProxyModel(m_callersModel);
callerProxy->setSourceModel(m_callersModel);
@@ -148,6 +146,7 @@ void CallgrindWidgetHandler::ensureDockWidgets()
m_calleesView = new CostView(parenWidget);
m_calleesView->sortByColumn(CallModel::CostColumn);
m_calleesView->setObjectName("Valgrind.CallgrindWidgetHandler.CalleesView");
m_calleesView->setFrameStyle(QFrame::NoFrame);
// enable sorting
QSortFilterProxyModel *calleeProxy = new QSortFilterProxyModel(m_calleesModel);
calleeProxy->setSourceModel(m_calleesModel);
@@ -247,7 +246,7 @@ void CallgrindWidgetHandler::populateActions(QLayout *layout)
menu->addAction(m_costRelative);
// show costs relative to parent
m_costRelativeToParent = new QAction(tr("Relative Costs To Parent"), this);
m_costRelativeToParent = new QAction(tr("Relative Costs to Parent"), this);
///FIXME: icon
m_costRelativeToParent->setToolTip(tr("Show costs relative to parent functions inclusive cost."));
m_costRelativeToParent->setCheckable(true);
@@ -333,8 +332,19 @@ void CallgrindWidgetHandler::doClear(bool clearParseData)
void CallgrindWidgetHandler::slotRequestDump()
{
setBusy(true);
m_visualisation->setText(tr("Populating..."));
emit dumpRequested();
}
void CallgrindWidgetHandler::setBusy(bool busy)
{
QCursor cursor(busy ? Qt::BusyCursor : Qt::ArrowCursor);
QList<QWidget *> widgets;
widgets << m_flatView << m_calleesView << m_callersView << m_visualisation;
foreach(QWidget *widget, widgets) {
widget->setCursor(cursor);
}
}
void CallgrindWidgetHandler::selectFunction(const Function *func)
@@ -510,6 +520,9 @@ void CallgrindWidgetHandler::setParseData(ParseData *data)
// clear history for new data
m_stackBrowser->clear();
// unset busy state
setBusy(false);
}
void CallgrindWidgetHandler::updateEventCombo()

View File

@@ -94,10 +94,6 @@ public:
Callgrind::Internal::CostDelegate::CostFormat costFormat() const;
signals:
void dumpRequested();
void resetRequested();
void pauseToggled(bool checked);
void functionSelected(const Valgrind::Callgrind::Function *);
void costFormatChanged(Callgrind::Internal::CostDelegate::CostFormat format);
@@ -121,6 +117,9 @@ private slots:
void slotGoToOverview();
void stackBrowserChanged();
/// If \param busy is true, all widgets get a busy cursor when hovered
void setBusy(bool busy);
void dataFunctionSelected(const QModelIndex &index);
void calleeFunctionSelected(const QModelIndex &index);
void callerFunctionSelected(const QModelIndex &index);
@@ -138,6 +137,7 @@ private:
Valgrind::Callgrind::CallModel *m_callersModel;
Valgrind::Callgrind::CallModel *m_calleesModel;
// callgrind widgets
CostView *m_flatView;
CostView *m_callersView;
CostView *m_calleesView;

View File

@@ -41,6 +41,10 @@
#include <coreplugin/progressmanager/futureprogress.h>
#include <extensionsystem/pluginmanager.h>
#include <projectexplorer/applicationrunconfiguration.h>
#include <analyzerbase/analyzermanager.h>
#include <QtGui/QApplication>
#include <QtGui/QMainWindow>
#define VALGRIND_DEBUG_OUTPUT 0
@@ -53,6 +57,7 @@ ValgrindEngine::ValgrindEngine(const AnalyzerStartParameters &sp,
: IAnalyzerEngine(sp, runConfiguration),
m_settings(0),
m_progress(new QFutureInterface<void>()),
m_progressWatcher(new QFutureWatcher<void>()),
m_isStopping(false)
{
if (runConfiguration)
@@ -60,6 +65,11 @@ ValgrindEngine::ValgrindEngine(const AnalyzerStartParameters &sp,
if (!m_settings)
m_settings = AnalyzerGlobalSettings::instance();
connect(m_progressWatcher, SIGNAL(canceled()),
this, SLOT(handleProgressCanceled()));
connect(m_progressWatcher, SIGNAL(finished()),
this, SLOT(handleProgressFinished()));
}
ValgrindEngine::~ValgrindEngine()
@@ -75,6 +85,7 @@ void ValgrindEngine::start()
progressTitle(), "valgrind");
fp->setKeepOnFinish(Core::FutureProgress::DontKeepOnFinish);
m_progress->reportStarted();
m_progressWatcher->setFuture(m_progress->future());
#if VALGRIND_DEBUG_OUTPUT
emit standardOutputReceived(tr("Valgrind options: %1").arg(toolArguments().join(" ")));
@@ -119,6 +130,16 @@ QString ValgrindEngine::executable() const
return startParameters().debuggee;
}
void ValgrindEngine::handleProgressCanceled()
{
AnalyzerManager::instance()->stopTool();
}
void ValgrindEngine::handleProgressFinished()
{
QApplication::alert(Core::ICore::instance()->mainWindow(), 3000);
}
void ValgrindEngine::runnerFinished()
{
emit standardOutputReceived(tr("** Analyzing finished **"));

View File

@@ -48,6 +48,7 @@
#include <QtCore/QString>
#include <QtCore/QByteArray>
#include <QtCore/QFutureInterface>
#include <QtCore/QFutureWatcher>
namespace Analyzer {
class AnalyzerSettings;
@@ -76,8 +77,11 @@ protected:
Analyzer::AnalyzerSettings *m_settings;
QFutureInterface<void> *m_progress;
QFutureWatcher<void> *m_progressWatcher;
private slots:
void handleProgressCanceled();
void handleProgressFinished();
void runnerFinished();
void receiveStandardOutput(const QByteArray &);