Analyzer/Debugger: clean up

Namespace, parameters, popup output on error more directly.

Change-Id: I9b88e54b6b06defce5643a1c7123284e58fd5a22
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
hjk
2013-01-10 11:36:15 +01:00
parent 38f6c349e1
commit 5addc5d1b9
4 changed files with 51 additions and 57 deletions

View File

@@ -121,6 +121,8 @@ AppOutputPane::AppOutputPane() :
m_stopButton(new QToolButton), m_stopButton(new QToolButton),
m_attachButton(new QToolButton) m_attachButton(new QToolButton)
{ {
setObjectName(QLatin1String("AppOutputPane")); // Used in valgrind engine
// Rerun // Rerun
m_reRunButton->setIcon(QIcon(QLatin1String(ProjectExplorer::Constants::ICON_RUN_SMALL))); m_reRunButton->setIcon(QIcon(QLatin1String(ProjectExplorer::Constants::ICON_RUN_SMALL)));
m_reRunButton->setToolTip(tr("Re-run this run-configuration")); m_reRunButton->setToolTip(tr("Re-run this run-configuration"));

View File

@@ -86,6 +86,7 @@
#include <utils/stylehelper.h> #include <utils/stylehelper.h>
using namespace Analyzer; using namespace Analyzer;
using namespace ProjectExplorer;
using namespace Valgrind::XmlProtocol; using namespace Valgrind::XmlProtocol;
namespace Valgrind { namespace Valgrind {
@@ -116,11 +117,11 @@ void MemcheckErrorFilterProxyModel::setFilterExternalIssues(bool filter)
bool MemcheckErrorFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const bool MemcheckErrorFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
{ {
// we only deal with toplevel items // We only deal with toplevel items.
if (sourceParent.isValid()) if (sourceParent.isValid())
return true; return true;
// because toplevel items have no parent, we can't use sourceParent to find them. we just use // Because toplevel items have no parent, we can't use sourceParent to find them. we just use
// sourceParent as an invalid index, telling the model that the index we're looking for has no // sourceParent as an invalid index, telling the model that the index we're looking for has no
// parent. // parent.
QAbstractItemModel *model = sourceModel(); QAbstractItemModel *model = sourceModel();
@@ -130,25 +131,23 @@ bool MemcheckErrorFilterProxyModel::filterAcceptsRow(int sourceRow, const QModel
const Error error = sourceIndex.data(ErrorListModel::ErrorRole).value<Error>(); const Error error = sourceIndex.data(ErrorListModel::ErrorRole).value<Error>();
// filter on kind // Filter on kind
if (!m_acceptedKinds.contains(error.kind())) if (!m_acceptedKinds.contains(error.kind()))
return false; return false;
// filter non-project stuff // Filter non-project stuff
if (m_filterExternalIssues && !error.stacks().isEmpty()) { if (m_filterExternalIssues && !error.stacks().isEmpty()) {
// ALGORITHM: look at last five stack frames, if none of these is inside any open projects, // ALGORITHM: look at last five stack frames, if none of these is inside any open projects,
// assume this error was created by an external library // assume this error was created by an external library
ProjectExplorer::SessionManager *session SessionManager *session = ProjectExplorerPlugin::instance()->session();
= ProjectExplorer::ProjectExplorerPlugin::instance()->session();
QSet<QString> validFolders; QSet<QString> validFolders;
foreach (ProjectExplorer::Project *project, session->projects()) { foreach (Project *project, session->projects()) {
validFolders << project->projectDirectory(); validFolders << project->projectDirectory();
foreach (ProjectExplorer::Target *target, project->targets()) { foreach (Target *target, project->targets()) {
foreach (ProjectExplorer::BuildConfiguration *config, target->buildConfigurations()) { foreach (BuildConfiguration *config, target->buildConfigurations())
validFolders << config->buildDirectory(); validFolders << config->buildDirectory();
} }
} }
}
const QVector< Frame > frames = error.stacks().first().frames(); const QVector< Frame > frames = error.stacks().first().frames();
@@ -228,13 +227,11 @@ void MemcheckTool::settingsDestroyed(QObject *settings)
void MemcheckTool::maybeActiveRunConfigurationChanged() void MemcheckTool::maybeActiveRunConfigurationChanged()
{ {
AnalyzerSettings *settings = 0; AnalyzerSettings *settings = 0;
ProjectExplorer::ProjectExplorerPlugin *pe = ProjectExplorer::ProjectExplorerPlugin::instance(); ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance();
if (ProjectExplorer::Project *project = pe->startupProject()) { if (Project *project = pe->startupProject())
if (ProjectExplorer::Target *target = project->activeTarget()) { if (Target *target = project->activeTarget())
if (ProjectExplorer::RunConfiguration *rc = target->activeRunConfiguration()) if (RunConfiguration *rc = target->activeRunConfiguration())
settings = rc->extraAspect<AnalyzerRunConfigurationAspect>(); settings = rc->extraAspect<AnalyzerRunConfigurationAspect>();
}
}
if (!settings) // fallback to global settings if (!settings) // fallback to global settings
settings = AnalyzerGlobalSettings::instance(); settings = AnalyzerGlobalSettings::instance();
@@ -285,9 +282,9 @@ Core::Id MemcheckTool::id() const
return Core::Id("Memcheck"); return Core::Id("Memcheck");
} }
ProjectExplorer::RunMode MemcheckTool::runMode() const RunMode MemcheckTool::runMode() const
{ {
return ProjectExplorer::MemcheckRunMode; return MemcheckRunMode;
} }
QString MemcheckTool::displayName() const QString MemcheckTool::displayName() const
@@ -392,7 +389,7 @@ QWidget *MemcheckTool::createWidgets()
errorDock->show(); errorDock->show();
mw->splitDockWidget(mw->toolBarDockWidget(), errorDock, Qt::Vertical); mw->splitDockWidget(mw->toolBarDockWidget(), errorDock, Qt::Vertical);
connect(ProjectExplorer::ProjectExplorerPlugin::instance(), connect(ProjectExplorerPlugin::instance(),
SIGNAL(updateRunActions()), SLOT(maybeActiveRunConfigurationChanged())); SIGNAL(updateRunActions()), SLOT(maybeActiveRunConfigurationChanged()));
// //
@@ -450,10 +447,10 @@ QWidget *MemcheckTool::createWidgets()
} }
IAnalyzerEngine *MemcheckTool::createEngine(const AnalyzerStartParameters &sp, IAnalyzerEngine *MemcheckTool::createEngine(const AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration) RunConfiguration *runConfiguration)
{ {
m_frameFinder->setFiles(runConfiguration ? runConfiguration->target() m_frameFinder->setFiles(runConfiguration ? runConfiguration->target()
->project()->files(ProjectExplorer::Project::AllFiles) : QStringList()); ->project()->files(Project::AllFiles) : QStringList());
MemcheckEngine *engine = new MemcheckEngine(this, sp, runConfiguration); MemcheckEngine *engine = new MemcheckEngine(this, sp, runConfiguration);
@@ -479,7 +476,7 @@ void MemcheckTool::engineStarting(const IAnalyzerEngine *engine)
clearErrorView(); clearErrorView();
QString dir; QString dir;
if (ProjectExplorer::RunConfiguration *rc = engine->runConfiguration()) if (RunConfiguration *rc = engine->runConfiguration())
dir = rc->target()->project()->projectDirectory() + QDir::separator(); dir = rc->target()->project()->projectDirectory() + QDir::separator();
const MemcheckEngine *mEngine = dynamic_cast<const MemcheckEngine *>(engine); const MemcheckEngine *mEngine = dynamic_cast<const MemcheckEngine *>(engine);

View File

@@ -45,9 +45,12 @@
#define VALGRIND_DEBUG_OUTPUT 0 #define VALGRIND_DEBUG_OUTPUT 0
using namespace Analyzer; using namespace Analyzer;
using namespace Valgrind::Internal; using namespace Core;
using namespace Utils; using namespace Utils;
namespace Valgrind {
namespace Internal {
const int progressMaximum = 1000000; const int progressMaximum = 1000000;
ValgrindEngine::ValgrindEngine(IAnalyzerTool *tool, const AnalyzerStartParameters &sp, ValgrindEngine::ValgrindEngine(IAnalyzerTool *tool, const AnalyzerStartParameters &sp,
@@ -79,9 +82,9 @@ bool ValgrindEngine::start()
{ {
emit starting(this); emit starting(this);
Core::FutureProgress *fp = Core::ICore::progressManager()->addTask(m_progress->future(), FutureProgress *fp = ICore::progressManager()->addTask(m_progress->future(),
progressTitle(), QLatin1String("valgrind")); progressTitle(), QLatin1String("valgrind"));
fp->setKeepOnFinish(Core::FutureProgress::HideOnFinish); fp->setKeepOnFinish(FutureProgress::HideOnFinish);
m_progress->setProgressRange(0, progressMaximum); m_progress->setProgressRange(0, progressMaximum);
m_progress->reportStarted(); m_progress->reportStarted();
m_progressWatcher->setFuture(m_progress->future()); m_progressWatcher->setFuture(m_progress->future());
@@ -89,9 +92,9 @@ bool ValgrindEngine::start()
const AnalyzerStartParameters &sp = startParameters(); const AnalyzerStartParameters &sp = startParameters();
#if VALGRIND_DEBUG_OUTPUT #if VALGRIND_DEBUG_OUTPUT
emit outputReceived(tr("Valgrind options: %1").arg(toolArguments().join(QLatin1Char(' '))), Utils::DebugFormat); emit outputReceived(tr("Valgrind options: %1").arg(toolArguments().join(QLatin1Char(' '))), DebugFormat);
emit outputReceived(tr("Working directory: %1").arg(sp.workingDirectory), Utils::DebugFormat); emit outputReceived(tr("Working directory: %1").arg(sp.workingDirectory), DebugFormat);
emit outputReceived(tr("Commandline arguments: %1").arg(sp.debuggeeArgs), Utils::DebugFormat); emit outputReceived(tr("Commandline arguments: %1").arg(sp.debuggeeArgs), DebugFormat);
#endif #endif
runner()->setWorkingDirectory(sp.workingDirectory); runner()->setWorkingDirectory(sp.workingDirectory);
@@ -140,12 +143,12 @@ void ValgrindEngine::handleProgressCanceled()
void ValgrindEngine::handleProgressFinished() void ValgrindEngine::handleProgressFinished()
{ {
QApplication::alert(Core::ICore::mainWindow(), 3000); QApplication::alert(ICore::mainWindow(), 3000);
} }
void ValgrindEngine::runnerFinished() void ValgrindEngine::runnerFinished()
{ {
emit outputReceived(tr("** Analyzing finished **\n"), Utils::NormalMessageFormat); emit outputReceived(tr("** Analyzing finished **\n"), NormalMessageFormat);
emit finished(); emit finished();
m_progress->reportFinished(); m_progress->reportFinished();
@@ -156,7 +159,7 @@ void ValgrindEngine::runnerFinished()
this, SLOT(runnerFinished())); this, SLOT(runnerFinished()));
} }
void ValgrindEngine::receiveProcessOutput(const QByteArray &b, Utils::OutputFormat format) void ValgrindEngine::receiveProcessOutput(const QByteArray &output, OutputFormat format)
{ {
int progress = m_progress->progressValue(); int progress = m_progress->progressValue();
if (progress < 5 * progressMaximum / 10) if (progress < 5 * progressMaximum / 10)
@@ -164,32 +167,30 @@ void ValgrindEngine::receiveProcessOutput(const QByteArray &b, Utils::OutputForm
else if (progress < 9 * progressMaximum / 10) else if (progress < 9 * progressMaximum / 10)
progress += progress / 1000; progress += progress / 1000;
m_progress->setProgressValue(progress); m_progress->setProgressValue(progress);
emit outputReceived(QString::fromLocal8Bit(b), format); emit outputReceived(QString::fromLocal8Bit(output), format);
} }
void ValgrindEngine::receiveProcessError(const QString &error, QProcess::ProcessError e) void ValgrindEngine::receiveProcessError(const QString &message, QProcess::ProcessError error)
{ {
if (e == QProcess::FailedToStart) { if (error == QProcess::FailedToStart) {
const QString &valgrind = m_settings->subConfig<ValgrindBaseSettings>()->valgrindExecutable(); const QString &valgrind = m_settings->subConfig<ValgrindBaseSettings>()->valgrindExecutable();
if (!valgrind.isEmpty()) if (!valgrind.isEmpty())
emit outputReceived(tr("** Error: \"%1\" could not be started: %2 **\n").arg(valgrind).arg(error), Utils::ErrorMessageFormat); emit outputReceived(tr("** Error: \"%1\" could not be started: %2 **\n").arg(valgrind).arg(message), ErrorMessageFormat);
else else
emit outputReceived(tr("** Error: no valgrind executable set **\n"), Utils::ErrorMessageFormat); emit outputReceived(tr("** Error: no valgrind executable set **\n"), ErrorMessageFormat);
} else if (m_isStopping && e == QProcess::Crashed) { // process gets killed on stop } else if (m_isStopping && error == QProcess::Crashed) { // process gets killed on stop
emit outputReceived(tr("** Process Terminated **\n"), Utils::ErrorMessageFormat); emit outputReceived(tr("** Process Terminated **\n"), ErrorMessageFormat);
} else { } else {
emit outputReceived(QString::fromLatin1("** %1 **\n").arg(error), Utils::ErrorMessageFormat); emit outputReceived(QString::fromLatin1("** %1 **\n").arg(message), ErrorMessageFormat);
} }
if (m_isStopping) if (m_isStopping)
return; return;
///FIXME: get a better API for this into Qt Creator QObject *obj = ExtensionSystem::PluginManager::getObjectByName(QLatin1String("AppOutputPane"));
QList<Core::IOutputPane *> panes = ExtensionSystem::PluginManager::getObjects<Core::IOutputPane>(); if (IOutputPane *pane = qobject_cast<IOutputPane *>(obj))
foreach (Core::IOutputPane *pane, panes) { pane->popup(IOutputPane::NoModeSwitch);
if (pane->displayName() == tr("Application Output")) {
pane->popup(Core::IOutputPane::NoModeSwitch);
break;
}
}
} }
} // namespace Internal
} // namepsace Valgrind

View File

@@ -32,19 +32,13 @@
#define VALGRINDENGINE_H #define VALGRINDENGINE_H
#include <analyzerbase/ianalyzerengine.h> #include <analyzerbase/ianalyzerengine.h>
#include <utils/environment.h> #include <utils/environment.h>
#include <valgrind/valgrindrunner.h> #include <valgrind/valgrindrunner.h>
#include <QString>
#include <QByteArray>
#include <QFutureInterface> #include <QFutureInterface>
#include <QFutureWatcher> #include <QFutureWatcher>
namespace Analyzer { namespace Analyzer { class AnalyzerSettings; }
class AnalyzerSettings;
}
namespace Valgrind { namespace Valgrind {
namespace Internal { namespace Internal {
@@ -78,8 +72,8 @@ private slots:
void handleProgressFinished(); void handleProgressFinished();
void runnerFinished(); void runnerFinished();
void receiveProcessOutput(const QByteArray &, Utils::OutputFormat); void receiveProcessOutput(const QByteArray &output, Utils::OutputFormat format);
void receiveProcessError(const QString &, QProcess::ProcessError); void receiveProcessError(const QString &message, QProcess::ProcessError error);
private: private:
bool m_isStopping; bool m_isStopping;