[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdev-valgrind] /: Fix broken current tool selection and tools parameters processing
From:       Anton Anikin <null () kde ! org>
Date:       2017-01-31 16:32:45
Message-ID: E1cYbML-0007M8-F1 () code ! kde ! org
[Download RAW message or body]

Git commit 6bef72b2ea92c2271ba92422e99acd2c3b6c2d36 by Anton Anikin.
Committed on 31/01/2017 at 16:29.
Pushed by antonanikin into branch 'master'.

Fix broken current tool selection and tools parameters processing

Previous commits have led to the fact that for any current tool choice Memcheck \
always runs. The commit also fixes wrong tool parameters processing (caused by \
previous renames).

A  +27   -0    config/tools.h     [License: GPL (v2+)]
M  +18   -13   interfaces/ijob.cpp
M  +5    -5    tools/cachegrind/job.cpp
M  +4    -4    tools/callgrind/job.cpp
M  +3    -1    tools/generic/configpage.cpp
M  +10   -11   tools/massif/job.cpp

https://commits.kde.org/kdev-valgrind/6bef72b2ea92c2271ba92422e99acd2c3b6c2d36

diff --git a/config/tools.h b/config/tools.h
new file mode 100644
index 0000000..4e77fc7
--- /dev/null
+++ b/config/tools.h
@@ -0,0 +1,27 @@
+/* This file is part of KDevelop
+   Copyright 2017 Anton Anikin <anton.anikin@htower.ru>
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.
+*/
+
+#pragma once
+
+#include <QStringList>
+
+namespace valgrind
+{
+    static const QStringList valgrindTools{ "memcheck", "massif", "cachegrind", \
"callgrind" }; +}
diff --git a/interfaces/ijob.cpp b/interfaces/ijob.cpp
index 8a3cf25..b2e3b58 100644
--- a/interfaces/ijob.cpp
+++ b/interfaces/ijob.cpp
@@ -32,6 +32,8 @@
 #include "debug.h"
 #include "plugin.h"
 
+#include "config/tools.h"
+
 #include "globalsettings.h"
 
 #include "cachegrind/job.h"
@@ -56,24 +58,24 @@
 namespace valgrind
 {
 
-// The factory for jobs
 IJob* IJob::createToolJob(KDevelop::ILaunchConfiguration* cfg, Plugin* plugin, \
QObject* parent)  {
-    const QString& name = cfg->config().readEntry(QStringLiteral("Current Tool"), \
QStringLiteral("memcheck")); +    const int toolIndex = \
cfg->config().readEntry(QStringLiteral("Valgrind Current Tool"), 0); +    const \
QString& toolName = valgrindTools.at(toolIndex);  
-    if (name == QStringLiteral("memcheck"))
+    if (toolName == QStringLiteral("memcheck"))
         return new MemcheckJob(cfg, plugin, parent);
 
-    else if (name == QStringLiteral("massif"))
+    else if (toolName == QStringLiteral("massif"))
         return new MassifJob(cfg, plugin, parent);
 
-    else if (name == QStringLiteral("cachegrind"))
+    else if (toolName == QStringLiteral("cachegrind"))
         return new CachegrindJob(cfg, plugin, parent);
 
-    else if (name == QStringLiteral("callgrind"))
+    else if (toolName == QStringLiteral("callgrind"))
         return new CallgrindJob(cfg, plugin, parent);
 
-    qCDebug(KDEV_VALGRIND) << "can't create this job, " << name << "unknow job";
+    qCDebug(KDEV_VALGRIND) << "can't create this job, " << toolName << " unknow \
job";  
     return nullptr;
 }
@@ -201,16 +203,19 @@ void IJob::processModeArgs(
 QStringList IJob::buildCommandLine() const
 {
     static const t_valgrind_cfg_argarray genericArgs = {
-        {QStringLiteral("Current Tool"), QStringLiteral("--tool="), \
                QStringLiteral("str")},
-        {QStringLiteral("Stackframe Depth"), QStringLiteral("--num-callers="), \
                QStringLiteral("int")},
-        {QStringLiteral("Maximum Stackframe Size"), \
                QStringLiteral("--max-stackframe="), QStringLiteral("int")},
-        {QStringLiteral("Limit Errors"), QStringLiteral("--error-limit="), \
QStringLiteral("bool")} +        {QStringLiteral("Valgrind Stackframe Depth"), \
QStringLiteral("--num-callers="), QStringLiteral("int")}, +        \
{QStringLiteral("Valgrind Maximum Stackframe Size"), \
QStringLiteral("--max-stackframe="), QStringLiteral("int")}, +        \
{QStringLiteral("Valgrind Limit Errors"), QStringLiteral("--error-limit="), \
QStringLiteral("bool")}  };
     static const int genericArgsCount = sizeof(genericArgs) / sizeof(*genericArgs);
 
+    QStringList result;
     KConfigGroup config = m_launchcfg->config();
-    QStringList result = KShell::splitArgs(config.readEntry(QStringLiteral("Valgrind \
                Arguments"),
-                                                            QStringLiteral("")));
+
+    const int toolIndex = config.readEntry(QStringLiteral("Valgrind Current Tool"), \
0); +    result += QStringLiteral("--tool=%1").arg(valgrindTools.at(toolIndex));
+
+    result += KShell::splitArgs(config.readEntry(QStringLiteral("Valgrind Extra \
Parameters"), QStringLiteral("")));  
     processModeArgs(result, genericArgs, genericArgsCount, config);
     addToolArgs(result, config);
diff --git a/tools/cachegrind/job.cpp b/tools/cachegrind/job.cpp
index 84110f9..21f1e36 100644
--- a/tools/cachegrind/job.cpp
+++ b/tools/cachegrind/job.cpp
@@ -71,13 +71,13 @@ void CachegrindJob::processEnded()
         parser.parse(cgOutput);
     }
 
-    if (config.readEntry(QStringLiteral("Launch KCachegrind"), false)) {
+    if (config.readEntry(QStringLiteral("Cachegrind Launch KCachegrind"), false)) {
         args.clear();
         args += m_outputFile;
 
         QString kcg = \
KDevelop::Path(GlobalSettings::kcachegrindExecutablePath()).toLocalFile();  
-        //Proxy used to remove file at the end of KCachegrind
+        // Proxy used to remove file at the end of KCachegrind
         new QFileProxyRemove(kcg, args, m_outputFile, \
dynamic_cast<QObject*>(m_plugin));  }
     else
@@ -87,9 +87,9 @@ void CachegrindJob::processEnded()
 void CachegrindJob::addToolArgs(QStringList& args, KConfigGroup& cfg) const
 {
     static const t_valgrind_cfg_argarray cgArgs = {
-        {QStringLiteral("Cachegrind Arguments"), QStringLiteral(""), \
                QStringLiteral("str")},
-        {QStringLiteral("Cachegrind Cache simulation"), \
                QStringLiteral("--cache-sim="), QStringLiteral("bool")},
-        {QStringLiteral("Cachegrind Branch simulation"), \
QStringLiteral("--branch-sim="), QStringLiteral("bool")} +        \
{QStringLiteral("Cachegrind Extra Parameters"), QStringLiteral(""), \
QStringLiteral("str")}, +        {QStringLiteral("Cachegrind Cache Simulation"), \
QStringLiteral("--cache-sim="), QStringLiteral("bool")}, +        \
{QStringLiteral("Cachegrind Branch Simulation"), QStringLiteral("--branch-sim="), \
QStringLiteral("bool")}  };
     static const int count = sizeof(cgArgs) / sizeof(*cgArgs);
 
diff --git a/tools/callgrind/job.cpp b/tools/callgrind/job.cpp
index a546289..a836005 100644
--- a/tools/callgrind/job.cpp
+++ b/tools/callgrind/job.cpp
@@ -73,7 +73,7 @@ void CallgrindJob::processEnded()
         parser.parse(caOutput);
     }
 
-    if (config.readEntry(QStringLiteral("Launch KCachegrind"), false)) {
+    if (config.readEntry(QStringLiteral("Callgrind Launch KCachegrind"), false)) {
         args.clear();
         args += m_outputFile;
 
@@ -89,9 +89,9 @@ void CallgrindJob::processEnded()
 void CallgrindJob::addToolArgs(QStringList& args, KConfigGroup& cfg) const
 {
     static const t_valgrind_cfg_argarray cgArgs = {
-        {QStringLiteral("Callgrind Arguments"), QStringLiteral(""), \
                QStringLiteral("str")},
-        {QStringLiteral("Callgrind Cache simulation"), \
                QStringLiteral("--cache-sim="), QStringLiteral("bool")},
-        {QStringLiteral("Callgrind Branch simulation"), \
QStringLiteral("--branch-sim="), QStringLiteral("bool")} +        \
{QStringLiteral("Callgrind Extra Parameters"), QStringLiteral(""), \
QStringLiteral("str")}, +        {QStringLiteral("Callgrind Cache Simulation"), \
QStringLiteral("--cache-sim="), QStringLiteral("bool")}, +        \
{QStringLiteral("Callgrind Branch Simulation"), QStringLiteral("--branch-sim="), \
QStringLiteral("bool")}  };
     static const int count = sizeof(cgArgs) / sizeof(*cgArgs);
 
diff --git a/tools/generic/configpage.cpp b/tools/generic/configpage.cpp
index 346547a..4519b1c 100644
--- a/tools/generic/configpage.cpp
+++ b/tools/generic/configpage.cpp
@@ -21,6 +21,8 @@
 #include "configpage.h"
 #include "ui_configpage.h"
 
+#include "config/tools.h"
+
 #include <kconfiggroup.h>
 
 namespace valgrind
@@ -32,7 +34,7 @@ GenericConfigPage::GenericConfigPage(QWidget* parent)
     ui = new Ui::GenericConfig();
     ui->setupUi(this);
 
-    ui->currentTool->addItems({ "memcheck", "massif", "cachegrind", "callgrind"});
+    ui->currentTool->addItems(valgrindTools);
 
     connect(ui->extraParameters, &QLineEdit::textEdited, this, \
                &GenericConfigPage::changed);
     connect(ui->limitErrors, &QCheckBox::toggled, this, \
                &GenericConfigPage::changed);
diff --git a/tools/massif/job.cpp b/tools/massif/job.cpp
index 93efb1a..8c9d326 100644
--- a/tools/massif/job.cpp
+++ b/tools/massif/job.cpp
@@ -71,8 +71,7 @@ void MassifJob::processEnded()
         parser.parse(m_outputFile);
     }
 
-
-    if (config.readEntry("launchVisualizer", false)) {
+    if (config.readEntry("Massif Launch Visualizer", false)) {
         QStringList args;
         args += m_outputFile;
         QString mv = \
KDevelop::Path(GlobalSettings::massifVisualizerExecutablePath()).toLocalFile(); @@ \
-84,19 +83,19 @@ void MassifJob::processEnded()  void \
MassifJob::addToolArgs(QStringList& args, KConfigGroup& cfg) const  {
     static const t_valgrind_cfg_argarray massifArgs = {
-        {QStringLiteral("Massif Arguments"), QStringLiteral(""), \
                QStringLiteral("str")},
-        {QStringLiteral("depth"), QStringLiteral("--depth="), \
                QStringLiteral("int")},
-        {QStringLiteral("threshold"), QStringLiteral("--threshold="), \
                QStringLiteral("float")},
-        {QStringLiteral("peakInaccuracy"), QStringLiteral("--peak-inaccuracy="), \
                QStringLiteral("float")},
-        {QStringLiteral("maxSnapshots"), QStringLiteral("--max-snapshots="), \
                QStringLiteral("int")},
-        {QStringLiteral("snapshotFreq"), QStringLiteral("--detailed-freq="), \
                QStringLiteral("int")},
-        {QStringLiteral("profileHeap"), QStringLiteral("--heap="), \
                QStringLiteral("bool")},
-        {QStringLiteral("profileStack"), QStringLiteral("--stacks="), \
QStringLiteral("bool")} +        {QStringLiteral("Massif Extra Parameters"), \
QStringLiteral(""), QStringLiteral("str")}, +        {QStringLiteral("Massif Snapshot \
Tree Depth"), QStringLiteral("--depth="), QStringLiteral("int")}, +        \
{QStringLiteral("Massif Threshold"), QStringLiteral("--threshold="), \
QStringLiteral("float")}, +        {QStringLiteral("Massif Peak Inaccuracy"), \
QStringLiteral("--peak-inaccuracy="), QStringLiteral("float")}, +        \
{QStringLiteral("Massif Maximum Snapshots"), QStringLiteral("--max-snapshots="), \
QStringLiteral("int")}, +        {QStringLiteral("Massif Detailed Snapshots \
Frequency"), QStringLiteral("--detailed-freq="), QStringLiteral("int")}, +        \
{QStringLiteral("Massif Profile Heap"), QStringLiteral("--heap="), \
QStringLiteral("bool")}, +        {QStringLiteral("Massif Profile Stack"), \
QStringLiteral("--stacks="), QStringLiteral("bool")}  };
     static const int count = sizeof(massifArgs) / sizeof(*massifArgs);
 
 
-    int tu = cfg.readEntry(QStringLiteral("timeUnit"), 0);
+    int tu = cfg.readEntry(QStringLiteral("Massif Time Unit"), 0);
 
     if (tu == 0)
         args += QStringLiteral("--time-unit=i");


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic