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 "valgrindconfigwidget.h"
|
2011-07-12 16:47:32 +02:00
|
|
|
#include "valgrindsettings.h"
|
2013-08-08 17:37:37 +02:00
|
|
|
#include "valgrindplugin.h"
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2020-01-16 17:51:53 +01:00
|
|
|
#include <debugger/analyzer/analyzericons.h>
|
|
|
|
|
|
2014-06-16 18:25:52 +04:00
|
|
|
#include <utils/algorithm.h>
|
2012-08-23 15:53:58 +02:00
|
|
|
#include <utils/hostosinfo.h>
|
2021-02-18 14:18:34 +01:00
|
|
|
#include <utils/layoutbuilder.h>
|
2011-07-12 16:47:32 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QFileDialog>
|
2021-02-18 14:18:34 +01:00
|
|
|
#include <QListView>
|
|
|
|
|
#include <QPushButton>
|
|
|
|
|
#include <QStandardItemModel>
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2014-06-19 14:16:45 +02:00
|
|
|
#include <functional>
|
|
|
|
|
|
2021-02-18 14:18:34 +01:00
|
|
|
using namespace Utils;
|
|
|
|
|
|
2011-07-12 16:47:32 +02:00
|
|
|
namespace Valgrind {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2020-01-16 17:51:53 +01:00
|
|
|
class ValgrindBaseSettings;
|
|
|
|
|
|
|
|
|
|
class ValgrindConfigWidget : public Core::IOptionsPageWidget
|
|
|
|
|
{
|
|
|
|
|
Q_DECLARE_TR_FUNCTIONS(Valgrind::Internal::ValgrindConfigWidget)
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit ValgrindConfigWidget(ValgrindBaseSettings *settings);
|
|
|
|
|
|
|
|
|
|
void apply() final
|
|
|
|
|
{
|
2021-02-18 14:18:34 +01:00
|
|
|
ValgrindGlobalSettings::instance()->group.apply();
|
2020-01-16 17:51:53 +01:00
|
|
|
ValgrindGlobalSettings::instance()->writeSettings();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setSuppressions(const QStringList &files);
|
|
|
|
|
QStringList suppressions() const;
|
|
|
|
|
|
|
|
|
|
void slotAddSuppression();
|
|
|
|
|
void slotRemoveSuppression();
|
|
|
|
|
void slotSuppressionsRemoved(const QStringList &files);
|
|
|
|
|
void slotSuppressionsAdded(const QStringList &files);
|
|
|
|
|
void slotSuppressionSelectionChanged();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void updateUi();
|
|
|
|
|
|
|
|
|
|
ValgrindBaseSettings *m_settings;
|
2021-02-18 14:18:34 +01:00
|
|
|
|
|
|
|
|
QPushButton *addSuppression;
|
|
|
|
|
QPushButton *removeSuppression;
|
|
|
|
|
QListView *suppressionList;
|
|
|
|
|
|
|
|
|
|
QStandardItemModel m_model;
|
2020-01-16 17:51:53 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ValgrindConfigWidget::ValgrindConfigWidget(ValgrindBaseSettings *settings)
|
2021-02-18 14:18:34 +01:00
|
|
|
: m_settings(settings)
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
2021-02-18 14:18:34 +01:00
|
|
|
addSuppression = new QPushButton(tr("Add..."));
|
|
|
|
|
removeSuppression = new QPushButton(tr("Remove"));
|
|
|
|
|
|
|
|
|
|
suppressionList = new QListView;
|
|
|
|
|
suppressionList->setModel(&m_model);
|
|
|
|
|
suppressionList->setSelectionMode(QAbstractItemView::MultiSelection);
|
|
|
|
|
|
|
|
|
|
using namespace Layouting;
|
|
|
|
|
const Break nl;
|
|
|
|
|
ValgrindBaseSettings &s = *settings;
|
|
|
|
|
|
|
|
|
|
Grid generic {
|
|
|
|
|
s.valgrindExecutable, nl,
|
|
|
|
|
s.valgrindArguments, nl,
|
|
|
|
|
s.selfModifyingCodeDetection, nl
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Grid memcheck {
|
|
|
|
|
s.memcheckArguments, nl,
|
|
|
|
|
s.trackOrigins, nl,
|
|
|
|
|
s.showReachable, nl,
|
|
|
|
|
s.leakCheckOnFinish, nl,
|
|
|
|
|
s.numCallers, nl,
|
|
|
|
|
s.filterExternalIssues, nl,
|
|
|
|
|
Item {
|
|
|
|
|
Group {
|
|
|
|
|
Title(tr("Suppression files:")),
|
|
|
|
|
Row {
|
|
|
|
|
suppressionList,
|
|
|
|
|
Column { addSuppression, removeSuppression, Stretch() }
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
2 // Span.
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Grid callgrind {
|
|
|
|
|
s.callgrindArguments, nl,
|
|
|
|
|
s.kcachegrindExecutable, nl,
|
|
|
|
|
s.minimumInclusiveCostRatio, nl,
|
|
|
|
|
s.visualizationMinimumInclusiveCostRatio, nl,
|
|
|
|
|
s.enableEventToolTips, nl,
|
|
|
|
|
Item {
|
|
|
|
|
Group {
|
|
|
|
|
s.enableCacheSim,
|
|
|
|
|
s.enableBranchSim,
|
|
|
|
|
s.collectSystime,
|
|
|
|
|
s.collectBusEvents,
|
|
|
|
|
},
|
|
|
|
|
2 // Span.
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Column {
|
|
|
|
|
Group { Title(tr("Valgrind Generic Settings")), generic },
|
|
|
|
|
Group { Title(tr("MemCheck Memory Analysis Options")), memcheck },
|
|
|
|
|
Group { Title(tr("CallGrind Profiling Options")), callgrind },
|
|
|
|
|
Stretch(),
|
|
|
|
|
}.attachTo(this);
|
2011-03-04 12:15:18 +01:00
|
|
|
|
|
|
|
|
|
2011-07-25 20:16:29 +02:00
|
|
|
updateUi();
|
2015-01-30 11:02:24 +01:00
|
|
|
connect(m_settings, &ValgrindBaseSettings::changed, this, &ValgrindConfigWidget::updateUi);
|
2011-07-25 20:16:29 +02:00
|
|
|
|
2021-02-18 14:18:34 +01:00
|
|
|
connect(addSuppression, &QPushButton::clicked,
|
|
|
|
|
this, &ValgrindConfigWidget::slotAddSuppression);
|
|
|
|
|
connect(removeSuppression, &QPushButton::clicked,
|
|
|
|
|
this, &ValgrindConfigWidget::slotRemoveSuppression);
|
2021-02-17 11:00:36 +01:00
|
|
|
|
2021-02-18 14:18:34 +01:00
|
|
|
connect(&s, &ValgrindBaseSettings::suppressionFilesRemoved,
|
2015-01-30 11:02:24 +01:00
|
|
|
this, &ValgrindConfigWidget::slotSuppressionsRemoved);
|
2021-02-18 14:18:34 +01:00
|
|
|
connect(&s, &ValgrindBaseSettings::suppressionFilesAdded,
|
2015-01-30 11:02:24 +01:00
|
|
|
this, &ValgrindConfigWidget::slotSuppressionsAdded);
|
2011-07-12 16:47:32 +02:00
|
|
|
|
2021-02-18 14:18:34 +01:00
|
|
|
connect(suppressionList->selectionModel(), &QItemSelectionModel::selectionChanged,
|
2015-02-06 12:39:07 +02:00
|
|
|
this, &ValgrindConfigWidget::slotSuppressionSelectionChanged);
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2021-02-18 14:18:34 +01:00
|
|
|
slotSuppressionSelectionChanged();
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
2011-07-12 16:47:32 +02:00
|
|
|
|
2011-07-25 20:16:29 +02:00
|
|
|
void ValgrindConfigWidget::updateUi()
|
|
|
|
|
{
|
2021-02-18 14:18:34 +01:00
|
|
|
m_model.clear();
|
2011-07-25 20:16:29 +02:00
|
|
|
foreach (const QString &file, m_settings->suppressionFiles())
|
2021-02-18 14:18:34 +01:00
|
|
|
m_model.appendRow(new QStandardItem(file));
|
2011-07-25 20:16:29 +02:00
|
|
|
}
|
|
|
|
|
|
2011-07-12 16:47:32 +02:00
|
|
|
void ValgrindConfigWidget::slotAddSuppression()
|
|
|
|
|
{
|
2019-03-20 17:49:26 +01:00
|
|
|
ValgrindGlobalSettings *conf = ValgrindGlobalSettings::instance();
|
2011-07-12 16:47:32 +02:00
|
|
|
QTC_ASSERT(conf, return);
|
2011-11-10 17:08:20 +01:00
|
|
|
QStringList files = QFileDialog::getOpenFileNames(this,
|
|
|
|
|
tr("Valgrind Suppression Files"),
|
2021-02-18 14:18:34 +01:00
|
|
|
conf->lastSuppressionDirectory.value(),
|
2011-11-10 17:08:20 +01:00
|
|
|
tr("Valgrind Suppression File (*.supp);;All Files (*)"));
|
|
|
|
|
//dialog.setHistory(conf->lastSuppressionDialogHistory());
|
|
|
|
|
if (!files.isEmpty()) {
|
|
|
|
|
foreach (const QString &file, files)
|
2021-02-18 14:18:34 +01:00
|
|
|
m_model.appendRow(new QStandardItem(file));
|
2011-11-10 17:08:20 +01:00
|
|
|
m_settings->addSuppressionFiles(files);
|
2021-02-18 14:18:34 +01:00
|
|
|
conf->lastSuppressionDirectory.setValue(QFileInfo(files.at(0)).absolutePath());
|
2011-11-10 17:08:20 +01:00
|
|
|
//conf->setLastSuppressionDialogHistory(dialog.history());
|
2011-07-12 16:47:32 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ValgrindConfigWidget::slotSuppressionsAdded(const QStringList &files)
|
|
|
|
|
{
|
|
|
|
|
QStringList filesToAdd = files;
|
2021-02-18 14:18:34 +01:00
|
|
|
for (int i = 0, c = m_model.rowCount(); i < c; ++i)
|
|
|
|
|
filesToAdd.removeAll(m_model.item(i)->text());
|
2011-07-12 16:47:32 +02:00
|
|
|
|
|
|
|
|
foreach (const QString &file, filesToAdd)
|
2021-02-18 14:18:34 +01:00
|
|
|
m_model.appendRow(new QStandardItem(file));
|
2011-07-12 16:47:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ValgrindConfigWidget::slotRemoveSuppression()
|
|
|
|
|
{
|
|
|
|
|
// remove from end so no rows get invalidated
|
|
|
|
|
QList<int> rows;
|
|
|
|
|
|
|
|
|
|
QStringList removed;
|
2021-02-18 14:18:34 +01:00
|
|
|
foreach (const QModelIndex &index, suppressionList->selectionModel()->selectedIndexes()) {
|
2011-07-12 16:47:32 +02:00
|
|
|
rows << index.row();
|
|
|
|
|
removed << index.data().toString();
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-16 18:25:52 +04:00
|
|
|
Utils::sort(rows, std::greater<int>());
|
2011-07-12 16:47:32 +02:00
|
|
|
|
|
|
|
|
foreach (int row, rows)
|
2021-02-18 14:18:34 +01:00
|
|
|
m_model.removeRow(row);
|
2011-07-12 16:47:32 +02:00
|
|
|
|
|
|
|
|
m_settings->removeSuppressionFiles(removed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ValgrindConfigWidget::slotSuppressionsRemoved(const QStringList &files)
|
|
|
|
|
{
|
2021-02-18 14:18:34 +01:00
|
|
|
for (int i = 0; i < m_model.rowCount(); ++i) {
|
|
|
|
|
if (files.contains(m_model.item(i)->text())) {
|
|
|
|
|
m_model.removeRow(i);
|
2011-07-12 16:47:32 +02:00
|
|
|
--i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ValgrindConfigWidget::setSuppressions(const QStringList &files)
|
|
|
|
|
{
|
2021-02-18 14:18:34 +01:00
|
|
|
m_model.clear();
|
2011-07-12 16:47:32 +02:00
|
|
|
foreach (const QString &file, files)
|
2021-02-18 14:18:34 +01:00
|
|
|
m_model.appendRow(new QStandardItem(file));
|
2011-07-12 16:47:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList ValgrindConfigWidget::suppressions() const
|
|
|
|
|
{
|
|
|
|
|
QStringList ret;
|
|
|
|
|
|
2021-02-18 14:18:34 +01:00
|
|
|
for (int i = 0; i < m_model.rowCount(); ++i)
|
|
|
|
|
ret << m_model.item(i)->text();
|
2011-07-12 16:47:32 +02:00
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ValgrindConfigWidget::slotSuppressionSelectionChanged()
|
|
|
|
|
{
|
2021-02-18 14:18:34 +01:00
|
|
|
removeSuppression->setEnabled(suppressionList->selectionModel()->hasSelection());
|
2011-07-12 16:47:32 +02:00
|
|
|
}
|
|
|
|
|
|
2020-01-16 17:51:53 +01:00
|
|
|
// ValgrindOptionsPage
|
|
|
|
|
|
|
|
|
|
ValgrindOptionsPage::ValgrindOptionsPage()
|
|
|
|
|
{
|
|
|
|
|
setId(ANALYZER_VALGRIND_SETTINGS);
|
|
|
|
|
setDisplayName(ValgrindConfigWidget::tr("Valgrind"));
|
|
|
|
|
setCategory("T.Analyzer");
|
|
|
|
|
setDisplayCategory(QCoreApplication::translate("Analyzer", "Analyzer"));
|
|
|
|
|
setCategoryIconPath(Analyzer::Icons::SETTINGSCATEGORY_ANALYZER);
|
|
|
|
|
setWidgetCreator([] { return new ValgrindConfigWidget(ValgrindGlobalSettings::instance()); });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QWidget *ValgrindOptionsPage::createSettingsWidget(ValgrindBaseSettings *settings)
|
|
|
|
|
{
|
|
|
|
|
return new ValgrindConfigWidget(settings);
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-12 16:47:32 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Valgrind
|