forked from qt-creator/qt-creator
Analyzer: Use Utils::OutputFormat everywhere
Replace hard distinction between 'out', 'err' with flexible OutputFormat. Also make sure that QmlProfiler shows application output. Change-Id: I130c71884321e4c59c9a75f0836c37a7f0e805c4 Reviewed-on: http://codereview.qt.nokia.com/458 Reviewed-by: Christiaan Janssen <christiaan.janssen@nokia.com>
This commit is contained in:
@@ -128,14 +128,14 @@ void LocalValgrindProcess::readyReadStandardError()
|
||||
{
|
||||
const QByteArray b = m_process.readAllStandardError();
|
||||
if (!b.isEmpty())
|
||||
emit standardErrorReceived(b);
|
||||
emit processOutput(b, Utils::StdErrFormat);
|
||||
}
|
||||
|
||||
void LocalValgrindProcess::readyReadStandardOutput()
|
||||
{
|
||||
const QByteArray b = m_process.readAllStandardOutput();
|
||||
if (!b.isEmpty())
|
||||
emit standardOutputReceived(b);
|
||||
emit processOutput(b, Utils::StdOutFormat);
|
||||
}
|
||||
|
||||
////////////////////////
|
||||
@@ -202,9 +202,9 @@ void RemoteValgrindProcess::connected()
|
||||
|
||||
m_process = m_connection->createRemoteProcess(cmd.toUtf8());
|
||||
connect(m_process.data(), SIGNAL(errorOutputAvailable(QByteArray)),
|
||||
this, SIGNAL(standardErrorReceived(QByteArray)));
|
||||
this, SLOT(standardError(QByteArray)));
|
||||
connect(m_process.data(), SIGNAL(outputAvailable(QByteArray)),
|
||||
this, SIGNAL(standardOutputReceived(QByteArray)));
|
||||
this, SLOT(standardOutput(QByteArray)));
|
||||
connect(m_process.data(), SIGNAL(closed(int)),
|
||||
this, SLOT(closed(int)));
|
||||
connect(m_process.data(), SIGNAL(started()),
|
||||
@@ -242,7 +242,7 @@ void RemoteValgrindProcess::processStarted()
|
||||
|
||||
m_findPID = m_connection->createRemoteProcess(cmd.toUtf8());
|
||||
connect(m_findPID.data(), SIGNAL(errorOutputAvailable(QByteArray)),
|
||||
this, SIGNAL(standardErrorReceived(QByteArray)));
|
||||
this, SLOT(standardOutput(QByteArray)));
|
||||
connect(m_findPID.data(), SIGNAL(outputAvailable(QByteArray)),
|
||||
this, SLOT(findPIDOutputReceived(QByteArray)));
|
||||
m_findPID->start();
|
||||
@@ -263,6 +263,16 @@ void RemoteValgrindProcess::findPIDOutputReceived(const QByteArray &output)
|
||||
}
|
||||
}
|
||||
|
||||
void RemoteValgrindProcess::standardOutput(const QByteArray &output)
|
||||
{
|
||||
emit processOutput(output, Utils::StdOutFormat);
|
||||
}
|
||||
|
||||
void RemoteValgrindProcess::standardError(const QByteArray &output)
|
||||
{
|
||||
emit processOutput(output, Utils::StdErrFormat);
|
||||
}
|
||||
|
||||
void RemoteValgrindProcess::error(Utils::SshError error)
|
||||
{
|
||||
switch (error) {
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include <utils/qtcprocess.h>
|
||||
#include <utils/ssh/sshremoteprocess.h>
|
||||
#include <utils/ssh/sshconnection.h>
|
||||
#include <utils/outputformat.h>
|
||||
|
||||
namespace Valgrind {
|
||||
|
||||
@@ -73,8 +74,7 @@ signals:
|
||||
void started();
|
||||
void finished(int, QProcess::ExitStatus);
|
||||
void error(QProcess::ProcessError);
|
||||
void standardOutputReceived(const QByteArray &);
|
||||
void standardErrorReceived(const QByteArray &);
|
||||
void processOutput(const QByteArray &, Utils::OutputFormat format);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -149,6 +149,8 @@ private slots:
|
||||
void error(Utils::SshError error);
|
||||
void processStarted();
|
||||
void findPIDOutputReceived(const QByteArray &output);
|
||||
void standardOutput(const QByteArray &output);
|
||||
void standardError(const QByteArray &output);
|
||||
|
||||
private:
|
||||
Utils::SshConnectionParameters m_params;
|
||||
|
||||
@@ -97,10 +97,8 @@ void ValgrindRunner::Private::run(ValgrindProcess *_process)
|
||||
valgrindArgs << QLatin1String("--dsymutil=yes");
|
||||
#endif
|
||||
|
||||
QObject::connect(process, SIGNAL(standardOutputReceived(QByteArray)),
|
||||
q, SIGNAL(standardOutputReceived(QByteArray)));
|
||||
QObject::connect(process, SIGNAL(standardErrorReceived(QByteArray)),
|
||||
q, SIGNAL(standardErrorReceived(QByteArray)));
|
||||
QObject::connect(process, SIGNAL(processOutput(QByteArray,Utils::OutputFormat)),
|
||||
q, SIGNAL(processOutputReceived(QByteArray,Utils::OutputFormat)));
|
||||
QObject::connect(process, SIGNAL(started()),
|
||||
q, SLOT(processStarted()));
|
||||
QObject::connect(process, SIGNAL(finished(int, QProcess::ExitStatus)),
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#define VALGRIND_RUNNER_H
|
||||
|
||||
#include <QtCore/QProcess>
|
||||
#include <utils/outputformat.h>
|
||||
|
||||
#include "valgrind_global.h"
|
||||
|
||||
@@ -85,8 +86,7 @@ protected:
|
||||
virtual QString tool() const = 0;
|
||||
|
||||
signals:
|
||||
void standardOutputReceived(const QByteArray &);
|
||||
void standardErrorReceived(const QByteArray &);
|
||||
void processOutputReceived(const QByteArray &, Utils::OutputFormat);
|
||||
void processErrorReceived(const QString &, QProcess::ProcessError);
|
||||
void started();
|
||||
void finished();
|
||||
|
||||
@@ -76,10 +76,8 @@ AnalyzerRunControl::AnalyzerRunControl(const AnalyzerStartParameters &sp,
|
||||
IAnalyzerTool *tool = AnalyzerManager::instance()->currentTool();
|
||||
d->m_engine = tool->createEngine(sp, runConfiguration);
|
||||
|
||||
connect(d->m_engine, SIGNAL(standardErrorReceived(QString)),
|
||||
SLOT(receiveStandardError(QString)));
|
||||
connect(d->m_engine, SIGNAL(standardOutputReceived(QString)),
|
||||
SLOT(receiveStandardOutput(QString)));
|
||||
connect(d->m_engine, SIGNAL(outputReceived(QString,Utils::OutputFormat)),
|
||||
SLOT(receiveOutput(QString,Utils::OutputFormat)));
|
||||
connect(d->m_engine, SIGNAL(taskToBeAdded(ProjectExplorer::Task::TaskType,QString,QString,int)),
|
||||
SLOT(addTask(ProjectExplorer::Task::TaskType,QString,QString,int)));
|
||||
connect(d->m_engine, SIGNAL(finished()),
|
||||
@@ -138,14 +136,9 @@ QIcon AnalyzerRunControl::icon() const
|
||||
return QIcon(QLatin1String(":/images/analyzer_start_small.png"));
|
||||
}
|
||||
|
||||
void AnalyzerRunControl::receiveStandardOutput(const QString &text)
|
||||
void AnalyzerRunControl::receiveOutput(const QString &text, Utils::OutputFormat format)
|
||||
{
|
||||
appendMessage(text, Utils::StdOutFormat);
|
||||
}
|
||||
|
||||
void AnalyzerRunControl::receiveStandardError(const QString &text)
|
||||
{
|
||||
appendMessage(text, Utils::StdErrFormat);
|
||||
appendMessage(text, format);
|
||||
}
|
||||
|
||||
void AnalyzerRunControl::addTask(ProjectExplorer::Task::TaskType type, const QString &description,
|
||||
|
||||
@@ -64,8 +64,7 @@ public:
|
||||
QIcon icon() const;
|
||||
|
||||
private slots:
|
||||
void receiveStandardOutput(const QString &);
|
||||
void receiveStandardError(const QString &);
|
||||
void receiveOutput(const QString &, Utils::OutputFormat format);
|
||||
|
||||
void addTask(ProjectExplorer::Task::TaskType type, const QString &description,
|
||||
const QString &file, int line);
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
|
||||
#include <projectexplorer/task.h>
|
||||
#include <utils/ssh/sshconnection.h>
|
||||
#include <utils/outputformat.h>
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QString>
|
||||
@@ -76,9 +77,7 @@ public:
|
||||
|
||||
signals:
|
||||
/// should be emitted when the debuggee outputted something
|
||||
void standardOutputReceived(const QString &);
|
||||
/// should be emitted when the debuggee outputted an error
|
||||
void standardErrorReceived(const QString &);
|
||||
void outputReceived(const QString &, Utils::OutputFormat format);
|
||||
/// can be emitted when you want to show a task, e.g. to display an error
|
||||
void taskToBeAdded(ProjectExplorer::Task::TaskType type, const QString &description,
|
||||
const QString &file, int line);
|
||||
|
||||
@@ -245,9 +245,9 @@ void QmlProfilerEngine::filterApplicationMessage(const QString &msg)
|
||||
}
|
||||
|
||||
|
||||
void QmlProfilerEngine::logApplicationMessage(const QString &msg, Utils::OutputFormat /*format*/)
|
||||
void QmlProfilerEngine::logApplicationMessage(const QString &msg, Utils::OutputFormat format)
|
||||
{
|
||||
qDebug() << "app: " << msg;
|
||||
emit outputReceived(msg, format);
|
||||
|
||||
filterApplicationMessage(msg);
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ Valgrind::ValgrindRunner * CallgrindEngine::runner()
|
||||
|
||||
void CallgrindEngine::start()
|
||||
{
|
||||
emit standardOutputReceived(tr("Profiling %1").arg(executable()));
|
||||
emit outputReceived(tr("Profiling %1\n").arg(executable()), Utils::NormalMessageFormat);
|
||||
ValgrindEngine::start();
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,8 @@ void MemcheckEngine::start()
|
||||
{
|
||||
m_runner.setParser(&m_parser);
|
||||
|
||||
emit standardOutputReceived(tr("Analyzing memory of %1").arg(executable()));
|
||||
emit outputReceived(tr("Analyzing memory of %1\n").arg(executable()),
|
||||
Utils::NormalMessageFormat);
|
||||
ValgrindEngine::start();
|
||||
}
|
||||
|
||||
|
||||
@@ -88,9 +88,9 @@ void ValgrindEngine::start()
|
||||
m_progressWatcher->setFuture(m_progress->future());
|
||||
|
||||
#if VALGRIND_DEBUG_OUTPUT
|
||||
emit standardOutputReceived(tr("Valgrind options: %1").arg(toolArguments().join(" ")));
|
||||
emit standardOutputReceived(tr("Working directory: %1").arg(m_workingDirectory));
|
||||
emit standardOutputReceived(tr("Command-line arguments: %1").arg(m_commandLineArguments));
|
||||
emit outputReceived(tr("Valgrind options: %1").arg(toolArguments().join(" ")), Utils::DebugFormat);
|
||||
emit outputReceived(tr("Working directory: %1").arg(m_workingDirectory), Utils::DebugFormat);
|
||||
emit outputReceived(tr("Command-line arguments: %1").arg(m_commandLineArguments), Utils::DebugFormat);
|
||||
#endif
|
||||
|
||||
const AnalyzerStartParameters &sp = startParameters();
|
||||
@@ -104,10 +104,8 @@ void ValgrindEngine::start()
|
||||
runner()->setDebuggeeArguments(sp.debuggeeArgs);
|
||||
runner()->setEnvironment(sp.environment);
|
||||
|
||||
connect(runner(), SIGNAL(standardOutputReceived(QByteArray)),
|
||||
SLOT(receiveStandardOutput(QByteArray)));
|
||||
connect(runner(), SIGNAL(standardErrorReceived(QByteArray)),
|
||||
SLOT(receiveStandardError(QByteArray)));
|
||||
connect(runner(), SIGNAL(processOutputReceived(QByteArray,Utils::OutputFormat)),
|
||||
SLOT(receiveProcessOutput(QByteArray,Utils::OutputFormat)));
|
||||
connect(runner(), SIGNAL(processErrorReceived(QString, QProcess::ProcessError)),
|
||||
SLOT(receiveProcessError(QString, QProcess::ProcessError)));
|
||||
connect(runner(), SIGNAL(finished()),
|
||||
@@ -142,29 +140,20 @@ void ValgrindEngine::handleProgressFinished()
|
||||
|
||||
void ValgrindEngine::runnerFinished()
|
||||
{
|
||||
emit standardOutputReceived(tr("** Analyzing finished **"));
|
||||
emit outputReceived(tr("** Analyzing finished **\n"), Utils::NormalMessageFormat);
|
||||
emit finished();
|
||||
|
||||
m_progress->reportFinished();
|
||||
|
||||
disconnect(runner(), SIGNAL(standardOutputReceived(QByteArray)),
|
||||
this, SLOT(receiveStandardOutput(QByteArray)));
|
||||
disconnect(runner(), SIGNAL(standardErrorReceived(QByteArray)),
|
||||
this, SLOT(receiveStandardError(QByteArray)));
|
||||
disconnect(runner(), SIGNAL(processErrorReceived(QString, QProcess::ProcessError)),
|
||||
this, SLOT(receiveProcessError(QString, QProcess::ProcessError)));
|
||||
disconnect(runner(), SIGNAL(processOutputReceived(QByteArray,Utils::OutputFormat)),
|
||||
this, SLOT(receiveProcessOutput(QByteArray,Utils::OutputFormat)));
|
||||
disconnect(runner(), SIGNAL(finished()),
|
||||
this, SLOT(runnerFinished()));
|
||||
}
|
||||
|
||||
void ValgrindEngine::receiveStandardOutput(const QByteArray &b)
|
||||
void ValgrindEngine::receiveProcessOutput(const QByteArray &b, Utils::OutputFormat format)
|
||||
{
|
||||
emit standardOutputReceived(QString::fromLocal8Bit(b));
|
||||
}
|
||||
|
||||
void ValgrindEngine::receiveStandardError(const QByteArray &b)
|
||||
{
|
||||
emit standardErrorReceived(QString::fromLocal8Bit(b));
|
||||
emit outputReceived(QString::fromLocal8Bit(b), format);
|
||||
}
|
||||
|
||||
void ValgrindEngine::receiveProcessError(const QString &error, QProcess::ProcessError e)
|
||||
@@ -172,14 +161,14 @@ void ValgrindEngine::receiveProcessError(const QString &error, QProcess::Process
|
||||
if (e == QProcess::FailedToStart) {
|
||||
const QString &valgrind = m_settings->subConfig<ValgrindSettings>()->valgrindExecutable();
|
||||
if (!valgrind.isEmpty()) {
|
||||
emit standardErrorReceived(tr("** Error: \"%1\" could not be started: %2 **").arg(valgrind).arg(error));
|
||||
emit outputReceived(tr("** Error: \"%1\" could not be started: %2 **\n").arg(valgrind).arg(error), Utils::ErrorMessageFormat);
|
||||
} else {
|
||||
emit standardErrorReceived(tr("** Error: no valgrind executable set **"));
|
||||
emit outputReceived(tr("** Error: no valgrind executable set **\n"), Utils::ErrorMessageFormat);
|
||||
}
|
||||
} else if (m_isStopping && e == QProcess::Crashed) { // process gets killed on stop
|
||||
emit standardErrorReceived(tr("** Process Terminated **"));
|
||||
emit outputReceived(tr("** Process Terminated **\n"), Utils::ErrorMessageFormat);
|
||||
} else {
|
||||
emit standardErrorReceived(QString("** %1 **").arg(error));
|
||||
emit outputReceived(QString("** %1 **\n").arg(error), Utils::ErrorMessageFormat);
|
||||
}
|
||||
|
||||
if (m_isStopping)
|
||||
|
||||
@@ -83,8 +83,7 @@ private slots:
|
||||
void handleProgressFinished();
|
||||
void runnerFinished();
|
||||
|
||||
void receiveStandardOutput(const QByteArray &);
|
||||
void receiveStandardError(const QByteArray &);
|
||||
void receiveProcessOutput(const QByteArray &, Utils::OutputFormat);
|
||||
void receiveProcessError(const QString &, QProcess::ProcessError);
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user