From 0aa4339353dba2cb97cc53827f0114fb93e58965 Mon Sep 17 00:00:00 2001 From: David Schulz <david.schulz@theqtcompany.com> Date: Thu, 13 Aug 2015 15:30:47 +0200 Subject: [PATCH] Cdb: Remove the command from the response. It was just used for diagnostic messages. The commands can still be identified via the token in the messages. Change-Id: If1c6f9e66bd65d9d3a16cb403d297c83b0c52d0e Reviewed-by: Niels Weber <niels.weber@theqtcompany.com> --- src/plugins/debugger/cdb/cdbengine.cpp | 59 +++++++++++++------------- src/plugins/debugger/cdb/cdbengine.h | 1 + 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index e97888eca4..29eaabf12d 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -215,17 +215,13 @@ public: : token(0) {} - CdbCommand(const QByteArray &cmd, int token, CdbEngine::CommandHandler h) + CdbCommand(int token, CdbEngine::CommandHandler h) : token(token), handler(h) - { - response.command = cmd; - } + {} int token; CdbEngine::CommandHandler handler; - - CdbResponse response; // FIXME: remove. }; template <class CommandPtrType> @@ -1212,7 +1208,7 @@ void CdbEngine::postBuiltinCommand(const QByteArray &cmd, return; } const int token = m_nextCommandToken++; - CdbCommandPtr pendingCommand(new CdbCommand(cmd, token, handler)); + CdbCommandPtr pendingCommand(new CdbCommand(token, handler)); m_builtinCommandQueue.push_back(pendingCommand); // Enclose command in echo-commands for token @@ -1252,7 +1248,7 @@ void CdbEngine::postExtensionCommand(const QByteArray &cmd, if (!arguments.isEmpty()) str << ' ' << arguments; - CdbCommandPtr pendingCommand(new CdbCommand(fullCmd, token, handler)); + CdbCommandPtr pendingCommand(new CdbCommand(token, handler)); m_extensionCommandQueue.push_back(pendingCommand); // Enclose command in echo-commands for token @@ -2286,19 +2282,21 @@ void CdbEngine::handleExtensionMessage(char t, int token, const QByteArray &what if (index != -1) { // Did the command finish? Take off queue and complete, invoke CB const CdbCommandPtr command = m_extensionCommandQueue.takeAt(index); + if (debug) + qDebug("### Completed extension command for token=%d, pending=%d", + command->token, m_extensionCommandQueue.size()); + + if (!command->handler) + return; + CdbResponse response; if (t == 'R') { - command->response.success = true; - command->response.reply = message; + response.success = true; + response.reply = message; } else { - command->response.success = false; - command->response.errorMessage = message; - } - if (debug) - qDebug("### Completed extension command '%s', token=%d, pending=%d", - command->response.command.constData(), command->token, m_extensionCommandQueue.size()); - if (command->handler) { - command->handler(command->response); + response.success = false; + response.errorMessage = message; } + command->handler(response); return; } } @@ -2456,22 +2454,24 @@ void CdbEngine::parseOutputLine(QByteArray line) if (isCommandToken) { // Did the command finish? Invoke callback and remove from queue. if (debug) - qDebug("### Completed builtin command '%s', token=%d, %d lines, pending=%d", - currentCommand->response.command.constData(), currentCommand->token, - currentCommand->response.reply.count('\n'), m_builtinCommandQueue.size() - 1); + qDebug("### Completed builtin command for token=%d, %d lines, pending=%d", + currentCommand->token, + m_currentBuiltinCommandReply.count('\n'), m_builtinCommandQueue.size() - 1); QTC_ASSERT(token == currentCommand->token, return; ); if (boolSetting(VerboseLog)) - showMessage(QLatin1String(currentCommand->response.reply), LogMisc); - if (currentCommand->handler) { - currentCommand->handler(currentCommand->response); - } + showMessage(QLatin1String(m_currentBuiltinCommandReply), LogMisc); + CdbResponse response; + response.reply = m_currentBuiltinCommandReply; + if (currentCommand->handler) + currentCommand->handler(response); m_builtinCommandQueue.removeAt(m_currentBuiltinCommandIndex); m_currentBuiltinCommandIndex = -1; + m_currentBuiltinCommandReply.clear(); } else { // Record output of current command - if (!currentCommand->response.reply.isEmpty()) - currentCommand->response.reply.push_back('\n'); - currentCommand->response.reply.push_back(line); + if (!m_currentBuiltinCommandReply.isEmpty()) + m_currentBuiltinCommandReply.push_back('\n'); + m_currentBuiltinCommandReply.push_back(line); } return; } // m_currentCommandIndex @@ -2482,8 +2482,7 @@ void CdbEngine::parseOutputLine(QByteArray line) m_currentBuiltinCommandIndex = index; const CdbCommandPtr ¤tCommand = m_builtinCommandQueue.at(m_currentBuiltinCommandIndex); if (debug) - qDebug("### Gathering output for '%s' token %d", - currentCommand->response.command.constData(), currentCommand->token); + qDebug("### Gathering output for token %d", currentCommand->token); return; } const char versionString[] = "Microsoft (R) Windows Debugger Version"; diff --git a/src/plugins/debugger/cdb/cdbengine.h b/src/plugins/debugger/cdb/cdbengine.h index 7888ca5010..458274fec6 100644 --- a/src/plugins/debugger/cdb/cdbengine.h +++ b/src/plugins/debugger/cdb/cdbengine.h @@ -249,6 +249,7 @@ private: int m_nextCommandToken; QList<CdbCommandPtr> m_builtinCommandQueue; int m_currentBuiltinCommandIndex; //!< Current command whose output is recorded. + QByteArray m_currentBuiltinCommandReply; QList<CdbCommandPtr> m_extensionCommandQueue; QMap<QString, NormalizedSourceFileName> m_normalizedFileCache; const QByteArray m_extensionCommandPrefixBA; //!< Library name used as prefix -- GitLab