diff --git a/src/plugins/qnx/blackberryapplicationrunner.cpp b/src/plugins/qnx/blackberryapplicationrunner.cpp index 806f98f4d9287ac911c5c77baa7cd7719513a068..4da11f95b7ee6674c94d4d787cddb8e1e610d8e1 100644 --- a/src/plugins/qnx/blackberryapplicationrunner.cpp +++ b/src/plugins/qnx/blackberryapplicationrunner.cpp @@ -84,6 +84,7 @@ using namespace Qnx::Internal; BlackBerryApplicationRunner::BlackBerryApplicationRunner(bool debugMode, BlackBerryRunConfiguration *runConfiguration, QObject *parent) : QObject(parent) , m_debugMode(debugMode) + , m_slog2infoFound(true) , m_pid(-1) , m_appId(QString()) , m_running(false) @@ -91,6 +92,7 @@ BlackBerryApplicationRunner::BlackBerryApplicationRunner(bool debugMode, BlackBe , m_launchProcess(0) , m_stopProcess(0) , m_tailProcess(0) + , m_testSlog2Process(0) , m_runningStateTimer(new QTimer(this)) , m_runningStateProcess(0) { @@ -141,6 +143,17 @@ void BlackBerryApplicationRunner::start() m_running = true; } +void BlackBerryApplicationRunner::checkSlog2Info() +{ + // Not necessary to retest if slog2info exists. + if (!m_testSlog2Process) { + m_testSlog2Process = new QSsh::SshRemoteProcessRunner(this); + connect(m_testSlog2Process, SIGNAL(processClosed(int)), + this, SLOT(handleSlog2InfoFound())); + m_testSlog2Process->run("slog2info", m_sshParams); + } +} + void BlackBerryApplicationRunner::startFinished(int exitCode, QProcess::ExitStatus exitStatus) { if (exitCode == 0 && exitStatus == QProcess::NormalExit && m_pid > -1) { @@ -164,6 +177,12 @@ ProjectExplorer::RunControl::StopResult BlackBerryApplicationRunner::stop() m_stopping = true; + if (m_testSlog2Process && m_testSlog2Process->isProcessRunning()) { + m_testSlog2Process->cancel(); + delete m_testSlog2Process; + m_testSlog2Process = 0; + } + QStringList args; args << QLatin1String("-terminateApp"); args << QLatin1String("-device") << m_deviceHost; @@ -234,7 +253,11 @@ void BlackBerryApplicationRunner::killTailProcess() QSsh::SshRemoteProcessRunner *slayProcess = new QSsh::SshRemoteProcessRunner(this); connect(slayProcess, SIGNAL(processClosed(int)), this, SIGNAL(finished())); - slayProcess->run("slay tail", m_sshParams); + if (m_slog2infoFound) { + slayProcess->run("slay slog2info", m_sshParams); + } else { + slayProcess->run("slay tail", m_sshParams); + } // Not supported by OpenSSH server //m_tailProcess->sendSignalToProcess(Utils::SshRemoteProcess::KillSignal); @@ -264,21 +287,62 @@ void BlackBerryApplicationRunner::tailApplicationLog() this, SLOT(handleTailConnectionError())); } - const QString command = QLatin1String("tail -c +1 -f /accounts/1000/appdata/") + m_appId - + QLatin1String("/logs/log"); - + QString command; + if (m_slog2infoFound) { + command = QString::fromLatin1("slog2info -w"); + } else { + command = QLatin1String("tail -c +1 -f /accounts/1000/appdata/") + m_appId + + QLatin1String("/logs/log"); + } m_tailProcess->run(command.toLatin1(), m_sshParams); } +void BlackBerryApplicationRunner::handleSlog2InfoFound() +{ + QSsh::SshRemoteProcessRunner *process = qobject_cast<QSsh::SshRemoteProcessRunner *>(sender()); + QTC_ASSERT(process, return); + + m_slog2infoFound = (process->processExitCode() == 0); + + tailApplicationLog(); +} + void BlackBerryApplicationRunner::handleTailOutput() { QSsh::SshRemoteProcessRunner *process = qobject_cast<QSsh::SshRemoteProcessRunner *>(sender()); QTC_ASSERT(process, return); const QString message = QString::fromLatin1(process->readAllStandardOutput()); + if (m_slog2infoFound) { + const QStringList multiLine = message.split(QLatin1Char('\n')); + Q_FOREACH (const QString &line, multiLine) { + if ( line.contains(m_appId) ) { + QStringList validLineBeginnings; + validLineBeginnings << QLatin1String("qt-msg 0 ") + << QLatin1String("qt-msg* 0 ") + << QLatin1String(" 0 "); + Q_FOREACH (const QString &beginning, validLineBeginnings) { + if (showQtMessage(beginning, line)) + break; + } + } + } + return; + } emit output(message, Utils::StdOutFormat); } +bool BlackBerryApplicationRunner::showQtMessage(const QString& pattern, const QString& line) +{ + const int index = line.indexOf(pattern); + if (index != -1) { + const QString str = line.right(line.length()-index-pattern.length()) + QLatin1Char('\n'); + emit output(str, Utils::StdOutFormat); + return true; + } + return false; +} + void BlackBerryApplicationRunner::handleTailError() { QSsh::SshRemoteProcessRunner *process = qobject_cast<QSsh::SshRemoteProcessRunner *>(sender()); diff --git a/src/plugins/qnx/blackberryapplicationrunner.h b/src/plugins/qnx/blackberryapplicationrunner.h index c7da6e05f70377d077359f5dbad156d85d315c56..2993eb09f33605a2eb831703eba77049f6d92b37 100644 --- a/src/plugins/qnx/blackberryapplicationrunner.h +++ b/src/plugins/qnx/blackberryapplicationrunner.h @@ -62,7 +62,7 @@ public: public slots: void start(); - void tailApplicationLog(); + void checkSlog2Info(); signals: void output(const QString &msg, Utils::OutputFormat format); @@ -72,6 +72,8 @@ signals: void startFailed(const QString &msg); private slots: + bool showQtMessage(const QString& pattern, const QString& line); + void tailApplicationLog(); void startFinished(int exitCode, QProcess::ExitStatus exitStatus); void stopFinished(int exitCode, QProcess::ExitStatus exitStatus); @@ -86,11 +88,14 @@ private slots: void determineRunningState(); void readRunningStateStandardOutput(); + void handleSlog2InfoFound(); + private: void reset(); void killTailProcess(); bool m_debugMode; + bool m_slog2infoFound; qint64 m_pid; QString m_appId; @@ -108,7 +113,7 @@ private: QProcess *m_launchProcess; QProcess *m_stopProcess; QSsh::SshRemoteProcessRunner *m_tailProcess; - + QSsh::SshRemoteProcessRunner *m_testSlog2Process; QTimer *m_runningStateTimer; QProcess *m_runningStateProcess; }; diff --git a/src/plugins/qnx/blackberrydebugsupport.cpp b/src/plugins/qnx/blackberrydebugsupport.cpp index fbc46e3cfa5902df52a465b4973c95fd802c6a13..19823e54a2f8356a9f76567ac61937f8bf91ad75 100644 --- a/src/plugins/qnx/blackberrydebugsupport.cpp +++ b/src/plugins/qnx/blackberrydebugsupport.cpp @@ -58,7 +58,7 @@ BlackBerryDebugSupport::BlackBerryDebugSupport(BlackBerryRunConfiguration *runCo runControl, SLOT(appendMessage(QString,Utils::OutputFormat))); connect(m_runner, SIGNAL(started()), this, SLOT(handleStarted())); - connect(m_runner, SIGNAL(started()), m_runner, SLOT(tailApplicationLog())); + connect(m_runner, SIGNAL(started()), m_runner, SLOT(checkSlog2Info())); connect(m_runner, SIGNAL(startFailed(QString)), this, SLOT(handleStartFailed(QString))); connect(m_runner, SIGNAL(output(QString,Utils::OutputFormat)), this, SLOT(handleApplicationOutput(QString,Utils::OutputFormat))); diff --git a/src/plugins/qnx/blackberryruncontrol.cpp b/src/plugins/qnx/blackberryruncontrol.cpp index 408f14cd3f438982b5ad00a344ff4a0306671b34..89c8e8fcc15c198b5ba16df7cdb388e2444bbf95 100644 --- a/src/plugins/qnx/blackberryruncontrol.cpp +++ b/src/plugins/qnx/blackberryruncontrol.cpp @@ -93,5 +93,5 @@ void BlackBerryRunControl::launchTailProcess() { // Delay the launch of "tail" to ensure the blackberry-connect // connection has been properly established - QTimer::singleShot(500, m_runner, SLOT(tailApplicationLog())); + QTimer::singleShot(500, m_runner, SLOT(checkSlog2Info())); }