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"
|
2022-07-08 16:08:27 +02:00
|
|
|
|
|
|
|
|
#include "callgrindcostdelegate.h"
|
2011-03-04 12:15:18 +01:00
|
|
|
#include "valgrindconfigwidget.h"
|
2022-07-08 16:08:27 +02:00
|
|
|
#include "valgrindtr.h"
|
2011-03-04 12:15:18 +01:00
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
2021-02-18 14:18:34 +01:00
|
|
|
|
2022-05-17 14:59:01 +02:00
|
|
|
#include <utils/algorithm.h>
|
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 <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
|
|
|
|
2022-07-08 16:08:27 +02:00
|
|
|
namespace Valgrind::Internal {
|
2011-07-12 16:47:32 +02:00
|
|
|
|
2021-03-09 17:40:29 +01:00
|
|
|
//
|
|
|
|
|
// SuppressionAspect
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
class SuppressionAspectPrivate : public QObject
|
|
|
|
|
{
|
|
|
|
|
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.
|
|
|
|
|
};
|
|
|
|
|
|
2021-09-30 17:12:10 +02:00
|
|
|
void SuppressionAspect::addSuppressionFile(const FilePath &suppression)
|
2021-03-09 17:40:29 +01:00
|
|
|
{
|
2021-09-30 17:12:10 +02:00
|
|
|
FilePaths val = value();
|
2021-09-14 12:37:35 +02:00
|
|
|
val.append(suppression);
|
|
|
|
|
setValue(val);
|
2021-03-09 17:40:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SuppressionAspectPrivate::slotAddSuppression()
|
|
|
|
|
{
|
|
|
|
|
ValgrindGlobalSettings *conf = ValgrindGlobalSettings::instance();
|
|
|
|
|
QTC_ASSERT(conf, return);
|
2021-08-17 16:36:42 +02:00
|
|
|
const FilePaths files =
|
|
|
|
|
FileUtils::getOpenFilePaths(nullptr,
|
2022-07-08 16:08:27 +02:00
|
|
|
Tr::tr("Valgrind Suppression Files"),
|
2021-08-17 16:36:42 +02:00
|
|
|
conf->lastSuppressionDirectory.filePath(),
|
2022-07-08 16:08:27 +02:00
|
|
|
Tr::tr("Valgrind Suppression File (*.supp);;All Files (*)"));
|
2021-03-09 17:40:29 +01:00
|
|
|
//dialog.setHistory(conf->lastSuppressionDialogHistory());
|
|
|
|
|
if (!files.isEmpty()) {
|
2021-08-17 16:36:42 +02:00
|
|
|
for (const FilePath &file : files)
|
|
|
|
|
m_model.appendRow(new QStandardItem(file.toString()));
|
|
|
|
|
conf->lastSuppressionDirectory.setFilePath(files.at(0).absolutePath());
|
2021-03-09 17:40:29 +01:00
|
|
|
//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);
|
2021-09-14 12:37:35 +02:00
|
|
|
setSettingsKey("Analyzer.Valgrind.SuppressionFiles");
|
2021-03-09 17:40:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SuppressionAspect::~SuppressionAspect()
|
|
|
|
|
{
|
|
|
|
|
delete d;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-30 17:12:10 +02:00
|
|
|
FilePaths SuppressionAspect::value() const
|
2021-03-09 17:40:29 +01:00
|
|
|
{
|
2022-08-02 09:27:21 +02:00
|
|
|
return FileUtils::toFilePathList(BaseAspect::value().toStringList());
|
2021-03-09 17:40:29 +01:00
|
|
|
}
|
|
|
|
|
|
2021-09-30 17:12:10 +02:00
|
|
|
void SuppressionAspect::setValue(const FilePaths &val)
|
2021-03-09 17:40:29 +01:00
|
|
|
{
|
2021-09-30 17:12:10 +02:00
|
|
|
BaseAspect::setValue(Utils::transform<QStringList>(val, &FilePath::toString));
|
2021-03-09 17:40:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SuppressionAspect::addToLayout(LayoutBuilder &builder)
|
|
|
|
|
{
|
|
|
|
|
QTC_CHECK(!d->addEntry);
|
|
|
|
|
QTC_CHECK(!d->removeEntry);
|
|
|
|
|
QTC_CHECK(!d->entryList);
|
|
|
|
|
|
|
|
|
|
using namespace Layouting;
|
|
|
|
|
|
2022-07-08 16:08:27 +02:00
|
|
|
d->addEntry = new QPushButton(Tr::tr("Add..."));
|
|
|
|
|
d->removeEntry = new QPushButton(Tr::tr("Remove"));
|
2021-03-09 17:40:29 +01:00
|
|
|
|
2021-09-14 12:37:35 +02:00
|
|
|
d->entryList = createSubWidget<QListView>();
|
2021-03-09 17:40:29 +01:00
|
|
|
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);
|
|
|
|
|
|
2022-07-22 18:54:04 +02:00
|
|
|
builder.addItem(Column { Tr::tr("Suppression files:"), st });
|
2021-03-11 19:02:42 +01:00
|
|
|
Row group {
|
|
|
|
|
d->entryList.data(),
|
2022-07-22 18:54:04 +02:00
|
|
|
Column { d->addEntry.data(), d->removeEntry.data(), st }
|
2021-03-09 17:40:29 +01:00
|
|
|
};
|
2021-03-11 19:02:42 +01:00
|
|
|
builder.addItem(Span { 2, group });
|
2021-09-14 12:37:35 +02:00
|
|
|
|
2021-09-30 17:12:10 +02:00
|
|
|
setVolatileValue(BaseAspect::value());
|
2021-03-09 17:40:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SuppressionAspect::fromMap(const QVariantMap &map)
|
|
|
|
|
{
|
2021-09-14 12:37:35 +02:00
|
|
|
BaseAspect::fromMap(map);
|
2021-03-09 17:40:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SuppressionAspect::toMap(QVariantMap &map) const
|
|
|
|
|
{
|
2021-09-14 12:37:35 +02:00
|
|
|
BaseAspect::toMap(map);
|
2021-03-09 17:40:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
|
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");
|
2022-07-08 16:08:27 +02:00
|
|
|
valgrindExecutable.setDisplayName(Tr::tr("Valgrind Command"));
|
|
|
|
|
valgrindExecutable.setLabelText(Tr::tr("Valgrind executable:"));
|
2021-02-18 14:18:34 +01:00
|
|
|
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);
|
2022-07-08 16:08:27 +02:00
|
|
|
valgrindArguments.setLabelText(Tr::tr("Valgrind arguments:"));
|
2021-02-18 14:18:34 +01:00
|
|
|
|
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");
|
2022-07-08 16:08:27 +02:00
|
|
|
selfModifyingCodeDetection.setLabelText(Tr::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);
|
2022-07-08 16:08:27 +02:00
|
|
|
memcheckArguments.setLabelText(Tr::tr("Extra MemCheck arguments:"));
|
2021-02-18 14:18:34 +01:00
|
|
|
|
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);
|
2022-07-08 16:08:27 +02:00
|
|
|
filterExternalIssues.setLabelText(Tr::tr("Show Project Costs Only"));
|
|
|
|
|
filterExternalIssues.setToolTip(Tr::tr("Show only profiling info that originated from this project source."));
|
2021-02-18 14:18:34 +01:00
|
|
|
|
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);
|
2022-07-08 16:08:27 +02:00
|
|
|
trackOrigins.setLabelText(Tr::tr("Track origins of uninitialized memory"));
|
2021-02-18 14:18:34 +01:00
|
|
|
|
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);
|
2022-07-08 16:08:27 +02:00
|
|
|
showReachable.setLabelText(Tr::tr("Show reachable and indirectly lost blocks"));
|
2021-02-18 14:18:34 +01:00
|
|
|
|
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);
|
2022-07-08 16:08:27 +02:00
|
|
|
leakCheckOnFinish.addOption(Tr::tr("No"));
|
|
|
|
|
leakCheckOnFinish.addOption(Tr::tr("Summary Only"));
|
|
|
|
|
leakCheckOnFinish.addOption(Tr::tr("Full"));
|
|
|
|
|
leakCheckOnFinish.setLabelText(Tr::tr("Check for leaks on finish:"));
|
2021-02-18 14:18:34 +01:00
|
|
|
|
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);
|
2022-07-08 16:08:27 +02:00
|
|
|
numCallers.setLabelText(Tr::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);
|
2022-07-08 16:08:27 +02:00
|
|
|
kcachegrindExecutable.setLabelText(Tr::tr("KCachegrind executable:"));
|
2021-02-18 14:18:34 +01:00
|
|
|
kcachegrindExecutable.setExpectedKind(Utils::PathChooser::Command);
|
2022-07-08 16:08:27 +02:00
|
|
|
kcachegrindExecutable.setDisplayName(Tr::tr("KCachegrind Command"));
|
2021-02-18 14:18:34 +01:00
|
|
|
|
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);
|
2022-07-08 16:08:27 +02:00
|
|
|
callgrindArguments.setLabelText(Tr::tr("Extra CallGrind arguments:"));
|
2021-02-18 14:18:34 +01:00
|
|
|
|
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);
|
2022-07-08 16:08:27 +02:00
|
|
|
enableEventToolTips.setLabelText(Tr::tr("Show additional information for events in tooltips"));
|
2021-02-18 14:18:34 +01:00
|
|
|
|
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);
|
2022-07-08 16:08:27 +02:00
|
|
|
enableCacheSim.setLabelText(Tr::tr("Enable cache simulation"));
|
|
|
|
|
enableCacheSim.setToolTip("<html><head/><body>" + Tr::tr(
|
2021-02-18 14:18:34 +01:00
|
|
|
"<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);
|
2022-07-08 16:08:27 +02:00
|
|
|
enableBranchSim.setLabelText(Tr::tr("Enable branch prediction simulation"));
|
|
|
|
|
enableBranchSim.setToolTip("<html><head/><body>\n" + Tr::tr(
|
2021-02-18 14:18:34 +01:00
|
|
|
"<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);
|
2022-07-08 16:08:27 +02:00
|
|
|
collectSystime.setLabelText(Tr::tr("Collect system call time"));
|
|
|
|
|
collectSystime.setToolTip(Tr::tr("Collects information for system call times."));
|
2021-02-18 14:18:34 +01:00
|
|
|
|
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");
|
2022-07-08 16:08:27 +02:00
|
|
|
collectBusEvents.setLabelText(Tr::tr("Collect global bus events"));
|
|
|
|
|
collectBusEvents.setToolTip(Tr::tr("Collect the number of global bus events that are executed. "
|
2021-02-18 14:18:34 +01:00
|
|
|
"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);
|
2022-07-08 16:08:27 +02:00
|
|
|
minimumInclusiveCostRatio.setSuffix(Tr::tr("%"));
|
|
|
|
|
minimumInclusiveCostRatio.setLabelText(Tr::tr("Result view: Minimum event cost:"));
|
|
|
|
|
minimumInclusiveCostRatio.setToolTip(Tr::tr("Limits the amount of results the profiler gives you. "
|
2021-02-18 14:18:34 +01:00
|
|
|
"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);
|
2022-07-08 16:08:27 +02:00
|
|
|
visualizationMinimumInclusiveCostRatio.setLabelText(Tr::tr("Visualization: Minimum event cost:"));
|
|
|
|
|
visualizationMinimumInclusiveCostRatio.setSuffix(Tr::tr("%"));
|
2021-02-18 14:18:34 +01:00
|
|
|
|
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
|
2022-07-08 16:08:27 +02:00
|
|
|
detectCycles.setToolTip(Tr::tr("Enable cycle detection to properly handle recursive "
|
2021-02-18 14:18:34 +01:00
|
|
|
"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
|
2022-07-08 16:08:27 +02:00
|
|
|
shortenTemplates.setToolTip(Tr::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
|
|
|
}
|
|
|
|
|
|
2022-07-08 16:08:27 +02:00
|
|
|
} // Valgrind::Internal
|