summaryrefslogtreecommitdiff
path: root/src/plugins/debugger/cdb
diff options
context:
space:
mode:
authorDavid Schulz <david.schulz@theqtcompany.com>2015-08-13 15:39:04 +0200
committerDavid Schulz <david.schulz@theqtcompany.com>2015-08-28 10:54:34 +0000
commitbe8290eefb4e3ccf661a9aa9e0b484abe02ce88d (patch)
tree2819285a92e0406d9ee4472b18b321926c863d87 /src/plugins/debugger/cdb
parented30c612f43bff05a1855ca0d6e2c9edd0d0bc2f (diff)
downloadqt-creator-be8290eefb4e3ccf661a9aa9e0b484abe02ce88d.tar.gz
Cdb: Simplify storing split cdb replies.
Change-Id: Ia50b9255c0da70b8c473349ab2a6b6f3d88e01ed Reviewed-by: Niels Weber <niels.weber@theqtcompany.com>
Diffstat (limited to 'src/plugins/debugger/cdb')
-rw-r--r--src/plugins/debugger/cdb/cdbengine.cpp60
-rw-r--r--src/plugins/debugger/cdb/cdbengine.h26
2 files changed, 43 insertions, 43 deletions
diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp
index 29eaabf12d..321efe45bd 100644
--- a/src/plugins/debugger/cdb/cdbengine.cpp
+++ b/src/plugins/debugger/cdb/cdbengine.cpp
@@ -193,20 +193,6 @@ static inline bool isCreatorConsole(const DebuggerRunParameters &sp)
&& (sp.startMode == StartInternal || sp.startMode == StartExternal);
}
-class CdbResponse
-{
-public:
- CdbResponse()
- : success(false)
- {}
-
- QByteArray command;
-
- QByteArray reply;
- QByteArray errorMessage;
- bool success;
-};
-
// Base data structure for command queue entries with callback
class CdbCommand
{
@@ -269,7 +255,6 @@ CdbEngine::CdbEngine(const DebuggerRunParameters &sp) :
m_accessible(false),
m_specialStopMode(NoSpecialStop),
m_nextCommandToken(0),
- m_currentBuiltinCommandIndex(-1),
m_extensionCommandPrefixBA("!" QT_CREATOR_CDB_EXT "."),
m_operateByInstructionPending(true),
m_operateByInstruction(true), // Default CDB setting
@@ -308,7 +293,6 @@ void CdbEngine::init()
m_accessible = false;
m_specialStopMode = NoSpecialStop;
m_nextCommandToken = 0;
- m_currentBuiltinCommandIndex = -1;
m_operateByInstructionPending = action(OperateByInstruction)->isChecked();
m_verboseLogPending = boolSetting(VerboseLog);
m_operateByInstruction = true; // Default CDB setting
@@ -2443,46 +2427,42 @@ void CdbEngine::parseOutputLine(QByteArray line)
bool isStartToken = false;
const bool isCommandToken = checkCommandToken(m_tokenPrefix, line, &token, &isStartToken);
if (debug > 1)
- qDebug("Reading CDB stdout '%s',\n isCommand=%d, token=%d, isStart=%d, current=%d",
- line.constData(), isCommandToken, token, isStartToken, m_currentBuiltinCommandIndex);
+ qDebug("Reading CDB stdout '%s',\n isCommand=%d, token=%d, isStart=%d",
+ line.constData(), isCommandToken, token, isStartToken);
// If there is a current command, wait for end of output indicated by token,
// command, trigger handler and finish, else append to its output.
- if (m_currentBuiltinCommandIndex != -1) {
- QTC_ASSERT(!isStartToken && m_currentBuiltinCommandIndex < m_builtinCommandQueue.size(), return; );
- const CdbCommandPtr &currentCommand = m_builtinCommandQueue.at(m_currentBuiltinCommandIndex);
+ if (m_currentBuiltinResponse.token != -1) {
+ QTC_ASSERT(!isStartToken, return);
if (isCommandToken) {
// Did the command finish? Invoke callback and remove from queue.
if (debug)
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; );
+ m_currentBuiltinResponse.token, m_currentBuiltinResponse.reply.count('\n'),
+ m_builtinCommandQueue.size() - 1);
+ QTC_ASSERT(token == m_currentBuiltinResponse.token, return);
if (boolSetting(VerboseLog))
- showMessage(QLatin1String(m_currentBuiltinCommandReply), LogMisc);
- CdbResponse response;
- response.reply = m_currentBuiltinCommandReply;
+ showMessage(QLatin1String(m_currentBuiltinResponse.reply), LogMisc);
+ const int commandIndex = indexOfCommand(m_builtinCommandQueue, m_currentBuiltinResponse.token);
+ QTC_ASSERT(commandIndex >= 0 && commandIndex < m_builtinCommandQueue.size(), return);
+ const CdbCommandPtr &currentCommand = m_builtinCommandQueue.at(commandIndex);
if (currentCommand->handler)
- currentCommand->handler(response);
- m_builtinCommandQueue.removeAt(m_currentBuiltinCommandIndex);
- m_currentBuiltinCommandIndex = -1;
- m_currentBuiltinCommandReply.clear();
+ currentCommand->handler(m_currentBuiltinResponse);
+ m_builtinCommandQueue.removeAt(commandIndex);
+ m_currentBuiltinResponse.clear();
} else {
// Record output of current command
- if (!m_currentBuiltinCommandReply.isEmpty())
- m_currentBuiltinCommandReply.push_back('\n');
- m_currentBuiltinCommandReply.push_back(line);
+ if (!m_currentBuiltinResponse.reply.isEmpty())
+ m_currentBuiltinResponse.reply.push_back('\n');
+ m_currentBuiltinResponse.reply.push_back(line);
}
return;
- } // m_currentCommandIndex
+ }
if (isCommandToken) {
// Beginning command token encountered, start to record output.
- const int index = indexOfCommand(m_builtinCommandQueue, token);
- QTC_ASSERT(isStartToken && index != -1, return; );
- m_currentBuiltinCommandIndex = index;
- const CdbCommandPtr &currentCommand = m_builtinCommandQueue.at(m_currentBuiltinCommandIndex);
+ m_currentBuiltinResponse.token = token;
if (debug)
- qDebug("### Gathering output for token %d", currentCommand->token);
+ qDebug("### Gathering output for token %d", 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 458274fec6..e24eb88e34 100644
--- a/src/plugins/debugger/cdb/cdbengine.h
+++ b/src/plugins/debugger/cdb/cdbengine.h
@@ -50,11 +50,32 @@ namespace Internal {
class DisassemblerAgent;
class CdbCommand;
-class CdbResponse;
struct MemoryViewCookie;
class ByteArrayInputStream;
class GdbMi;
+class CdbResponse
+{
+ // TODO: replace with DebuggerResponse
+public:
+ CdbResponse()
+ : token(-1), success(false)
+ {}
+
+ void clear()
+ {
+ token = -1;
+ reply.clear();
+ errorMessage.clear();
+ success = false;
+ }
+
+ int token;
+ QByteArray reply;
+ QByteArray errorMessage;
+ bool success;
+};
+
class CdbEngine : public DebuggerEngine
{
Q_OBJECT
@@ -248,8 +269,7 @@ private:
ProjectExplorer::DeviceProcessSignalOperation::Ptr m_signalOperation;
int m_nextCommandToken;
QList<CdbCommandPtr> m_builtinCommandQueue;
- int m_currentBuiltinCommandIndex; //!< Current command whose output is recorded.
- QByteArray m_currentBuiltinCommandReply;
+ CdbResponse m_currentBuiltinResponse; //!< Current command whose output is recorded.
QList<CdbCommandPtr> m_extensionCommandQueue;
QMap<QString, NormalizedSourceFileName> m_normalizedFileCache;
const QByteArray m_extensionCommandPrefixBA; //!< Library name used as prefix