Commit be8290ee authored by David Schulz's avatar David Schulz

Cdb: Simplify storing split cdb replies.

Change-Id: Ia50b9255c0da70b8c473349ab2a6b6f3d88e01ed
Reviewed-by: default avatarNiels Weber <niels.weber@theqtcompany.com>
parent ed30c612
...@@ -193,20 +193,6 @@ static inline bool isCreatorConsole(const DebuggerRunParameters &sp) ...@@ -193,20 +193,6 @@ static inline bool isCreatorConsole(const DebuggerRunParameters &sp)
&& (sp.startMode == StartInternal || sp.startMode == StartExternal); && (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 // Base data structure for command queue entries with callback
class CdbCommand class CdbCommand
{ {
...@@ -269,7 +255,6 @@ CdbEngine::CdbEngine(const DebuggerRunParameters &sp) : ...@@ -269,7 +255,6 @@ CdbEngine::CdbEngine(const DebuggerRunParameters &sp) :
m_accessible(false), m_accessible(false),
m_specialStopMode(NoSpecialStop), m_specialStopMode(NoSpecialStop),
m_nextCommandToken(0), m_nextCommandToken(0),
m_currentBuiltinCommandIndex(-1),
m_extensionCommandPrefixBA("!" QT_CREATOR_CDB_EXT "."), m_extensionCommandPrefixBA("!" QT_CREATOR_CDB_EXT "."),
m_operateByInstructionPending(true), m_operateByInstructionPending(true),
m_operateByInstruction(true), // Default CDB setting m_operateByInstruction(true), // Default CDB setting
...@@ -308,7 +293,6 @@ void CdbEngine::init() ...@@ -308,7 +293,6 @@ void CdbEngine::init()
m_accessible = false; m_accessible = false;
m_specialStopMode = NoSpecialStop; m_specialStopMode = NoSpecialStop;
m_nextCommandToken = 0; m_nextCommandToken = 0;
m_currentBuiltinCommandIndex = -1;
m_operateByInstructionPending = action(OperateByInstruction)->isChecked(); m_operateByInstructionPending = action(OperateByInstruction)->isChecked();
m_verboseLogPending = boolSetting(VerboseLog); m_verboseLogPending = boolSetting(VerboseLog);
m_operateByInstruction = true; // Default CDB setting m_operateByInstruction = true; // Default CDB setting
...@@ -2443,46 +2427,42 @@ void CdbEngine::parseOutputLine(QByteArray line) ...@@ -2443,46 +2427,42 @@ void CdbEngine::parseOutputLine(QByteArray line)
bool isStartToken = false; bool isStartToken = false;
const bool isCommandToken = checkCommandToken(m_tokenPrefix, line, &token, &isStartToken); const bool isCommandToken = checkCommandToken(m_tokenPrefix, line, &token, &isStartToken);
if (debug > 1) if (debug > 1)
qDebug("Reading CDB stdout '%s',\n isCommand=%d, token=%d, isStart=%d, current=%d", qDebug("Reading CDB stdout '%s',\n isCommand=%d, token=%d, isStart=%d",
line.constData(), isCommandToken, token, isStartToken, m_currentBuiltinCommandIndex); line.constData(), isCommandToken, token, isStartToken);
// If there is a current command, wait for end of output indicated by token, // If there is a current command, wait for end of output indicated by token,
// command, trigger handler and finish, else append to its output. // command, trigger handler and finish, else append to its output.
if (m_currentBuiltinCommandIndex != -1) { if (m_currentBuiltinResponse.token != -1) {
QTC_ASSERT(!isStartToken && m_currentBuiltinCommandIndex < m_builtinCommandQueue.size(), return; ); QTC_ASSERT(!isStartToken, return);
const CdbCommandPtr &currentCommand = m_builtinCommandQueue.at(m_currentBuiltinCommandIndex);
if (isCommandToken) { if (isCommandToken) {
// Did the command finish? Invoke callback and remove from queue. // Did the command finish? Invoke callback and remove from queue.
if (debug) if (debug)
qDebug("### Completed builtin command for token=%d, %d lines, pending=%d", qDebug("### Completed builtin command for token=%d, %d lines, pending=%d",
currentCommand->token, m_currentBuiltinResponse.token, m_currentBuiltinResponse.reply.count('\n'),
m_currentBuiltinCommandReply.count('\n'), m_builtinCommandQueue.size() - 1); m_builtinCommandQueue.size() - 1);
QTC_ASSERT(token == currentCommand->token, return; ); QTC_ASSERT(token == m_currentBuiltinResponse.token, return);
if (boolSetting(VerboseLog)) if (boolSetting(VerboseLog))
showMessage(QLatin1String(m_currentBuiltinCommandReply), LogMisc); showMessage(QLatin1String(m_currentBuiltinResponse.reply), LogMisc);
CdbResponse response; const int commandIndex = indexOfCommand(m_builtinCommandQueue, m_currentBuiltinResponse.token);
response.reply = m_currentBuiltinCommandReply; QTC_ASSERT(commandIndex >= 0 && commandIndex < m_builtinCommandQueue.size(), return);
const CdbCommandPtr &currentCommand = m_builtinCommandQueue.at(commandIndex);
if (currentCommand->handler) if (currentCommand->handler)
currentCommand->handler(response); currentCommand->handler(m_currentBuiltinResponse);
m_builtinCommandQueue.removeAt(m_currentBuiltinCommandIndex); m_builtinCommandQueue.removeAt(commandIndex);
m_currentBuiltinCommandIndex = -1; m_currentBuiltinResponse.clear();
m_currentBuiltinCommandReply.clear();
} else { } else {
// Record output of current command // Record output of current command
if (!m_currentBuiltinCommandReply.isEmpty()) if (!m_currentBuiltinResponse.reply.isEmpty())
m_currentBuiltinCommandReply.push_back('\n'); m_currentBuiltinResponse.reply.push_back('\n');
m_currentBuiltinCommandReply.push_back(line); m_currentBuiltinResponse.reply.push_back(line);
} }
return; return;
} // m_currentCommandIndex }
if (isCommandToken) { if (isCommandToken) {
// Beginning command token encountered, start to record output. // Beginning command token encountered, start to record output.
const int index = indexOfCommand(m_builtinCommandQueue, token); m_currentBuiltinResponse.token = token;
QTC_ASSERT(isStartToken && index != -1, return; );
m_currentBuiltinCommandIndex = index;
const CdbCommandPtr &currentCommand = m_builtinCommandQueue.at(m_currentBuiltinCommandIndex);
if (debug) if (debug)
qDebug("### Gathering output for token %d", currentCommand->token); qDebug("### Gathering output for token %d", token);
return; return;
} }
const char versionString[] = "Microsoft (R) Windows Debugger Version"; const char versionString[] = "Microsoft (R) Windows Debugger Version";
......
...@@ -50,11 +50,32 @@ namespace Internal { ...@@ -50,11 +50,32 @@ namespace Internal {
class DisassemblerAgent; class DisassemblerAgent;
class CdbCommand; class CdbCommand;
class CdbResponse;
struct MemoryViewCookie; struct MemoryViewCookie;
class ByteArrayInputStream; class ByteArrayInputStream;
class GdbMi; 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 class CdbEngine : public DebuggerEngine
{ {
Q_OBJECT Q_OBJECT
...@@ -248,8 +269,7 @@ private: ...@@ -248,8 +269,7 @@ private:
ProjectExplorer::DeviceProcessSignalOperation::Ptr m_signalOperation; ProjectExplorer::DeviceProcessSignalOperation::Ptr m_signalOperation;
int m_nextCommandToken; int m_nextCommandToken;
QList<CdbCommandPtr> m_builtinCommandQueue; QList<CdbCommandPtr> m_builtinCommandQueue;
int m_currentBuiltinCommandIndex; //!< Current command whose output is recorded. CdbResponse m_currentBuiltinResponse; //!< Current command whose output is recorded.
QByteArray m_currentBuiltinCommandReply;
QList<CdbCommandPtr> m_extensionCommandQueue; QList<CdbCommandPtr> m_extensionCommandQueue;
QMap<QString, NormalizedSourceFileName> m_normalizedFileCache; QMap<QString, NormalizedSourceFileName> m_normalizedFileCache;
const QByteArray m_extensionCommandPrefixBA; //!< Library name used as prefix const QByteArray m_extensionCommandPrefixBA; //!< Library name used as prefix
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment