forked from qt-creator/qt-creator
Valgrind: Clean up tools interface a bit
Mainly move tool specific code from plugin.cpp to *tool.cpp. Clean up includes etc. Change-Id: Ic968ead9d93099c59abe9f99a9db529305160f95 Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
@@ -36,31 +36,17 @@
|
|||||||
namespace Valgrind {
|
namespace Valgrind {
|
||||||
namespace Callgrind {
|
namespace Callgrind {
|
||||||
|
|
||||||
//BEGIN CallModel::Private
|
|
||||||
|
|
||||||
class CallModel::Private
|
class CallModel::Private
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Private();
|
const ParseData *m_data = 0;
|
||||||
|
|
||||||
const ParseData *m_data;
|
|
||||||
QVector<const FunctionCall *> m_calls;
|
QVector<const FunctionCall *> m_calls;
|
||||||
int m_event;
|
int m_event = 0;
|
||||||
const Function *m_function;
|
const Function *m_function = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
CallModel::Private::Private()
|
CallModel::CallModel()
|
||||||
: m_data(0)
|
: d(new Private)
|
||||||
, m_event(0)
|
|
||||||
, m_function(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//END CallModel::Private
|
|
||||||
|
|
||||||
//BEGIN CallModel
|
|
||||||
CallModel::CallModel(QObject *parent)
|
|
||||||
: QAbstractItemModel(parent), d(new Private)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class CallModel : public QAbstractItemModel
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit CallModel(QObject *parent);
|
CallModel();
|
||||||
virtual ~CallModel();
|
virtual ~CallModel();
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|||||||
@@ -41,27 +41,16 @@
|
|||||||
namespace Valgrind {
|
namespace Valgrind {
|
||||||
namespace Callgrind {
|
namespace Callgrind {
|
||||||
|
|
||||||
//BEGIN DataModel::Private
|
|
||||||
|
|
||||||
class DataModel::Private
|
class DataModel::Private
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Private()
|
|
||||||
: m_data(0)
|
|
||||||
, m_event(0)
|
|
||||||
, m_verboseToolTips(true)
|
|
||||||
, m_cycleDetection(false)
|
|
||||||
, m_shortenTemplates(false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void updateFunctions();
|
void updateFunctions();
|
||||||
|
|
||||||
const ParseData *m_data;
|
const ParseData *m_data = 0;
|
||||||
int m_event;
|
int m_event = 0;
|
||||||
bool m_verboseToolTips;
|
bool m_verboseToolTips = true;
|
||||||
bool m_cycleDetection;
|
bool m_cycleDetection = false;
|
||||||
bool m_shortenTemplates;
|
bool m_shortenTemplates = false;
|
||||||
QVector<const Function *> m_functions;
|
QVector<const Function *> m_functions;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -77,10 +66,8 @@ void DataModel::Private::updateFunctions()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//BEGIN DataModel
|
DataModel::DataModel()
|
||||||
|
: d(new Private)
|
||||||
DataModel::DataModel(QObject *parent)
|
|
||||||
: QAbstractItemModel(parent), d(new Private)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class DataModel : public QAbstractItemModel
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DataModel(QObject *parent);
|
DataModel();
|
||||||
virtual ~DataModel();
|
virtual ~DataModel();
|
||||||
|
|
||||||
virtual void setParseData(const ParseData *data);
|
virtual void setParseData(const ParseData *data);
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -28,8 +28,6 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
namespace ProjectExplorer { class RunConfiguration; }
|
|
||||||
|
|
||||||
namespace Valgrind {
|
namespace Valgrind {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -41,27 +39,10 @@ const char CallgrindCalleesDockId[] = "Callgrind.Callees.Dock";
|
|||||||
const char CallgrindFlatDockId[] = "Callgrind.Flat.Dock";
|
const char CallgrindFlatDockId[] = "Callgrind.Flat.Dock";
|
||||||
const char CallgrindVisualizationDockId[] = "Callgrind.Visualization.Dock";
|
const char CallgrindVisualizationDockId[] = "Callgrind.Visualization.Dock";
|
||||||
|
|
||||||
class ValgrindRunControl;
|
|
||||||
const char CALLGRIND_RUN_MODE[] = "CallgrindTool.CallgrindRunMode";
|
const char CALLGRIND_RUN_MODE[] = "CallgrindTool.CallgrindRunMode";
|
||||||
|
|
||||||
class CallgrindToolPrivate;
|
void initCallgrindTool(QObject *parent);
|
||||||
|
void destroyCallgrindTool();
|
||||||
class CallgrindTool : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
CallgrindTool(QObject *parent);
|
|
||||||
~CallgrindTool();
|
|
||||||
|
|
||||||
ValgrindRunControl *createRunControl(ProjectExplorer::RunConfiguration *runConfiguration);
|
|
||||||
QWidget *createWidgets();
|
|
||||||
|
|
||||||
void handleShowCostsOfFunction();
|
|
||||||
|
|
||||||
private:
|
|
||||||
CallgrindToolPrivate *d;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Valgrind
|
} // namespace Valgrind
|
||||||
|
|||||||
@@ -30,9 +30,11 @@
|
|||||||
#include "valgrindsettings.h"
|
#include "valgrindsettings.h"
|
||||||
#include "valgrindplugin.h"
|
#include "valgrindplugin.h"
|
||||||
|
|
||||||
#include <debugger/analyzer/analyzermanager.h>
|
|
||||||
#include <debugger/analyzer/analyzerutils.h>
|
|
||||||
#include <debugger/analyzer/analyzerconstants.h>
|
#include <debugger/analyzer/analyzerconstants.h>
|
||||||
|
#include <debugger/analyzer/analyzermanager.h>
|
||||||
|
#include <debugger/analyzer/analyzerstartparameters.h>
|
||||||
|
#include <debugger/analyzer/analyzerutils.h>
|
||||||
|
#include <debugger/analyzer/startremotedialog.h>
|
||||||
|
|
||||||
#include <valgrind/valgrindsettings.h>
|
#include <valgrind/valgrindsettings.h>
|
||||||
#include <valgrind/xmlprotocol/errorlistmodel.h>
|
#include <valgrind/xmlprotocol/errorlistmodel.h>
|
||||||
@@ -62,26 +64,26 @@
|
|||||||
#include <coreplugin/id.h>
|
#include <coreplugin/id.h>
|
||||||
|
|
||||||
#include <utils/fancymainwindow.h>
|
#include <utils/fancymainwindow.h>
|
||||||
#include <utils/styledbar.h>
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
#include <utils/styledbar.h>
|
||||||
|
#include <utils/stylehelper.h>
|
||||||
|
|
||||||
#include <QString>
|
#include <QAction>
|
||||||
#include <QLatin1String>
|
#include <QCheckBox>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QDockWidget>
|
||||||
|
#include <QFile>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QFile>
|
|
||||||
#include <QDir>
|
|
||||||
|
|
||||||
#include <QDockWidget>
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QComboBox>
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QSpinBox>
|
#include <QLatin1String>
|
||||||
#include <QAction>
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
#include <QSortFilterProxyModel>
|
||||||
|
#include <QSpinBox>
|
||||||
|
#include <QString>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QCheckBox>
|
|
||||||
#include <utils/stylehelper.h>
|
|
||||||
|
|
||||||
using namespace Analyzer;
|
using namespace Analyzer;
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
@@ -90,7 +92,23 @@ using namespace Valgrind::XmlProtocol;
|
|||||||
namespace Valgrind {
|
namespace Valgrind {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
// ---------------------------- MemcheckErrorFilterProxyModel
|
class FrameFinder;
|
||||||
|
|
||||||
|
class MemcheckErrorFilterProxyModel : public QSortFilterProxyModel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MemcheckErrorFilterProxyModel(QObject *parent = 0);
|
||||||
|
|
||||||
|
public:
|
||||||
|
void setAcceptedKinds(const QList<int> &acceptedKinds);
|
||||||
|
void setFilterExternalIssues(bool filter);
|
||||||
|
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QList<int> m_acceptedKinds;
|
||||||
|
bool m_filterExternalIssues;
|
||||||
|
};
|
||||||
|
|
||||||
MemcheckErrorFilterProxyModel::MemcheckErrorFilterProxyModel(QObject *parent)
|
MemcheckErrorFilterProxyModel::MemcheckErrorFilterProxyModel(QObject *parent)
|
||||||
: QSortFilterProxyModel(parent),
|
: QSortFilterProxyModel(parent),
|
||||||
m_filterExternalIssues(false)
|
m_filterExternalIssues(false)
|
||||||
@@ -178,6 +196,56 @@ static void initKindFilterAction(QAction *action, const QVariantList &kinds)
|
|||||||
action->setData(kinds);
|
action->setData(kinds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class MemcheckTool : public QObject
|
||||||
|
{
|
||||||
|
Q_DECLARE_TR_FUNCTIONS(Valgrind::Internal::MemcheckTool)
|
||||||
|
|
||||||
|
public:
|
||||||
|
MemcheckTool(QObject *parent);
|
||||||
|
|
||||||
|
QWidget *createWidgets();
|
||||||
|
|
||||||
|
MemcheckRunControl *createRunControl(ProjectExplorer::RunConfiguration *runConfiguration,
|
||||||
|
Core::Id runMode);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void settingsDestroyed(QObject *settings);
|
||||||
|
void maybeActiveRunConfigurationChanged();
|
||||||
|
|
||||||
|
void engineStarting(const MemcheckRunControl *engine);
|
||||||
|
void engineFinished();
|
||||||
|
void loadingExternalXmlLogFileFinished();
|
||||||
|
|
||||||
|
void parserError(const Valgrind::XmlProtocol::Error &error);
|
||||||
|
void internalParserError(const QString &errorString);
|
||||||
|
void updateErrorFilter();
|
||||||
|
|
||||||
|
void loadExternalXmlLogFile();
|
||||||
|
|
||||||
|
void setBusyCursor(bool busy);
|
||||||
|
|
||||||
|
void clearErrorView();
|
||||||
|
void updateFromSettings();
|
||||||
|
int updateUiAfterFinishedHelper();
|
||||||
|
|
||||||
|
private:
|
||||||
|
ValgrindBaseSettings *m_settings;
|
||||||
|
QMenu *m_filterMenu;
|
||||||
|
|
||||||
|
FrameFinder *m_frameFinder;
|
||||||
|
Valgrind::XmlProtocol::ErrorListModel *m_errorModel;
|
||||||
|
MemcheckErrorFilterProxyModel *m_errorProxyModel;
|
||||||
|
MemcheckErrorView *m_errorView;
|
||||||
|
|
||||||
|
QList<QAction *> m_errorFilterActions;
|
||||||
|
QAction *m_filterProjectAction;
|
||||||
|
QList<QAction *> m_suppressionActions;
|
||||||
|
QAction *m_suppressionSeparator;
|
||||||
|
QAction *m_loadExternalLogFile;
|
||||||
|
QAction *m_goBack;
|
||||||
|
QAction *m_goNext;
|
||||||
|
};
|
||||||
|
|
||||||
MemcheckTool::MemcheckTool(QObject *parent)
|
MemcheckTool::MemcheckTool(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
@@ -216,6 +284,55 @@ MemcheckTool::MemcheckTool(QObject *parent)
|
|||||||
a = new QAction(tr("Invalid Calls to \"free()\""), this);
|
a = new QAction(tr("Invalid Calls to \"free()\""), this);
|
||||||
initKindFilterAction(a, { InvalidFree, MismatchedFree });
|
initKindFilterAction(a, { InvalidFree, MismatchedFree });
|
||||||
m_errorFilterActions.append(a);
|
m_errorFilterActions.append(a);
|
||||||
|
|
||||||
|
|
||||||
|
using namespace std::placeholders;
|
||||||
|
|
||||||
|
AnalyzerManager::registerToolbar(MemcheckPerspectiveId, createWidgets());
|
||||||
|
|
||||||
|
ActionDescription desc;
|
||||||
|
desc.setToolTip(tr("Valgrind Analyze Memory uses the "
|
||||||
|
"Memcheck tool to find memory leaks."));
|
||||||
|
|
||||||
|
if (!Utils::HostOsInfo::isWindowsHost()) {
|
||||||
|
desc.setText(tr("Valgrind Memory Analyzer"));
|
||||||
|
desc.setPerspectiveId(MemcheckPerspectiveId);
|
||||||
|
desc.setRunControlCreator(std::bind(&MemcheckTool::createRunControl, this, _1, _2));
|
||||||
|
desc.setToolMode(DebugMode);
|
||||||
|
desc.setRunMode(MEMCHECK_RUN_MODE);
|
||||||
|
desc.setMenuGroup(Analyzer::Constants::G_ANALYZER_TOOLS);
|
||||||
|
AnalyzerManager::registerAction("Memcheck.Local", desc);
|
||||||
|
|
||||||
|
desc.setText(tr("Valgrind Memory Analyzer with GDB"));
|
||||||
|
desc.setToolTip(tr("Valgrind Analyze Memory with GDB uses the "
|
||||||
|
"Memcheck tool to find memory leaks.\nWhen a problem is detected, "
|
||||||
|
"the application is interrupted and can be debugged."));
|
||||||
|
desc.setPerspectiveId(MemcheckPerspectiveId);
|
||||||
|
desc.setRunControlCreator(std::bind(&MemcheckTool::createRunControl, this, _1, _2));
|
||||||
|
desc.setToolMode(DebugMode);
|
||||||
|
desc.setRunMode(MEMCHECK_WITH_GDB_RUN_MODE);
|
||||||
|
desc.setMenuGroup(Analyzer::Constants::G_ANALYZER_TOOLS);
|
||||||
|
AnalyzerManager::registerAction("MemcheckWithGdb.Local", desc);
|
||||||
|
}
|
||||||
|
|
||||||
|
desc.setText(tr("Valgrind Memory Analyzer (External Remote Application)"));
|
||||||
|
desc.setPerspectiveId(MemcheckPerspectiveId);
|
||||||
|
desc.setCustomToolStarter([this](ProjectExplorer::RunConfiguration *runConfig) {
|
||||||
|
StartRemoteDialog dlg;
|
||||||
|
if (dlg.exec() != QDialog::Accepted)
|
||||||
|
return;
|
||||||
|
ValgrindRunControl *rc = createRunControl(runConfig, MEMCHECK_RUN_MODE);
|
||||||
|
QTC_ASSERT(rc, return);
|
||||||
|
const auto runnable = dlg.runnable();
|
||||||
|
rc->setRunnable(runnable);
|
||||||
|
AnalyzerConnection connection;
|
||||||
|
connection.connParams = dlg.sshParams();
|
||||||
|
rc->setConnection(connection);
|
||||||
|
rc->setDisplayName(runnable.executable);
|
||||||
|
ProjectExplorerPlugin::startRunControl(rc, MEMCHECK_RUN_MODE);
|
||||||
|
});
|
||||||
|
desc.setMenuGroup(Analyzer::Constants::G_ANALYZER_REMOTE_TOOLS);
|
||||||
|
AnalyzerManager::registerAction("Memcheck.Remote", desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemcheckTool::settingsDestroyed(QObject *settings)
|
void MemcheckTool::settingsDestroyed(QObject *settings)
|
||||||
@@ -576,5 +693,18 @@ void MemcheckTool::setBusyCursor(bool busy)
|
|||||||
m_errorView->setCursor(cursor);
|
m_errorView->setCursor(cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static MemcheckTool *theMemcheckTool;
|
||||||
|
|
||||||
|
void initMemcheckTool(QObject *parent)
|
||||||
|
{
|
||||||
|
theMemcheckTool = new MemcheckTool(parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
void destroyMemcheckTool()
|
||||||
|
{
|
||||||
|
delete theMemcheckTool;
|
||||||
|
theMemcheckTool = 0;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Valgrind
|
} // namespace Valgrind
|
||||||
|
|||||||
@@ -27,24 +27,7 @@
|
|||||||
#ifndef MEMCHECKTOOL_H
|
#ifndef MEMCHECKTOOL_H
|
||||||
#define MEMCHECKTOOL_H
|
#define MEMCHECKTOOL_H
|
||||||
|
|
||||||
#include <coreplugin/id.h>
|
#include <QObject>
|
||||||
|
|
||||||
#include <QSortFilterProxyModel>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
class QModelIndex;
|
|
||||||
class QAction;
|
|
||||||
class QMenu;
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
namespace Valgrind {
|
|
||||||
namespace XmlProtocol {
|
|
||||||
class ErrorListModel;
|
|
||||||
class Error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace ProjectExplorer { class RunConfiguration; }
|
|
||||||
|
|
||||||
namespace Valgrind {
|
namespace Valgrind {
|
||||||
|
|
||||||
@@ -56,80 +39,8 @@ const char MemcheckErrorDockId[] = "Memcheck.Dock.Error";
|
|||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class FrameFinder;
|
void initMemcheckTool(QObject *parent);
|
||||||
class MemcheckErrorView;
|
void destroyMemcheckTool();
|
||||||
class MemcheckRunControl;
|
|
||||||
class ValgrindBaseSettings;
|
|
||||||
|
|
||||||
|
|
||||||
class MemcheckErrorFilterProxyModel : public QSortFilterProxyModel
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
MemcheckErrorFilterProxyModel(QObject *parent = 0);
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void setAcceptedKinds(const QList<int> &acceptedKinds);
|
|
||||||
void setFilterExternalIssues(bool filter);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
QList<int> m_acceptedKinds;
|
|
||||||
bool m_filterExternalIssues;
|
|
||||||
};
|
|
||||||
|
|
||||||
class MemcheckTool : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
MemcheckTool(QObject *parent);
|
|
||||||
|
|
||||||
QWidget *createWidgets();
|
|
||||||
|
|
||||||
MemcheckRunControl *createRunControl(ProjectExplorer::RunConfiguration *runConfiguration,
|
|
||||||
Core::Id runMode);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void settingsDestroyed(QObject *settings);
|
|
||||||
void maybeActiveRunConfigurationChanged();
|
|
||||||
|
|
||||||
void engineStarting(const MemcheckRunControl *engine);
|
|
||||||
void engineFinished();
|
|
||||||
void loadingExternalXmlLogFileFinished();
|
|
||||||
|
|
||||||
void parserError(const Valgrind::XmlProtocol::Error &error);
|
|
||||||
void internalParserError(const QString &errorString);
|
|
||||||
void updateErrorFilter();
|
|
||||||
|
|
||||||
void loadExternalXmlLogFile();
|
|
||||||
|
|
||||||
void setBusyCursor(bool busy);
|
|
||||||
|
|
||||||
void clearErrorView();
|
|
||||||
void updateFromSettings();
|
|
||||||
int updateUiAfterFinishedHelper();
|
|
||||||
|
|
||||||
private:
|
|
||||||
ValgrindBaseSettings *m_settings;
|
|
||||||
QMenu *m_filterMenu;
|
|
||||||
|
|
||||||
FrameFinder *m_frameFinder;
|
|
||||||
Valgrind::XmlProtocol::ErrorListModel *m_errorModel;
|
|
||||||
MemcheckErrorFilterProxyModel *m_errorProxyModel;
|
|
||||||
MemcheckErrorView *m_errorView;
|
|
||||||
|
|
||||||
QList<QAction *> m_errorFilterActions;
|
|
||||||
QAction *m_filterProjectAction;
|
|
||||||
QList<QAction *> m_suppressionActions;
|
|
||||||
QAction *m_suppressionSeparator;
|
|
||||||
QAction *m_loadExternalLogFile;
|
|
||||||
QAction *m_goBack;
|
|
||||||
QAction *m_goNext;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Valgrind
|
} // namespace Valgrind
|
||||||
|
|||||||
@@ -28,37 +28,20 @@
|
|||||||
|
|
||||||
#include "callgrindtool.h"
|
#include "callgrindtool.h"
|
||||||
#include "memchecktool.h"
|
#include "memchecktool.h"
|
||||||
#include "memcheckengine.h"
|
|
||||||
#include "valgrindruncontrolfactory.h"
|
#include "valgrindruncontrolfactory.h"
|
||||||
#include "valgrindsettings.h"
|
#include "valgrindsettings.h"
|
||||||
#include "valgrindconfigwidget.h"
|
#include "valgrindconfigwidget.h"
|
||||||
|
|
||||||
#include <debugger/analyzer/analyzericons.h>
|
|
||||||
#include <debugger/analyzer/analyzermanager.h>
|
|
||||||
#include <debugger/analyzer/analyzerruncontrol.h>
|
|
||||||
#include <debugger/analyzer/analyzerstartparameters.h>
|
|
||||||
#include <debugger/analyzer/startremotedialog.h>
|
|
||||||
|
|
||||||
#include <coreplugin/dialogs/ioptionspage.h>
|
#include <coreplugin/dialogs/ioptionspage.h>
|
||||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
|
||||||
#include <coreplugin/actionmanager/command.h>
|
|
||||||
#include <coreplugin/coreconstants.h>
|
|
||||||
#include <coreplugin/icontext.h>
|
#include <coreplugin/icontext.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
#include <cppeditor/cppeditorconstants.h>
|
|
||||||
|
|
||||||
#include <projectexplorer/projectexplorer.h>
|
#include <projectexplorer/projectexplorer.h>
|
||||||
|
|
||||||
#include <utils/hostosinfo.h>
|
|
||||||
|
|
||||||
#include <QtPlugin>
|
#include <QtPlugin>
|
||||||
#include <QAction>
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
|
||||||
using namespace Analyzer;
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
|
|
||||||
@@ -108,132 +91,31 @@ ValgrindPlugin::~ValgrindPlugin()
|
|||||||
|
|
||||||
bool ValgrindPlugin::initialize(const QStringList &, QString *)
|
bool ValgrindPlugin::initialize(const QStringList &, QString *)
|
||||||
{
|
{
|
||||||
theGlobalSettings = new ValgrindGlobalSettings();
|
theGlobalSettings = new ValgrindGlobalSettings;
|
||||||
theGlobalSettings->readSettings();
|
theGlobalSettings->readSettings();
|
||||||
|
|
||||||
addAutoReleasedObject(new ValgrindOptionsPage());
|
addAutoReleasedObject(new ValgrindOptionsPage);
|
||||||
addAutoReleasedObject(new ValgrindRunControlFactory());
|
addAutoReleasedObject(new ValgrindRunControlFactory);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ValgrindPlugin::extensionsInitialized()
|
void ValgrindPlugin::extensionsInitialized()
|
||||||
{
|
{
|
||||||
using namespace std::placeholders;
|
initMemcheckTool(this);
|
||||||
|
initCallgrindTool(this);
|
||||||
|
}
|
||||||
|
|
||||||
QString callgrindToolTip = tr("Valgrind Function Profile uses the "
|
ExtensionSystem::IPlugin::ShutdownFlag ValgrindPlugin::aboutToShutdown()
|
||||||
"Callgrind tool to record function calls when a program runs.");
|
{
|
||||||
|
destroyCallgrindTool();
|
||||||
QString memcheckToolTip = tr("Valgrind Analyze Memory uses the "
|
destroyMemcheckTool();
|
||||||
"Memcheck tool to find memory leaks.");
|
return SynchronousShutdown;
|
||||||
|
|
||||||
auto mcTool = new MemcheckTool(this);
|
|
||||||
auto cgTool = new CallgrindTool(this);
|
|
||||||
auto cgRunControlCreator = [cgTool](RunConfiguration *runConfiguration, Id) {
|
|
||||||
return cgTool->createRunControl(runConfiguration);
|
|
||||||
};
|
|
||||||
|
|
||||||
AnalyzerManager::registerToolbar(MemcheckPerspectiveId, mcTool->createWidgets());
|
|
||||||
AnalyzerManager::registerToolbar(CallgrindPerspectiveId, cgTool->createWidgets());
|
|
||||||
|
|
||||||
ActionDescription desc;
|
|
||||||
|
|
||||||
if (!Utils::HostOsInfo::isWindowsHost()) {
|
|
||||||
desc.setText(tr("Valgrind Memory Analyzer"));
|
|
||||||
desc.setToolTip(memcheckToolTip);
|
|
||||||
desc.setPerspectiveId(MemcheckPerspectiveId);
|
|
||||||
desc.setRunControlCreator([mcTool](RunConfiguration *runConfig, Id runMode) {
|
|
||||||
return mcTool->createRunControl(runConfig, runMode);
|
|
||||||
});
|
|
||||||
desc.setToolMode(DebugMode);
|
|
||||||
desc.setRunMode(MEMCHECK_RUN_MODE);
|
|
||||||
desc.setMenuGroup(Analyzer::Constants::G_ANALYZER_TOOLS);
|
|
||||||
AnalyzerManager::registerAction("Memcheck.Local", desc);
|
|
||||||
|
|
||||||
desc.setText(tr("Valgrind Memory Analyzer with GDB"));
|
|
||||||
desc.setToolTip(tr("Valgrind Analyze Memory with GDB uses the "
|
|
||||||
"Memcheck tool to find memory leaks.\nWhen a problem is detected, "
|
|
||||||
"the application is interrupted and can be debugged."));
|
|
||||||
desc.setPerspectiveId(MemcheckPerspectiveId);
|
|
||||||
desc.setRunControlCreator([mcTool](RunConfiguration *runConfig, Id runMode) {
|
|
||||||
return mcTool->createRunControl(runConfig, runMode);
|
|
||||||
});
|
|
||||||
desc.setToolMode(DebugMode);
|
|
||||||
desc.setRunMode(MEMCHECK_WITH_GDB_RUN_MODE);
|
|
||||||
desc.setMenuGroup(Analyzer::Constants::G_ANALYZER_TOOLS);
|
|
||||||
AnalyzerManager::registerAction("MemcheckWithGdb.Local", desc);
|
|
||||||
|
|
||||||
desc.setText(tr("Valgrind Function Profiler"));
|
|
||||||
desc.setToolTip(callgrindToolTip);
|
|
||||||
desc.setPerspectiveId(CallgrindPerspectiveId);
|
|
||||||
desc.setRunControlCreator(cgRunControlCreator);
|
|
||||||
desc.setToolMode(OptimizedMode);
|
|
||||||
desc.setRunMode(CALLGRIND_RUN_MODE);
|
|
||||||
desc.setMenuGroup(Analyzer::Constants::G_ANALYZER_TOOLS);
|
|
||||||
AnalyzerManager::registerAction(CallgrindLocalActionId, desc);
|
|
||||||
}
|
|
||||||
|
|
||||||
desc.setText(tr("Valgrind Memory Analyzer (External Remote Application)"));
|
|
||||||
desc.setToolTip(memcheckToolTip);
|
|
||||||
desc.setPerspectiveId(MemcheckPerspectiveId);
|
|
||||||
desc.setCustomToolStarter([mcTool](ProjectExplorer::RunConfiguration *runConfig) {
|
|
||||||
StartRemoteDialog dlg;
|
|
||||||
if (dlg.exec() != QDialog::Accepted)
|
|
||||||
return;
|
|
||||||
ValgrindRunControl *rc = mcTool->createRunControl(runConfig, MEMCHECK_RUN_MODE);
|
|
||||||
QTC_ASSERT(rc, return);
|
|
||||||
const auto runnable = dlg.runnable();
|
|
||||||
rc->setRunnable(runnable);
|
|
||||||
AnalyzerConnection connection;
|
|
||||||
connection.connParams = dlg.sshParams();
|
|
||||||
rc->setConnection(connection);
|
|
||||||
rc->setDisplayName(runnable.executable);
|
|
||||||
ProjectExplorerPlugin::startRunControl(rc, MEMCHECK_RUN_MODE);
|
|
||||||
});
|
|
||||||
desc.setMenuGroup(Analyzer::Constants::G_ANALYZER_REMOTE_TOOLS);
|
|
||||||
AnalyzerManager::registerAction("Memcheck.Remote", desc);
|
|
||||||
|
|
||||||
desc.setText(tr("Valgrind Function Profiler (External Remote Application)"));
|
|
||||||
desc.setToolTip(callgrindToolTip);
|
|
||||||
desc.setPerspectiveId(CallgrindPerspectiveId);
|
|
||||||
desc.setCustomToolStarter([cgTool](ProjectExplorer::RunConfiguration *runConfig) {
|
|
||||||
StartRemoteDialog dlg;
|
|
||||||
if (dlg.exec() != QDialog::Accepted)
|
|
||||||
return;
|
|
||||||
ValgrindRunControl *rc = cgTool->createRunControl(runConfig);
|
|
||||||
QTC_ASSERT(rc, return);
|
|
||||||
const auto runnable = dlg.runnable();
|
|
||||||
rc->setRunnable(runnable);
|
|
||||||
AnalyzerConnection connection;
|
|
||||||
connection.connParams = dlg.sshParams();
|
|
||||||
rc->setConnection(connection);
|
|
||||||
rc->setDisplayName(runnable.executable);
|
|
||||||
ProjectExplorerPlugin::startRunControl(rc, CALLGRIND_RUN_MODE);
|
|
||||||
});
|
|
||||||
desc.setMenuGroup(Analyzer::Constants::G_ANALYZER_REMOTE_TOOLS);
|
|
||||||
AnalyzerManager::registerAction(CallgrindRemoteActionId, desc);
|
|
||||||
|
|
||||||
// If there is a CppEditor context menu add our own context menu actions.
|
|
||||||
if (ActionContainer *editorContextMenu =
|
|
||||||
ActionManager::actionContainer(CppEditor::Constants::M_CONTEXT)) {
|
|
||||||
Context analyzerContext = Context(Analyzer::Constants::C_ANALYZEMODE);
|
|
||||||
editorContextMenu->addSeparator(analyzerContext);
|
|
||||||
|
|
||||||
QAction *action = new QAction(tr("Profile Costs of This Function and Its Callees"), this);
|
|
||||||
action->setIcon(Analyzer::Icons::ANALYZER_CONTROL_START.icon());
|
|
||||||
connect(action, &QAction::triggered, cgTool,
|
|
||||||
&CallgrindTool::handleShowCostsOfFunction);
|
|
||||||
Command *cmd = ActionManager::registerAction(action, "Analyzer.Callgrind.ShowCostsOfFunction",
|
|
||||||
analyzerContext);
|
|
||||||
editorContextMenu->addAction(cmd);
|
|
||||||
cmd->setAttribute(Command::CA_Hide);
|
|
||||||
cmd->setAttribute(Command::CA_NonConfigurable);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ValgrindGlobalSettings *ValgrindPlugin::globalSettings()
|
ValgrindGlobalSettings *ValgrindPlugin::globalSettings()
|
||||||
{
|
{
|
||||||
return theGlobalSettings;
|
return theGlobalSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -44,8 +44,9 @@ public:
|
|||||||
ValgrindPlugin() {}
|
ValgrindPlugin() {}
|
||||||
~ValgrindPlugin();
|
~ValgrindPlugin();
|
||||||
|
|
||||||
bool initialize(const QStringList &arguments, QString *errorString);
|
bool initialize(const QStringList &arguments, QString *errorString) override;
|
||||||
void extensionsInitialized();
|
void extensionsInitialized() override;
|
||||||
|
ShutdownFlag aboutToShutdown() override;
|
||||||
|
|
||||||
static ValgrindGlobalSettings *globalSettings();
|
static ValgrindGlobalSettings *globalSettings();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user