Commit 5addc5d1 authored by hjk's avatar hjk
Browse files

Analyzer/Debugger: clean up



Namespace, parameters, popup output on error more directly.

Change-Id: I9b88e54b6b06defce5643a1c7123284e58fd5a22
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 38f6c349
......@@ -121,6 +121,8 @@ AppOutputPane::AppOutputPane() :
m_stopButton(new QToolButton),
m_attachButton(new QToolButton)
{
setObjectName(QLatin1String("AppOutputPane")); // Used in valgrind engine
// Rerun
m_reRunButton->setIcon(QIcon(QLatin1String(ProjectExplorer::Constants::ICON_RUN_SMALL)));
m_reRunButton->setToolTip(tr("Re-run this run-configuration"));
......
......@@ -86,6 +86,7 @@
#include <utils/stylehelper.h>
using namespace Analyzer;
using namespace ProjectExplorer;
using namespace Valgrind::XmlProtocol;
namespace Valgrind {
......@@ -116,11 +117,11 @@ void MemcheckErrorFilterProxyModel::setFilterExternalIssues(bool filter)
bool MemcheckErrorFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
{
// we only deal with toplevel items
// We only deal with toplevel items.
if (sourceParent.isValid())
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
// parent.
QAbstractItemModel *model = sourceModel();
......@@ -130,23 +131,21 @@ bool MemcheckErrorFilterProxyModel::filterAcceptsRow(int sourceRow, const QModel
const Error error = sourceIndex.data(ErrorListModel::ErrorRole).value<Error>();
// filter on kind
// Filter on kind
if (!m_acceptedKinds.contains(error.kind()))
return false;
// filter non-project stuff
// Filter non-project stuff
if (m_filterExternalIssues && !error.stacks().isEmpty()) {
// 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
ProjectExplorer::SessionManager *session
= ProjectExplorer::ProjectExplorerPlugin::instance()->session();
SessionManager *session = ProjectExplorerPlugin::instance()->session();
QSet<QString> validFolders;
foreach (ProjectExplorer::Project *project, session->projects()) {
foreach (Project *project, session->projects()) {
validFolders << project->projectDirectory();
foreach (ProjectExplorer::Target *target, project->targets()) {
foreach (ProjectExplorer::BuildConfiguration *config, target->buildConfigurations()) {
foreach (Target *target, project->targets()) {
foreach (BuildConfiguration *config, target->buildConfigurations())
validFolders << config->buildDirectory();
}
}
}
......@@ -155,7 +154,7 @@ bool MemcheckErrorFilterProxyModel::filterAcceptsRow(int sourceRow, const QModel
const int framesToLookAt = qMin(6, frames.size());
bool inProject = false;
for ( int i = 0; i < framesToLookAt; ++i ) {
for (int i = 0; i < framesToLookAt; ++i) {
const Frame &frame = frames.at(i);
foreach (const QString &folder, validFolders) {
if (frame.object().startsWith(folder)) {
......@@ -228,13 +227,11 @@ void MemcheckTool::settingsDestroyed(QObject *settings)
void MemcheckTool::maybeActiveRunConfigurationChanged()
{
AnalyzerSettings *settings = 0;
ProjectExplorer::ProjectExplorerPlugin *pe = ProjectExplorer::ProjectExplorerPlugin::instance();
if (ProjectExplorer::Project *project = pe->startupProject()) {
if (ProjectExplorer::Target *target = project->activeTarget()) {
if (ProjectExplorer::RunConfiguration *rc = target->activeRunConfiguration())
ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance();
if (Project *project = pe->startupProject())
if (Target *target = project->activeTarget())
if (RunConfiguration *rc = target->activeRunConfiguration())
settings = rc->extraAspect<AnalyzerRunConfigurationAspect>();
}
}
if (!settings) // fallback to global settings
settings = AnalyzerGlobalSettings::instance();
......@@ -285,9 +282,9 @@ Core::Id MemcheckTool::id() const
return Core::Id("Memcheck");
}
ProjectExplorer::RunMode MemcheckTool::runMode() const
RunMode MemcheckTool::runMode() const
{
return ProjectExplorer::MemcheckRunMode;
return MemcheckRunMode;
}
QString MemcheckTool::displayName() const
......@@ -392,7 +389,7 @@ QWidget *MemcheckTool::createWidgets()
errorDock->show();
mw->splitDockWidget(mw->toolBarDockWidget(), errorDock, Qt::Vertical);
connect(ProjectExplorer::ProjectExplorerPlugin::instance(),
connect(ProjectExplorerPlugin::instance(),
SIGNAL(updateRunActions()), SLOT(maybeActiveRunConfigurationChanged()));
//
......@@ -450,10 +447,10 @@ QWidget *MemcheckTool::createWidgets()
}
IAnalyzerEngine *MemcheckTool::createEngine(const AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration)
RunConfiguration *runConfiguration)
{
m_frameFinder->setFiles(runConfiguration ? runConfiguration->target()
->project()->files(ProjectExplorer::Project::AllFiles) : QStringList());
->project()->files(Project::AllFiles) : QStringList());
MemcheckEngine *engine = new MemcheckEngine(this, sp, runConfiguration);
......@@ -479,7 +476,7 @@ void MemcheckTool::engineStarting(const IAnalyzerEngine *engine)
clearErrorView();
QString dir;
if (ProjectExplorer::RunConfiguration *rc = engine->runConfiguration())
if (RunConfiguration *rc = engine->runConfiguration())
dir = rc->target()->project()->projectDirectory() + QDir::separator();
const MemcheckEngine *mEngine = dynamic_cast<const MemcheckEngine *>(engine);
......
......@@ -45,9 +45,12 @@
#define VALGRIND_DEBUG_OUTPUT 0
using namespace Analyzer;
using namespace Valgrind::Internal;
using namespace Core;
using namespace Utils;
namespace Valgrind {
namespace Internal {
const int progressMaximum = 1000000;
ValgrindEngine::ValgrindEngine(IAnalyzerTool *tool, const AnalyzerStartParameters &sp,
......@@ -79,9 +82,9 @@ bool ValgrindEngine::start()
{
emit starting(this);
Core::FutureProgress *fp = Core::ICore::progressManager()->addTask(m_progress->future(),
FutureProgress *fp = ICore::progressManager()->addTask(m_progress->future(),
progressTitle(), QLatin1String("valgrind"));
fp->setKeepOnFinish(Core::FutureProgress::HideOnFinish);
fp->setKeepOnFinish(FutureProgress::HideOnFinish);
m_progress->setProgressRange(0, progressMaximum);
m_progress->reportStarted();
m_progressWatcher->setFuture(m_progress->future());
......@@ -89,9 +92,9 @@ bool ValgrindEngine::start()
const AnalyzerStartParameters &sp = startParameters();
#if VALGRIND_DEBUG_OUTPUT
emit outputReceived(tr("Valgrind options: %1").arg(toolArguments().join(QLatin1Char(' '))), Utils::DebugFormat);
emit outputReceived(tr("Working directory: %1").arg(sp.workingDirectory), Utils::DebugFormat);
emit outputReceived(tr("Commandline arguments: %1").arg(sp.debuggeeArgs), Utils::DebugFormat);
emit outputReceived(tr("Valgrind options: %1").arg(toolArguments().join(QLatin1Char(' '))), DebugFormat);
emit outputReceived(tr("Working directory: %1").arg(sp.workingDirectory), DebugFormat);
emit outputReceived(tr("Commandline arguments: %1").arg(sp.debuggeeArgs), DebugFormat);
#endif
runner()->setWorkingDirectory(sp.workingDirectory);
......@@ -140,12 +143,12 @@ void ValgrindEngine::handleProgressCanceled()
void ValgrindEngine::handleProgressFinished()
{
QApplication::alert(Core::ICore::mainWindow(), 3000);
QApplication::alert(ICore::mainWindow(), 3000);
}
void ValgrindEngine::runnerFinished()
{
emit outputReceived(tr("** Analyzing finished **\n"), Utils::NormalMessageFormat);
emit outputReceived(tr("** Analyzing finished **\n"), NormalMessageFormat);
emit finished();
m_progress->reportFinished();
......@@ -156,7 +159,7 @@ void ValgrindEngine::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();
if (progress < 5 * progressMaximum / 10)
......@@ -164,32 +167,30 @@ void ValgrindEngine::receiveProcessOutput(const QByteArray &b, Utils::OutputForm
else if (progress < 9 * progressMaximum / 10)
progress += progress / 1000;
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();
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
emit outputReceived(tr("** Error: no valgrind executable set **\n"), Utils::ErrorMessageFormat);
} else if (m_isStopping && e == QProcess::Crashed) { // process gets killed on stop
emit outputReceived(tr("** Process Terminated **\n"), Utils::ErrorMessageFormat);
emit outputReceived(tr("** Error: no valgrind executable set **\n"), ErrorMessageFormat);
} else if (m_isStopping && error == QProcess::Crashed) { // process gets killed on stop
emit outputReceived(tr("** Process Terminated **\n"), ErrorMessageFormat);
} else {
emit outputReceived(QString::fromLatin1("** %1 **\n").arg(error), Utils::ErrorMessageFormat);
emit outputReceived(QString::fromLatin1("** %1 **\n").arg(message), ErrorMessageFormat);
}
if (m_isStopping)
return;
///FIXME: get a better API for this into Qt Creator
QList<Core::IOutputPane *> panes = ExtensionSystem::PluginManager::getObjects<Core::IOutputPane>();
foreach (Core::IOutputPane *pane, panes) {
if (pane->displayName() == tr("Application Output")) {
pane->popup(Core::IOutputPane::NoModeSwitch);
break;
}
}
QObject *obj = ExtensionSystem::PluginManager::getObjectByName(QLatin1String("AppOutputPane"));
if (IOutputPane *pane = qobject_cast<IOutputPane *>(obj))
pane->popup(IOutputPane::NoModeSwitch);
}
} // namespace Internal
} // namepsace Valgrind
......@@ -32,19 +32,13 @@
#define VALGRINDENGINE_H
#include <analyzerbase/ianalyzerengine.h>
#include <utils/environment.h>
#include <valgrind/valgrindrunner.h>
#include <QString>
#include <QByteArray>
#include <QFutureInterface>
#include <QFutureWatcher>
namespace Analyzer {
class AnalyzerSettings;
}
namespace Analyzer { class AnalyzerSettings; }
namespace Valgrind {
namespace Internal {
......@@ -78,8 +72,8 @@ private slots:
void handleProgressFinished();
void runnerFinished();
void receiveProcessOutput(const QByteArray &, Utils::OutputFormat);
void receiveProcessError(const QString &, QProcess::ProcessError);
void receiveProcessOutput(const QByteArray &output, Utils::OutputFormat format);
void receiveProcessError(const QString &message, QProcess::ProcessError error);
private:
bool m_isStopping;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment