Commit f2bf0a5e authored by Friedemann Kleint's avatar Friedemann Kleint

Debugger: Move handling of 'Log timestamps' into outputwindow.

Remove some unused leftovers from DebuggerOuputWindow.
parent 0f0c1711
......@@ -34,6 +34,7 @@
#include <QtCore/QDebug>
#include <QtCore/QFile>
#include <QtCore/QTime>
#include <QtGui/QAction>
#include <QtGui/QHBoxLayout>
......@@ -411,6 +412,9 @@ void DebuggerOutputWindow::showOutput(int channel, const QString &output)
QTextCursor cursor = oldCursor;
cursor.movePosition(QTextCursor::End);
bool atEnd = oldCursor.position() == cursor.position();
if (theDebuggerBoolSetting(LogTimeStamps))
m_combinedText->appendPlainText(charForChannel(LogTime) + logTimeStamp());
foreach (QString line, output.split('\n')) {
// FIXME: QTextEdit asserts on really long lines...
const int n = 30000;
......@@ -431,6 +435,8 @@ void DebuggerOutputWindow::showOutput(int channel, const QString &output)
void DebuggerOutputWindow::showInput(int channel, const QString &input)
{
Q_UNUSED(channel)
if (theDebuggerBoolSetting(LogTimeStamps))
m_inputText->appendPlainText(logTimeStamp());
m_inputText->appendPlainText(input);
QTextCursor cursor = m_inputText->textCursor();
cursor.movePosition(QTextCursor::End);
......@@ -461,4 +467,27 @@ QString DebuggerOutputWindow::inputContents() const
return m_inputText->toPlainText();
}
QString DebuggerOutputWindow::logTimeStamp()
{
// Cache the last log time entry by ms. If time progresses,
// report the difference to the last time stamp in ms.
static const QString logTimeFormat(QLatin1String("hh:mm:ss.zzz"));
static QTime lastTime = QTime::currentTime();
static QString lastTimeStamp = lastTime.toString(logTimeFormat);
const QTime currentTime = QTime::currentTime();
if (currentTime != lastTime) {
const int elapsedMS = lastTime.msecsTo(currentTime);
lastTime = currentTime;
lastTimeStamp = lastTime.toString(logTimeFormat);
// Append time elapsed
QString rc = lastTimeStamp;
rc += QLatin1String(" [");
rc += QString::number(elapsedMS);
rc += QLatin1String("ms]");
return rc;
}
return lastTimeStamp;
}
#include "debuggeroutputwindow.moc"
......@@ -46,20 +46,15 @@ class DebuggerOutputWindow : public QWidget
Q_OBJECT
public:
DebuggerOutputWindow(QWidget *parent = 0);
explicit DebuggerOutputWindow(QWidget *parent = 0);
QWidget *outputWidget(QWidget *) { return this; }
QList<QWidget*> toolBarWidgets() const { return QList<QWidget *>(); }
QString name() const { return windowTitle(); }
void visibilityChanged(bool /*visible*/) {}
void bringPaneToForeground() { emit showPage(); }
void setCursor(const QCursor &cursor);
QString combinedContents() const;
QString inputContents() const;
static QString logTimeStamp();
public slots:
void clearContents();
void showOutput(int channel, const QString &output);
......
......@@ -66,6 +66,7 @@
#include "sourcefileswindow.h"
#include "debuggerdialogs.h"
#include "debuggeroutputwindow.h"
#include <utils/qtcassert.h>
#include <utils/fancymainwindow.h>
......@@ -312,25 +313,19 @@ void GdbEngine::readDebugeeOutput(const QByteArray &data)
void GdbEngine::handleResponse(const QByteArray &buff)
{
static QTime lastTime;
if (theDebuggerBoolSetting(LogTimeStamps))
showMessage(currentTime(), LogTime);
showMessage(QString::fromLocal8Bit(buff, buff.length()), LogOutput);
#if 0
static QTime lastTime;
qDebug() // << "#### start response handling #### "
<< currentTime()
<< lastTime.msecsTo(QTime::currentTime()) << "ms,"
<< "buf:" << buff.left(1500) << "..."
//<< "buf:" << buff
<< "size:" << buff.size();
lastTime = QTime::currentTime();
#else
//qDebug() << "buf:" << buff;
#endif
lastTime = QTime::currentTime();
if (buff.isEmpty() || buff == "(gdb) ")
return;
......@@ -2013,7 +2008,7 @@ void GdbEngine::setTokenBarrier()
PENDING_DEBUG("\n--- token barrier ---\n");
showMessage(_("--- token barrier ---"), LogMiscInput);
if (theDebuggerBoolSetting(LogTimeStamps))
showMessage(currentTime(), LogMiscInput);
showMessage(DebuggerOutputWindow::logTimeStamp(), LogMiscInput);
m_oldestAcceptableToken = currentToken();
}
......@@ -3369,7 +3364,7 @@ void GdbEngine::rebuildWatchModel()
m_processedNames.clear();
PENDING_DEBUG("REBUILDING MODEL" << count);
if (theDebuggerBoolSetting(LogTimeStamps))
showMessage(currentTime(), LogMiscInput);
showMessage(DebuggerOutputWindow::logTimeStamp(), LogMiscInput);
showMessage(_("<Rebuild Watchmodel %1>").arg(count), LogMiscInput);
showStatusMessage(tr("Finished retrieving data"), 400);
watchHandler()->endCycle();
......
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