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>
|
|
|
|
|
#include <utils/qtcassert.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 <QSettings>
|
|
|
|
|
#include <QDebug>
|
2011-07-12 16:47:32 +02:00
|
|
|
|
2012-08-22 23:35:02 +02:00
|
|
|
const char numCallersC[] = "Analyzer.Valgrind.NumCallers";
|
2013-09-09 11:43:39 +02:00
|
|
|
const char leakCheckOnFinishC[] = "Analyzer.Valgrind.LeakCheckOnFinish";
|
|
|
|
|
const char showReachableC[] = "Analyzer.Valgrind.ShowReachable";
|
2012-08-22 23:35:02 +02:00
|
|
|
const char trackOriginsC[] = "Analyzer.Valgrind.TrackOrigins";
|
2013-09-06 16:33:48 +02:00
|
|
|
const char selfModifyingCodeDetectionC[] = "Analyzer.Valgrind.SelfModifyingCodeDetection";
|
2012-08-22 23:35:02 +02:00
|
|
|
const char suppressionFilesC[] = "Analyzer.Valgrind.SupressionFiles";
|
|
|
|
|
const char removedSuppressionFilesC[] = "Analyzer.Valgrind.RemovedSuppressionFiles";
|
|
|
|
|
const char addedSuppressionFilesC[] = "Analyzer.Valgrind.AddedSuppressionFiles";
|
|
|
|
|
const char filterExternalIssuesC[] = "Analyzer.Valgrind.FilterExternalIssues";
|
|
|
|
|
const char visibleErrorKindsC[] = "Analyzer.Valgrind.VisibleErrorKinds";
|
|
|
|
|
|
|
|
|
|
const char lastSuppressionDirectoryC[] = "Analyzer.Valgrind.LastSuppressionDirectory";
|
|
|
|
|
const char lastSuppressionHistoryC[] = "Analyzer.Valgrind.LastSuppressionHistory";
|
|
|
|
|
|
2018-11-07 23:55:59 +02:00
|
|
|
const char kcachegrindExeC[] = "Analyzer.Valgrind.KCachegrindExecutable";
|
2012-08-22 23:35:02 +02:00
|
|
|
const char callgrindEnableCacheSimC[] = "Analyzer.Valgrind.Callgrind.EnableCacheSim";
|
|
|
|
|
const char callgrindEnableBranchSimC[] = "Analyzer.Valgrind.Callgrind.EnableBranchSim";
|
|
|
|
|
const char callgrindCollectSystimeC[] = "Analyzer.Valgrind.Callgrind.CollectSystime";
|
|
|
|
|
const char callgrindCollectBusEventsC[] = "Analyzer.Valgrind.Callgrind.CollectBusEvents";
|
|
|
|
|
const char callgrindEnableEventToolTipsC[] = "Analyzer.Valgrind.Callgrind.EnableEventToolTips";
|
|
|
|
|
const char callgrindMinimumCostRatioC[] = "Analyzer.Valgrind.Callgrind.MinimumCostRatio";
|
|
|
|
|
const char callgrindVisualisationMinimumCostRatioC[] = "Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio";
|
|
|
|
|
|
|
|
|
|
const char callgrindCycleDetectionC[] = "Analyzer.Valgrind.Callgrind.CycleDetection";
|
|
|
|
|
const char callgrindShortenTemplates[] = "Analyzer.Valgrind.Callgrind.ShortenTemplates";
|
|
|
|
|
const char callgrindCostFormatC[] = "Analyzer.Valgrind.Callgrind.CostFormat";
|
|
|
|
|
|
|
|
|
|
const char valgrindExeC[] = "Analyzer.Valgrind.ValgrindExecutable";
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2011-07-12 16:47:32 +02:00
|
|
|
namespace Valgrind {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// ValgrindBaseSettings
|
|
|
|
|
//
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2013-08-09 15:20:21 +02:00
|
|
|
/**
|
|
|
|
|
* Utility function to set @p val if @p key is present in @p map.
|
|
|
|
|
*/
|
|
|
|
|
template <typename T> void setIfPresent(const QVariantMap &map, const QString &key, T *val)
|
|
|
|
|
{
|
|
|
|
|
if (map.contains(key))
|
|
|
|
|
*val = map.value(key).template value<T>();
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-10 15:39:27 +02:00
|
|
|
ValgrindBaseSettings::ValgrindBaseSettings(const ConfigWidgetCreator &creator)
|
|
|
|
|
: ISettingsAspect(creator)
|
|
|
|
|
{}
|
|
|
|
|
|
2012-02-22 12:36:39 +01:00
|
|
|
void ValgrindBaseSettings::fromMap(const QVariantMap &map)
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
2011-07-12 16:47:32 +02:00
|
|
|
// General
|
2018-12-01 20:56:21 +02:00
|
|
|
setIfPresent(map, valgrindExeC, &m_valgrindExecutable);
|
|
|
|
|
setIfPresent(map, selfModifyingCodeDetectionC,
|
2013-09-06 16:33:48 +02:00
|
|
|
(int*) &m_selfModifyingCodeDetection);
|
2011-07-12 16:47:32 +02:00
|
|
|
|
|
|
|
|
// Memcheck
|
2018-12-01 20:56:21 +02:00
|
|
|
setIfPresent(map, numCallersC, &m_numCallers);
|
|
|
|
|
setIfPresent(map, leakCheckOnFinishC, (int*) &m_leakCheckOnFinish);
|
|
|
|
|
setIfPresent(map, showReachableC, &m_showReachable);
|
|
|
|
|
setIfPresent(map, trackOriginsC, &m_trackOrigins);
|
|
|
|
|
setIfPresent(map, filterExternalIssuesC, &m_filterExternalIssues);
|
|
|
|
|
if (map.contains(visibleErrorKindsC)) {
|
2011-07-12 16:47:32 +02:00
|
|
|
m_visibleErrorKinds.clear();
|
2018-12-01 20:56:21 +02:00
|
|
|
foreach (const QVariant &val, map.value(visibleErrorKindsC).toList())
|
2011-07-12 16:47:32 +02:00
|
|
|
m_visibleErrorKinds << val.toInt();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Callgrind
|
2018-11-07 23:55:59 +02:00
|
|
|
setIfPresent(map, kcachegrindExeC, &m_kcachegrindExecutable);
|
2018-12-01 20:56:21 +02:00
|
|
|
setIfPresent(map, callgrindEnableCacheSimC, &m_enableCacheSim);
|
|
|
|
|
setIfPresent(map, callgrindEnableBranchSimC, &m_enableBranchSim);
|
|
|
|
|
setIfPresent(map, callgrindCollectSystimeC, &m_collectSystime);
|
|
|
|
|
setIfPresent(map, callgrindCollectBusEventsC, &m_collectBusEvents);
|
|
|
|
|
setIfPresent(map, callgrindEnableEventToolTipsC, &m_enableEventToolTips);
|
|
|
|
|
setIfPresent(map, callgrindMinimumCostRatioC, &m_minimumInclusiveCostRatio);
|
|
|
|
|
setIfPresent(map, callgrindVisualisationMinimumCostRatioC,
|
2011-07-12 16:47:32 +02:00
|
|
|
&m_visualisationMinimumInclusiveCostRatio);
|
|
|
|
|
|
2011-07-25 20:16:29 +02:00
|
|
|
emit changed();
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2013-08-12 17:05:52 +02:00
|
|
|
void ValgrindBaseSettings::toMap(QVariantMap &map) const
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
2011-07-12 16:47:32 +02:00
|
|
|
// General
|
2018-12-01 20:56:21 +02:00
|
|
|
map.insert(valgrindExeC, m_valgrindExecutable);
|
|
|
|
|
map.insert(selfModifyingCodeDetectionC, m_selfModifyingCodeDetection);
|
2011-07-12 16:47:32 +02:00
|
|
|
|
|
|
|
|
// Memcheck
|
2018-12-01 20:56:21 +02:00
|
|
|
map.insert(numCallersC, m_numCallers);
|
|
|
|
|
map.insert(leakCheckOnFinishC, m_leakCheckOnFinish);
|
|
|
|
|
map.insert(showReachableC, m_showReachable);
|
|
|
|
|
map.insert(trackOriginsC, m_trackOrigins);
|
|
|
|
|
map.insert(filterExternalIssuesC, m_filterExternalIssues);
|
2011-07-12 16:47:32 +02:00
|
|
|
QVariantList errorKinds;
|
|
|
|
|
foreach (int i, m_visibleErrorKinds)
|
|
|
|
|
errorKinds << i;
|
2018-12-01 20:56:21 +02:00
|
|
|
map.insert(visibleErrorKindsC, errorKinds);
|
2011-07-12 16:47:32 +02:00
|
|
|
|
|
|
|
|
// Callgrind
|
2018-11-07 23:55:59 +02:00
|
|
|
map.insert(kcachegrindExeC, m_kcachegrindExecutable);
|
2018-12-01 20:56:21 +02:00
|
|
|
map.insert(callgrindEnableCacheSimC, m_enableCacheSim);
|
|
|
|
|
map.insert(callgrindEnableBranchSimC, m_enableBranchSim);
|
|
|
|
|
map.insert(callgrindCollectSystimeC, m_collectSystime);
|
|
|
|
|
map.insert(callgrindCollectBusEventsC, m_collectBusEvents);
|
|
|
|
|
map.insert(callgrindEnableEventToolTipsC, m_enableEventToolTips);
|
|
|
|
|
map.insert(callgrindMinimumCostRatioC, m_minimumInclusiveCostRatio);
|
|
|
|
|
map.insert(callgrindVisualisationMinimumCostRatioC,
|
2011-07-12 16:47:32 +02:00
|
|
|
m_visualisationMinimumInclusiveCostRatio);
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-07-12 16:47:32 +02:00
|
|
|
void ValgrindBaseSettings::setValgrindExecutable(const QString &valgrindExecutable)
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
2017-11-16 20:41:58 +02:00
|
|
|
m_valgrindExecutable = valgrindExecutable;
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
2013-09-06 16:33:48 +02:00
|
|
|
void ValgrindBaseSettings::setSelfModifyingCodeDetection(int smcDetection)
|
|
|
|
|
{
|
|
|
|
|
if (m_selfModifyingCodeDetection != smcDetection) {
|
|
|
|
|
m_selfModifyingCodeDetection = (SelfModifyingCodeDetection) smcDetection;
|
|
|
|
|
emit selfModifyingCodeDetectionChanged(smcDetection);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-12 16:47:32 +02:00
|
|
|
QString ValgrindBaseSettings::valgrindExecutable() const
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
|
|
|
|
return m_valgrindExecutable;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-06 16:33:48 +02:00
|
|
|
ValgrindBaseSettings::SelfModifyingCodeDetection ValgrindBaseSettings::selfModifyingCodeDetection() const
|
|
|
|
|
{
|
|
|
|
|
return m_selfModifyingCodeDetection;
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-12 16:47:32 +02:00
|
|
|
void ValgrindBaseSettings::setNumCallers(int numCallers)
|
|
|
|
|
{
|
|
|
|
|
if (m_numCallers != numCallers) {
|
|
|
|
|
m_numCallers = numCallers;
|
|
|
|
|
emit numCallersChanged(numCallers);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-09 11:43:39 +02:00
|
|
|
void ValgrindBaseSettings::setLeakCheckOnFinish(int leakCheckOnFinish)
|
|
|
|
|
{
|
|
|
|
|
if (m_leakCheckOnFinish != leakCheckOnFinish) {
|
|
|
|
|
m_leakCheckOnFinish = (LeakCheckOnFinish) leakCheckOnFinish;
|
|
|
|
|
emit leakCheckOnFinishChanged(leakCheckOnFinish);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ValgrindBaseSettings::setShowReachable(bool showReachable)
|
|
|
|
|
{
|
|
|
|
|
if (m_showReachable != showReachable) {
|
|
|
|
|
m_showReachable = showReachable;
|
|
|
|
|
emit showReachableChanged(showReachable);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-12 16:47:32 +02:00
|
|
|
void ValgrindBaseSettings::setTrackOrigins(bool trackOrigins)
|
|
|
|
|
{
|
|
|
|
|
if (m_trackOrigins != trackOrigins) {
|
|
|
|
|
m_trackOrigins = trackOrigins;
|
|
|
|
|
emit trackOriginsChanged(trackOrigins);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ValgrindBaseSettings::setFilterExternalIssues(bool filterExternalIssues)
|
|
|
|
|
{
|
|
|
|
|
if (m_filterExternalIssues != filterExternalIssues) {
|
|
|
|
|
m_filterExternalIssues = filterExternalIssues;
|
|
|
|
|
emit filterExternalIssuesChanged(filterExternalIssues);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ValgrindBaseSettings::setVisibleErrorKinds(const QList<int> &visibleErrorKinds)
|
|
|
|
|
{
|
|
|
|
|
if (m_visibleErrorKinds != visibleErrorKinds) {
|
|
|
|
|
m_visibleErrorKinds = visibleErrorKinds;
|
|
|
|
|
emit visibleErrorKindsChanged(visibleErrorKinds);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-07 23:55:59 +02:00
|
|
|
QString ValgrindBaseSettings::kcachegrindExecutable() const
|
|
|
|
|
{
|
|
|
|
|
return m_kcachegrindExecutable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ValgrindBaseSettings::setKCachegrindExecutable(const QString &exec)
|
|
|
|
|
{
|
|
|
|
|
m_kcachegrindExecutable = exec;
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-12 16:47:32 +02:00
|
|
|
void ValgrindBaseSettings::setEnableCacheSim(bool enable)
|
|
|
|
|
{
|
|
|
|
|
if (m_enableCacheSim == enable)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_enableCacheSim = enable;
|
|
|
|
|
emit enableCacheSimChanged(enable);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ValgrindBaseSettings::setEnableBranchSim(bool enable)
|
|
|
|
|
{
|
|
|
|
|
if (m_enableBranchSim == enable)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_enableBranchSim = enable;
|
|
|
|
|
emit enableBranchSimChanged(enable);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ValgrindBaseSettings::setCollectSystime(bool collect)
|
|
|
|
|
{
|
|
|
|
|
if (m_collectSystime == collect)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_collectSystime = collect;
|
|
|
|
|
emit collectSystimeChanged(collect);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ValgrindBaseSettings::setCollectBusEvents(bool collect)
|
|
|
|
|
{
|
|
|
|
|
if (m_collectBusEvents == collect)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_collectBusEvents = collect;
|
|
|
|
|
emit collectBusEventsChanged(collect);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ValgrindBaseSettings::setEnableEventToolTips(bool enable)
|
|
|
|
|
{
|
|
|
|
|
if (m_enableEventToolTips == enable)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_enableEventToolTips = enable;
|
|
|
|
|
emit enableEventToolTipsChanged(enable);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ValgrindBaseSettings::setMinimumInclusiveCostRatio(
|
|
|
|
|
double minimumInclusiveCostRatio)
|
|
|
|
|
{
|
|
|
|
|
if (m_minimumInclusiveCostRatio == minimumInclusiveCostRatio)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_minimumInclusiveCostRatio = qBound(0.0, minimumInclusiveCostRatio, 100.0);
|
|
|
|
|
emit minimumInclusiveCostRatioChanged(minimumInclusiveCostRatio);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ValgrindBaseSettings::setVisualisationMinimumInclusiveCostRatio(
|
|
|
|
|
double minimumInclusiveCostRatio)
|
|
|
|
|
{
|
|
|
|
|
if (m_visualisationMinimumInclusiveCostRatio == minimumInclusiveCostRatio)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_visualisationMinimumInclusiveCostRatio = qBound(0.0, minimumInclusiveCostRatio, 100.0);
|
|
|
|
|
emit visualisationMinimumInclusiveCostRatioChanged(minimumInclusiveCostRatio);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// ValgrindGlobalSettings
|
|
|
|
|
//
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2019-03-20 17:49:26 +01:00
|
|
|
static ValgrindGlobalSettings *theGlobalSettings = nullptr;
|
|
|
|
|
|
2013-08-08 17:37:37 +02:00
|
|
|
ValgrindGlobalSettings::ValgrindGlobalSettings()
|
2018-09-10 15:39:27 +02:00
|
|
|
: ValgrindBaseSettings([this] { return new ValgrindConfigWidget(this, true); })
|
2011-07-12 16:47:32 +02:00
|
|
|
{
|
2019-03-20 17:49:26 +01:00
|
|
|
theGlobalSettings = this;
|
2013-08-08 17:37:37 +02:00
|
|
|
readSettings();
|
2011-07-12 16:47:32 +02:00
|
|
|
}
|
|
|
|
|
|
2019-03-20 17:49:26 +01:00
|
|
|
ValgrindGlobalSettings *ValgrindGlobalSettings::instance()
|
|
|
|
|
{
|
|
|
|
|
return theGlobalSettings;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-22 12:36:39 +01:00
|
|
|
void ValgrindGlobalSettings::fromMap(const QVariantMap &map)
|
2011-07-12 16:47:32 +02:00
|
|
|
{
|
|
|
|
|
ValgrindBaseSettings::fromMap(map);
|
|
|
|
|
|
|
|
|
|
// Memcheck
|
2018-12-01 20:56:21 +02:00
|
|
|
m_suppressionFiles = map.value(suppressionFilesC).toStringList();
|
|
|
|
|
m_lastSuppressionDirectory = map.value(lastSuppressionDirectoryC).toString();
|
|
|
|
|
m_lastSuppressionHistory = map.value(lastSuppressionHistoryC).toStringList();
|
2011-07-12 16:47:32 +02:00
|
|
|
|
|
|
|
|
// Callgrind
|
|
|
|
|
// special code as the default one does not cope with the enum properly
|
2018-12-01 20:56:21 +02:00
|
|
|
if (map.contains(callgrindCostFormatC))
|
|
|
|
|
m_costFormat = static_cast<CostDelegate::CostFormat>(map.value(callgrindCostFormatC).toInt());
|
|
|
|
|
setIfPresent(map, callgrindCycleDetectionC, &m_detectCycles);
|
|
|
|
|
setIfPresent(map, callgrindShortenTemplates, &m_shortenTemplates);
|
2011-07-12 16:47:32 +02:00
|
|
|
}
|
|
|
|
|
|
2013-08-12 17:05:52 +02:00
|
|
|
void ValgrindGlobalSettings::toMap(QVariantMap &map) const
|
2011-07-12 16:47:32 +02:00
|
|
|
{
|
2013-08-12 17:05:52 +02:00
|
|
|
ValgrindBaseSettings::toMap(map);
|
2011-07-12 16:47:32 +02:00
|
|
|
|
|
|
|
|
// Memcheck
|
2018-12-01 20:56:21 +02:00
|
|
|
map.insert(suppressionFilesC, m_suppressionFiles);
|
|
|
|
|
map.insert(lastSuppressionDirectoryC, m_lastSuppressionDirectory);
|
|
|
|
|
map.insert(lastSuppressionHistoryC, m_lastSuppressionHistory);
|
2011-07-12 16:47:32 +02:00
|
|
|
|
|
|
|
|
// Callgrind
|
2018-12-01 20:56:21 +02:00
|
|
|
map.insert(callgrindCostFormatC, m_costFormat);
|
|
|
|
|
map.insert(callgrindCycleDetectionC, m_detectCycles);
|
|
|
|
|
map.insert(callgrindShortenTemplates, m_shortenTemplates);
|
2011-07-12 16:47:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Memcheck
|
|
|
|
|
//
|
|
|
|
|
QStringList ValgrindGlobalSettings::suppressionFiles() const
|
|
|
|
|
{
|
|
|
|
|
return m_suppressionFiles;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ValgrindGlobalSettings::addSuppressionFiles(const QStringList &suppressions)
|
|
|
|
|
{
|
|
|
|
|
foreach (const QString &s, suppressions)
|
|
|
|
|
if (!m_suppressionFiles.contains(s))
|
|
|
|
|
m_suppressionFiles.append(s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ValgrindGlobalSettings::removeSuppressionFiles(const QStringList &suppressions)
|
|
|
|
|
{
|
|
|
|
|
foreach (const QString &s, suppressions)
|
|
|
|
|
m_suppressionFiles.removeAll(s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString ValgrindGlobalSettings::lastSuppressionDialogDirectory() const
|
|
|
|
|
{
|
|
|
|
|
return m_lastSuppressionDirectory;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ValgrindGlobalSettings::setLastSuppressionDialogDirectory(const QString &directory)
|
|
|
|
|
{
|
|
|
|
|
m_lastSuppressionDirectory = directory;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList ValgrindGlobalSettings::lastSuppressionDialogHistory() const
|
|
|
|
|
{
|
|
|
|
|
return m_lastSuppressionHistory;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ValgrindGlobalSettings::setLastSuppressionDialogHistory(const QStringList &history)
|
|
|
|
|
{
|
|
|
|
|
m_lastSuppressionHistory = history;
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-08 17:37:37 +02:00
|
|
|
static const char groupC[] = "Analyzer";
|
|
|
|
|
|
|
|
|
|
void ValgrindGlobalSettings::readSettings()
|
|
|
|
|
{
|
|
|
|
|
QVariantMap defaults;
|
|
|
|
|
|
|
|
|
|
// General
|
2018-12-01 20:56:21 +02:00
|
|
|
defaults.insert(valgrindExeC, "valgrind");
|
|
|
|
|
defaults.insert(selfModifyingCodeDetectionC, DetectSmcStackOnly);
|
2013-08-08 17:37:37 +02:00
|
|
|
|
|
|
|
|
// Memcheck
|
2018-12-01 20:56:21 +02:00
|
|
|
defaults.insert(numCallersC, 25);
|
|
|
|
|
defaults.insert(leakCheckOnFinishC, LeakCheckOnFinishSummaryOnly);
|
|
|
|
|
defaults.insert(showReachableC, false);
|
|
|
|
|
defaults.insert(trackOriginsC, true);
|
|
|
|
|
defaults.insert(filterExternalIssuesC, true);
|
2013-08-08 17:37:37 +02:00
|
|
|
QVariantList defaultErrorKinds;
|
|
|
|
|
for (int i = 0; i < Valgrind::XmlProtocol::MemcheckErrorKindCount; ++i)
|
|
|
|
|
defaultErrorKinds << i;
|
2018-12-01 20:56:21 +02:00
|
|
|
defaults.insert(visibleErrorKindsC, defaultErrorKinds);
|
2013-08-08 17:37:37 +02:00
|
|
|
|
2018-12-01 20:56:21 +02:00
|
|
|
defaults.insert(suppressionFilesC, QStringList());
|
|
|
|
|
defaults.insert(lastSuppressionDirectoryC, QString());
|
|
|
|
|
defaults.insert(lastSuppressionHistoryC, QStringList());
|
2013-08-08 17:37:37 +02:00
|
|
|
|
|
|
|
|
// Callgrind
|
2018-11-07 23:55:59 +02:00
|
|
|
defaults.insert(kcachegrindExeC, "kcachegrind");
|
2018-12-01 20:56:21 +02:00
|
|
|
defaults.insert(callgrindEnableCacheSimC, false);
|
|
|
|
|
defaults.insert(callgrindEnableBranchSimC, false);
|
|
|
|
|
defaults.insert(callgrindCollectSystimeC, false);
|
|
|
|
|
defaults.insert(callgrindCollectBusEventsC, false);
|
|
|
|
|
defaults.insert(callgrindEnableEventToolTipsC, true);
|
|
|
|
|
defaults.insert(callgrindMinimumCostRatioC, 0.01);
|
|
|
|
|
defaults.insert(callgrindVisualisationMinimumCostRatioC, 10.0);
|
|
|
|
|
|
|
|
|
|
defaults.insert(callgrindCostFormatC, CostDelegate::FormatRelative);
|
|
|
|
|
defaults.insert(callgrindCycleDetectionC, true);
|
|
|
|
|
defaults.insert(callgrindShortenTemplates, true);
|
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);
|
2013-08-08 17:37:37 +02:00
|
|
|
QVariantMap map = defaults;
|
|
|
|
|
for (QVariantMap::ConstIterator it = defaults.constBegin(); it != defaults.constEnd(); ++it)
|
|
|
|
|
map.insert(it.key(), settings->value(it.key(), it.value()));
|
|
|
|
|
settings->endGroup();
|
|
|
|
|
|
|
|
|
|
fromMap(map);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ValgrindGlobalSettings::writeSettings() const
|
|
|
|
|
{
|
|
|
|
|
QSettings *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)
|
2013-08-08 17:37:37 +02:00
|
|
|
settings->setValue(it.key(), it.value());
|
|
|
|
|
settings->endGroup();
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-12 16:47:32 +02:00
|
|
|
//
|
|
|
|
|
// Callgrind
|
|
|
|
|
//
|
|
|
|
|
CostDelegate::CostFormat ValgrindGlobalSettings::costFormat() const
|
|
|
|
|
{
|
|
|
|
|
return m_costFormat;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ValgrindGlobalSettings::setCostFormat(CostDelegate::CostFormat format)
|
|
|
|
|
{
|
|
|
|
|
m_costFormat = format;
|
2013-08-08 17:37:37 +02:00
|
|
|
writeSettings();
|
2011-07-12 16:47:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ValgrindGlobalSettings::detectCycles() const
|
|
|
|
|
{
|
|
|
|
|
return m_detectCycles;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-22 23:35:02 +02:00
|
|
|
void ValgrindGlobalSettings::setDetectCycles(bool on)
|
2011-07-12 16:47:32 +02:00
|
|
|
{
|
2012-08-22 23:35:02 +02:00
|
|
|
m_detectCycles = on;
|
2013-08-08 17:37:37 +02:00
|
|
|
writeSettings();
|
2012-08-22 23:35:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ValgrindGlobalSettings::shortenTemplates() const
|
|
|
|
|
{
|
|
|
|
|
return m_shortenTemplates;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ValgrindGlobalSettings::setShortenTemplates(bool on)
|
|
|
|
|
{
|
|
|
|
|
m_shortenTemplates = on;
|
2013-08-08 17:37:37 +02:00
|
|
|
writeSettings();
|
2011-07-12 16:47:32 +02:00
|
|
|
}
|
|
|
|
|
|
2011-03-04 12:15:18 +01:00
|
|
|
|
2011-07-12 16:47:32 +02:00
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// ValgrindProjectSettings
|
|
|
|
|
//
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2018-09-10 15:39:27 +02:00
|
|
|
ValgrindProjectSettings::ValgrindProjectSettings()
|
|
|
|
|
: ValgrindBaseSettings([this] { return new ValgrindConfigWidget(this, false); })
|
2018-04-26 11:04:03 +02:00
|
|
|
{}
|
|
|
|
|
|
2012-02-22 12:36:39 +01:00
|
|
|
void ValgrindProjectSettings::fromMap(const QVariantMap &map)
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
2011-07-12 16:47:32 +02:00
|
|
|
ValgrindBaseSettings::fromMap(map);
|
|
|
|
|
|
|
|
|
|
// Memcheck
|
2018-12-01 20:56:21 +02:00
|
|
|
setIfPresent(map, addedSuppressionFilesC, &m_addedSuppressionFiles);
|
|
|
|
|
setIfPresent(map, removedSuppressionFilesC, &m_disabledGlobalSuppressionFiles);
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
2011-07-12 16:47:32 +02:00
|
|
|
|
2013-08-12 17:05:52 +02:00
|
|
|
void ValgrindProjectSettings::toMap(QVariantMap &map) const
|
2011-07-12 16:47:32 +02:00
|
|
|
{
|
2013-08-12 17:05:52 +02:00
|
|
|
ValgrindBaseSettings::toMap(map);
|
2011-07-12 16:47:32 +02:00
|
|
|
|
|
|
|
|
// Memcheck
|
2018-12-01 20:56:21 +02:00
|
|
|
map.insert(addedSuppressionFilesC, m_addedSuppressionFiles);
|
|
|
|
|
map.insert(removedSuppressionFilesC, m_disabledGlobalSuppressionFiles);
|
2011-07-12 16:47:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Memcheck
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
void ValgrindProjectSettings::addSuppressionFiles(const QStringList &suppressions)
|
|
|
|
|
{
|
2019-03-20 17:49:26 +01:00
|
|
|
const QStringList globalSuppressions = ValgrindGlobalSettings::instance()->suppressionFiles();
|
|
|
|
|
for (const QString &s : suppressions) {
|
2011-07-12 16:47:32 +02:00
|
|
|
if (m_addedSuppressionFiles.contains(s))
|
|
|
|
|
continue;
|
|
|
|
|
m_disabledGlobalSuppressionFiles.removeAll(s);
|
|
|
|
|
if (!globalSuppressions.contains(s))
|
|
|
|
|
m_addedSuppressionFiles.append(s);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ValgrindProjectSettings::removeSuppressionFiles(const QStringList &suppressions)
|
|
|
|
|
{
|
2019-03-20 17:49:26 +01:00
|
|
|
const QStringList globalSuppressions = ValgrindGlobalSettings::instance()->suppressionFiles();
|
|
|
|
|
for (const QString &s : suppressions) {
|
2011-07-12 16:47:32 +02:00
|
|
|
m_addedSuppressionFiles.removeAll(s);
|
|
|
|
|
if (globalSuppressions.contains(s))
|
|
|
|
|
m_disabledGlobalSuppressionFiles.append(s);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList ValgrindProjectSettings::suppressionFiles() const
|
|
|
|
|
{
|
2019-03-20 17:49:26 +01:00
|
|
|
QStringList ret = ValgrindGlobalSettings::instance()->suppressionFiles();
|
|
|
|
|
for (const QString &s : m_disabledGlobalSuppressionFiles)
|
2011-07-12 16:47:32 +02:00
|
|
|
ret.removeAll(s);
|
|
|
|
|
ret.append(m_addedSuppressionFiles);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Valgrind
|