2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-03-04 12:15:19 +01:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2011-03-04 12:15:19 +01:00
|
|
|
** Author: Nicolas Arnaud-Cormos, KDAB (nicolas.arnaud-cormos@kdab.com)
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-03-04 12:15:19 +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
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
2014-10-01 13:21:18 +02:00
|
|
|
** conditions see http://www.qt.io/licensing. For further information
|
|
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2011-03-04 12:15:19 +01:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2011-03-04 12:15:19 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-03-04 12:15:19 +01:00
|
|
|
|
|
|
|
|
#include "memcheckengine.h"
|
|
|
|
|
|
2011-07-12 16:47:32 +02:00
|
|
|
#include "valgrindsettings.h"
|
2011-03-04 12:15:19 +01:00
|
|
|
|
2013-07-30 14:08:01 +02:00
|
|
|
#include <projectexplorer/projectexplorer.h>
|
|
|
|
|
#include <projectexplorer/taskhub.h>
|
|
|
|
|
|
2011-03-04 12:15:19 +01:00
|
|
|
#include <valgrind/xmlprotocol/error.h>
|
|
|
|
|
#include <valgrind/xmlprotocol/status.h>
|
|
|
|
|
|
|
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
2011-04-04 14:39:29 +02:00
|
|
|
using namespace Analyzer;
|
2013-07-30 14:08:01 +02:00
|
|
|
using namespace ProjectExplorer;
|
2011-03-04 12:15:19 +01:00
|
|
|
using namespace Valgrind::XmlProtocol;
|
|
|
|
|
|
2011-05-23 13:50:28 +02:00
|
|
|
namespace Valgrind {
|
2011-05-18 17:05:49 +02:00
|
|
|
namespace Internal {
|
2011-04-04 14:39:29 +02:00
|
|
|
|
2013-07-30 14:08:01 +02:00
|
|
|
MemcheckRunControl::MemcheckRunControl(const AnalyzerStartParameters &sp,
|
2015-02-03 23:56:02 +02:00
|
|
|
RunConfiguration *runConfiguration)
|
2013-07-30 14:08:01 +02:00
|
|
|
: ValgrindRunControl(sp, runConfiguration)
|
2011-03-04 12:15:19 +01:00
|
|
|
{
|
2015-01-30 11:02:24 +01:00
|
|
|
connect(&m_parser, &XmlProtocol::ThreadedParser::error,
|
|
|
|
|
this, &MemcheckRunControl::parserError);
|
|
|
|
|
connect(&m_parser, &XmlProtocol::ThreadedParser::suppressionCount,
|
|
|
|
|
this, &MemcheckRunControl::suppressionCount);
|
|
|
|
|
connect(&m_parser, &XmlProtocol::ThreadedParser::internalError,
|
|
|
|
|
this, &MemcheckRunControl::internalParserError);
|
2011-03-04 12:15:19 +01:00
|
|
|
}
|
|
|
|
|
|
2013-07-30 14:08:01 +02:00
|
|
|
QString MemcheckRunControl::progressTitle() const
|
2011-03-04 12:15:19 +01:00
|
|
|
{
|
|
|
|
|
return tr("Analyzing Memory");
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-30 14:08:01 +02:00
|
|
|
Valgrind::ValgrindRunner *MemcheckRunControl::runner()
|
2011-03-04 12:15:19 +01:00
|
|
|
{
|
|
|
|
|
return &m_runner;
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-30 14:08:01 +02:00
|
|
|
bool MemcheckRunControl::startEngine()
|
2011-03-04 12:15:19 +01:00
|
|
|
{
|
|
|
|
|
m_runner.setParser(&m_parser);
|
|
|
|
|
|
2013-07-30 14:08:01 +02:00
|
|
|
// Clear about-to-be-outdated tasks.
|
2013-08-15 12:14:46 +02:00
|
|
|
TaskHub::clearTasks(Analyzer::Constants::ANALYZERTASK_ID);
|
2013-07-30 14:08:01 +02:00
|
|
|
|
2013-10-17 13:48:04 +02:00
|
|
|
appendMessage(tr("Analyzing memory of %1").arg(executable()) + QLatin1Char('\n'),
|
2011-06-10 16:34:06 +02:00
|
|
|
Utils::NormalMessageFormat);
|
2013-07-30 14:08:01 +02:00
|
|
|
return ValgrindRunControl::startEngine();
|
2011-03-04 12:15:19 +01:00
|
|
|
}
|
|
|
|
|
|
2013-07-30 14:08:01 +02:00
|
|
|
void MemcheckRunControl::stopEngine()
|
2011-03-04 12:15:19 +01:00
|
|
|
{
|
2015-02-06 12:39:07 +02:00
|
|
|
disconnect(&m_parser, &ThreadedParser::internalError,
|
|
|
|
|
this, &MemcheckRunControl::internalParserError);
|
2013-07-30 14:08:01 +02:00
|
|
|
ValgrindRunControl::stopEngine();
|
2011-03-04 12:15:19 +01:00
|
|
|
}
|
|
|
|
|
|
2013-07-30 14:08:01 +02:00
|
|
|
QStringList MemcheckRunControl::toolArguments() const
|
2011-03-04 12:15:19 +01:00
|
|
|
{
|
|
|
|
|
QStringList arguments;
|
|
|
|
|
arguments << QLatin1String("--gen-suppressions=all");
|
|
|
|
|
|
2013-08-08 17:37:37 +02:00
|
|
|
QTC_ASSERT(m_settings, return arguments);
|
2011-03-04 12:15:19 +01:00
|
|
|
|
2013-08-08 17:37:37 +02:00
|
|
|
if (m_settings->trackOrigins())
|
2011-03-04 12:15:19 +01:00
|
|
|
arguments << QLatin1String("--track-origins=yes");
|
|
|
|
|
|
2013-09-09 11:43:39 +02:00
|
|
|
if (m_settings->showReachable())
|
|
|
|
|
arguments << QLatin1String("--show-reachable=yes");
|
|
|
|
|
|
|
|
|
|
QString leakCheckValue;
|
|
|
|
|
switch (m_settings->leakCheckOnFinish()) {
|
|
|
|
|
case ValgrindBaseSettings::LeakCheckOnFinishNo:
|
|
|
|
|
leakCheckValue = QLatin1String("no");
|
|
|
|
|
break;
|
|
|
|
|
case ValgrindBaseSettings::LeakCheckOnFinishYes:
|
|
|
|
|
leakCheckValue = QLatin1String("full");
|
|
|
|
|
break;
|
|
|
|
|
case ValgrindBaseSettings::LeakCheckOnFinishSummaryOnly:
|
|
|
|
|
default:
|
|
|
|
|
leakCheckValue = QLatin1String("summary");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
arguments << QLatin1String("--leak-check=") + leakCheckValue;
|
|
|
|
|
|
2013-08-08 17:37:37 +02:00
|
|
|
foreach (const QString &file, m_settings->suppressionFiles())
|
2012-11-26 15:02:17 +02:00
|
|
|
arguments << QString::fromLatin1("--suppressions=%1").arg(file);
|
2011-03-04 12:15:19 +01:00
|
|
|
|
2013-08-08 17:37:37 +02:00
|
|
|
arguments << QString::fromLatin1("--num-callers=%1").arg(m_settings->numCallers());
|
2011-03-04 12:15:19 +01:00
|
|
|
return arguments;
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-30 14:08:01 +02:00
|
|
|
QStringList MemcheckRunControl::suppressionFiles() const
|
2011-03-04 12:15:19 +01:00
|
|
|
{
|
2013-08-08 17:37:37 +02:00
|
|
|
return m_settings->suppressionFiles();
|
2011-03-04 12:15:19 +01:00
|
|
|
}
|
|
|
|
|
|
2011-05-18 17:05:49 +02:00
|
|
|
} // namespace Internal
|
2011-05-23 13:50:28 +02:00
|
|
|
} // namespace Valgrind
|