From a360c65e4dd90d3dd5cea6fc8c6e410e06627132 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@nokia.com> Date: Fri, 19 Jun 2009 12:47:23 +0200 Subject: [PATCH] Made CDB use colored output and add LogWarning. --- src/plugins/debugger/cdb/cdbdebugengine.cpp | 19 ++++-------- src/plugins/debugger/cdb/cdbdebugengine.h | 1 - .../debugger/cdb/cdbdebugeventcallback.cpp | 6 ++-- .../debugger/cdb/cdbdebugeventcallback.h | 4 +-- src/plugins/debugger/cdb/cdbdebugoutput.cpp | 31 ++++++------------- src/plugins/debugger/cdb/cdbdebugoutput.h | 4 +-- src/plugins/debugger/cdb/cdbdumperhelper.cpp | 29 +++++++++-------- src/plugins/debugger/cdb/cdbdumperhelper.h | 1 - src/plugins/debugger/debuggermanager.h | 1 + src/plugins/debugger/debuggeroutputwindow.cpp | 6 ++++ 10 files changed, 44 insertions(+), 58 deletions(-) diff --git a/src/plugins/debugger/cdb/cdbdebugengine.cpp b/src/plugins/debugger/cdb/cdbdebugengine.cpp index 97f26dfb9bc..d317a9145ba 100644 --- a/src/plugins/debugger/cdb/cdbdebugengine.cpp +++ b/src/plugins/debugger/cdb/cdbdebugengine.cpp @@ -417,10 +417,10 @@ CdbDebugEngine::CdbDebugEngine(DebuggerManager *parent, const QSharedPointer<Cdb connect(&m_d->m_consoleStubProc, SIGNAL(processError(QString)), this, SLOT(slotConsoleStubError(QString))); connect(&m_d->m_consoleStubProc, SIGNAL(processStarted()), this, SLOT(slotConsoleStubStarted())); connect(&m_d->m_consoleStubProc, SIGNAL(wrapperStopped()), this, SLOT(slotConsoleStubTerminated())); - connect(&m_d->m_debugOutputCallBack, SIGNAL(debuggerOutput(QString,QString)), - m_d->m_debuggerManager, SLOT(showDebuggerOutput(QString,QString))); - connect(&m_d->m_debugOutputCallBack, SIGNAL(debuggerInputPrompt(QString,QString)), - m_d->m_debuggerManager, SLOT(showDebuggerInput(QString,QString))); + connect(&m_d->m_debugOutputCallBack, SIGNAL(debuggerOutput(int,QString)), + m_d->m_debuggerManager, SLOT(showDebuggerOutput(int,QString))); + connect(&m_d->m_debugOutputCallBack, SIGNAL(debuggerInputPrompt(int,QString)), + m_d->m_debuggerManager, SLOT(showDebuggerInput(int,QString))); connect(&m_d->m_debugOutputCallBack, SIGNAL(debuggeeOutput(QString)), m_d->m_debuggerManager, SLOT(showApplicationOutput(QString))); connect(&m_d->m_debugOutputCallBack, SIGNAL(debuggeeInputPrompt(QString)), @@ -755,7 +755,7 @@ void CdbDebugEnginePrivate::endDebugging(EndDebuggingMode em) if (!errorMessage.isEmpty()) { errorMessage = QString::fromLatin1("There were errors trying to end debugging: %1").arg(errorMessage); - m_debuggerManagerAccess->showDebuggerOutput(QLatin1String("error"), errorMessage); + m_debuggerManagerAccess->showDebuggerOutput(LogError, errorMessage); m_engine->warning(errorMessage); } } @@ -1370,16 +1370,9 @@ void CdbDebugEngine::slotConsoleStubTerminated() exitDebugger(); } -void CdbDebugEngine::slotAttachedCrashed() -{ - m_d->m_debuggerManagerAccess->showDebuggerOutput("A","A"); - m_d->handleDebugEvent(); -} - void CdbDebugEngine::warning(const QString &w) { - static const QString prefix = QLatin1String("warning:"); - m_d->m_debuggerManagerAccess->showDebuggerOutput(prefix, w); + m_d->m_debuggerManagerAccess->showDebuggerOutput(LogWarning, w); qWarning("%s\n", qPrintable(w)); } diff --git a/src/plugins/debugger/cdb/cdbdebugengine.h b/src/plugins/debugger/cdb/cdbdebugengine.h index 00beb734c7c..13725bb97e4 100644 --- a/src/plugins/debugger/cdb/cdbdebugengine.h +++ b/src/plugins/debugger/cdb/cdbdebugengine.h @@ -107,7 +107,6 @@ private slots: void slotConsoleStubStarted(); void slotConsoleStubError(const QString &msg); void slotConsoleStubTerminated(); - void slotAttachedCrashed(); void warning(const QString &w); private: diff --git a/src/plugins/debugger/cdb/cdbdebugeventcallback.cpp b/src/plugins/debugger/cdb/cdbdebugeventcallback.cpp index c5cf17ace36..30daf12c073 100644 --- a/src/plugins/debugger/cdb/cdbdebugeventcallback.cpp +++ b/src/plugins/debugger/cdb/cdbdebugeventcallback.cpp @@ -372,9 +372,9 @@ STDMETHODIMP CdbDebugEventCallback::SystemError( } // -----------ExceptionLoggerEventCallback -CdbExceptionLoggerEventCallback::CdbExceptionLoggerEventCallback(const QString &logPrefix, +CdbExceptionLoggerEventCallback::CdbExceptionLoggerEventCallback(int logChannel, IDebuggerManagerAccessForEngines *access) : - m_logPrefix(logPrefix), + m_logChannel(logChannel), m_access(access) { } @@ -399,7 +399,7 @@ STDMETHODIMP CdbExceptionLoggerEventCallback::Exception( } if (debugCDB) qDebug() << Q_FUNC_INFO << '\n' << m_exceptionMessages.back(); - m_access->showDebuggerOutput(m_logPrefix, m_exceptionMessages.back()); + m_access->showDebuggerOutput(m_logChannel, m_exceptionMessages.back()); return S_OK; } diff --git a/src/plugins/debugger/cdb/cdbdebugeventcallback.h b/src/plugins/debugger/cdb/cdbdebugeventcallback.h index 4466f0d9934..86145a13736 100644 --- a/src/plugins/debugger/cdb/cdbdebugeventcallback.h +++ b/src/plugins/debugger/cdb/cdbdebugeventcallback.h @@ -241,7 +241,7 @@ private: class CdbExceptionLoggerEventCallback : public CdbDebugEventCallbackBase { public: - explicit CdbExceptionLoggerEventCallback(const QString &logPrefix, + explicit CdbExceptionLoggerEventCallback(int logChannel, IDebuggerManagerAccessForEngines *access); STDMETHOD(GetInterestMask)( @@ -260,7 +260,7 @@ public: QList<ULONG> exceptionCodes() const { return m_exceptionCodes; } private: - const QString m_logPrefix; + const int m_logChannel; IDebuggerManagerAccessForEngines *m_access; QList<ULONG> m_exceptionCodes; QStringList m_exceptionMessages; diff --git a/src/plugins/debugger/cdb/cdbdebugoutput.cpp b/src/plugins/debugger/cdb/cdbdebugoutput.cpp index d9b7fc2d0ca..73e85dd7ac2 100644 --- a/src/plugins/debugger/cdb/cdbdebugoutput.cpp +++ b/src/plugins/debugger/cdb/cdbdebugoutput.cpp @@ -96,26 +96,15 @@ IDebugOutputCallbacksWide *CdbDebugOutputBase::getOutputCallback(CIDebugClient * // ------------------------- CdbDebugOutput // Return a prefix for debugger messages -static QString prefix(ULONG mask) +static int logChannel(ULONG mask) { - if (mask & (DEBUG_OUTPUT_PROMPT_REGISTERS)) { - static const QString p = QLatin1String("registers:"); - return p; - } - if (mask & (DEBUG_OUTPUT_EXTENSION_WARNING|DEBUG_OUTPUT_WARNING)) { - static const QString p = QLatin1String("warning:"); - return p; - } - if (mask & (DEBUG_OUTPUT_ERROR)) { - static const QString p = QLatin1String("error:"); - return p; - } - if (mask & DEBUG_OUTPUT_SYMBOLS) { - static const QString p = QLatin1String("symbols:"); - return p; - } - static const QString commonPrefix = QLatin1String("cdb:"); - return commonPrefix; + if (mask & (DEBUG_OUTPUT_PROMPT_REGISTERS)) + return LogMisc; + if (mask & (DEBUG_OUTPUT_EXTENSION_WARNING|DEBUG_OUTPUT_WARNING)) + return LogError; + if (mask & (DEBUG_OUTPUT_ERROR)) + return LogError; + return LogMisc; } enum OutputKind { DebuggerOutput, DebuggerPromptOutput, DebuggeeOutput, DebuggeePromptOutput }; @@ -144,10 +133,10 @@ void CdbDebugOutput::output(ULONG mask, const QString &_msg) switch (outputKind(mask)) { case DebuggerOutput: - debuggerOutput(prefix(mask), msg); + debuggerOutput(logChannel(mask), msg); break; case DebuggerPromptOutput: - emit debuggerInputPrompt(prefix(mask), msg); + emit debuggerInputPrompt(logChannel(mask), msg); break; case DebuggeeOutput: emit debuggeeOutput(msg); diff --git a/src/plugins/debugger/cdb/cdbdebugoutput.h b/src/plugins/debugger/cdb/cdbdebugoutput.h index 1b5574a59ba..06e3523a4e0 100644 --- a/src/plugins/debugger/cdb/cdbdebugoutput.h +++ b/src/plugins/debugger/cdb/cdbdebugoutput.h @@ -82,8 +82,8 @@ protected: virtual void output(ULONG mask, const QString &message); signals: - void debuggerOutput(const QString &prefix, const QString &message); - void debuggerInputPrompt(const QString &prefix, const QString &message); + void debuggerOutput(int channel, const QString &message); + void debuggerInputPrompt(int channel, const QString &message); void debuggeeOutput(const QString &message); void debuggeeInputPrompt(const QString &message); }; diff --git a/src/plugins/debugger/cdb/cdbdumperhelper.cpp b/src/plugins/debugger/cdb/cdbdumperhelper.cpp index d9c27c7021f..910eae6aa7e 100644 --- a/src/plugins/debugger/cdb/cdbdumperhelper.cpp +++ b/src/plugins/debugger/cdb/cdbdumperhelper.cpp @@ -148,7 +148,7 @@ static bool debuggeeLoadLibrary(IDebuggerManagerAccessForEngines *access, if (loadDebug > 1) qDebug() << Q_FUNC_INFO << moduleName; // Try to ignore the breakpoints - CdbExceptionLoggerEventCallback exLogger(QLatin1String(dumperPrefixC), access); + CdbExceptionLoggerEventCallback exLogger(LogWarning, access); EventCallbackRedirector eventRedir(cif->debugClient, &exLogger); // Make a call to LoadLibraryA. First, reserve memory in debugger // and copy name over. @@ -219,7 +219,6 @@ static QString msgLoadSucceeded(const QString &library, bool injectOrCall) CdbDumperHelper::CdbDumperHelper(DebuggerManager *manager, CdbComInterfaces *cif) : m_tryInjectLoad(true), - m_messagePrefix(QLatin1String(dumperPrefixC)), m_state(NotLoaded), m_manager(manager), m_access(manager), @@ -241,7 +240,7 @@ void CdbDumperHelper::disable() { if (loadDebug) qDebug() << Q_FUNC_INFO; - m_access->showDebuggerOutput(m_messagePrefix, QCoreApplication::translate("Debugger::Internal::CdbDumperHelper", "Disabling dumpers due to debuggee crash...")); + m_access->showDebuggerOutput(LogMisc, QCoreApplication::translate("Debugger::Internal::CdbDumperHelper", "Disabling dumpers due to debuggee crash...")); m_state = Disabled; } @@ -288,7 +287,7 @@ void CdbDumperHelper::moduleLoadHook(const QString &module, HANDLE debuggeeHandl } else { m_state = InjectLoadFailed; // Ok, try call loading... - m_access->showDebuggerOutput(m_messagePrefix, msgLoadFailed(m_library, true, errorMessage)); + m_access->showDebuggerOutput(LogMisc, msgLoadFailed(m_library, true, errorMessage)); } } break; @@ -296,7 +295,7 @@ void CdbDumperHelper::moduleLoadHook(const QString &module, HANDLE debuggeeHandl // check if gdbmacros.dll loaded if (module.contains(QLatin1String(dumperModuleNameC), Qt::CaseInsensitive)) { m_state = Loaded; - m_access->showDebuggerOutput(m_messagePrefix, msgLoadSucceeded(m_library, true)); + m_access->showDebuggerOutput(LogMisc, msgLoadSucceeded(m_library, true)); } break; } @@ -343,17 +342,17 @@ bool CdbDumperHelper::ensureInitialized(QString *errorMessage) switch (initCallLoad(errorMessage)) { case CallLoadOk: case CallLoadAlreadyLoaded: - m_access->showDebuggerOutput(m_messagePrefix, msgLoadSucceeded(m_library, false)); + m_access->showDebuggerOutput(LogMisc, msgLoadSucceeded(m_library, false)); m_state = Loaded; break; case CallLoadError: *errorMessage = msgLoadFailed(m_library, false, *errorMessage); - m_access->showDebuggerOutput(m_messagePrefix, *errorMessage); + m_access->showDebuggerOutput(LogError, *errorMessage); m_access->showQtDumperLibraryWarning(*errorMessage); m_state = Disabled; // No message here, no point in retrying return false; case CallLoadNoQtApp: - m_access->showDebuggerOutput(m_messagePrefix, QCoreApplication::translate("Debugger::Internal::CdbDumperHelper", "The debuggee does not appear to be Qt application.")); + m_access->showDebuggerOutput(LogMisc, QCoreApplication::translate("Debugger::Internal::CdbDumperHelper", "The debuggee does not appear to be Qt application.")); m_state = Disabled; // No message here return true; } @@ -365,13 +364,13 @@ bool CdbDumperHelper::ensureInitialized(QString *errorMessage) m_manager->showStatusMessage(QCoreApplication::translate("Debugger::Internal::CdbDumperHelper", "Initializing dumpers..."), 10000); const bool ok = initResolveSymbols(errorMessage) && initKnownTypes(errorMessage); if (ok) { - m_access->showDebuggerOutput(m_messagePrefix, QCoreApplication::translate("Debugger::Internal::CdbDumperHelper", "Custom dumper library initialized.")); - m_access->showDebuggerOutput(m_messagePrefix, m_helper.toString()); + m_access->showDebuggerOutput(LogMisc, QCoreApplication::translate("Debugger::Internal::CdbDumperHelper", "Custom dumper library initialized.")); + m_access->showDebuggerOutput(LogMisc, m_helper.toString()); m_state = Initialized; } else { m_state = Disabled; // No message here *errorMessage = QCoreApplication::translate("Debugger::Internal::CdbDumperHelper", "The custom dumper library could not be initialized: %1").arg(*errorMessage); - m_access->showDebuggerOutput(m_messagePrefix, *errorMessage); + m_access->showDebuggerOutput(LogMisc, *errorMessage); m_access->showQtDumperLibraryWarning(*errorMessage); } return ok; @@ -475,7 +474,7 @@ bool CdbDumperHelper::callDumper(const QString &callCmd, const QByteArray &inBuf bool ignoreAccessViolation, QString *errorMessage) { *outDataPtr = 0; - CdbExceptionLoggerEventCallback exLogger(m_messagePrefix, m_access); + CdbExceptionLoggerEventCallback exLogger(LogWarning, m_access); EventCallbackRedirector eventRedir(m_cif->debugClient, &exLogger); // write input buffer if (!inBuffer.isEmpty()) { @@ -555,7 +554,7 @@ CdbDumperHelper::DumpResult CdbDumperHelper::dumpType(const WatchData &wd, bool // Ensure types are parsed and known. if (!ensureInitialized(errorMessage)) { *errorMessage = msgDumpFailed(wd, errorMessage); - m_access->showDebuggerOutput(m_messagePrefix, *errorMessage); + m_access->showDebuggerOutput(LogError, *errorMessage); return DumpError; } @@ -570,7 +569,7 @@ CdbDumperHelper::DumpResult CdbDumperHelper::dumpType(const WatchData &wd, bool const QString message = QCoreApplication::translate("Debugger::Internal::CdbDumperHelper", "Querying dumpers for '%1'/'%2' (%3)"). arg(wd.name, wd.exp, wd.type); - m_access->showDebuggerOutput(m_messagePrefix, message); + m_access->showDebuggerOutput(LogMisc, message); const DumpExecuteResult der = executeDump(wd, td, dumpChildren, source, result, errorMessage); if (der == DumpExecuteOk) @@ -582,7 +581,7 @@ CdbDumperHelper::DumpResult CdbDumperHelper::dumpType(const WatchData &wd, bool m_failedTypes.push_back(wd.type); // log error *errorMessage = msgDumpFailed(wd, errorMessage); - m_access->showDebuggerOutput(m_messagePrefix, *errorMessage); + m_access->showDebuggerOutput(LogWarning, *errorMessage); return DumpError; } diff --git a/src/plugins/debugger/cdb/cdbdumperhelper.h b/src/plugins/debugger/cdb/cdbdumperhelper.h index 802cd9895c6..ccff93f0b62 100644 --- a/src/plugins/debugger/cdb/cdbdumperhelper.h +++ b/src/plugins/debugger/cdb/cdbdumperhelper.h @@ -117,7 +117,6 @@ private: static bool writeToDebuggee(CIDebugDataSpaces *ds, const QByteArray &buffer, quint64 address, QString *errorMessage); const bool m_tryInjectLoad; - const QString m_messagePrefix; State m_state; DebuggerManager *m_manager; IDebuggerManagerAccessForEngines *m_access; diff --git a/src/plugins/debugger/debuggermanager.h b/src/plugins/debugger/debuggermanager.h index 9928fabeb3b..5f5a6a17eb8 100644 --- a/src/plugins/debugger/debuggermanager.h +++ b/src/plugins/debugger/debuggermanager.h @@ -131,6 +131,7 @@ enum LogChannel { LogInput, // Used for user input LogOutput, + LogWarning, LogError, LogStatus, // Used for status changed messages LogDebug, diff --git a/src/plugins/debugger/debuggeroutputwindow.cpp b/src/plugins/debugger/debuggeroutputwindow.cpp index 7596ebee3da..f59ca2a83bc 100644 --- a/src/plugins/debugger/debuggeroutputwindow.cpp +++ b/src/plugins/debugger/debuggeroutputwindow.cpp @@ -60,6 +60,7 @@ static QChar charForChannel(int channel) { switch (channel) { case LogDebug: return 'd'; + case LogWarning: return 'w'; case LogError: return 'e'; case LogInput: return '<'; case LogOutput: return '>'; @@ -73,6 +74,7 @@ static LogChannel channelForChar(QChar c) { switch (c.unicode()) { case 'd': return LogDebug; + case 'w': return LogWarning; case 'e': return LogError; case '<': return LogInput; case '>': return LogOutput; @@ -107,6 +109,10 @@ private: format.setForeground(Qt::darkGreen); setFormat(1, text.size(), format); break; + case LogWarning: + format.setForeground(Qt::darkYellow); + setFormat(1, text.size(), format); + break; case LogError: format.setForeground(Qt::red); setFormat(1, text.size(), format); -- GitLab