forked from qt-creator/qt-creator
analyzer: add a button to shorten names of function templates
Task-number: QTCREATORBUG-7746 Change-Id: I5ba6c5b63c319d7b65239c6b730c0da90ef20c4f Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -67,6 +67,7 @@ public:
|
|||||||
, m_event(0)
|
, m_event(0)
|
||||||
, m_verboseToolTips(true)
|
, m_verboseToolTips(true)
|
||||||
, m_cycleDetection(false)
|
, m_cycleDetection(false)
|
||||||
|
, m_shortenTemplates(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,6 +77,7 @@ public:
|
|||||||
int m_event;
|
int m_event;
|
||||||
bool m_verboseToolTips;
|
bool m_verboseToolTips;
|
||||||
bool m_cycleDetection;
|
bool m_cycleDetection;
|
||||||
|
bool m_shortenTemplates;
|
||||||
QVector<const Function *> m_functions;
|
QVector<const Function *> m_functions;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -214,6 +216,23 @@ static QString noWrap(const QString &str)
|
|||||||
return escapedStr.replace(QLatin1Char('-'), "‑");
|
return escapedStr.replace(QLatin1Char('-'), "‑");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QString shortenTemplate(QString str)
|
||||||
|
{
|
||||||
|
int depth = 0;
|
||||||
|
int j = 0;
|
||||||
|
for (int i = 0, n = str.size(); i != n; ++i) {
|
||||||
|
int c = str.at(i).unicode();
|
||||||
|
if (c == '>')
|
||||||
|
--depth;
|
||||||
|
if (depth == 0)
|
||||||
|
str[j++] = str.at(i);
|
||||||
|
if (c == '<')
|
||||||
|
++depth;
|
||||||
|
}
|
||||||
|
str.truncate(j);
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
QVariant DataModel::data(const QModelIndex &index, int role) const
|
QVariant DataModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
//QTC_ASSERT(index.isValid() && index.model() == this, return QVariant());
|
//QTC_ASSERT(index.isValid() && index.model() == this, return QVariant());
|
||||||
@@ -224,7 +243,7 @@ QVariant DataModel::data(const QModelIndex &index, int role) const
|
|||||||
|
|
||||||
if (role == Qt::DisplayRole) {
|
if (role == Qt::DisplayRole) {
|
||||||
if (index.column() == NameColumn)
|
if (index.column() == NameColumn)
|
||||||
return func->name();
|
return d->m_shortenTemplates ? shortenTemplate(func->name()) : func->name();
|
||||||
if (index.column() == LocationColumn)
|
if (index.column() == LocationColumn)
|
||||||
return func->location();
|
return func->location();
|
||||||
if (index.column() == CalledColumn)
|
if (index.column() == CalledColumn)
|
||||||
@@ -368,5 +387,13 @@ void DataModel::enableCycleDetection(bool enabled)
|
|||||||
endResetModel();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DataModel::setShortenTemplates(bool enabled)
|
||||||
|
{
|
||||||
|
beginResetModel();
|
||||||
|
d->m_shortenTemplates = enabled;
|
||||||
|
d->updateFunctions();
|
||||||
|
endResetModel();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Valgrind
|
} // namespace Valgrind
|
||||||
} // namespace Callgrind
|
} // namespace Callgrind
|
||||||
|
@@ -87,6 +87,7 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
/// enable/disable cycle detection
|
/// enable/disable cycle detection
|
||||||
void enableCycleDetection(bool enabled);
|
void enableCycleDetection(bool enabled);
|
||||||
|
void setShortenTemplates(bool enabled);
|
||||||
|
|
||||||
/// Only one cost event column will be shown, this decides which one it is.
|
/// 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.
|
/// By default it is the first event in the @c ParseData, i.e. 0.
|
||||||
|
@@ -134,6 +134,7 @@ public slots:
|
|||||||
void selectFunction(const Valgrind::Callgrind::Function *);
|
void selectFunction(const Valgrind::Callgrind::Function *);
|
||||||
void setCostFormat(Valgrind::Internal::CostDelegate::CostFormat format);
|
void setCostFormat(Valgrind::Internal::CostDelegate::CostFormat format);
|
||||||
void enableCycleDetection(bool enabled);
|
void enableCycleDetection(bool enabled);
|
||||||
|
void shortenTemplates(bool enabled);
|
||||||
void setCostEvent(int index);
|
void setCostEvent(int index);
|
||||||
|
|
||||||
/// This function will add custom text marks to the editor
|
/// This function will add custom text marks to the editor
|
||||||
@@ -196,6 +197,7 @@ public:
|
|||||||
QAction *m_costRelative;
|
QAction *m_costRelative;
|
||||||
QAction *m_costRelativeToParent;
|
QAction *m_costRelativeToParent;
|
||||||
QAction *m_cycleDetection;
|
QAction *m_cycleDetection;
|
||||||
|
QAction *m_shortenTemplates;
|
||||||
QComboBox *m_eventCombo;
|
QComboBox *m_eventCombo;
|
||||||
|
|
||||||
QTimer *m_updateTimer;
|
QTimer *m_updateTimer;
|
||||||
@@ -370,6 +372,11 @@ void CallgrindToolPrivate::enableCycleDetection(bool enabled)
|
|||||||
m_cycleDetection->setChecked(enabled);
|
m_cycleDetection->setChecked(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CallgrindToolPrivate::shortenTemplates(bool enabled)
|
||||||
|
{
|
||||||
|
m_shortenTemplates->setChecked(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
// Following functions can be called with actions=0 or widgets=0
|
// Following functions can be called with actions=0 or widgets=0
|
||||||
// depending on initialization sequence (whether callgrind was current).
|
// depending on initialization sequence (whether callgrind was current).
|
||||||
CostDelegate::CostFormat CallgrindToolPrivate::costFormat() const
|
CostDelegate::CostFormat CallgrindToolPrivate::costFormat() const
|
||||||
@@ -763,7 +770,6 @@ QWidget *CallgrindToolPrivate::createWidgets()
|
|||||||
|
|
||||||
// show costs as absolute numbers
|
// show costs as absolute numbers
|
||||||
m_costAbsolute = new QAction(tr("Absolute Costs"), this);
|
m_costAbsolute = new QAction(tr("Absolute Costs"), this);
|
||||||
///FIXME: icon
|
|
||||||
m_costAbsolute->setToolTip(tr("Show costs as absolute numbers."));
|
m_costAbsolute->setToolTip(tr("Show costs as absolute numbers."));
|
||||||
m_costAbsolute->setCheckable(true);
|
m_costAbsolute->setCheckable(true);
|
||||||
m_costAbsolute->setChecked(true);
|
m_costAbsolute->setChecked(true);
|
||||||
@@ -773,7 +779,6 @@ QWidget *CallgrindToolPrivate::createWidgets()
|
|||||||
|
|
||||||
// show costs in percentages
|
// show costs in percentages
|
||||||
m_costRelative = new QAction(tr("Relative Costs"), this);
|
m_costRelative = new QAction(tr("Relative Costs"), this);
|
||||||
///FIXME: icon (percentage sign?)
|
|
||||||
m_costRelative->setToolTip(tr("Show costs relative to total inclusive cost."));
|
m_costRelative->setToolTip(tr("Show costs relative to total inclusive cost."));
|
||||||
m_costRelative->setCheckable(true);
|
m_costRelative->setCheckable(true);
|
||||||
connect(m_costRelative, SIGNAL(toggled(bool)), SLOT(updateCostFormat()));
|
connect(m_costRelative, SIGNAL(toggled(bool)), SLOT(updateCostFormat()));
|
||||||
@@ -782,7 +787,6 @@ QWidget *CallgrindToolPrivate::createWidgets()
|
|||||||
|
|
||||||
// show costs relative to parent
|
// 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->setToolTip(tr("Show costs relative to parent functions inclusive cost."));
|
||||||
m_costRelativeToParent->setCheckable(true);
|
m_costRelativeToParent->setCheckable(true);
|
||||||
connect(m_costRelativeToParent, SIGNAL(toggled(bool)), SLOT(updateCostFormat()));
|
connect(m_costRelativeToParent, SIGNAL(toggled(bool)), SLOT(updateCostFormat()));
|
||||||
@@ -792,12 +796,14 @@ QWidget *CallgrindToolPrivate::createWidgets()
|
|||||||
QToolButton *button = new QToolButton;
|
QToolButton *button = new QToolButton;
|
||||||
button->setMenu(menu);
|
button->setMenu(menu);
|
||||||
button->setPopupMode(QToolButton::InstantPopup);
|
button->setPopupMode(QToolButton::InstantPopup);
|
||||||
button->setText(tr("Cost Format"));
|
button->setText(QLatin1String("$"));
|
||||||
|
button->setToolTip(tr("Cost Format"));
|
||||||
layout->addWidget(button);
|
layout->addWidget(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
// cycle detection
|
// cycle detection
|
||||||
action = new QAction(tr("Cycle Detection"), this); ///FIXME: icon
|
//action = new QAction(QLatin1String("Cycle Detection"), this); ///FIXME: icon
|
||||||
|
action = new QAction(QLatin1String("O"), this); ///FIXME: icon
|
||||||
action->setToolTip(tr("Enable cycle detection to properly handle recursive or circular function calls."));
|
action->setToolTip(tr("Enable cycle detection to properly handle recursive or circular function calls."));
|
||||||
action->setCheckable(true);
|
action->setCheckable(true);
|
||||||
connect(action, SIGNAL(toggled(bool)), m_dataModel, SLOT(enableCycleDetection(bool)));
|
connect(action, SIGNAL(toggled(bool)), m_dataModel, SLOT(enableCycleDetection(bool)));
|
||||||
@@ -805,6 +811,15 @@ QWidget *CallgrindToolPrivate::createWidgets()
|
|||||||
layout->addWidget(createToolButton(action));
|
layout->addWidget(createToolButton(action));
|
||||||
m_cycleDetection = action;
|
m_cycleDetection = action;
|
||||||
|
|
||||||
|
// shorter template signature
|
||||||
|
action = new QAction(QLatin1String("<>"), this);
|
||||||
|
action->setToolTip(tr("This removes template parameter lists when displaying function names."));
|
||||||
|
action->setCheckable(true);
|
||||||
|
connect(action, SIGNAL(toggled(bool)), m_dataModel, SLOT(setShortenTemplates(bool)));
|
||||||
|
connect(action, SIGNAL(toggled(bool)), m_settings, SLOT(setShortenTemplates(bool)));
|
||||||
|
layout->addWidget(createToolButton(action));
|
||||||
|
m_shortenTemplates = action;
|
||||||
|
|
||||||
// filtering
|
// filtering
|
||||||
action = new QAction(tr("Show Project Costs Only"), this);
|
action = new QAction(tr("Show Project Costs Only"), this);
|
||||||
action->setIcon(QIcon(Core::Constants::ICON_FILTER));
|
action->setIcon(QIcon(Core::Constants::ICON_FILTER));
|
||||||
|
@@ -43,29 +43,30 @@
|
|||||||
|
|
||||||
using namespace Analyzer;
|
using namespace Analyzer;
|
||||||
|
|
||||||
static const char numCallersC[] = "Analyzer.Valgrind.NumCallers";
|
const char numCallersC[] = "Analyzer.Valgrind.NumCallers";
|
||||||
static const char trackOriginsC[] = "Analyzer.Valgrind.TrackOrigins";
|
const char trackOriginsC[] = "Analyzer.Valgrind.TrackOrigins";
|
||||||
static const char suppressionFilesC[] = "Analyzer.Valgrind.SupressionFiles";
|
const char suppressionFilesC[] = "Analyzer.Valgrind.SupressionFiles";
|
||||||
static const char removedSuppressionFilesC[] = "Analyzer.Valgrind.RemovedSuppressionFiles";
|
const char removedSuppressionFilesC[] = "Analyzer.Valgrind.RemovedSuppressionFiles";
|
||||||
static const char addedSuppressionFilesC[] = "Analyzer.Valgrind.AddedSuppressionFiles";
|
const char addedSuppressionFilesC[] = "Analyzer.Valgrind.AddedSuppressionFiles";
|
||||||
static const char filterExternalIssuesC[] = "Analyzer.Valgrind.FilterExternalIssues";
|
const char filterExternalIssuesC[] = "Analyzer.Valgrind.FilterExternalIssues";
|
||||||
static const char visibleErrorKindsC[] = "Analyzer.Valgrind.VisibleErrorKinds";
|
const char visibleErrorKindsC[] = "Analyzer.Valgrind.VisibleErrorKinds";
|
||||||
|
|
||||||
static const char lastSuppressionDirectoryC[] = "Analyzer.Valgrind.LastSuppressionDirectory";
|
const char lastSuppressionDirectoryC[] = "Analyzer.Valgrind.LastSuppressionDirectory";
|
||||||
static const char lastSuppressionHistoryC[] = "Analyzer.Valgrind.LastSuppressionHistory";
|
const char lastSuppressionHistoryC[] = "Analyzer.Valgrind.LastSuppressionHistory";
|
||||||
|
|
||||||
static const char callgrindEnableCacheSimC[] = "Analyzer.Valgrind.Callgrind.EnableCacheSim";
|
const char callgrindEnableCacheSimC[] = "Analyzer.Valgrind.Callgrind.EnableCacheSim";
|
||||||
static const char callgrindEnableBranchSimC[] = "Analyzer.Valgrind.Callgrind.EnableBranchSim";
|
const char callgrindEnableBranchSimC[] = "Analyzer.Valgrind.Callgrind.EnableBranchSim";
|
||||||
static const char callgrindCollectSystimeC[] = "Analyzer.Valgrind.Callgrind.CollectSystime";
|
const char callgrindCollectSystimeC[] = "Analyzer.Valgrind.Callgrind.CollectSystime";
|
||||||
static const char callgrindCollectBusEventsC[] = "Analyzer.Valgrind.Callgrind.CollectBusEvents";
|
const char callgrindCollectBusEventsC[] = "Analyzer.Valgrind.Callgrind.CollectBusEvents";
|
||||||
static const char callgrindEnableEventToolTipsC[] = "Analyzer.Valgrind.Callgrind.EnableEventToolTips";
|
const char callgrindEnableEventToolTipsC[] = "Analyzer.Valgrind.Callgrind.EnableEventToolTips";
|
||||||
static const char callgrindMinimumCostRatioC[] = "Analyzer.Valgrind.Callgrind.MinimumCostRatio";
|
const char callgrindMinimumCostRatioC[] = "Analyzer.Valgrind.Callgrind.MinimumCostRatio";
|
||||||
static const char callgrindVisualisationMinimumCostRatioC[] = "Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio";
|
const char callgrindVisualisationMinimumCostRatioC[] = "Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio";
|
||||||
|
|
||||||
static const char callgrindCycleDetectionC[] = "Analyzer.Valgrind.Callgrind.CycleDetection";
|
const char callgrindCycleDetectionC[] = "Analyzer.Valgrind.Callgrind.CycleDetection";
|
||||||
static const char callgrindCostFormatC[] = "Analyzer.Valgrind.Callgrind.CostFormat";
|
const char callgrindShortenTemplates[] = "Analyzer.Valgrind.Callgrind.ShortenTemplates";
|
||||||
|
const char callgrindCostFormatC[] = "Analyzer.Valgrind.Callgrind.CostFormat";
|
||||||
|
|
||||||
static const char valgrindExeC[] = "Analyzer.Valgrind.ValgrindExecutable";
|
const char valgrindExeC[] = "Analyzer.Valgrind.ValgrindExecutable";
|
||||||
|
|
||||||
namespace Valgrind {
|
namespace Valgrind {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -322,6 +323,7 @@ void ValgrindGlobalSettings::fromMap(const QVariantMap &map)
|
|||||||
if (map.contains(QLatin1String(callgrindCostFormatC)))
|
if (map.contains(QLatin1String(callgrindCostFormatC)))
|
||||||
m_costFormat = static_cast<CostDelegate::CostFormat>(map.value(QLatin1String(callgrindCostFormatC)).toInt());
|
m_costFormat = static_cast<CostDelegate::CostFormat>(map.value(QLatin1String(callgrindCostFormatC)).toInt());
|
||||||
setIfPresent(map, QLatin1String(callgrindCycleDetectionC), &m_detectCycles);
|
setIfPresent(map, QLatin1String(callgrindCycleDetectionC), &m_detectCycles);
|
||||||
|
setIfPresent(map, QLatin1String(callgrindShortenTemplates), &m_shortenTemplates);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap ValgrindGlobalSettings::toMap() const
|
QVariantMap ValgrindGlobalSettings::toMap() const
|
||||||
@@ -336,6 +338,7 @@ QVariantMap ValgrindGlobalSettings::toMap() const
|
|||||||
// Callgrind
|
// Callgrind
|
||||||
map.insert(QLatin1String(callgrindCostFormatC), m_costFormat);
|
map.insert(QLatin1String(callgrindCostFormatC), m_costFormat);
|
||||||
map.insert(QLatin1String(callgrindCycleDetectionC), m_detectCycles);
|
map.insert(QLatin1String(callgrindCycleDetectionC), m_detectCycles);
|
||||||
|
map.insert(QLatin1String(callgrindShortenTemplates), m_shortenTemplates);
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
@@ -401,9 +404,20 @@ bool ValgrindGlobalSettings::detectCycles() const
|
|||||||
return m_detectCycles;
|
return m_detectCycles;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ValgrindGlobalSettings::setDetectCycles(bool detect)
|
void ValgrindGlobalSettings::setDetectCycles(bool on)
|
||||||
{
|
{
|
||||||
m_detectCycles = detect;
|
m_detectCycles = on;
|
||||||
|
AnalyzerGlobalSettings::instance()->writeSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ValgrindGlobalSettings::shortenTemplates() const
|
||||||
|
{
|
||||||
|
return m_shortenTemplates;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ValgrindGlobalSettings::setShortenTemplates(bool on)
|
||||||
|
{
|
||||||
|
m_shortenTemplates = on;
|
||||||
AnalyzerGlobalSettings::instance()->writeSettings();
|
AnalyzerGlobalSettings::instance()->writeSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -202,17 +202,19 @@ private:
|
|||||||
* Global callgrind settings
|
* Global callgrind settings
|
||||||
*/
|
*/
|
||||||
public:
|
public:
|
||||||
|
|
||||||
CostDelegate::CostFormat costFormat() const;
|
CostDelegate::CostFormat costFormat() const;
|
||||||
bool detectCycles() const;
|
bool detectCycles() const;
|
||||||
|
bool shortenTemplates() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setCostFormat(Valgrind::Internal::CostDelegate::CostFormat format);
|
void setCostFormat(Valgrind::Internal::CostDelegate::CostFormat format);
|
||||||
void setDetectCycles(bool detect);
|
void setDetectCycles(bool on);
|
||||||
|
void setShortenTemplates(bool on);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CostDelegate::CostFormat m_costFormat;
|
CostDelegate::CostFormat m_costFormat;
|
||||||
bool m_detectCycles;
|
bool m_detectCycles;
|
||||||
|
bool m_shortenTemplates;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user