From a23311f8e7600d70df2cb6ff05e2d5f44f740ef8 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Fri, 1 Jul 2022 14:49:14 +0200 Subject: [PATCH] Debugger: use QtcProcess output buffer Change-Id: I03326879bbcf2411a1feab8b6826ddd4c0981286 Reviewed-by: Christian Stenger --- src/plugins/debugger/cdb/cdbengine.cpp | 36 +++----------------------- src/plugins/debugger/cdb/cdbengine.h | 3 --- 2 files changed, 4 insertions(+), 35 deletions(-) diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index 153f3ce85a7..5ce9bd2ab9b 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -204,10 +204,8 @@ CdbEngine::CdbEngine() : this, &CdbEngine::createFullBacktrace); connect(&m_process, &QtcProcess::started, this, &CdbEngine::processStarted); connect(&m_process, &QtcProcess::done, this, &CdbEngine::processDone); - connect(&m_process, &QtcProcess::readyReadStandardOutput, - this, &CdbEngine::readyReadStandardOut); - connect(&m_process, &QtcProcess::readyReadStandardError, - this, &CdbEngine::readyReadStandardOut); + m_process.setStdOutLineCallback([this](const QString &line) { parseOutputLine(line); }); + m_process.setStdErrLineCallback([this](const QString &line) { parseOutputLine(line); }); connect(&s->useDebuggingHelpers, &BaseAspect::changed, this, &CdbEngine::updateLocals); @@ -230,7 +228,6 @@ void CdbEngine::init() m_autoBreakPointCorrection = false; m_wow64State = wow64Uninitialized; - m_outputBuffer.clear(); m_commandForToken.clear(); m_currentBuiltinResponse.clear(); m_extensionMessageBuffer.clear(); @@ -434,7 +431,6 @@ void CdbEngine::setupEngine() QLocale::system().toString(extensionFi.lastModified(), QLocale::ShortFormat)); showMessage(msg, LogMisc); - m_outputBuffer.clear(); m_autoBreakPointCorrection = false; Environment inferiorEnvironment = sp.inferior.environment.isValid() @@ -2282,6 +2278,8 @@ void CdbEngine::parseOutputLine(QString line) // it should happen only in initial and exit stages. Note however that // if the output is not hooked, sequences of prompts are possible which // can mix things up. + if (line.endsWith('\n')) + line.chop(1); while (isCdbPrompt(line)) line.remove(0, CdbPromptLength); // An extension notification (potentially consisting of several chunks) @@ -2394,32 +2392,6 @@ void CdbEngine::parseOutputLine(QString line) } } -void CdbEngine::readyReadStandardOut() -{ - if (m_ignoreCdbOutput) - return; - m_outputBuffer += m_process.readAllStandardOutput(); - // Split into lines and parse line by line. - while (true) { - const int endOfLinePos = m_outputBuffer.indexOf('\n'); - if (endOfLinePos == -1) { - break; - } else { - // Check for '\r\n' - QByteArray line = m_outputBuffer.left(endOfLinePos); - if (!line.isEmpty() && line.at(line.size() - 1) == '\r') - line.truncate(line.size() - 1); - parseOutputLine(QString::fromLocal8Bit(line)); - m_outputBuffer.remove(0, endOfLinePos + 1); - } - } -} - -void CdbEngine::readyReadStandardError() -{ - showMessage(QString::fromLocal8Bit(m_process.readAllStandardError()), LogError); -} - #if 0 // Join breakpoint ids for a multi-breakpoint id commands like 'bc', 'be', 'bd' static QByteArray multiBreakpointCommand(const char *cmdC, const Breakpoints &bps) diff --git a/src/plugins/debugger/cdb/cdbengine.h b/src/plugins/debugger/cdb/cdbengine.h index 916e8a7db9c..c26cd901b8b 100644 --- a/src/plugins/debugger/cdb/cdbengine.h +++ b/src/plugins/debugger/cdb/cdbengine.h @@ -101,8 +101,6 @@ public: static QString extensionLibraryName(bool is64Bit, bool isArm = false); private: - void readyReadStandardOut(); - void readyReadStandardError(); void processStarted(); void processDone(); void runCommand(const DebuggerCommand &cmd) override; @@ -198,7 +196,6 @@ private: Utils::QtcProcess m_process; DebuggerStartMode m_effectiveStartMode = NoStartMode; - QByteArray m_outputBuffer; //! Debugger accessible (expecting commands) bool m_accessible = false; StopMode m_stopMode = NoStopRequested;