forked from qt-creator/qt-creator
Blackberry uses slog2info now to debug.
Change-Id: I93a33ac96eceaf74b5d9a6a0f4d552ea690d60eb Reviewed-by: Tobias Nätterlund <tobias.naetterlund@kdab.com> Reviewed-by: Mehdi Fekari <mfekari@rim.com> Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
This commit is contained in:
committed by
Christian Kandeler
parent
530ebc4b0b
commit
6ddb0f7945
@@ -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()));
|
||||
|
||||
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
|
||||
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());
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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)));
|
||||
|
||||
@@ -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()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user