diff --git a/src/plugins/debugger/cdb/cdbdebugengine.cpp b/src/plugins/debugger/cdb/cdbdebugengine.cpp index 17f88931de046b1d774239b425a7a7299bdf95e9..f98eaa6a305b9d6b9c27e07cb9d668c2519066bf 100644 --- a/src/plugins/debugger/cdb/cdbdebugengine.cpp +++ b/src/plugins/debugger/cdb/cdbdebugengine.cpp @@ -121,7 +121,7 @@ static QString msgFunctionFailed(const char *func, const QString &why) CdbDebugEnginePrivate::CdbDebugEnginePrivate(DebuggerManager *manager, const QSharedPointer<CdbOptions> &options, - CdbDebugEngine* engine) : + CdbDebugEngine *engine) : m_options(options), m_hDebuggeeProcess(0), m_hDebuggeeThread(0), @@ -149,16 +149,12 @@ bool CdbDebugEnginePrivate::init(QString *errorMessage) if (!CdbCore::CoreEngine::init(m_options->path, errorMessage)) return false; - CdbDebugOutput *output = new CdbDebugOutput; + CdbDebugOutput *output = new CdbDebugOutput(m_engine); setDebugOutput(DebugOutputBasePtr(output)); connect(output, SIGNAL(debuggerOutput(int,QString)), manager(), SLOT(showDebuggerOutput(int,QString))); connect(output, SIGNAL(debuggerInputPrompt(int,QString)), manager(), SLOT(showDebuggerInput(int,QString))); - connect(output, SIGNAL(debuggeeOutput(QString,bool)), - manager(), SLOT(showApplicationOutput(QString,bool))); - connect(output, SIGNAL(debuggeeInputPrompt(QString,bool)), - manager(), SLOT(showApplicationOutput(QString,bool))); setDebugEventCallback(DebugEventCallbackBasePtr(new CdbDebugEventCallback(m_engine))); updateCodeLevel(); diff --git a/src/plugins/debugger/cdb/cdbdebugoutput.cpp b/src/plugins/debugger/cdb/cdbdebugoutput.cpp index 6d55d3326c68f56868dc80269dbf7e06c958ce6e..f9e8d23be7ecc14c552ec4c2b1d91625cd8c06f8 100644 --- a/src/plugins/debugger/cdb/cdbdebugoutput.cpp +++ b/src/plugins/debugger/cdb/cdbdebugoutput.cpp @@ -31,6 +31,7 @@ #include "cdbdebugengine.h" #include "cdbdebugengine_p.h" #include "cdbcom.h" +#include "debuggerrunner.h" namespace Debugger { namespace Internal { @@ -62,27 +63,30 @@ static inline OutputKind outputKind(ULONG mask) return DebuggerOutput; } -CdbDebugOutput::CdbDebugOutput() +CdbDebugOutput::CdbDebugOutput(CdbDebugEngine *engine) + : m_engine(engine) { } void CdbDebugOutput::output(ULONG mask, const QString &msg) { + DebuggerRunControl *runControl = m_engine->runControl(); + QTC_ASSER(runControl, return); if (debugCDB > 1) qDebug() << Q_FUNC_INFO << "\n " << msg; switch (outputKind(mask)) { case DebuggerOutput: - debuggerOutput(logChannel(mask), msg); + runControl->showDebuggerOutput(msg, logChannel(mask)); break; case DebuggerPromptOutput: - emit debuggerInputPrompt(logChannel(mask), msg); + runControl->showDebuggerInput(msg, logChannel(mask)); break; case DebuggeeOutput: - emit debuggeeOutput(msg, true); + runControl->showApplicationOutput(msg, true); break; case DebuggeePromptOutput: - emit debuggeeInputPrompt(msg, false); + runControl->showApplicationOutput(msg, false); break; } } diff --git a/src/plugins/debugger/cdb/cdbdebugoutput.h b/src/plugins/debugger/cdb/cdbdebugoutput.h index 989c937ca541c7bf8290c07e035aeec9a6989a8e..c0e2fed867b7cc927483e56497b2340ed71fd578 100644 --- a/src/plugins/debugger/cdb/cdbdebugoutput.h +++ b/src/plugins/debugger/cdb/cdbdebugoutput.h @@ -38,20 +38,16 @@ namespace Debugger { namespace Internal { // Standard CDB output handler -class CdbDebugOutput : public QObject, public CdbCore::DebugOutputBase +class CdbDebugOutput : public CdbCore::DebugOutputBase { - Q_OBJECT public: - CdbDebugOutput(); + explicit CdbDebugOutput(CdbDebugEngine *engine); protected: virtual void output(ULONG mask, const QString &message); -signals: - void debuggerOutput(int channel, const QString &message); - void debuggerInputPrompt(int channel, const QString &message); - void debuggeeOutput(const QString &message, bool onStderr); - void debuggeeInputPrompt(const QString &message, bool onStderr); +private: + CdbDebugEngine *m_engine; }; } // namespace Internal diff --git a/src/plugins/debugger/debuggeragents.cpp b/src/plugins/debugger/debuggeragents.cpp index 2258c66083f02703e46faf041d23495a1db85f5e..9c7a62ea194629e6613131db49205bc1c5714b0b 100644 --- a/src/plugins/debugger/debuggeragents.cpp +++ b/src/plugins/debugger/debuggeragents.cpp @@ -261,7 +261,9 @@ void DisassemblerViewAgent::setFrame(const StackFrame &frame, bool tryMixed) if (it != d->cache.end()) { QString msg = _("Use cache disassembler for '%1' in '%2'") .arg(frame.function).arg(frame.file); - d->manager->showDebuggerOutput(msg); + QTC_ASSERT(d->manager->runControl(), /**/); + if (d->manager->runControl()) + d->manager->runControl()->showDebuggerOutput(msg); setContents(*it); return; } diff --git a/src/plugins/debugger/debuggermanager.cpp b/src/plugins/debugger/debuggermanager.cpp index 2e5e9939b06fa1e8bbf23cb920c55b31bb5a44dd..3697cea36edffeaee20420f468e4359f592237d5 100644 --- a/src/plugins/debugger/debuggermanager.cpp +++ b/src/plugins/debugger/debuggermanager.cpp @@ -107,7 +107,7 @@ // use Q_FUNC_INFO? # define STATE_DEBUG(s) \ do { QString msg; QTextStream ts(&msg); ts << s; \ - showDebuggerOutput(LogDebug, msg); } while (0) + showDebuggerOutput(msg, LogDebug); } while (0) #else # define STATE_DEBUG(s) #endif @@ -504,12 +504,6 @@ void DebuggerManager::init() connect(localsView->header(), SIGNAL(sectionResized(int,int,int)), this, SLOT(updateWatchersHeader(int,int,int)), Qt::QueuedConnection); - // Log - connect(this, SIGNAL(emitShowInput(int, QString)), - d->m_outputWindow, SLOT(showInput(int, QString)), Qt::QueuedConnection); - connect(this, SIGNAL(emitShowOutput(int, QString)), - d->m_outputWindow, SLOT(showOutput(int, QString)), Qt::QueuedConnection); - // Tooltip qRegisterMetaType<WatchData>("WatchData"); qRegisterMetaType<StackCookie>("StackCookie"); @@ -836,7 +830,7 @@ void DebuggerManager::clearStatusMessage() void DebuggerManager::showStatusMessage(const QString &msg0, int timeout) { Q_UNUSED(timeout) - showDebuggerOutput(LogStatus, msg0); + showDebuggerOutput(msg0, LogStatus); QString msg = msg0; msg.replace(QLatin1Char('\n'), QString()); d->m_statusLabel->setText(msg); @@ -877,11 +871,6 @@ void DebuggerManager::notifyInferiorPidChanged(qint64 pid) } } -void DebuggerManager::showApplicationOutput(const QString &str, bool onStdErr) -{ - emit applicationOutputAvailable(str, onStdErr); -} - void DebuggerManager::aboutToShutdown() { STATE_DEBUG(d->m_engine); @@ -1071,9 +1060,8 @@ void DebuggerManager::startNewDebugger(DebuggerRunControl *runControl) ProjectExplorer::ToolChain::ToolChainType(sp->toolChainType)); d->m_plugin->activateDebugMode(); - showDebuggerOutput(LogStatus, - tr("Starting debugger for tool chain '%1'...").arg(toolChainName)); - showDebuggerOutput(LogDebug, DebuggerSettings::instance()->dump()); + showDebuggerOutput(tr("Starting debugger for tool chain '%1'...").arg(toolChainName), LogStatus); + showDebuggerOutput(DebuggerSettings::instance()->dump(), LogDebug); QString errorMessage; QString settingsIdHint; @@ -1583,31 +1571,12 @@ void DebuggerManager::modulesDockToggled(bool on) reloadModules(); } - -////////////////////////////////////////////////////////////////////// -// -// Output specific stuff -// -////////////////////////////////////////////////////////////////////// - -void DebuggerManager::showDebuggerOutput(int channel, const QString &msg) +void DebuggerManager::showDebuggerOutput(const QString &msg, int channel) { - if (d->m_outputWindow) { - emit emitShowOutput(channel, msg); - if (channel == LogError) - ensureLogVisible(); - } else { + if (runControl()) + runControl()->showDebuggerOutput(msg, channel); + else qDebug() << "OUTPUT: " << channel << msg; - - } -} - -void DebuggerManager::showDebuggerInput(int channel, const QString &msg) -{ - if (d->m_outputWindow) - emit emitShowInput(channel, msg); - else - qDebug() << "INPUT: " << channel << msg; } @@ -1807,7 +1776,7 @@ void DebuggerManager::setState(DebuggerState state, bool forced) if (!forced && !isAllowedTransition(d->m_state, state)) qDebug() << "UNEXPECTED STATE TRANSITION: " << msg; - showDebuggerOutput(LogDebug, msg); + showDebuggerOutput(msg, LogDebug); //resetLocation(); if (state == d->m_state) @@ -2034,6 +2003,12 @@ DebuggerRunControl *DebuggerManager::runControl() const return const_cast<DebuggerRunControl *>(d->m_runControl); } +DebuggerOutputWindow *DebuggerManager::debuggerOutputWindow() const +{ + return d->m_outputWindow; +} + + ////////////////////////////////////////////////////////////////////// // // AbstractDebuggerEngine @@ -2055,6 +2030,7 @@ void IDebuggerEngine::setState(DebuggerState state, bool forced) m_manager->setState(state, forced); } + ////////////////////////////////////////////////////////////////////// // // Testing diff --git a/src/plugins/debugger/debuggermanager.h b/src/plugins/debugger/debuggermanager.h index 1da2ba552007e0fe5ef4993d730cf85e9082d4de..492cc830937b626b7b4545cd289db46d40b3e1d0 100644 --- a/src/plugins/debugger/debuggermanager.h +++ b/src/plugins/debugger/debuggermanager.h @@ -235,18 +235,12 @@ public slots: static const char *stateName(int s); public slots: // FIXME - void showDebuggerOutput(const QString &msg) - { showDebuggerOutput(LogDebug, msg); } void ensureLogVisible(); void updateWatchersWindow(); void updateWatchersHeader(int section, int oldSize, int newSize); void activateBreakpoint(int index); //private slots: // FIXME - void showDebuggerOutput(int channel, const QString &msg); - void showDebuggerInput(int channel, const QString &msg); - void showApplicationOutput(const QString &data, bool onStdErr); - void reloadSourceFiles(); void sourceFilesDockToggled(bool on); @@ -271,6 +265,7 @@ public: Internal::ThreadsHandler *threadsHandler() const; Internal::WatchHandler *watchHandler() const; Internal::SnapshotHandler *snapshotHandler() const; + Internal::DebuggerOutputWindow *debuggerOutputWindow() const; private: Internal::SourceFilesWindow *sourceFileWindow() const; @@ -316,12 +311,11 @@ signals: void statusMessageRequested(const QString &msg, int timeout); // -1 for 'forever' void applicationOutputAvailable(const QString &output, bool onStdErr); void messageAvailable(const QString &output, bool isError); - void emitShowOutput(int channel, const QString &output); - void emitShowInput(int channel, const QString &input); private: void init(); // void runTest(const QString &fileName); + void showDebuggerOutput(const QString &msg, int channel); Q_SLOT void createNewDock(QWidget *widget); void aboutToShutdown(); diff --git a/src/plugins/debugger/debuggerrunner.cpp b/src/plugins/debugger/debuggerrunner.cpp index a5b4fe1e2c3a893b4b463e3abe5d4bc3821f8230..41bcd22dd12283490042aab86842335d369f865c 100644 --- a/src/plugins/debugger/debuggerrunner.cpp +++ b/src/plugins/debugger/debuggerrunner.cpp @@ -29,6 +29,7 @@ #include "debuggerrunner.h" #include "debuggermanager.h" +#include "debuggeroutputwindow.h" #include <projectexplorer/debugginghelper.h> #include <projectexplorer/environment.h> @@ -48,6 +49,8 @@ #include <QtGui/QTextDocument> using namespace ProjectExplorer; +using namespace Debugger::Internal; + namespace Debugger { @@ -147,9 +150,6 @@ DebuggerRunControl::DebuggerRunControl(DebuggerManager *manager, connect(m_manager, SIGNAL(debuggingFinished()), this, SLOT(debuggingFinished()), Qt::QueuedConnection); - connect(m_manager, SIGNAL(applicationOutputAvailable(QString, bool)), - this, SLOT(slotAddToOutputWindowInline(QString, bool)), - Qt::QueuedConnection); connect(m_manager, SIGNAL(messageAvailable(QString, bool)), this, SLOT(slotMessageAvailable(QString, bool))); connect(m_manager, SIGNAL(inferiorPidChanged(qint64)), @@ -161,6 +161,7 @@ DebuggerRunControl::DebuggerRunControl(DebuggerManager *manager, if (m_startParameters.environment.empty()) m_startParameters.environment = ProjectExplorer::Environment().toStringList(); m_startParameters.useTerminal = false; + } QString DebuggerRunControl::displayName() const @@ -183,21 +184,19 @@ void DebuggerRunControl::start() QString errorMessage; QString settingsCategory; QString settingsPage; - if (m_manager->checkDebugConfiguration(m_startParameters.toolChainType, &errorMessage, - &settingsCategory, &settingsPage)) { + if (m_manager->checkDebugConfiguration(m_startParameters.toolChainType, + &errorMessage, &settingsCategory, &settingsPage)) { m_manager->startNewDebugger(this); emit started(); } else { appendMessage(this, errorMessage, true); emit finished(); - Core::ICore::instance()->showWarningWithOptions(tr("Debugger"), errorMessage, - QString(), - settingsCategory, settingsPage); + Core::ICore::instance()->showWarningWithOptions(tr("Debugger"), + errorMessage, QString(), settingsCategory, settingsPage); } } -void DebuggerRunControl::slotAddToOutputWindowInline(const QString &data, - bool onStdErr) +void DebuggerRunControl::showApplicationOutput(const QString &data, bool onStdErr) { emit addToOutputWindowInline(this, data, onStdErr); } @@ -207,6 +206,20 @@ void DebuggerRunControl::slotMessageAvailable(const QString &data, bool isError) emit appendMessage(this, data, isError); } +void DebuggerRunControl::showDebuggerOutput(const QString &output, int channel) +{ + DebuggerOutputWindow *ow = m_manager->debuggerOutputWindow(); + QTC_ASSERT(ow, return); + ow->showOutput(channel, output); +} + +void DebuggerRunControl::showDebuggerInput(const QString &input, int channel) +{ + DebuggerOutputWindow *ow = m_manager->debuggerOutputWindow(); + QTC_ASSERT(ow, return); + ow->showInput(channel, input); +} + void DebuggerRunControl::stop() { m_running = false; diff --git a/src/plugins/debugger/debuggerrunner.h b/src/plugins/debugger/debuggerrunner.h index ec72a53c79d714f06887aa688c80c12079b56a1b..7a725d56b2c9f7ea5180c178feb273d068e95a71 100644 --- a/src/plugins/debugger/debuggerrunner.h +++ b/src/plugins/debugger/debuggerrunner.h @@ -129,14 +129,20 @@ public: signals: void stopRequested(); +public slots: + void showDebuggerOutput(const QString &msg) + { showDebuggerOutput(msg, LogDebug); } + void showApplicationOutput(const QString &output, bool onStdErr); + void showDebuggerOutput(const QString &output, int channel); + void showDebuggerInput(const QString &input, int channel); + private slots: - void slotAddToOutputWindowInline(const QString &output, bool onStdErr); void slotMessageAvailable(const QString &data, bool isError); private: void init(); - DebuggerManager *m_manager; DebuggerStartParameters m_startParameters; + DebuggerManager *m_manager; bool m_running; }; diff --git a/src/plugins/debugger/gdb/abstractgdbadapter.h b/src/plugins/debugger/gdb/abstractgdbadapter.h index 27ab138de409f5abedf98f6d0f202ff82761f02f..7caad479b3ba9fea05ee0858309d2c3b76d8f09a 100644 --- a/src/plugins/debugger/gdb/abstractgdbadapter.h +++ b/src/plugins/debugger/gdb/abstractgdbadapter.h @@ -107,7 +107,7 @@ protected: { m_engine->setState(state); } const DebuggerStartParameters &startParameters() const { return m_engine->startParameters(); } - const DebuggerRunControl *runControl() const + DebuggerRunControl *runControl() const { return m_engine->runControl(); } void debugMessage(const QString &msg) const { m_engine->debugMessage(msg); } diff --git a/src/plugins/debugger/gdb/classicgdbengine.cpp b/src/plugins/debugger/gdb/classicgdbengine.cpp index 675efccdbc71fca6f259a202a320d897786c21a4..e88dce268c3fcfbf023fe0c39a5e8b7624f9662d 100644 --- a/src/plugins/debugger/gdb/classicgdbengine.cpp +++ b/src/plugins/debugger/gdb/classicgdbengine.cpp @@ -160,8 +160,8 @@ void GdbEngine::runDebuggingHelperClassic(const WatchData &data0, bool dumpChild // Avoid endless loops created by faulty dumpers. QByteArray processedName = QByteArray::number(dumpChildren) + '-' + data.iname; if (m_processedNames.contains(processedName)) { - showDebuggerInput(LogStatus, - _("<Breaking endless loop for " + data.iname + '>')); + showDebuggerInput( + _("<Breaking endless loop for " + data.iname + '>'), LogStatus); data.setAllUnneeded(); data.setValue(_("<unavailable>")); data.setHasChildren(false); diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 81ebabb095cae672ed89f28c4c07870a7d58106a..03348580bbff8e6af2db5ca8cd3c39b35780de27 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -343,7 +343,7 @@ void GdbEngine::readDebugeeOutput(const QByteArray &data) void GdbEngine::debugMessage(const QString &msg) { - showDebuggerOutput(LogDebug, msg); + showDebuggerOutput(msg, LogDebug); } void GdbEngine::handleResponse(const QByteArray &buff) @@ -351,8 +351,8 @@ void GdbEngine::handleResponse(const QByteArray &buff) static QTime lastTime; if (theDebuggerBoolSetting(LogTimeStamps)) - showDebuggerOutput(LogTime, currentTime()); - showDebuggerOutput(LogOutput, QString::fromLocal8Bit(buff, buff.length())); + showDebuggerOutput(currentTime(), LogTime); + showDebuggerOutput(QString::fromLocal8Bit(buff, buff.length()), LogOutput); #if 0 qDebug() // << "#### start response handling #### " @@ -824,7 +824,7 @@ void GdbEngine::flushCommand(const GdbCommand &cmd0) { GdbCommand cmd = cmd0; if (state() == DebuggerNotReady) { - showDebuggerInput(LogInput, _(cmd.command)); + showDebuggerInput(_(cmd.command), LogInput); debugMessage(_("GDB PROCESS NOT RUNNING, PLAIN CMD IGNORED: " + cmd.command)); return; } @@ -833,7 +833,7 @@ void GdbEngine::flushCommand(const GdbCommand &cmd0) cmd.postTime = QTime::currentTime(); m_cookieForToken[currentToken()] = cmd; cmd.command = QByteArray::number(currentToken()) + cmd.command; - showDebuggerInput(LogInput, _(cmd.command)); + showDebuggerInput(_(cmd.command), LogInput); m_gdbAdapter->write(cmd.command + "\r\n"); @@ -958,9 +958,10 @@ void GdbEngine::handleResultRecord(GdbResponse *response) GdbCommand cmd = m_cookieForToken.take(token); if (theDebuggerBoolSetting(LogTimeStamps)) { - showDebuggerOutput(LogTime, _("Response time: %1: %2 s") + showDebuggerOutput(_("Response time: %1: %2 s") .arg(_(cmd.command)) - .arg(cmd.postTime.msecsTo(QTime::currentTime()) / 1000.)); + .arg(cmd.postTime.msecsTo(QTime::currentTime()) / 1000.), + LogTime); } if (response->token < m_oldestAcceptableToken && (cmd.flags & Discardable)) { @@ -2049,9 +2050,9 @@ void GdbEngine::setTokenBarrier() ); } PENDING_DEBUG("\n--- token barrier ---\n"); - showDebuggerInput(LogMisc, _("--- token barrier ---")); + showDebuggerInput(_("--- token barrier ---"), LogMisc); if (theDebuggerBoolSetting(LogTimeStamps)) - showDebuggerInput(LogMisc, currentTime()); + showDebuggerInput(currentTime(), LogMisc); m_oldestAcceptableToken = currentToken(); } @@ -3375,8 +3376,8 @@ void GdbEngine::updateWatchData(const WatchData &data) //qDebug() << "PROCESSED NAMES: " << processedName << m_processedNames; if (m_processedNames.contains(processedName)) { WatchData data1 = data; - showDebuggerInput(LogStatus, - _("<Breaking endless loop for " + data.iname + '>')); + showDebuggerInput(_("<Breaking endless loop for " + data.iname + '>'), + LogStatus); data1.setAllUnneeded(); data1.setValue(_("<unavailable>")); data1.setHasChildren(false); @@ -3427,8 +3428,8 @@ void GdbEngine::rebuildWatchModel() m_processedNames.clear(); PENDING_DEBUG("REBUILDING MODEL" << count); if (theDebuggerBoolSetting(LogTimeStamps)) - showDebuggerInput(LogMisc, currentTime()); - showDebuggerInput(LogStatus, _("<Rebuild Watchmodel %1>").arg(count)); + showDebuggerInput(currentTime(), LogMisc); + showDebuggerInput(_("<Rebuild Watchmodel %1>").arg(count), LogStatus); showStatusMessage(tr("Finished retrieving data"), 400); manager()->watchHandler()->endCycle(); showToolTip(); @@ -3456,7 +3457,7 @@ void GdbEngine::sendWatchParameters(const QByteArray ¶ms0) const QByteArray inBufferCmd = arrayFillCommand("qDumpInBuffer", params); params.replace('\0','!'); - showDebuggerInput(LogMisc, QString::fromUtf8(params)); + showDebuggerInput(QString::fromUtf8(params), LogMisc); params.clear(); params.append('\0'); @@ -4033,14 +4034,13 @@ bool GdbEngine::startGdb(const QStringList &args, const QString &gdb, const QStr // Check for existing values. if (environment.contains(pythonPathVariable)) { const QString oldPythonPath = environment.value(pythonPathVariable); - manager()->showDebuggerOutput(LogMisc, - _("Using existing python path: %1").arg(oldPythonPath)); + showDebuggerOutput(_("Using existing python path: %1") + .arg(oldPythonPath), LogMisc); } else { const QString pythonPath = QDir::toNativeSeparators(dir.absoluteFilePath(winPythonVersion)); environment.insert(pythonPathVariable, pythonPath); - manager()->showDebuggerOutput(LogMisc, - _("Python path: %1").arg(pythonPath)); + showDebuggerOutput(_("Python path: %1").arg(pythonPath), LogMisc); gdbProc()->setProcessEnvironment(environment); } foundPython = true; diff --git a/src/plugins/debugger/gdb/remotegdbserveradapter.cpp b/src/plugins/debugger/gdb/remotegdbserveradapter.cpp index 37ad747a6c379518e0767dba9b5471296246d280..8d26c85b8ce47db5fd9365eae889654cd66143b9 100644 --- a/src/plugins/debugger/gdb/remotegdbserveradapter.cpp +++ b/src/plugins/debugger/gdb/remotegdbserveradapter.cpp @@ -142,13 +142,13 @@ void RemoteGdbServerAdapter::uploadProcError(QProcess::ProcessError error) void RemoteGdbServerAdapter::readUploadStandardOutput() { QByteArray ba = m_uploadProc.readAllStandardOutput(); - m_engine->showDebuggerOutput(LogOutput, QString::fromLocal8Bit(ba, ba.length())); + runControl()->showDebuggerOutput(QString::fromLocal8Bit(ba, ba.length()), LogOutput); } void RemoteGdbServerAdapter::readUploadStandardError() { QByteArray ba = m_uploadProc.readAllStandardError(); - m_engine->showDebuggerOutput(LogError, QString::fromLocal8Bit(ba, ba.length())); + runControl()->showDebuggerOutput(QString::fromLocal8Bit(ba, ba.length()), LogError); } void RemoteGdbServerAdapter::startInferior() diff --git a/src/plugins/debugger/gdb/remoteplaingdbadapter.cpp b/src/plugins/debugger/gdb/remoteplaingdbadapter.cpp index 77443ad75382b167c11f5df5289cfd4b62dd451a..14d6eceb7db54c57e3216b98ea1b8e83be6eaf70 100644 --- a/src/plugins/debugger/gdb/remoteplaingdbadapter.cpp +++ b/src/plugins/debugger/gdb/remoteplaingdbadapter.cpp @@ -86,7 +86,8 @@ QString RemotePlainGdbAdapter::fromLocalEncoding(const QByteArray &b) const void RemotePlainGdbAdapter::handleApplicationOutput(const QByteArray &output) { - m_engine->manager()->showApplicationOutput(output, false); + QTC_ASSERT(m_engine->runControl(), return); + m_engine->runControl()->showApplicationOutput(output, false); } } // namespace Internal diff --git a/src/plugins/debugger/gdb/trkgdbadapter.cpp b/src/plugins/debugger/gdb/trkgdbadapter.cpp index 20912fd32d47f050c6b42764e06f2f2d8c20cef2..a54f5b733a935d18b43e88a7ea5ae08fd7655297 100644 --- a/src/plugins/debugger/gdb/trkgdbadapter.cpp +++ b/src/plugins/debugger/gdb/trkgdbadapter.cpp @@ -1139,7 +1139,7 @@ void TrkGdbAdapter::handleTrkResult(const TrkResult &result) trk::Launcher::parseNotifyStopped(result.data, &pid, &tid, &addr, &reason); const QString msg = trk::Launcher::msgStopped(pid, tid, addr, reason); logMessage(prefix + msg); - m_engine->manager()->showDebuggerOutput(LogMisc, msg); + runControl()->showDebuggerOutput(msg, LogMisc); sendTrkAck(result.token); if (addr) { // Todo: Do not send off GdbMessages if a synced gdb diff --git a/src/plugins/debugger/idebuggerengine.cpp b/src/plugins/debugger/idebuggerengine.cpp index de8d7eefe1af2fc83511919a7069f91021dbd153..5e61071a024cd55a6f2c83cd4f770fde26b2d4f8 100644 --- a/src/plugins/debugger/idebuggerengine.cpp +++ b/src/plugins/debugger/idebuggerengine.cpp @@ -30,6 +30,8 @@ #include "idebuggerengine.h" #include "debuggermanager.h" +#include <utils/qtcassert.h> + namespace Debugger { namespace Internal { @@ -56,14 +58,16 @@ bool IDebuggerEngine::checkConfiguration(int toolChain, return true; } -void IDebuggerEngine::showDebuggerInput(int channel, const QString &msg) +void IDebuggerEngine::showDebuggerInput(const QString &msg, int channel) const { - m_manager->showDebuggerInput(channel, msg); + QTC_ASSERT(runControl(), return); + runControl()->showDebuggerInput(msg, channel); } -void IDebuggerEngine::showDebuggerOutput(int channel, const QString &msg) +void IDebuggerEngine::showDebuggerOutput(const QString &msg, int channel) const { - m_manager->showDebuggerOutput(channel, msg); + QTC_ASSERT(runControl(), return); + runControl()->showDebuggerOutput(msg, channel); } } // namespace Internal diff --git a/src/plugins/debugger/idebuggerengine.h b/src/plugins/debugger/idebuggerengine.h index 605e66253f13417faa87162df6236c77d141aa92..1880a67acf6bd371fef4c665c8a72f0ae092ac48 100644 --- a/src/plugins/debugger/idebuggerengine.h +++ b/src/plugins/debugger/idebuggerengine.h @@ -133,8 +133,8 @@ public: virtual QString qtNamespace() const { return QString(); } // Convenience - void showDebuggerInput(int channel, const QString &msg); - void showDebuggerOutput(int channel, const QString &msg); + void showDebuggerInput(const QString &msg, int channel = LogDebug) const; + void showDebuggerOutput(const QString &msg, int channel = LogDebug) const; protected: void showStatusMessage(const QString &msg, int timeout = -1); diff --git a/src/plugins/debugger/pdb/pdbengine.cpp b/src/plugins/debugger/pdb/pdbengine.cpp index 1746e6d40589b4ecef0b75d85fe3ebcdb5d7df07..6910bc87fb02cfa97b6ce03082717900a245da33 100644 --- a/src/plugins/debugger/pdb/pdbengine.cpp +++ b/src/plugins/debugger/pdb/pdbengine.cpp @@ -94,7 +94,7 @@ void PdbEngine::executeDebuggerCommand(const QString &command) { XSDEBUG("PdbEngine::executeDebuggerCommand:" << command); if (state() == DebuggerNotReady) { - debugMessage(_("PDB PROCESS NOT RUNNING, PLAIN CMD IGNORED: ") + command); + showDebuggerOutput(_("PDB PROCESS NOT RUNNING, PLAIN CMD IGNORED: ") + command); return; } m_pdbProc.write(command.toLatin1() + "\n"); @@ -112,7 +112,7 @@ void PdbEngine::postCommand(const QByteArray &command, cmd.callbackName = callbackName; cmd.cookie = cookie; m_commands.enqueue(cmd); - showDebuggerInput(LogMisc, _(cmd.command)); + showDebuggerInput(_(cmd.command), LogInput); m_pdbProc.write(cmd.command + "\n"); } @@ -144,9 +144,9 @@ void PdbEngine::startDebugger() m_scriptFileName = QFileInfo(runControl()->sp().executable).absoluteFilePath(); QFile scriptFile(m_scriptFileName); if (!scriptFile.open(QIODevice::ReadOnly|QIODevice::Text)) { - //debugMessage("STARTING " +m_scriptFileName + "FAILED"); - manager()->showDebuggerOutput(LogError, QString::fromLatin1("Cannot open %1: %2"). - arg(m_scriptFileName, scriptFile.errorString())); + //showDebuggerOutput("STARTING " +m_scriptFileName + "FAILED"); + showDebuggerOutput(QString::fromLatin1("Cannot open %1: %2"). + arg(m_scriptFileName, scriptFile.errorString()), LogError); emit startFailed(); return; } @@ -158,7 +158,7 @@ void PdbEngine::startDebugger() m_pdbProc.disconnect(); // From any previous runs m_pdb = _("/usr/bin/python"); - debugMessage(_("STARTING PDB ") + m_pdb); + showDebuggerOutput(_("STARTING PDB ") + m_pdb); QStringList gdbArgs; gdbArgs += _("-i"); gdbArgs += _("/usr/bin/pdb"); @@ -186,7 +186,7 @@ void PdbEngine::startDebugger() const QString msg = tr("Unable to start pdb '%1': %2") .arg(m_pdb, m_pdbProc.errorString()); setState(AdapterStartFailed); - debugMessage(_("ADAPTER START FAILED")); + showDebuggerOutput(_("ADAPTER START FAILED")); if (!msg.isEmpty()) { const QString title = tr("Adapter start failed"); Core::ICore::instance()->showWarningWithOptions(title, msg); @@ -200,7 +200,7 @@ void PdbEngine::startDebugger() setState(InferiorRunning); attemptBreakpointSynchronization(); - debugMessage(_("PDB STARTED, INITIALIZING IT")); + showDebuggerOutput(_("PDB STARTED, INITIALIZING IT")); const QByteArray dumperSourcePath = Core::ICore::instance()->resourcePath().toLocal8Bit() + "/gdbmacros/"; postCommand("execfile('" + dumperSourcePath + "pdumper.py')", @@ -556,7 +556,7 @@ void PdbEngine::updateWatchData(const WatchData &data) void PdbEngine::handlePdbError(QProcess::ProcessError error) { - debugMessage(_("HANDLE PDB ERROR")); + showDebuggerOutput(_("HANDLE PDB ERROR")); switch (error) { case QProcess::Crashed: break; // will get a processExited() as well @@ -602,7 +602,7 @@ QString PdbEngine::errorMessage(QProcess::ProcessError error) const void PdbEngine::handlePdbFinished(int code, QProcess::ExitStatus type) { - debugMessage(_("PDB PROCESS FINISHED, status %1, code %2").arg(type).arg(code)); + showDebuggerOutput(_("PDB PROCESS FINISHED, status %1, code %2").arg(type).arg(code)); //shutdown(); //initializeVariables(); setState(DebuggerNotReady, true); @@ -612,7 +612,7 @@ void PdbEngine::readPdbStandardError() { QByteArray err = m_pdbProc.readAllStandardError(); qWarning() << "Unexpected pdb stderr:" << err; - showDebuggerOutput(LogDebug, _("Unexpected pdb stderr: " + err)); + showDebuggerOutput(_("Unexpected pdb stderr: " + err)); } void PdbEngine::readPdbStandardOutput() @@ -623,7 +623,7 @@ void PdbEngine::readPdbStandardOutput() while ((pos = m_inbuffer.indexOf("(Pdb)")) != -1) { PdbResponse response; response.data = m_inbuffer.left(pos).trimmed(); - showDebuggerOutput(LogDebug, _(response.data)); + showDebuggerOutput(_(response.data)); m_inbuffer = m_inbuffer.mid(pos + 6); QTC_ASSERT(!m_commands.isEmpty(), qDebug() << "RESPONSE: " << response.data; return) @@ -806,11 +806,6 @@ void PdbEngine::handleLoadDumper(const PdbResponse &response) continueInferior(); } -void PdbEngine::debugMessage(const QString &msg) -{ - showDebuggerOutput(LogDebug, msg); -} - unsigned PdbEngine::debuggerCapabilities() const { return ReloadModuleCapability; diff --git a/src/plugins/debugger/pdb/pdbengine.h b/src/plugins/debugger/pdb/pdbengine.h index c3c8de919f28e3d618b53b26de6004451f1b8e02..9c91364372119b72795d44a77aeb9395a25344c9 100644 --- a/src/plugins/debugger/pdb/pdbengine.h +++ b/src/plugins/debugger/pdb/pdbengine.h @@ -105,7 +105,6 @@ private: void updateWatchData(const WatchData &data); private: - void debugMessage(const QString &msg); QString errorMessage(QProcess::ProcessError error) const; unsigned debuggerCapabilities() const; diff --git a/src/plugins/debugger/qml/qmlengine.cpp b/src/plugins/debugger/qml/qmlengine.cpp index c52151caef640271ce0bd54d8acda078eb40beeb..1598ca2975221aa527aa9ff95ecbb611c33438b9 100644 --- a/src/plugins/debugger/qml/qmlengine.cpp +++ b/src/plugins/debugger/qml/qmlengine.cpp @@ -460,7 +460,7 @@ void QmlEngine::sendCommandNow(const QmlCommand &cmd) int result = m_socket->write(cmd.command); Q_UNUSED(result) m_socket->flush(); - showDebuggerInput(LogInput, QString::number(cmd.token) + " " + cmd.toString()); + showDebuggerInput(QString::number(cmd.token) + " " + cmd.toString(), LogInput); SDEBUG("SEND " << cmd.toString()); //<< " " << QString::number(result)); } @@ -536,11 +536,6 @@ void QmlEngine::updateSubItem(const WatchData &data0) QTC_ASSERT(false, return); } -void QmlEngine::debugMessage(const QString &msg) -{ - showDebuggerOutput(LogDebug, msg); -} - IDebuggerEngine *createQmlEngine(DebuggerManager *manager) { return new QmlEngine(manager); diff --git a/src/plugins/debugger/qml/qmlengine.h b/src/plugins/debugger/qml/qmlengine.h index d9b7636221721c9d61886f5426d92d4184e406ca..1667d2383e6f1ee1fb0e46b9fdeee4105418de9f 100644 --- a/src/plugins/debugger/qml/qmlengine.h +++ b/src/plugins/debugger/qml/qmlengine.h @@ -141,7 +141,6 @@ private: void postCommand(const QByteArray &cmd, QmlCommandCallback callback = 0, const char *callbackName = 0); void sendCommandNow(const QmlCommand &command); - void debugMessage(const QString &msg); QHash<int, QmlCommand> m_cookieForToken; diff --git a/src/plugins/debugger/script/scriptengine.cpp b/src/plugins/debugger/script/scriptengine.cpp index 6d2a06aa9742a0579e05b8d75f94e62baa71414e..63433c46b7b2fb4859ea841ef46705b766dfa712 100644 --- a/src/plugins/debugger/script/scriptengine.cpp +++ b/src/plugins/debugger/script/scriptengine.cpp @@ -128,7 +128,7 @@ void ScriptAgent::exceptionCatch(qint64 scriptId, const QScriptValue & exception const QString msg = QString::fromLatin1("An exception was caught on %1: '%2'"). arg(scriptId).arg(exception.toString()); SDEBUG(msg); - q->showDebuggerOutput(LogMisc, msg); + q->showDebuggerOutput(msg, LogMisc); } void ScriptAgent::exceptionThrow(qint64 scriptId, const QScriptValue &exception, @@ -140,13 +140,13 @@ void ScriptAgent::exceptionThrow(qint64 scriptId, const QScriptValue &exception, const QString msg = QString::fromLatin1("An exception occurred on %1: '%2'"). arg(scriptId).arg(exception.toString()); SDEBUG(msg); - q->showDebuggerOutput(LogMisc, msg); + q->showDebuggerOutput(msg, LogMisc); } void ScriptAgent::functionEntry(qint64 scriptId) { Q_UNUSED(scriptId) - q->showDebuggerOutput(LogMisc, QString::fromLatin1("Function entry occurred on %1").arg(scriptId)); + q->showDebuggerOutput(QString::fromLatin1("Function entry occurred on %1").arg(scriptId), LogMisc); q->checkForBreakCondition(true); } @@ -156,7 +156,7 @@ void ScriptAgent::functionExit(qint64 scriptId, const QScriptValue &returnValue) Q_UNUSED(returnValue) const QString msg = QString::fromLatin1("Function exit occurred on %1: '%2'").arg(scriptId).arg(returnValue.toString()); SDEBUG(msg); - q->showDebuggerOutput(LogMisc, msg); + q->showDebuggerOutput(msg, LogMisc); } void ScriptAgent::positionChange(qint64 scriptId, int lineNumber, int columnNumber) @@ -175,7 +175,8 @@ void ScriptAgent::scriptLoad(qint64 scriptId, const QString &program, Q_UNUSED(program) Q_UNUSED(fileName) Q_UNUSED(baseLineNumber) - q->showDebuggerOutput(LogMisc, QString::fromLatin1("Loaded: %1 id: %2").arg(fileName).arg(scriptId)); + q->showDebuggerOutput(QString::fromLatin1("Loaded: %1 id: %2") + .arg(fileName).arg(scriptId), LogMisc); } void ScriptAgent::scriptUnload(qint64 scriptId) @@ -251,8 +252,8 @@ void ScriptEngine::startDebugger() m_scriptFileName = QFileInfo(runControl()->sp().executable).absoluteFilePath(); QFile scriptFile(m_scriptFileName); if (!scriptFile.open(QIODevice::ReadOnly|QIODevice::Text)) { - manager()->showDebuggerOutput(LogError, QString::fromLatin1("Cannot open %1: %2"). - arg(m_scriptFileName, scriptFile.errorString())); + showDebuggerOutput(QString::fromLatin1("Cannot open %1: %2"). + arg(m_scriptFileName, scriptFile.errorString()), LogError); emit startFailed(); return; } @@ -262,7 +263,7 @@ void ScriptEngine::startDebugger() attemptBreakpointSynchronization(); setState(InferiorRunningRequested); showStatusMessage(tr("Running requested..."), 5000); - manager()->showDebuggerOutput(LogMisc, QLatin1String("Running: ") + m_scriptFileName); + showDebuggerOutput(QLatin1String("Running: ") + m_scriptFileName, LogMisc); QTimer::singleShot(0, this, SLOT(runInferior())); emit startSuccessful(); } @@ -329,14 +330,18 @@ void ScriptEngine::runInferior() const QScriptValue result = m_scriptEngine->evaluate(m_scriptContents, m_scriptFileName); setState(InferiorStopping); setState(InferiorStopped); + QString msg; if (m_scriptEngine->hasUncaughtException()) { - QString msg = QString::fromLatin1("An exception occurred during execution at line: %1\n%2\n"). - arg(m_scriptEngine->uncaughtExceptionLineNumber()).arg(m_scriptEngine->uncaughtException().toString()); - msg += m_scriptEngine->uncaughtExceptionBacktrace().join(QString(QLatin1Char('\n'))); - showDebuggerOutput(LogMisc, msg); + msg = QString::fromLatin1("An exception occurred during execution at line: %1\n%2\n") + .arg(m_scriptEngine->uncaughtExceptionLineNumber()) + .arg(m_scriptEngine->uncaughtException().toString()); + msg += m_scriptEngine->uncaughtExceptionBacktrace() + .join(QString(QLatin1Char('\n'))); } else { - showDebuggerOutput(LogMisc, QString::fromLatin1("Evaluation returns '%1'").arg(result.toString())); + msg = QString::fromLatin1("Evaluation returns '%1'") + .arg(result.toString()); } + showDebuggerOutput(msg, LogMisc); exitDebugger(); } @@ -789,11 +794,6 @@ void ScriptEngine::updateSubItem(const WatchData &data0) manager()->watchHandler()->insertBulkData(children); } -void ScriptEngine::showDebuggerOutput(int channel, const QString &m) -{ - manager()->showDebuggerOutput(channel, m); -} - IDebuggerEngine *createScriptEngine(DebuggerManager *manager) { return new ScriptEngine(manager); diff --git a/src/plugins/debugger/script/scriptengine.h b/src/plugins/debugger/script/scriptengine.h index ca2185199225c6c5111a04e50604face99c6db27..cea1ae830f3cc9d3e10aebff4bc5fbf4d35cfacb 100644 --- a/src/plugins/debugger/script/scriptengine.h +++ b/src/plugins/debugger/script/scriptengine.h @@ -104,8 +104,6 @@ private: void updateLocals(); void updateSubItem(const WatchData &data); - Q_SLOT void showDebuggerOutput(int channel, const QString &m); - private: friend class ScriptAgent; diff --git a/src/plugins/debugger/tcf/tcfengine.cpp b/src/plugins/debugger/tcf/tcfengine.cpp index 243905d7c5809f4757c3ac0bbfce05b4972bc39a..0c1c8a716482fc341dbaefb1d2c2bf0836ed9507 100644 --- a/src/plugins/debugger/tcf/tcfengine.cpp +++ b/src/plugins/debugger/tcf/tcfengine.cpp @@ -328,8 +328,9 @@ void TcfEngine::handleResponse(const QByteArray &response) int token = parts.at(1).toInt(); TcfCommand tcf = m_cookieForToken[token]; SDEBUG("COMMAND NOT RECOGNIZED FOR TOKEN" << token << tcf.toString()); - showDebuggerOutput(LogOutput, QString::number(token) + "^" - + "NOT RECOQNIZED: " + quoteUnprintableLatin1(response)); + showDebuggerOutput(QString::number(token) + "^" + + "NOT RECOQNIZED: " + quoteUnprintableLatin1(response), + LogOutput); acknowledgeResult(); } else if (n == 2 && tag == "F") { // flow control m_congestion = parts.at(1).toInt(); @@ -339,9 +340,9 @@ void TcfEngine::handleResponse(const QByteArray &response) int token = parts.at(1).toInt(); QByteArray message = parts.at(2); JsonValue data(parts.at(3)); - showDebuggerOutput(LogOutput, QString("%1^%2%3").arg(token) + showDebuggerOutput(QString("%1^%2%3").arg(token) .arg(quoteUnprintableLatin1(response)) - .arg(QString::fromUtf8(data.toString()))); + .arg(QString::fromUtf8(data.toString())), LogOutput); TcfCommand tcf = m_cookieForToken[token]; JsonValue result(data); SDEBUG("GOOD RESPONSE: " << quoteUnprintableLatin1(response)); @@ -481,7 +482,7 @@ void TcfEngine::sendCommandNow(const TcfCommand &cmd) int result = m_socket->write(cmd.command); Q_UNUSED(result) m_socket->flush(); - showDebuggerInput(LogInput, QString::number(cmd.token) + " " + cmd.toString()); + showDebuggerInput(QString::number(cmd.token) + " " + cmd.toString(), LogInput); SDEBUG("SEND " << cmd.toString()); //<< " " << QString::number(result)); } @@ -557,11 +558,6 @@ void TcfEngine::updateSubItem(const WatchData &data0) QTC_ASSERT(false, return); } -void TcfEngine::debugMessage(const QString &msg) -{ - showDebuggerOutput(LogDebug, msg); -} - IDebuggerEngine *createTcfEngine(DebuggerManager *manager) { return new TcfEngine(manager); diff --git a/src/plugins/debugger/tcf/tcfengine.h b/src/plugins/debugger/tcf/tcfengine.h index 75dff4353c581b11354eb42855fb2a885c44ce31..d16502ebf48fe410e729a019da8de1f174002646 100644 --- a/src/plugins/debugger/tcf/tcfengine.h +++ b/src/plugins/debugger/tcf/tcfengine.h @@ -141,7 +141,6 @@ private: void postCommand(const QByteArray &cmd, TcfCommandCallback callback = 0, const char *callbackName = 0); void sendCommandNow(const TcfCommand &command); - void debugMessage(const QString &msg); QHash<int, TcfCommand> m_cookieForToken;