forked from qt-creator/qt-creator
Cdb: Remove command sequences.
Simplify the CdbResponse to become more like the DebuggerResponse. Change-Id: Ifdd7c69e340b4c18c0e1187eb2173979feccd5b9 Reviewed-by: Niels Weber <niels.weber@theqtcompany.com>
This commit is contained in:
@@ -197,14 +197,11 @@ class CdbResponse
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CdbResponse()
|
CdbResponse()
|
||||||
: commandSequence(0), success(false)
|
: success(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
QByteArray command;
|
QByteArray command;
|
||||||
|
|
||||||
// Continue with other commands as specified in CommandSequenceFlags
|
|
||||||
unsigned commandSequence;
|
|
||||||
|
|
||||||
QByteArray reply;
|
QByteArray reply;
|
||||||
QByteArray errorMessage;
|
QByteArray errorMessage;
|
||||||
bool success;
|
bool success;
|
||||||
@@ -218,11 +215,10 @@ public:
|
|||||||
: token(0)
|
: token(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CdbCommand(const QByteArray &cmd, int token, CdbEngine::CommandHandler h, unsigned nc)
|
CdbCommand(const QByteArray &cmd, int token, CdbEngine::CommandHandler h)
|
||||||
: token(token), handler(h)
|
: token(token), handler(h)
|
||||||
{
|
{
|
||||||
response.command = cmd;
|
response.command = cmd;
|
||||||
response.commandSequence = nc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int token;
|
int token;
|
||||||
@@ -1181,7 +1177,7 @@ void CdbEngine::handleThreads(const CdbResponse &response)
|
|||||||
data.fromString(response.reply);
|
data.fromString(response.reply);
|
||||||
threadsHandler()->updateThreads(data);
|
threadsHandler()->updateThreads(data);
|
||||||
// Continue sequence
|
// Continue sequence
|
||||||
postCommandSequence(response.commandSequence);
|
reloadFullStack();
|
||||||
} else {
|
} else {
|
||||||
showMessage(QString::fromLatin1(response.errorMessage), LogError);
|
showMessage(QString::fromLatin1(response.errorMessage), LogError);
|
||||||
}
|
}
|
||||||
@@ -1207,8 +1203,7 @@ void CdbEngine::postCommand(const QByteArray &cmd)
|
|||||||
// In order to catch the output, it is enclosed in 'echo' commands
|
// In order to catch the output, it is enclosed in 'echo' commands
|
||||||
// printing a specially formatted token to be identifiable in the output.
|
// printing a specially formatted token to be identifiable in the output.
|
||||||
void CdbEngine::postBuiltinCommand(const QByteArray &cmd,
|
void CdbEngine::postBuiltinCommand(const QByteArray &cmd,
|
||||||
CommandHandler handler,
|
CommandHandler handler)
|
||||||
unsigned nextCommandFlag)
|
|
||||||
{
|
{
|
||||||
if (!m_accessible) {
|
if (!m_accessible) {
|
||||||
const QString msg = QString::fromLatin1("Attempt to issue builtin command \"%1\" to non-accessible session (%2)")
|
const QString msg = QString::fromLatin1("Attempt to issue builtin command \"%1\" to non-accessible session (%2)")
|
||||||
@@ -1217,7 +1212,7 @@ void CdbEngine::postBuiltinCommand(const QByteArray &cmd,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const int token = m_nextCommandToken++;
|
const int token = m_nextCommandToken++;
|
||||||
CdbCommandPtr pendingCommand(new CdbCommand(cmd, token, handler, nextCommandFlag));
|
CdbCommandPtr pendingCommand(new CdbCommand(cmd, token, handler));
|
||||||
|
|
||||||
m_builtinCommandQueue.push_back(pendingCommand);
|
m_builtinCommandQueue.push_back(pendingCommand);
|
||||||
// Enclose command in echo-commands for token
|
// Enclose command in echo-commands for token
|
||||||
@@ -1226,9 +1221,9 @@ void CdbEngine::postBuiltinCommand(const QByteArray &cmd,
|
|||||||
str << ".echo \"" << m_tokenPrefix << token << "<\"\n"
|
str << ".echo \"" << m_tokenPrefix << token << "<\"\n"
|
||||||
<< cmd << "\n.echo \"" << m_tokenPrefix << token << ">\"";
|
<< cmd << "\n.echo \"" << m_tokenPrefix << token << ">\"";
|
||||||
if (debug)
|
if (debug)
|
||||||
qDebug("CdbEngine::postBuiltinCommand %dms '%s' token=%d %s next=%u, pending=%d, sequence=0x%x",
|
qDebug("CdbEngine::postBuiltinCommand %dms '%s' token=%d %s, pending=%d",
|
||||||
elapsedLogTime(), cmd.constData(), token, stateName(state()), nextCommandFlag,
|
elapsedLogTime(), cmd.constData(), token, stateName(state()),
|
||||||
m_builtinCommandQueue.size(), nextCommandFlag);
|
m_builtinCommandQueue.size());
|
||||||
if (debug > 1)
|
if (debug > 1)
|
||||||
qDebug("CdbEngine::postBuiltinCommand: resulting command '%s'\n",
|
qDebug("CdbEngine::postBuiltinCommand: resulting command '%s'\n",
|
||||||
fullCmd.constData());
|
fullCmd.constData());
|
||||||
@@ -1239,8 +1234,7 @@ void CdbEngine::postBuiltinCommand(const QByteArray &cmd,
|
|||||||
// pass along token for identification in queue.
|
// pass along token for identification in queue.
|
||||||
void CdbEngine::postExtensionCommand(const QByteArray &cmd,
|
void CdbEngine::postExtensionCommand(const QByteArray &cmd,
|
||||||
const QByteArray &arguments,
|
const QByteArray &arguments,
|
||||||
CommandHandler handler,
|
CommandHandler handler)
|
||||||
unsigned nextCommandFlag)
|
|
||||||
{
|
{
|
||||||
if (!m_accessible) {
|
if (!m_accessible) {
|
||||||
const QString msg = QString::fromLatin1("Attempt to issue extension command \"%1\" to non-accessible session (%2)")
|
const QString msg = QString::fromLatin1("Attempt to issue extension command \"%1\" to non-accessible session (%2)")
|
||||||
@@ -1258,14 +1252,14 @@ void CdbEngine::postExtensionCommand(const QByteArray &cmd,
|
|||||||
if (!arguments.isEmpty())
|
if (!arguments.isEmpty())
|
||||||
str << ' ' << arguments;
|
str << ' ' << arguments;
|
||||||
|
|
||||||
CdbCommandPtr pendingCommand(new CdbCommand(fullCmd, token, handler, nextCommandFlag));
|
CdbCommandPtr pendingCommand(new CdbCommand(fullCmd, token, handler));
|
||||||
|
|
||||||
m_extensionCommandQueue.push_back(pendingCommand);
|
m_extensionCommandQueue.push_back(pendingCommand);
|
||||||
// Enclose command in echo-commands for token
|
// Enclose command in echo-commands for token
|
||||||
if (debug)
|
if (debug)
|
||||||
qDebug("CdbEngine::postExtensionCommand %dms '%s' token=%d %s next=%u, pending=%d, sequence=0x%x",
|
qDebug("CdbEngine::postExtensionCommand %dms '%s' token=%d %s, pending=%d",
|
||||||
elapsedLogTime(), fullCmd.constData(), token, stateName(state()), nextCommandFlag,
|
elapsedLogTime(), fullCmd.constData(), token, stateName(state()),
|
||||||
m_extensionCommandQueue.size(), nextCommandFlag);
|
m_extensionCommandQueue.size());
|
||||||
postCommand(fullCmd);
|
postCommand(fullCmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1401,7 +1395,9 @@ void CdbEngine::selectThread(ThreadId threadId)
|
|||||||
threadsHandler()->setCurrentThread(threadId);
|
threadsHandler()->setCurrentThread(threadId);
|
||||||
|
|
||||||
const QByteArray cmd = '~' + QByteArray::number(threadId.raw()) + " s";
|
const QByteArray cmd = '~' + QByteArray::number(threadId.raw()) + " s";
|
||||||
postBuiltinCommand(cmd, CB(dummyHandler), CommandListStack);
|
postBuiltinCommand(cmd, [this](const CdbResponse &){
|
||||||
|
postExtensionCommand("stack", "unlimited", CB(handleStackTrace));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default address range for showing disassembly.
|
// Default address range for showing disassembly.
|
||||||
@@ -1637,7 +1633,7 @@ void CdbEngine::handleMemory(const CdbResponse &response, const MemoryViewCookie
|
|||||||
|
|
||||||
void CdbEngine::reloadModules()
|
void CdbEngine::reloadModules()
|
||||||
{
|
{
|
||||||
postCommandSequence(CommandListModules);
|
postExtensionCommand("modules", QByteArray(), CB(handleModules));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CdbEngine::loadSymbols(const QString & /* moduleName */)
|
void CdbEngine::loadSymbols(const QString & /* moduleName */)
|
||||||
@@ -1655,7 +1651,8 @@ void CdbEngine::requestModuleSymbols(const QString &moduleName)
|
|||||||
|
|
||||||
void CdbEngine::reloadRegisters()
|
void CdbEngine::reloadRegisters()
|
||||||
{
|
{
|
||||||
postCommandSequence(CommandListRegisters);
|
QTC_ASSERT(threadsHandler()->currentThreadIndex() >= 0, return);
|
||||||
|
postExtensionCommand("registers", QByteArray(), CB(handleRegistersExt));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CdbEngine::reloadSourceFiles()
|
void CdbEngine::reloadSourceFiles()
|
||||||
@@ -1666,7 +1663,12 @@ void CdbEngine::reloadFullStack()
|
|||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
qDebug("%s", Q_FUNC_INFO);
|
qDebug("%s", Q_FUNC_INFO);
|
||||||
postCommandSequence(CommandListStack);
|
postExtensionCommand("stack", "unlimited", CB(handleStackTrace));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CdbEngine::listBreakpoints()
|
||||||
|
{
|
||||||
|
postExtensionCommand("breakpoints", QByteArray("-v"), CB(handleBreakPoints));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CdbEngine::handlePid(const CdbResponse &response)
|
void CdbEngine::handlePid(const CdbResponse &response)
|
||||||
@@ -1712,8 +1714,6 @@ void CdbEngine::handleModules(const CdbResponse &response)
|
|||||||
showMessage(QString::fromLatin1("Failed to determine modules: %1").
|
showMessage(QString::fromLatin1("Failed to determine modules: %1").
|
||||||
arg(QLatin1String(response.errorMessage)), LogError);
|
arg(QLatin1String(response.errorMessage)), LogError);
|
||||||
}
|
}
|
||||||
postCommandSequence(response.commandSequence);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CdbEngine::handleRegistersExt(const CdbResponse &response)
|
void CdbEngine::handleRegistersExt(const CdbResponse &response)
|
||||||
@@ -1741,7 +1741,6 @@ void CdbEngine::handleRegistersExt(const CdbResponse &response)
|
|||||||
showMessage(QString::fromLatin1("Failed to determine registers: %1").
|
showMessage(QString::fromLatin1("Failed to determine registers: %1").
|
||||||
arg(QLatin1String(response.errorMessage)), LogError);
|
arg(QLatin1String(response.errorMessage)), LogError);
|
||||||
}
|
}
|
||||||
postCommandSequence(response.commandSequence);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CdbEngine::handleLocals(const CdbResponse &response, bool partialUpdate)
|
void CdbEngine::handleLocals(const CdbResponse &response, bool partialUpdate)
|
||||||
@@ -2058,7 +2057,7 @@ void CdbEngine::processStop(const GdbMi &stopReason, bool conditionalBreakPointT
|
|||||||
postCommand("~0 s");
|
postCommand("~0 s");
|
||||||
forcedThreadId = ThreadId(0);
|
forcedThreadId = ThreadId(0);
|
||||||
// Re-fetch stack again.
|
// Re-fetch stack again.
|
||||||
postCommandSequence(CommandListStack);
|
reloadFullStack();
|
||||||
} else {
|
} else {
|
||||||
const GdbMi stack = stopReason["stack"];
|
const GdbMi stack = stopReason["stack"];
|
||||||
if (stack.isValid()) {
|
if (stack.isValid()) {
|
||||||
@@ -2088,11 +2087,11 @@ void CdbEngine::processStop(const GdbMi &stopReason, bool conditionalBreakPointT
|
|||||||
}
|
}
|
||||||
// Fire off remaining commands asynchronously
|
// Fire off remaining commands asynchronously
|
||||||
if (!m_pendingBreakpointMap.isEmpty() && !m_pendingSubBreakpointMap.isEmpty())
|
if (!m_pendingBreakpointMap.isEmpty() && !m_pendingSubBreakpointMap.isEmpty())
|
||||||
postCommandSequence(CommandListBreakPoints);
|
listBreakpoints();
|
||||||
if (Internal::isDockVisible(QLatin1String(DOCKWIDGET_REGISTER)))
|
if (Internal::isDockVisible(QLatin1String(DOCKWIDGET_REGISTER)))
|
||||||
postCommandSequence(CommandListRegisters);
|
reloadRegisters();
|
||||||
if (Internal::isDockVisible(QLatin1String(DOCKWIDGET_MODULES)))
|
if (Internal::isDockVisible(QLatin1String(DOCKWIDGET_MODULES)))
|
||||||
postCommandSequence(CommandListModules);
|
reloadModules();
|
||||||
}
|
}
|
||||||
// After the sequence has been sent off and CDB is pondering the commands,
|
// After the sequence has been sent off and CDB is pondering the commands,
|
||||||
// pop up a message box for exceptions.
|
// pop up a message box for exceptions.
|
||||||
@@ -2208,7 +2207,7 @@ void CdbEngine::handleSwitchWow64Stack(const CdbResponse &response)
|
|||||||
else
|
else
|
||||||
m_wow64State = noWow64Stack;
|
m_wow64State = noWow64Stack;
|
||||||
// reload threads and the stack after switching the mode
|
// reload threads and the stack after switching the mode
|
||||||
postCommandSequence(CommandListThreads | CommandListStack);
|
postExtensionCommand("threads", QByteArray(), CB(handleThreads));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CdbEngine::handleSessionAccessible(unsigned long cdbExState)
|
void CdbEngine::handleSessionAccessible(unsigned long cdbExState)
|
||||||
@@ -2792,7 +2791,7 @@ void CdbEngine::attemptBreakpointSynchronization()
|
|||||||
}
|
}
|
||||||
// List breakpoints and send responses
|
// List breakpoints and send responses
|
||||||
if (addedChanged)
|
if (addedChanged)
|
||||||
postCommandSequence(CommandListBreakPoints);
|
listBreakpoints();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pass a file name through source mapping and normalize upper/lower case (for the editor
|
// Pass a file name through source mapping and normalize upper/lower case (for the editor
|
||||||
@@ -2964,7 +2963,6 @@ void CdbEngine::handleStackTrace(const CdbResponse &response)
|
|||||||
postBuiltinCommand("lm m wow64",
|
postBuiltinCommand("lm m wow64",
|
||||||
[this, stack](const CdbResponse &r) { handleCheckWow64(r, stack); });
|
[this, stack](const CdbResponse &r) { handleCheckWow64(r, stack); });
|
||||||
}
|
}
|
||||||
postCommandSequence(response.commandSequence);
|
|
||||||
} else {
|
} else {
|
||||||
showMessage(QString::fromLocal8Bit(response.errorMessage), LogError);
|
showMessage(QString::fromLocal8Bit(response.errorMessage), LogError);
|
||||||
}
|
}
|
||||||
@@ -2991,43 +2989,6 @@ void CdbEngine::handleExpression(const CdbResponse &response, BreakpointModelId
|
|||||||
doContinueInferior();
|
doContinueInferior();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CdbEngine::dummyHandler(const CdbResponse &command)
|
|
||||||
{
|
|
||||||
postCommandSequence(command.commandSequence);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Post a sequence of standard commands: Trigger next once one completes successfully
|
|
||||||
void CdbEngine::postCommandSequence(unsigned mask)
|
|
||||||
{
|
|
||||||
if (debug)
|
|
||||||
qDebug("postCommandSequence 0x%x\n", mask);
|
|
||||||
|
|
||||||
if (!mask)
|
|
||||||
return;
|
|
||||||
if (mask & CommandListThreads) {
|
|
||||||
postExtensionCommand("threads", QByteArray(), CB(handleThreads), mask & ~CommandListThreads);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (mask & CommandListStack) {
|
|
||||||
postExtensionCommand("stack", "unlimited", CB(handleStackTrace), mask & ~CommandListStack);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (mask & CommandListRegisters) {
|
|
||||||
QTC_ASSERT(threadsHandler()->currentThreadIndex() >= 0, return);
|
|
||||||
postExtensionCommand("registers", QByteArray(), CB(handleRegistersExt), mask & ~CommandListRegisters);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (mask & CommandListModules) {
|
|
||||||
postExtensionCommand("modules", QByteArray(), CB(handleModules), mask & ~CommandListModules);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (mask & CommandListBreakPoints) {
|
|
||||||
postExtensionCommand("breakpoints", QByteArray("-v"),
|
|
||||||
CB(handleBreakPoints), mask & ~CommandListBreakPoints);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CdbEngine::handleWidgetAt(const CdbResponse &response)
|
void CdbEngine::handleWidgetAt(const CdbResponse &response)
|
||||||
{
|
{
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
|||||||
@@ -60,15 +60,6 @@ class CdbEngine : public DebuggerEngine
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Flag bits for a sequence of commands
|
|
||||||
enum CommandSequenceFlags {
|
|
||||||
CommandListStack = 0x1,
|
|
||||||
CommandListThreads = 0x2,
|
|
||||||
CommandListRegisters = 0x4,
|
|
||||||
CommandListModules = 0x8,
|
|
||||||
CommandListBreakPoints = 0x10
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef QSharedPointer<CdbCommand> CdbCommandPtr;
|
typedef QSharedPointer<CdbCommand> CdbCommandPtr;
|
||||||
typedef std::function<void(const CdbResponse &)> CommandHandler;
|
typedef std::function<void(const CdbResponse &)> CommandHandler;
|
||||||
|
|
||||||
@@ -128,6 +119,7 @@ public:
|
|||||||
void reloadSourceFiles() override;
|
void reloadSourceFiles() override;
|
||||||
void reloadFullStack() override;
|
void reloadFullStack() override;
|
||||||
void loadAdditionalQmlStack() override;
|
void loadAdditionalQmlStack() override;
|
||||||
|
void listBreakpoints();
|
||||||
|
|
||||||
static QString extensionLibraryName(bool is64Bit);
|
static QString extensionLibraryName(bool is64Bit);
|
||||||
|
|
||||||
@@ -138,15 +130,12 @@ private slots:
|
|||||||
void processFinished();
|
void processFinished();
|
||||||
void postCommand(const QByteArray &cmd);
|
void postCommand(const QByteArray &cmd);
|
||||||
void postBuiltinCommand(const QByteArray &cmd,
|
void postBuiltinCommand(const QByteArray &cmd,
|
||||||
CommandHandler handler,
|
CommandHandler handler);
|
||||||
unsigned nextCommandFlag = 0);
|
|
||||||
|
|
||||||
void postExtensionCommand(const QByteArray &cmd,
|
void postExtensionCommand(const QByteArray &cmd,
|
||||||
const QByteArray &arguments,
|
const QByteArray &arguments,
|
||||||
CommandHandler handler,
|
CommandHandler handler);
|
||||||
unsigned nextCommandFlag = 0);
|
|
||||||
|
|
||||||
void postCommandSequence(unsigned mask);
|
|
||||||
void operateByInstructionTriggered(bool);
|
void operateByInstructionTriggered(bool);
|
||||||
void verboseLogTriggered(bool);
|
void verboseLogTriggered(bool);
|
||||||
|
|
||||||
@@ -214,7 +203,6 @@ private:
|
|||||||
void postResolveSymbol(const QString &module, const QString &function,
|
void postResolveSymbol(const QString &module, const QString &function,
|
||||||
DisassemblerAgent *agent);
|
DisassemblerAgent *agent);
|
||||||
// Builtin commands
|
// Builtin commands
|
||||||
void dummyHandler(const CdbResponse &);
|
|
||||||
void handleStackTrace(const CdbResponse &);
|
void handleStackTrace(const CdbResponse &);
|
||||||
void handleRegisters(const CdbResponse &);
|
void handleRegisters(const CdbResponse &);
|
||||||
void handleDisassembler(const CdbResponse &, DisassemblerAgent *agent);
|
void handleDisassembler(const CdbResponse &, DisassemblerAgent *agent);
|
||||||
|
|||||||
Reference in New Issue
Block a user