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
|
|
|
|
|
|
|
|
#include "ui_valgrindconfigwidget.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>
|
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>
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QStandardItemModel>
|
|
|
|
|
#include <QFileDialog>
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2014-06-19 14:16:45 +02:00
|
|
|
#include <functional>
|
|
|
|
|
|
2011-07-12 16:47:32 +02:00
|
|
|
namespace Valgrind {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2018-09-10 15:39:27 +02:00
|
|
|
ValgrindConfigWidget::ValgrindConfigWidget(ValgrindBaseSettings *settings, bool global)
|
|
|
|
|
: m_settings(settings),
|
2011-03-04 12:15:18 +01:00
|
|
|
m_ui(new Ui::ValgrindConfigWidget)
|
|
|
|
|
{
|
|
|
|
|
m_ui->setupUi(this);
|
2011-07-25 20:16:29 +02:00
|
|
|
m_model = new QStandardItemModel(this);
|
2011-03-04 12:15:18 +01:00
|
|
|
|
|
|
|
|
m_ui->valgrindExeChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
|
2013-11-25 14:38:44 +01:00
|
|
|
m_ui->valgrindExeChooser->setHistoryCompleter(QLatin1String("Valgrind.Command.History"));
|
2011-03-04 12:15:18 +01:00
|
|
|
m_ui->valgrindExeChooser->setPromptDialogTitle(tr("Valgrind Command"));
|
|
|
|
|
|
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
|
|
|
|
2015-08-20 14:56:30 +02:00
|
|
|
connect(m_ui->valgrindExeChooser, &Utils::PathChooser::rawPathChanged,
|
2015-01-30 11:02:24 +01:00
|
|
|
m_settings, &ValgrindBaseSettings::setValgrindExecutable);
|
|
|
|
|
connect(m_ui->smcDetectionComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
|
|
|
|
m_settings, &ValgrindBaseSettings::setSelfModifyingCodeDetection);
|
2011-07-12 16:47:32 +02:00
|
|
|
|
2012-08-23 15:53:58 +02:00
|
|
|
if (Utils::HostOsInfo::isWindowsHost()) {
|
|
|
|
|
// FIXME: 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.
|
|
|
|
|
m_ui->valgrindExeChooser->buttonAtIndex(0)->hide();
|
|
|
|
|
}
|
2011-07-14 12:20:12 +02:00
|
|
|
|
2011-07-12 16:47:32 +02:00
|
|
|
//
|
|
|
|
|
// Callgrind
|
|
|
|
|
//
|
2015-01-30 11:02:24 +01:00
|
|
|
connect(m_ui->enableCacheSim, &QCheckBox::toggled,
|
|
|
|
|
m_settings, &ValgrindBaseSettings::setEnableCacheSim);
|
2015-02-06 12:39:07 +02:00
|
|
|
connect(m_settings, &ValgrindBaseSettings::enableCacheSimChanged,
|
|
|
|
|
m_ui->enableCacheSim, &QAbstractButton::setChecked);
|
2011-07-12 16:47:32 +02:00
|
|
|
|
2015-01-30 11:02:24 +01:00
|
|
|
connect(m_ui->enableBranchSim, &QCheckBox::toggled,
|
|
|
|
|
m_settings, &ValgrindBaseSettings::setEnableBranchSim);
|
2015-02-06 12:39:07 +02:00
|
|
|
connect(m_settings, &ValgrindBaseSettings::enableBranchSimChanged,
|
|
|
|
|
m_ui->enableBranchSim, &QAbstractButton::setChecked);
|
2011-07-12 16:47:32 +02:00
|
|
|
|
2015-01-30 11:02:24 +01:00
|
|
|
connect(m_ui->collectSystime, &QCheckBox::toggled,
|
|
|
|
|
m_settings, &ValgrindBaseSettings::setCollectSystime);
|
2015-02-06 12:39:07 +02:00
|
|
|
connect(m_settings, &ValgrindBaseSettings::collectSystimeChanged,
|
|
|
|
|
m_ui->collectSystime, &QAbstractButton::setChecked);
|
2011-07-12 16:47:32 +02:00
|
|
|
|
2015-01-30 11:02:24 +01:00
|
|
|
connect(m_ui->collectBusEvents, &QCheckBox::toggled,
|
|
|
|
|
m_settings, &ValgrindBaseSettings::setCollectBusEvents);
|
2015-02-06 12:39:07 +02:00
|
|
|
connect(m_settings, &ValgrindBaseSettings::collectBusEventsChanged,
|
|
|
|
|
m_ui->collectBusEvents, &QAbstractButton::setChecked);
|
2011-07-12 16:47:32 +02:00
|
|
|
|
2015-01-30 11:02:24 +01:00
|
|
|
connect(m_ui->enableEventToolTips, &QGroupBox::toggled,
|
|
|
|
|
m_settings, &ValgrindBaseSettings::setEnableEventToolTips);
|
2015-02-06 12:39:07 +02:00
|
|
|
connect(m_settings, &ValgrindBaseSettings::enableEventToolTipsChanged,
|
|
|
|
|
m_ui->enableEventToolTips, &QGroupBox::setChecked);
|
2011-07-12 16:47:32 +02:00
|
|
|
|
2015-01-30 11:02:24 +01:00
|
|
|
connect(m_ui->minimumInclusiveCostRatio, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
|
|
|
|
m_settings, &ValgrindBaseSettings::setMinimumInclusiveCostRatio);
|
2015-02-06 12:39:07 +02:00
|
|
|
connect(m_settings, &ValgrindBaseSettings::minimumInclusiveCostRatioChanged,
|
|
|
|
|
m_ui->minimumInclusiveCostRatio, &QDoubleSpinBox::setValue);
|
2011-07-12 16:47:32 +02:00
|
|
|
|
2015-01-30 11:02:24 +01:00
|
|
|
connect(m_ui->visualisationMinimumInclusiveCostRatio, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
|
|
|
|
|
m_settings, &ValgrindBaseSettings::setVisualisationMinimumInclusiveCostRatio);
|
2015-02-06 12:39:07 +02:00
|
|
|
connect(m_settings, &ValgrindBaseSettings::visualisationMinimumInclusiveCostRatioChanged,
|
|
|
|
|
m_ui->visualisationMinimumInclusiveCostRatio, &QDoubleSpinBox::setValue);
|
2011-07-12 16:47:32 +02:00
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Memcheck
|
|
|
|
|
//
|
|
|
|
|
m_ui->suppressionList->setModel(m_model);
|
|
|
|
|
m_ui->suppressionList->setSelectionMode(QAbstractItemView::MultiSelection);
|
|
|
|
|
|
2015-01-30 11:02:24 +01:00
|
|
|
connect(m_ui->addSuppression, &QPushButton::clicked, this, &ValgrindConfigWidget::slotAddSuppression);
|
|
|
|
|
connect(m_ui->removeSuppression, &QPushButton::clicked, this, &ValgrindConfigWidget::slotRemoveSuppression);
|
2011-07-12 16:47:32 +02:00
|
|
|
|
2015-01-30 11:02:24 +01:00
|
|
|
connect(m_ui->numCallers, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
|
|
|
|
|
m_settings, &ValgrindBaseSettings::setNumCallers);
|
2015-02-06 12:39:07 +02:00
|
|
|
connect(m_settings, &ValgrindBaseSettings::numCallersChanged,
|
|
|
|
|
m_ui->numCallers, &QSpinBox::setValue);
|
2011-07-12 16:47:32 +02:00
|
|
|
|
2015-01-30 11:02:24 +01:00
|
|
|
connect(m_ui->leakCheckOnFinish, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
|
|
|
|
m_settings, &ValgrindBaseSettings::setLeakCheckOnFinish);
|
2015-02-06 12:39:07 +02:00
|
|
|
connect(m_settings, &ValgrindBaseSettings::leakCheckOnFinishChanged,
|
|
|
|
|
m_ui->leakCheckOnFinish, &QComboBox::setCurrentIndex);
|
2013-09-09 11:43:39 +02:00
|
|
|
|
2015-02-06 12:39:07 +02:00
|
|
|
connect(m_ui->showReachable, &QCheckBox::toggled,
|
|
|
|
|
m_settings, &ValgrindBaseSettings::setShowReachable);
|
|
|
|
|
connect(m_settings, &ValgrindBaseSettings::showReachableChanged,
|
|
|
|
|
m_ui->showReachable, &QAbstractButton::setChecked);
|
2013-09-09 11:43:39 +02:00
|
|
|
|
2015-01-30 11:02:24 +01:00
|
|
|
connect(m_ui->trackOrigins, &QCheckBox::toggled, m_settings, &ValgrindBaseSettings::setTrackOrigins);
|
2015-02-06 12:39:07 +02:00
|
|
|
connect(m_settings, &ValgrindBaseSettings::trackOriginsChanged,
|
|
|
|
|
m_ui->trackOrigins, &QAbstractButton::setChecked);
|
2011-07-12 16:47:32 +02:00
|
|
|
|
2015-01-30 11:02:24 +01:00
|
|
|
connect(m_settings, &ValgrindBaseSettings::suppressionFilesRemoved,
|
|
|
|
|
this, &ValgrindConfigWidget::slotSuppressionsRemoved);
|
|
|
|
|
connect(m_settings, &ValgrindBaseSettings::suppressionFilesAdded,
|
|
|
|
|
this, &ValgrindConfigWidget::slotSuppressionsAdded);
|
2011-07-12 16:47:32 +02:00
|
|
|
|
2015-02-06 12:39:07 +02:00
|
|
|
connect(m_ui->suppressionList->selectionModel(), &QItemSelectionModel::selectionChanged,
|
|
|
|
|
this, &ValgrindConfigWidget::slotSuppressionSelectionChanged);
|
2011-07-12 16:47:32 +02:00
|
|
|
slotSuppressionSelectionChanged();
|
|
|
|
|
|
|
|
|
|
if (!global) {
|
|
|
|
|
// In project settings we want a flat vertical list.
|
|
|
|
|
QVBoxLayout *l = new QVBoxLayout;
|
2014-11-21 12:41:23 +02:00
|
|
|
while (layout()->count()) {
|
|
|
|
|
QLayoutItem *item = layout()->takeAt(0);
|
|
|
|
|
if (QWidget *w = item->widget())
|
2011-07-12 16:47:32 +02:00
|
|
|
l->addWidget(w);
|
2014-11-21 12:41:23 +02:00
|
|
|
delete item;
|
|
|
|
|
}
|
2011-07-12 16:47:32 +02:00
|
|
|
delete layout();
|
|
|
|
|
setLayout(l);
|
|
|
|
|
}
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ValgrindConfigWidget::~ValgrindConfigWidget()
|
|
|
|
|
{
|
|
|
|
|
delete m_ui;
|
|
|
|
|
}
|
2011-07-12 16:47:32 +02:00
|
|
|
|
2011-07-25 20:16:29 +02:00
|
|
|
void ValgrindConfigWidget::updateUi()
|
|
|
|
|
{
|
|
|
|
|
m_ui->valgrindExeChooser->setPath(m_settings->valgrindExecutable());
|
2013-09-06 16:33:48 +02:00
|
|
|
m_ui->smcDetectionComboBox->setCurrentIndex(m_settings->selfModifyingCodeDetection());
|
2011-07-25 20:16:29 +02:00
|
|
|
m_ui->enableCacheSim->setChecked(m_settings->enableCacheSim());
|
|
|
|
|
m_ui->enableBranchSim->setChecked(m_settings->enableBranchSim());
|
|
|
|
|
m_ui->collectSystime->setChecked(m_settings->collectSystime());
|
|
|
|
|
m_ui->collectBusEvents->setChecked(m_settings->collectBusEvents());
|
|
|
|
|
m_ui->enableEventToolTips->setChecked(m_settings->enableEventToolTips());
|
|
|
|
|
m_ui->minimumInclusiveCostRatio->setValue(m_settings->minimumInclusiveCostRatio());
|
|
|
|
|
m_ui->visualisationMinimumInclusiveCostRatio->setValue(m_settings->visualisationMinimumInclusiveCostRatio());
|
|
|
|
|
m_ui->numCallers->setValue(m_settings->numCallers());
|
2013-09-09 11:43:39 +02:00
|
|
|
m_ui->leakCheckOnFinish->setCurrentIndex(m_settings->leakCheckOnFinish());
|
|
|
|
|
m_ui->showReachable->setChecked(m_settings->showReachable());
|
2011-07-25 20:16:29 +02:00
|
|
|
m_ui->trackOrigins->setChecked(m_settings->trackOrigins());
|
|
|
|
|
m_model->clear();
|
|
|
|
|
foreach (const QString &file, m_settings->suppressionFiles())
|
|
|
|
|
m_model->appendRow(new QStandardItem(file));
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-12 16:47:32 +02:00
|
|
|
void ValgrindConfigWidget::slotAddSuppression()
|
|
|
|
|
{
|
2013-08-08 17:37:37 +02:00
|
|
|
ValgrindGlobalSettings *conf = ValgrindPlugin::globalSettings();
|
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"),
|
|
|
|
|
conf->lastSuppressionDialogDirectory(),
|
|
|
|
|
tr("Valgrind Suppression File (*.supp);;All Files (*)"));
|
|
|
|
|
//dialog.setHistory(conf->lastSuppressionDialogHistory());
|
|
|
|
|
if (!files.isEmpty()) {
|
|
|
|
|
foreach (const QString &file, files)
|
2011-07-12 16:47:32 +02:00
|
|
|
m_model->appendRow(new QStandardItem(file));
|
2011-11-10 17:08:20 +01:00
|
|
|
m_settings->addSuppressionFiles(files);
|
|
|
|
|
conf->setLastSuppressionDialogDirectory(QFileInfo(files.at(0)).absolutePath());
|
|
|
|
|
//conf->setLastSuppressionDialogHistory(dialog.history());
|
2011-07-12 16:47:32 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ValgrindConfigWidget::slotSuppressionsAdded(const QStringList &files)
|
|
|
|
|
{
|
|
|
|
|
QStringList filesToAdd = files;
|
|
|
|
|
for (int i = 0, c = m_model->rowCount(); i < c; ++i)
|
|
|
|
|
filesToAdd.removeAll(m_model->item(i)->text());
|
|
|
|
|
|
|
|
|
|
foreach (const QString &file, filesToAdd)
|
|
|
|
|
m_model->appendRow(new QStandardItem(file));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ValgrindConfigWidget::slotRemoveSuppression()
|
|
|
|
|
{
|
|
|
|
|
// remove from end so no rows get invalidated
|
|
|
|
|
QList<int> rows;
|
|
|
|
|
|
|
|
|
|
QStringList removed;
|
|
|
|
|
foreach (const QModelIndex &index, m_ui->suppressionList->selectionModel()->selectedIndexes()) {
|
|
|
|
|
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)
|
|
|
|
|
m_model->removeRow(row);
|
|
|
|
|
|
|
|
|
|
m_settings->removeSuppressionFiles(removed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ValgrindConfigWidget::slotSuppressionsRemoved(const QStringList &files)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < m_model->rowCount(); ++i) {
|
|
|
|
|
if (files.contains(m_model->item(i)->text())) {
|
|
|
|
|
m_model->removeRow(i);
|
|
|
|
|
--i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ValgrindConfigWidget::setSuppressions(const QStringList &files)
|
|
|
|
|
{
|
|
|
|
|
m_model->clear();
|
|
|
|
|
foreach (const QString &file, files)
|
|
|
|
|
m_model->appendRow(new QStandardItem(file));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList ValgrindConfigWidget::suppressions() const
|
|
|
|
|
{
|
|
|
|
|
QStringList ret;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < m_model->rowCount(); ++i)
|
|
|
|
|
ret << m_model->item(i)->text();
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ValgrindConfigWidget::slotSuppressionSelectionChanged()
|
|
|
|
|
{
|
|
|
|
|
m_ui->removeSuppression->setEnabled(m_ui->suppressionList->selectionModel()->hasSelection());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Valgrind
|