2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-03-04 12:15:18 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
2011-03-04 12:15:18 +01:00
|
|
|
** Author: Milian Wolff, KDAB (milian.wolff@kdab.com)
|
2016-01-15 14:57:40 +01:00
|
|
|
** Contact: https://www.qt.io/licensing/
|
2011-03-04 12:15:18 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-03-04 12:15:18 +01: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-03-04 12:15:18 +01: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-03-04 12:15:18 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-03-04 12:15:18 +01:00
|
|
|
|
|
|
|
|
#include "valgrindsettings.h"
|
2013-08-08 17:37:37 +02:00
|
|
|
#include "valgrindplugin.h"
|
2011-03-04 12:15:18 +01:00
|
|
|
#include "valgrindconfigwidget.h"
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
2021-02-18 14:18:34 +01:00
|
|
|
|
2021-03-09 17:40:29 +01:00
|
|
|
#include <utils/layoutbuilder.h>
|
2011-03-04 12:15:18 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2021-03-09 17:40:29 +01:00
|
|
|
#include <utils/treemodel.h>
|
2021-02-18 14:18:34 +01:00
|
|
|
#include <utils/utilsicons.h>
|
|
|
|
|
|
2011-07-12 16:47:32 +02:00
|
|
|
#include <valgrind/xmlprotocol/error.h>
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDebug>
|
2021-03-09 17:40:29 +01:00
|
|
|
#include <QFileDialog>
|
|
|
|
|
#include <QListView>
|
|
|
|
|
#include <QPushButton>
|
|
|
|
|
#include <QSettings>
|
|
|
|
|
#include <QStandardItemModel>
|
2011-07-12 16:47:32 +02:00
|
|
|
|
2021-02-18 14:18:34 +01:00
|
|
|
using namespace Utils;
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2011-07-12 16:47:32 +02:00
|
|
|
namespace Valgrind {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2021-03-09 17:40:29 +01:00
|
|
|
//
|
|
|
|
|
// SuppressionAspect
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
// This is somewhat unusual, as it looks the same in Global Settings and Project
|
|
|
|
|
// settings, but behaves differently (Project only stores a diff) depending on
|
|
|
|
|
// context.
|
|
|
|
|
|
|
|
|
|
const char globalSuppressionKey[] = "Analyzer.Valgrind.SupressionFiles";
|
|
|
|
|
const char removedProjectSuppressionKey[] = "Analyzer.Valgrind.RemovedSuppressionFiles";
|
|
|
|
|
const char addedProjectSuppressionKey[] = "Analyzer.Valgrind.AddedSuppressionFiles";
|
|
|
|
|
|
|
|
|
|
class SuppressionAspectPrivate : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_DECLARE_TR_FUNCTIONS(Valgrind::Internal::ValgrindConfigWidget)
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
SuppressionAspectPrivate(SuppressionAspect *q, bool global) : q(q), isGlobal(global) {}
|
|
|
|
|
|
|
|
|
|
void slotAddSuppression();
|
|
|
|
|
void slotRemoveSuppression();
|
|
|
|
|
void slotSuppressionSelectionChanged();
|
|
|
|
|
|
|
|
|
|
SuppressionAspect *q;
|
|
|
|
|
const bool isGlobal;
|
|
|
|
|
|
|
|
|
|
QPointer<QPushButton> addEntry;
|
|
|
|
|
QPointer<QPushButton> removeEntry;
|
|
|
|
|
QPointer<QListView> entryList;
|
|
|
|
|
|
|
|
|
|
QStandardItemModel m_model; // The volatile value of this aspect.
|
|
|
|
|
|
|
|
|
|
QStringList globalSuppressionFiles; // Real value, only used for global settings
|
|
|
|
|
|
|
|
|
|
QStringList removedProjectSuppressionFiles; // Part of real value for project settings
|
|
|
|
|
QStringList addedProjectSuppressionFiles; // Part of real value for project settings
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void SuppressionAspect::addSuppressionFile(const QString &suppression)
|
|
|
|
|
{
|
|
|
|
|
if (d->isGlobal) {
|
|
|
|
|
d->globalSuppressionFiles.append(suppression);
|
|
|
|
|
} else {
|
|
|
|
|
const QStringList globalSuppressions = ValgrindGlobalSettings::instance()->suppressions.value();
|
|
|
|
|
if (!d->addedProjectSuppressionFiles.contains(suppression))
|
|
|
|
|
d->addedProjectSuppressionFiles.append(suppression);
|
|
|
|
|
d->removedProjectSuppressionFiles.removeAll(suppression);
|
|
|
|
|
}
|
|
|
|
|
setVolatileValue(value());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SuppressionAspectPrivate::slotAddSuppression()
|
|
|
|
|
{
|
|
|
|
|
ValgrindGlobalSettings *conf = ValgrindGlobalSettings::instance();
|
|
|
|
|
QTC_ASSERT(conf, return);
|
|
|
|
|
const QStringList files =
|
|
|
|
|
QFileDialog::getOpenFileNames(Core::ICore::dialogParent(),
|
|
|
|
|
tr("Valgrind Suppression Files"),
|
|
|
|
|
conf->lastSuppressionDirectory.value(),
|
|
|
|
|
tr("Valgrind Suppression File (*.supp);;All Files (*)"));
|
|
|
|
|
//dialog.setHistory(conf->lastSuppressionDialogHistory());
|
|
|
|
|
if (!files.isEmpty()) {
|
|
|
|
|
for (const QString &file : files)
|
|
|
|
|
m_model.appendRow(new QStandardItem(file));
|
|
|
|
|
conf->lastSuppressionDirectory.setValue(QFileInfo(files.at(0)).absolutePath());
|
|
|
|
|
//conf->setLastSuppressionDialogHistory(dialog.history());
|
|
|
|
|
if (!isGlobal)
|
|
|
|
|
q->apply();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SuppressionAspectPrivate::slotRemoveSuppression()
|
|
|
|
|
{
|
|
|
|
|
// remove from end so no rows get invalidated
|
|
|
|
|
QList<int> rows;
|
|
|
|
|
|
|
|
|
|
QStringList removed;
|
|
|
|
|
const QModelIndexList selected = entryList->selectionModel()->selectedIndexes();
|
|
|
|
|
for (const QModelIndex &index : selected) {
|
|
|
|
|
rows << index.row();
|
|
|
|
|
removed << index.data().toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Utils::sort(rows, std::greater<int>());
|
|
|
|
|
|
|
|
|
|
for (int row : qAsConst(rows))
|
|
|
|
|
m_model.removeRow(row);
|
|
|
|
|
|
|
|
|
|
if (!isGlobal)
|
|
|
|
|
q->apply();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SuppressionAspectPrivate::slotSuppressionSelectionChanged()
|
|
|
|
|
{
|
|
|
|
|
removeEntry->setEnabled(entryList->selectionModel()->hasSelection());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// SuppressionAspect
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
SuppressionAspect::SuppressionAspect(bool global)
|
|
|
|
|
{
|
|
|
|
|
d = new SuppressionAspectPrivate(this, global);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SuppressionAspect::~SuppressionAspect()
|
|
|
|
|
{
|
|
|
|
|
delete d;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList SuppressionAspect::value() const
|
|
|
|
|
{
|
|
|
|
|
// Note: BaseAspect::d->value is /not/ used.
|
|
|
|
|
if (d->isGlobal)
|
|
|
|
|
return d->globalSuppressionFiles;
|
|
|
|
|
|
|
|
|
|
QStringList ret = ValgrindGlobalSettings::instance()->suppressions.value();
|
|
|
|
|
for (const QString &s : d->removedProjectSuppressionFiles)
|
|
|
|
|
ret.removeAll(s);
|
|
|
|
|
ret.append(d->addedProjectSuppressionFiles);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SuppressionAspect::setValue(const QStringList &val)
|
|
|
|
|
{
|
|
|
|
|
if (d->isGlobal) {
|
|
|
|
|
d->globalSuppressionFiles = val;
|
|
|
|
|
} else {
|
|
|
|
|
const QStringList globals = ValgrindGlobalSettings::instance()->suppressions.value();
|
|
|
|
|
d->addedProjectSuppressionFiles.clear();
|
|
|
|
|
for (const QString &s : val) {
|
|
|
|
|
if (!globals.contains(s))
|
|
|
|
|
d->addedProjectSuppressionFiles.append(s);
|
|
|
|
|
}
|
|
|
|
|
d->removedProjectSuppressionFiles.clear();
|
|
|
|
|
for (const QString &s : globals) {
|
|
|
|
|
if (!val.contains(s))
|
|
|
|
|
d->removedProjectSuppressionFiles.append(s);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SuppressionAspect::addToLayout(LayoutBuilder &builder)
|
|
|
|
|
{
|
|
|
|
|
QTC_CHECK(!d->addEntry);
|
|
|
|
|
QTC_CHECK(!d->removeEntry);
|
|
|
|
|
QTC_CHECK(!d->entryList);
|
|
|
|
|
|
|
|
|
|
using namespace Layouting;
|
|
|
|
|
|
|
|
|
|
d->addEntry = new QPushButton(tr("Add..."));
|
|
|
|
|
d->removeEntry = new QPushButton(tr("Remove"));
|
|
|
|
|
|
|
|
|
|
d->entryList = new QListView;
|
|
|
|
|
d->entryList->setModel(&d->m_model);
|
|
|
|
|
d->entryList->setSelectionMode(QAbstractItemView::MultiSelection);
|
|
|
|
|
|
|
|
|
|
connect(d->addEntry, &QPushButton::clicked,
|
|
|
|
|
d, &SuppressionAspectPrivate::slotAddSuppression);
|
|
|
|
|
connect(d->removeEntry, &QPushButton::clicked,
|
|
|
|
|
d, &SuppressionAspectPrivate::slotRemoveSuppression);
|
|
|
|
|
connect(d->entryList->selectionModel(), &QItemSelectionModel::selectionChanged,
|
|
|
|
|
d, &SuppressionAspectPrivate::slotSuppressionSelectionChanged);
|
|
|
|
|
|
2021-03-11 19:02:42 +01:00
|
|
|
builder.addItem(tr("Suppression files:"));
|
|
|
|
|
Row group {
|
|
|
|
|
d->entryList.data(),
|
|
|
|
|
Column { d->addEntry.data(), d->removeEntry.data(), Stretch() }
|
2021-03-09 17:40:29 +01:00
|
|
|
};
|
2021-03-11 19:02:42 +01:00
|
|
|
builder.addItem(Span { 2, group });
|
2021-03-09 17:40:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SuppressionAspect::fromMap(const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
if (d->isGlobal) {
|
|
|
|
|
d->globalSuppressionFiles = map.value(globalSuppressionKey).toStringList();
|
|
|
|
|
} else {
|
|
|
|
|
d->addedProjectSuppressionFiles = map.value(addedProjectSuppressionKey).toStringList();
|
|
|
|
|
d->removedProjectSuppressionFiles = map.value(removedProjectSuppressionKey).toStringList();
|
|
|
|
|
}
|
|
|
|
|
setVolatileValue(value());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SuppressionAspect::toMap(QVariantMap &map) const
|
|
|
|
|
{
|
|
|
|
|
auto save = [&map](const QStringList &data, const QString &key) {
|
|
|
|
|
if (data.isEmpty())
|
|
|
|
|
map.remove(key);
|
|
|
|
|
else
|
|
|
|
|
map.insert(key, data);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (d->isGlobal) {
|
|
|
|
|
save(d->globalSuppressionFiles, globalSuppressionKey);
|
|
|
|
|
} else {
|
|
|
|
|
save(d->addedProjectSuppressionFiles, addedProjectSuppressionKey);
|
|
|
|
|
save(d->removedProjectSuppressionFiles, removedProjectSuppressionKey);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariant SuppressionAspect::volatileValue() const
|
|
|
|
|
{
|
|
|
|
|
QStringList ret;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < d->m_model.rowCount(); ++i)
|
|
|
|
|
ret << d->m_model.item(i)->text();
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SuppressionAspect::setVolatileValue(const QVariant &val)
|
|
|
|
|
{
|
|
|
|
|
const QStringList files = val.toStringList();
|
|
|
|
|
d->m_model.clear();
|
|
|
|
|
for (const QString &file : files)
|
|
|
|
|
d->m_model.appendRow(new QStandardItem(file));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SuppressionAspect::cancel()
|
|
|
|
|
{
|
|
|
|
|
setVolatileValue(value());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SuppressionAspect::apply()
|
|
|
|
|
{
|
|
|
|
|
setValue(volatileValue().toStringList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SuppressionAspect::finish()
|
|
|
|
|
{
|
|
|
|
|
setVolatileValue(value()); // Clean up m_model content
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-12 16:47:32 +02:00
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// ValgrindBaseSettings
|
|
|
|
|
//
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2021-03-09 17:40:29 +01:00
|
|
|
ValgrindBaseSettings::ValgrindBaseSettings(bool global)
|
|
|
|
|
: suppressions(global)
|
2021-02-18 14:18:34 +01:00
|
|
|
{
|
|
|
|
|
// Note that this is used twice, once for project settings in the .user files
|
|
|
|
|
// and once for global settings in QtCreator.ini. This uses intentionally
|
|
|
|
|
// the same key to facilitate copying using fromMap/toMap.
|
|
|
|
|
QString base = "Analyzer.Valgrind.";
|
|
|
|
|
|
2021-04-06 18:35:27 +02:00
|
|
|
registerAspect(&suppressions);
|
2021-03-09 17:40:29 +01:00
|
|
|
|
2021-04-06 18:35:27 +02:00
|
|
|
registerAspect(&valgrindExecutable);
|
2021-02-18 14:18:34 +01:00
|
|
|
valgrindExecutable.setSettingsKey(base + "ValgrindExecutable");
|
|
|
|
|
valgrindExecutable.setDefaultValue("valgrind");
|
|
|
|
|
valgrindExecutable.setDisplayStyle(StringAspect::PathChooserDisplay);
|
|
|
|
|
valgrindExecutable.setExpectedKind(PathChooser::Command);
|
|
|
|
|
valgrindExecutable.setHistoryCompleter("Valgrind.Command.History");
|
|
|
|
|
valgrindExecutable.setDisplayName(tr("Valgrind Command"));
|
|
|
|
|
valgrindExecutable.setLabelText(tr("Valgrind executable:"));
|
|
|
|
|
if (Utils::HostOsInfo::isWindowsHost()) {
|
|
|
|
|
// On Window we know that we don't have a local valgrind
|
|
|
|
|
// executable, so having the "Browse" button in the path chooser
|
|
|
|
|
// (which is needed for the remote executable) is confusing.
|
|
|
|
|
// FIXME: not deadly, still...
|
|
|
|
|
//valgrindExecutable. ... buttonAtIndex(0)->hide();
|
2011-07-12 16:47:32 +02:00
|
|
|
}
|
|
|
|
|
|
2021-04-06 18:35:27 +02:00
|
|
|
registerAspect(&valgrindArguments);
|
2021-02-18 14:18:34 +01:00
|
|
|
valgrindArguments.setSettingsKey(base + "ValgrindArguments");
|
|
|
|
|
valgrindArguments.setDisplayStyle(StringAspect::LineEditDisplay);
|
|
|
|
|
valgrindArguments.setLabelText(tr("Valgrind arguments:"));
|
|
|
|
|
|
2021-04-06 18:35:27 +02:00
|
|
|
registerAspect(&selfModifyingCodeDetection);
|
2021-02-18 14:18:34 +01:00
|
|
|
selfModifyingCodeDetection.setSettingsKey(base + "SelfModifyingCodeDetection");
|
|
|
|
|
selfModifyingCodeDetection.setDefaultValue(DetectSmcStackOnly);
|
|
|
|
|
selfModifyingCodeDetection.setDisplayStyle(SelectionAspect::DisplayStyle::ComboBox);
|
|
|
|
|
selfModifyingCodeDetection.addOption("No");
|
|
|
|
|
selfModifyingCodeDetection.addOption("Only on Stack");
|
|
|
|
|
selfModifyingCodeDetection.addOption("Everywhere");
|
|
|
|
|
selfModifyingCodeDetection.addOption("Everywhere Except in File-backend Mappings");
|
|
|
|
|
selfModifyingCodeDetection.setLabelText(tr("Detect self-modifying code:"));
|
2011-07-12 16:47:32 +02:00
|
|
|
|
|
|
|
|
// Memcheck
|
2021-04-06 18:35:27 +02:00
|
|
|
registerAspect(&memcheckArguments);
|
2021-02-18 14:18:34 +01:00
|
|
|
memcheckArguments.setSettingsKey(base + "Memcheck.Arguments");
|
|
|
|
|
memcheckArguments.setDisplayStyle(StringAspect::LineEditDisplay);
|
|
|
|
|
memcheckArguments.setLabelText(tr("Extra MemCheck arguments:"));
|
|
|
|
|
|
2021-04-06 18:35:27 +02:00
|
|
|
registerAspect(&filterExternalIssues);
|
2021-02-18 14:18:34 +01:00
|
|
|
filterExternalIssues.setSettingsKey(base + "FilterExternalIssues");
|
|
|
|
|
filterExternalIssues.setDefaultValue(true);
|
|
|
|
|
filterExternalIssues.setIcon(Icons::FILTER.icon());
|
|
|
|
|
filterExternalIssues.setLabelPlacement(BoolAspect::LabelPlacement::AtCheckBoxWithoutDummyLabel);
|
|
|
|
|
filterExternalIssues.setLabelText(tr("Show Project Costs Only"));
|
|
|
|
|
filterExternalIssues.setToolTip(tr("Show only profiling info that originated from this project source."));
|
|
|
|
|
|
2021-04-06 18:35:27 +02:00
|
|
|
registerAspect(&trackOrigins);
|
2021-02-18 14:18:34 +01:00
|
|
|
trackOrigins.setSettingsKey(base + "TrackOrigins");
|
|
|
|
|
trackOrigins.setDefaultValue(true);
|
|
|
|
|
trackOrigins.setLabelPlacement(BoolAspect::LabelPlacement::AtCheckBoxWithoutDummyLabel);
|
|
|
|
|
trackOrigins.setLabelText(tr("Track origins of uninitialized memory"));
|
|
|
|
|
|
2021-04-06 18:35:27 +02:00
|
|
|
registerAspect(&showReachable);
|
2021-02-18 14:18:34 +01:00
|
|
|
showReachable.setSettingsKey(base + "ShowReachable");
|
|
|
|
|
showReachable.setLabelPlacement(BoolAspect::LabelPlacement::AtCheckBoxWithoutDummyLabel);
|
|
|
|
|
showReachable.setLabelText(tr("Show reachable and indirectly lost blocks"));
|
|
|
|
|
|
2021-04-06 18:35:27 +02:00
|
|
|
registerAspect(&leakCheckOnFinish);
|
2021-02-18 14:18:34 +01:00
|
|
|
leakCheckOnFinish.setSettingsKey(base + "LeakCheckOnFinish");
|
|
|
|
|
leakCheckOnFinish.setDefaultValue(LeakCheckOnFinishSummaryOnly);
|
|
|
|
|
leakCheckOnFinish.setDisplayStyle(SelectionAspect::DisplayStyle::ComboBox);
|
|
|
|
|
leakCheckOnFinish.addOption(tr("No"));
|
|
|
|
|
leakCheckOnFinish.addOption(tr("Summary Only"));
|
|
|
|
|
leakCheckOnFinish.addOption(tr("Full"));
|
|
|
|
|
leakCheckOnFinish.setLabelText(tr("Check for leaks on finish:"));
|
|
|
|
|
|
2021-04-06 18:35:27 +02:00
|
|
|
registerAspect(&numCallers);
|
2021-02-18 14:18:34 +01:00
|
|
|
numCallers.setSettingsKey(base + "NumCallers");
|
|
|
|
|
numCallers.setDefaultValue(25);
|
|
|
|
|
numCallers.setLabelText(tr("Backtrace frame count:"));
|
2011-07-12 16:47:32 +02:00
|
|
|
|
|
|
|
|
// Callgrind
|
|
|
|
|
|
2021-04-06 18:35:27 +02:00
|
|
|
registerAspect(&kcachegrindExecutable);
|
2021-02-18 14:18:34 +01:00
|
|
|
kcachegrindExecutable.setSettingsKey(base + "KCachegrindExecutable");
|
|
|
|
|
kcachegrindExecutable.setDefaultValue("kcachegrind");
|
|
|
|
|
kcachegrindExecutable.setDisplayStyle(StringAspect::PathChooserDisplay);
|
|
|
|
|
kcachegrindExecutable.setLabelText(tr("KCachegrind executable:"));
|
|
|
|
|
kcachegrindExecutable.setExpectedKind(Utils::PathChooser::Command);
|
|
|
|
|
kcachegrindExecutable.setDisplayName(tr("KCachegrind Command"));
|
|
|
|
|
|
2021-04-06 18:35:27 +02:00
|
|
|
registerAspect(&callgrindArguments);
|
2021-02-18 14:18:34 +01:00
|
|
|
callgrindArguments.setSettingsKey(base + "Callgrind.Arguments");
|
|
|
|
|
callgrindArguments.setDisplayStyle(StringAspect::LineEditDisplay);
|
|
|
|
|
callgrindArguments.setLabelText(tr("Extra CallGrind arguments:"));
|
|
|
|
|
|
2021-04-06 18:35:27 +02:00
|
|
|
registerAspect(&enableEventToolTips);
|
2021-02-18 14:18:34 +01:00
|
|
|
enableEventToolTips.setDefaultValue(true);
|
|
|
|
|
enableEventToolTips.setSettingsKey(base + "Callgrind.EnableEventToolTips");
|
|
|
|
|
enableEventToolTips.setLabelPlacement(BoolAspect::LabelPlacement::AtCheckBoxWithoutDummyLabel);
|
|
|
|
|
enableEventToolTips.setLabelText(tr("Show additional information for events in tooltips"));
|
|
|
|
|
|
2021-04-06 18:35:27 +02:00
|
|
|
registerAspect(&enableCacheSim);
|
2021-02-18 14:18:34 +01:00
|
|
|
enableCacheSim.setSettingsKey(base + "Callgrind.EnableCacheSim");
|
|
|
|
|
enableCacheSim.setLabelPlacement(BoolAspect::LabelPlacement::AtCheckBoxWithoutDummyLabel);
|
|
|
|
|
enableCacheSim.setLabelText(tr("Enable cache simulation"));
|
|
|
|
|
enableCacheSim.setToolTip("<html><head/><body>" + tr(
|
|
|
|
|
"<p>Does full cache simulation.</p>\n"
|
|
|
|
|
"<p>By default, only instruction read accesses will be counted (\"Ir\").</p>\n"
|
|
|
|
|
"<p>\n"
|
|
|
|
|
"With cache simulation, further event counters are enabled:\n"
|
|
|
|
|
"<ul><li>Cache misses on instruction reads (\"I1mr\"/\"I2mr\").</li>\n"
|
|
|
|
|
"<li>Data read accesses (\"Dr\") and related cache misses (\"D1mr\"/\"D2mr\").</li>\n"
|
|
|
|
|
"<li>Data write accesses (\"Dw\") and related cache misses (\"D1mw\"/\"D2mw\").</li></ul>\n"
|
|
|
|
|
"</p>") + "</body></html>");
|
|
|
|
|
|
2021-04-06 18:35:27 +02:00
|
|
|
registerAspect(&enableBranchSim);
|
2021-02-18 14:18:34 +01:00
|
|
|
enableBranchSim.setSettingsKey(base + "Callgrind.EnableBranchSim");
|
|
|
|
|
enableBranchSim.setLabelPlacement(BoolAspect::LabelPlacement::AtCheckBoxWithoutDummyLabel);
|
|
|
|
|
enableBranchSim.setLabelText(tr("Enable branch prediction simulation"));
|
|
|
|
|
enableBranchSim.setToolTip("<html><head/><body>\n" + tr(
|
|
|
|
|
"<p>Does branch prediction simulation.</p>\n"
|
|
|
|
|
"<p>Further event counters are enabled: </p>\n"
|
|
|
|
|
"<ul><li>Number of executed conditional branches and related predictor misses (\n"
|
|
|
|
|
"\"Bc\"/\"Bcm\").</li>\n"
|
|
|
|
|
"<li>Executed indirect jumps and related misses of the jump address predictor (\n"
|
|
|
|
|
"\"Bi\"/\"Bim\").)</li></ul>") + "</body></html>");
|
|
|
|
|
|
2021-04-06 18:35:27 +02:00
|
|
|
registerAspect(&collectSystime);
|
2021-02-18 14:18:34 +01:00
|
|
|
collectSystime.setSettingsKey(base + "Callgrind.CollectSystime");
|
|
|
|
|
collectSystime.setLabelPlacement(BoolAspect::LabelPlacement::AtCheckBoxWithoutDummyLabel);
|
|
|
|
|
collectSystime.setLabelText(tr("Collect system call time"));
|
|
|
|
|
collectSystime.setToolTip(tr("Collects information for system call times."));
|
|
|
|
|
|
2021-04-06 18:35:27 +02:00
|
|
|
registerAspect(&collectBusEvents);
|
2021-02-18 14:18:34 +01:00
|
|
|
collectBusEvents.setLabelPlacement(BoolAspect::LabelPlacement::AtCheckBoxWithoutDummyLabel);
|
|
|
|
|
collectBusEvents.setSettingsKey(base + "Callgrind.CollectBusEvents");
|
|
|
|
|
collectBusEvents.setLabelText(tr("Collect global bus events"));
|
|
|
|
|
collectBusEvents.setToolTip(tr("Collect the number of global bus events that are executed. "
|
|
|
|
|
"The event type \"Ge\" is used for these events."));
|
|
|
|
|
|
2021-04-06 18:35:27 +02:00
|
|
|
registerAspect(&minimumInclusiveCostRatio);
|
2021-02-18 14:18:34 +01:00
|
|
|
minimumInclusiveCostRatio.setSettingsKey(base + "Callgrind.MinimumCostRatio");
|
|
|
|
|
minimumInclusiveCostRatio.setDefaultValue(0.01);
|
|
|
|
|
minimumInclusiveCostRatio.setSuffix(tr("%"));
|
|
|
|
|
minimumInclusiveCostRatio.setLabelText(tr("Result view: Minimum event cost:"));
|
|
|
|
|
minimumInclusiveCostRatio.setToolTip(tr("Limits the amount of results the profiler gives you. "
|
|
|
|
|
"A lower limit will likely increase performance."));
|
|
|
|
|
|
2021-04-06 18:35:27 +02:00
|
|
|
registerAspect(&visualizationMinimumInclusiveCostRatio);
|
2021-02-18 14:18:34 +01:00
|
|
|
visualizationMinimumInclusiveCostRatio.setSettingsKey(base + "Callgrind.VisualisationMinimumCostRatio");
|
|
|
|
|
visualizationMinimumInclusiveCostRatio.setDefaultValue(10.0);
|
|
|
|
|
visualizationMinimumInclusiveCostRatio.setLabelText(tr("Visualization: Minimum event cost:"));
|
|
|
|
|
visualizationMinimumInclusiveCostRatio.setSuffix(tr("%"));
|
|
|
|
|
|
2021-04-06 18:35:27 +02:00
|
|
|
registerAspect(&visibleErrorKinds);
|
2021-02-18 14:18:34 +01:00
|
|
|
visibleErrorKinds.setSettingsKey(base + "VisibleErrorKinds");
|
|
|
|
|
QList<int> defaultErrorKinds;
|
|
|
|
|
for (int i = 0; i < Valgrind::XmlProtocol::MemcheckErrorKindCount; ++i)
|
|
|
|
|
defaultErrorKinds << i;
|
|
|
|
|
visibleErrorKinds.setDefaultValue(defaultErrorKinds);
|
2018-11-07 23:55:59 +02:00
|
|
|
}
|
|
|
|
|
|
2011-07-12 16:47:32 +02:00
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// ValgrindGlobalSettings
|
|
|
|
|
//
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2019-03-20 17:49:26 +01:00
|
|
|
static ValgrindGlobalSettings *theGlobalSettings = nullptr;
|
|
|
|
|
|
2013-08-08 17:37:37 +02:00
|
|
|
ValgrindGlobalSettings::ValgrindGlobalSettings()
|
2021-03-09 17:40:29 +01:00
|
|
|
: ValgrindBaseSettings(true)
|
2011-07-12 16:47:32 +02:00
|
|
|
{
|
2019-03-20 17:49:26 +01:00
|
|
|
theGlobalSettings = this;
|
2019-08-28 08:55:28 +02:00
|
|
|
|
2021-02-18 14:18:34 +01:00
|
|
|
const QString base = "Analyzer.Valgrind";
|
2011-07-12 16:47:32 +02:00
|
|
|
|
2021-04-06 18:35:27 +02:00
|
|
|
registerAspect(&lastSuppressionDirectory);
|
2021-02-18 14:18:34 +01:00
|
|
|
lastSuppressionDirectory.setSettingsKey(base + "LastSuppressionDirectory");
|
2011-07-12 16:47:32 +02:00
|
|
|
|
2021-04-06 18:35:27 +02:00
|
|
|
registerAspect(&lastSuppressionHistory);
|
2021-02-18 14:18:34 +01:00
|
|
|
lastSuppressionHistory.setSettingsKey(base + "LastSuppressionHistory");
|
2011-07-12 16:47:32 +02:00
|
|
|
|
2021-04-06 18:35:27 +02:00
|
|
|
registerAspect(&detectCycles);
|
2021-02-18 14:18:34 +01:00
|
|
|
detectCycles.setSettingsKey(base + "Callgrind.CycleDetection");
|
|
|
|
|
detectCycles.setDefaultValue(true);
|
|
|
|
|
detectCycles.setLabelText("O"); // FIXME: Create a real icon
|
|
|
|
|
detectCycles.setToolTip(tr("Enable cycle detection to properly handle recursive "
|
|
|
|
|
"or circular function calls."));
|
2011-07-12 16:47:32 +02:00
|
|
|
|
2021-04-06 18:35:27 +02:00
|
|
|
registerAspect(&costFormat);
|
2021-02-18 14:18:34 +01:00
|
|
|
costFormat.setSettingsKey(base + "Callgrind.CostFormat");
|
|
|
|
|
costFormat.setDefaultValue(CostDelegate::FormatRelative);
|
|
|
|
|
costFormat.setDisplayStyle(SelectionAspect::DisplayStyle::ComboBox);
|
2011-07-12 16:47:32 +02:00
|
|
|
|
2021-04-06 18:35:27 +02:00
|
|
|
registerAspect(&shortenTemplates);
|
2021-02-18 14:18:34 +01:00
|
|
|
shortenTemplates.setSettingsKey(base + "Callgrind.ShortenTemplates");
|
|
|
|
|
shortenTemplates.setDefaultValue(true);
|
|
|
|
|
shortenTemplates.setLabelText("<>"); // FIXME: Create a real icon
|
|
|
|
|
shortenTemplates.setToolTip(tr("Remove template parameter lists when displaying function names."));
|
2011-07-12 16:47:32 +02:00
|
|
|
|
2021-02-18 14:18:34 +01:00
|
|
|
setConfigWidgetCreator([this] { return ValgrindOptionsPage::createSettingsWidget(this); });
|
|
|
|
|
readSettings();
|
|
|
|
|
|
2021-04-06 18:35:27 +02:00
|
|
|
setAutoApply(false);
|
2021-02-18 14:18:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ValgrindGlobalSettings *ValgrindGlobalSettings::instance()
|
|
|
|
|
{
|
|
|
|
|
return theGlobalSettings;
|
2011-07-12 16:47:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Memcheck
|
|
|
|
|
//
|
|
|
|
|
|
2021-02-18 14:18:34 +01:00
|
|
|
QVariantMap ValgrindBaseSettings::defaultSettings() const
|
2013-08-08 17:37:37 +02:00
|
|
|
{
|
|
|
|
|
QVariantMap defaults;
|
2021-04-06 18:35:27 +02:00
|
|
|
forEachAspect([&defaults](BaseAspect *aspect) {
|
2021-02-18 14:18:34 +01:00
|
|
|
defaults.insert(aspect->settingsKey(), aspect->defaultValue());
|
|
|
|
|
});
|
2021-02-15 16:44:09 +01:00
|
|
|
return defaults;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-18 14:18:34 +01:00
|
|
|
static const char groupC[] = "Analyzer";
|
|
|
|
|
|
2021-02-15 16:44:09 +01:00
|
|
|
void ValgrindGlobalSettings::readSettings()
|
|
|
|
|
{
|
2013-08-08 17:37:37 +02:00
|
|
|
// Read stored values
|
|
|
|
|
QSettings *settings = Core::ICore::settings();
|
2018-12-01 20:56:21 +02:00
|
|
|
settings->beginGroup(groupC);
|
2021-03-09 17:40:29 +01:00
|
|
|
QVariantMap map;
|
|
|
|
|
const QStringList childKey = settings->childKeys();
|
|
|
|
|
for (const QString &key : childKey)
|
|
|
|
|
map.insert(key, settings->value(key));
|
2013-08-08 17:37:37 +02:00
|
|
|
settings->endGroup();
|
|
|
|
|
|
|
|
|
|
fromMap(map);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ValgrindGlobalSettings::writeSettings() const
|
|
|
|
|
{
|
2021-02-15 16:44:09 +01:00
|
|
|
const QVariantMap defaults = defaultSettings();
|
|
|
|
|
|
|
|
|
|
Utils::QtcSettings *settings = Core::ICore::settings();
|
2018-12-01 20:56:21 +02:00
|
|
|
settings->beginGroup(groupC);
|
2013-08-12 17:05:52 +02:00
|
|
|
QVariantMap map;
|
|
|
|
|
toMap(map);
|
2015-04-01 11:19:32 +02:00
|
|
|
for (QVariantMap::ConstIterator it = map.constBegin(); it != map.constEnd(); ++it)
|
2021-02-15 16:44:09 +01:00
|
|
|
settings->setValueWithDefault(it.key(), it.value(), defaults.value(it.key()));
|
2013-08-08 17:37:37 +02:00
|
|
|
settings->endGroup();
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-12 16:47:32 +02:00
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// ValgrindProjectSettings
|
|
|
|
|
//
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2018-09-10 15:39:27 +02:00
|
|
|
ValgrindProjectSettings::ValgrindProjectSettings()
|
2021-03-09 17:40:29 +01:00
|
|
|
: ValgrindBaseSettings(false)
|
2019-08-28 08:55:28 +02:00
|
|
|
{
|
2020-01-16 17:51:53 +01:00
|
|
|
setConfigWidgetCreator([this] { return ValgrindOptionsPage::createSettingsWidget(this); });
|
2021-04-06 18:35:27 +02:00
|
|
|
|
|
|
|
|
connect(this, &AspectContainer::fromMapFinished, [this] {
|
|
|
|
|
// FIXME: Update project page e.g. on "Restore Global", aspects
|
|
|
|
|
// there are 'autoapply', and Aspect::cancel() is normally part of
|
|
|
|
|
// the 'manual apply' machinery.
|
|
|
|
|
setAutoApply(false);
|
|
|
|
|
cancel();
|
|
|
|
|
setAutoApply(true);
|
|
|
|
|
});
|
2011-07-12 16:47:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Valgrind
|