forked from qt-creator/qt-creator
the death of GdbCommandType & co.
instead of passing callback codes and dispatching them in a huge switch statement, pass around member function pointers as real callbacks. some codes which did not actually invoke a callback were completely eliminated. hope this doesn't impair debugging. ;) as a "side effect", command categorization by code is gone - there is a proper flag field for that now. as a real side effect, some suppressed assert failures might be back now. fix them properly if they do ...
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -63,16 +63,6 @@ class GdbMi;
|
|||||||
class WatchData;
|
class WatchData;
|
||||||
class BreakpointData;
|
class BreakpointData;
|
||||||
|
|
||||||
struct GdbCookie
|
|
||||||
{
|
|
||||||
GdbCookie() : type(0), synchronized(false) {}
|
|
||||||
|
|
||||||
QString command;
|
|
||||||
int type;
|
|
||||||
bool synchronized;
|
|
||||||
QVariant cookie;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum DebuggingHelperState
|
enum DebuggingHelperState
|
||||||
{
|
{
|
||||||
DebuggingHelperUninitialized,
|
DebuggingHelperUninitialized,
|
||||||
@@ -154,19 +144,47 @@ private:
|
|||||||
|
|
||||||
void handleResult(const GdbResultRecord &, int type, const QVariant &);
|
void handleResult(const GdbResultRecord &, int type, const QVariant &);
|
||||||
|
|
||||||
|
public: // otherwise the Qt flag macros are unhappy
|
||||||
|
enum GdbCommandFlag {
|
||||||
|
NoFlags = 0,
|
||||||
|
NeedsStop = 1,
|
||||||
|
Discardable = 2,
|
||||||
|
RebuildModel = 4,
|
||||||
|
WatchUpdate = Discardable|RebuildModel
|
||||||
|
};
|
||||||
|
Q_DECLARE_FLAGS(GdbCommandFlags, GdbCommandFlag)
|
||||||
|
private:
|
||||||
|
|
||||||
|
typedef void (GdbEngine::*GdbCommandCallback)(const GdbResultRecord &record, const QVariant &cookie);
|
||||||
|
|
||||||
|
struct GdbCommand
|
||||||
|
{
|
||||||
|
GdbCommand() : flags(0), callback(0), callbackName(0) {}
|
||||||
|
|
||||||
|
int flags;
|
||||||
|
GdbCommandCallback callback;
|
||||||
|
const char *callbackName;
|
||||||
|
QString command;
|
||||||
|
QVariant cookie;
|
||||||
|
};
|
||||||
|
|
||||||
// type and cookie are sender-internal data, opaque for the "event
|
// type and cookie are sender-internal data, opaque for the "event
|
||||||
// queue". resultNeeded == true increments m_pendingResults on
|
// queue". resultNeeded == true increments m_pendingResults on
|
||||||
// send and decrements on receipt, effectively preventing
|
// send and decrements on receipt, effectively preventing
|
||||||
// watch model updates before everything is finished.
|
// watch model updates before everything is finished.
|
||||||
enum StopNeeded { DoesNotNeedStop, NeedsStop };
|
void flushCommand(GdbCommand &cmd);
|
||||||
enum Synchronization { NotSynchronized, Synchronized };
|
void execCommandInternal(const QString &command, GdbCommandFlags flags,
|
||||||
void sendCommand(const QString &command,
|
GdbCommandCallback callback, const char *callbackName,
|
||||||
int type = 0, const QVariant &cookie = QVariant(),
|
const QVariant &cookie);
|
||||||
StopNeeded needStop = DoesNotNeedStop,
|
#define execCommand(command,callback) \
|
||||||
Synchronization synchronized = NotSynchronized);
|
execCommandInternal(command, NoFlags, &GdbEngine::callback, STRINGIFY(callback), QVariant())
|
||||||
void sendSynchronizedCommand(const QString & command,
|
#define execCommandF(command,callback,flags) \
|
||||||
int type = 0, const QVariant &cookie = QVariant(),
|
execCommandInternal(command, flags, &GdbEngine::callback, STRINGIFY(callback), QVariant())
|
||||||
StopNeeded needStop = DoesNotNeedStop);
|
#define execCommandC(command,callback,cookie) \
|
||||||
|
execCommandInternal(command, NoFlags, &GdbEngine::callback, STRINGIFY(callback), cookie)
|
||||||
|
#define execCommandFC(command,callback,flags,cookie) \
|
||||||
|
execCommandInternal(command, flags, &GdbEngine::callback, STRINGIFY(callback), cookie)
|
||||||
|
void sendCommand(const QString &command, GdbCommandFlags flags = NoFlags);
|
||||||
|
|
||||||
void setTokenBarrier();
|
void setTokenBarrier();
|
||||||
|
|
||||||
@@ -183,25 +201,27 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
int terminationIndex(const QByteArray &buffer, int &length);
|
int terminationIndex(const QByteArray &buffer, int &length);
|
||||||
void handleResponse(const QByteArray &buff);
|
void handleResponse(const QByteArray &buff);
|
||||||
void handleStart(const GdbResultRecord &response);
|
void handleStart(const GdbResultRecord &response, const QVariant &);
|
||||||
void handleAttach();
|
void handleAttach(const GdbResultRecord &, const QVariant &);
|
||||||
void handleStubAttached();
|
void handleStubAttached(const GdbResultRecord &, const QVariant &);
|
||||||
void handleAqcuiredInferior();
|
void handleAqcuiredInferior();
|
||||||
|
void handleAsyncOutput2(const GdbResultRecord &, const QVariant &cookie);
|
||||||
void handleAsyncOutput2(const GdbMi &data);
|
void handleAsyncOutput2(const GdbMi &data);
|
||||||
void handleAsyncOutput(const GdbMi &data);
|
void handleAsyncOutput(const GdbMi &data);
|
||||||
void handleResultRecord(const GdbResultRecord &response);
|
void handleResultRecord(const GdbResultRecord &response);
|
||||||
void handleFileExecAndSymbols(const GdbResultRecord &response);
|
void handleAutoContinue(const GdbResultRecord &, const QVariant &);
|
||||||
void handleExecRun(const GdbResultRecord &response);
|
void handleFileExecAndSymbols(const GdbResultRecord &response, const QVariant &);
|
||||||
void handleExecJumpToLine(const GdbResultRecord &response);
|
void handleExecRun(const GdbResultRecord &response, const QVariant &);
|
||||||
void handleExecRunToFunction(const GdbResultRecord &response);
|
void handleExecJumpToLine(const GdbResultRecord &response, const QVariant &);
|
||||||
void handleInfoShared(const GdbResultRecord &response);
|
void handleExecRunToFunction(const GdbResultRecord &response, const QVariant &);
|
||||||
void handleInfoProc(const GdbResultRecord &response);
|
void handleInfoShared(const GdbResultRecord &response, const QVariant &);
|
||||||
void handleInfoThreads(const GdbResultRecord &response);
|
void handleInfoProc(const GdbResultRecord &response, const QVariant &);
|
||||||
void handleShowVersion(const GdbResultRecord &response);
|
void handleInfoThreads(const GdbResultRecord &response, const QVariant &);
|
||||||
void handleQueryPwd(const GdbResultRecord &response);
|
void handleShowVersion(const GdbResultRecord &response, const QVariant &);
|
||||||
void handleQuerySources(const GdbResultRecord &response);
|
void handleQueryPwd(const GdbResultRecord &response, const QVariant &);
|
||||||
void handleTargetCore(const GdbResultRecord &response);
|
void handleQuerySources(const GdbResultRecord &response, const QVariant &);
|
||||||
void handleExit(const GdbResultRecord &response);
|
void handleTargetCore(const GdbResultRecord &, const QVariant &);
|
||||||
|
void handleExit(const GdbResultRecord &, const QVariant &);
|
||||||
void debugMessage(const QString &msg);
|
void debugMessage(const QString &msg);
|
||||||
|
|
||||||
OutputCollector m_outputCollector;
|
OutputCollector m_outputCollector;
|
||||||
@@ -214,7 +234,7 @@ private:
|
|||||||
|
|
||||||
Core::Utils::ConsoleProcess m_stubProc;
|
Core::Utils::ConsoleProcess m_stubProc;
|
||||||
|
|
||||||
QHash<int, GdbCookie> m_cookieForToken;
|
QHash<int, GdbCommand> m_cookieForToken;
|
||||||
QHash<int, QByteArray> m_customOutputForToken;
|
QHash<int, QByteArray> m_customOutputForToken;
|
||||||
|
|
||||||
QByteArray m_pendingConsoleStreamOutput;
|
QByteArray m_pendingConsoleStreamOutput;
|
||||||
@@ -237,13 +257,13 @@ private:
|
|||||||
//
|
//
|
||||||
// Breakpoint specific stuff
|
// Breakpoint specific stuff
|
||||||
//
|
//
|
||||||
void handleBreakList(const GdbResultRecord &record);
|
void handleBreakList(const GdbResultRecord &record, const QVariant &);
|
||||||
void handleBreakList(const GdbMi &table);
|
void handleBreakList(const GdbMi &table);
|
||||||
void handleBreakIgnore(const GdbResultRecord &record, int index);
|
void handleBreakIgnore(const GdbResultRecord &record, const QVariant &cookie);
|
||||||
void handleBreakInsert(const GdbResultRecord &record, int index);
|
void handleBreakInsert(const GdbResultRecord &record, const QVariant &cookie);
|
||||||
void handleBreakInsert1(const GdbResultRecord &record, int index);
|
void handleBreakInsert1(const GdbResultRecord &record, const QVariant &cookie);
|
||||||
void handleBreakCondition(const GdbResultRecord &record, int index);
|
void handleBreakCondition(const GdbResultRecord &record, const QVariant &cookie);
|
||||||
void handleBreakInfo(const GdbResultRecord &record, int index);
|
void handleBreakInfo(const GdbResultRecord &record, const QVariant &cookie);
|
||||||
void extractDataFromInfoBreak(const QString &output, BreakpointData *data);
|
void extractDataFromInfoBreak(const QString &output, BreakpointData *data);
|
||||||
void breakpointDataFromOutput(BreakpointData *data, const GdbMi &bkpt);
|
void breakpointDataFromOutput(BreakpointData *data, const GdbMi &bkpt);
|
||||||
void sendInsertBreakpoint(int index);
|
void sendInsertBreakpoint(int index);
|
||||||
@@ -253,7 +273,7 @@ private:
|
|||||||
// Disassembler specific stuff
|
// Disassembler specific stuff
|
||||||
//
|
//
|
||||||
void handleDisassemblerList(const GdbResultRecord &record,
|
void handleDisassemblerList(const GdbResultRecord &record,
|
||||||
const QString &cookie);
|
const QVariant &cookie);
|
||||||
void reloadDisassembler();
|
void reloadDisassembler();
|
||||||
QString m_address;
|
QString m_address;
|
||||||
|
|
||||||
@@ -262,15 +282,15 @@ private:
|
|||||||
// Modules specific stuff
|
// Modules specific stuff
|
||||||
//
|
//
|
||||||
void reloadModules();
|
void reloadModules();
|
||||||
void handleModulesList(const GdbResultRecord &record);
|
void handleModulesList(const GdbResultRecord &record, const QVariant &);
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Register specific stuff
|
// Register specific stuff
|
||||||
//
|
//
|
||||||
Q_SLOT void reloadRegisters();
|
Q_SLOT void reloadRegisters();
|
||||||
void handleRegisterListNames(const GdbResultRecord &record);
|
void handleRegisterListNames(const GdbResultRecord &record, const QVariant &);
|
||||||
void handleRegisterListValues(const GdbResultRecord &record);
|
void handleRegisterListValues(const GdbResultRecord &record, const QVariant &);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Source file specific stuff
|
// Source file specific stuff
|
||||||
@@ -280,9 +300,9 @@ private:
|
|||||||
//
|
//
|
||||||
// Stack specific stuff
|
// Stack specific stuff
|
||||||
//
|
//
|
||||||
void handleStackListFrames(const GdbResultRecord &record, bool isFull);
|
void handleStackListFrames(const GdbResultRecord &record, const QVariant &cookie);
|
||||||
void handleStackSelectThread(const GdbResultRecord &record, int cookie);
|
void handleStackSelectThread(const GdbResultRecord &, const QVariant &);
|
||||||
void handleStackListThreads(const GdbResultRecord &record, int cookie);
|
void handleStackListThreads(const GdbResultRecord &record, const QVariant &cookie);
|
||||||
Q_SLOT void reloadStack();
|
Q_SLOT void reloadStack();
|
||||||
Q_SLOT void reloadFullStack();
|
Q_SLOT void reloadFullStack();
|
||||||
|
|
||||||
@@ -316,25 +336,25 @@ private:
|
|||||||
bool hasDebuggingHelperForType(const QString &type) const;
|
bool hasDebuggingHelperForType(const QString &type) const;
|
||||||
|
|
||||||
void handleVarListChildren(const GdbResultRecord &record,
|
void handleVarListChildren(const GdbResultRecord &record,
|
||||||
const WatchData &cookie);
|
const QVariant &cookie);
|
||||||
void handleVarCreate(const GdbResultRecord &record,
|
void handleVarCreate(const GdbResultRecord &record,
|
||||||
const WatchData &cookie);
|
const QVariant &cookie);
|
||||||
void handleVarAssign();
|
void handleVarAssign(const GdbResultRecord &, const QVariant &);
|
||||||
void handleEvaluateExpression(const GdbResultRecord &record,
|
void handleEvaluateExpression(const GdbResultRecord &record,
|
||||||
const WatchData &cookie);
|
const QVariant &cookie);
|
||||||
void handleToolTip(const GdbResultRecord &record,
|
void handleToolTip(const GdbResultRecord &record,
|
||||||
const QByteArray &cookie);
|
const QVariant &cookie);
|
||||||
void handleQueryDebuggingHelper(const GdbResultRecord &record);
|
void handleQueryDebuggingHelper(const GdbResultRecord &record, const QVariant &);
|
||||||
void handleDebuggingHelperValue1(const GdbResultRecord &record,
|
void handleDebuggingHelperValue1(const GdbResultRecord &record,
|
||||||
const WatchData &cookie);
|
const QVariant &cookie);
|
||||||
void handleDebuggingHelperValue2(const GdbResultRecord &record,
|
void handleDebuggingHelperValue2(const GdbResultRecord &record,
|
||||||
const WatchData &cookie);
|
const QVariant &cookie);
|
||||||
void handleDebuggingHelperValue3(const GdbResultRecord &record,
|
void handleDebuggingHelperValue3(const GdbResultRecord &record,
|
||||||
const WatchData &cookie);
|
const QVariant &cookie);
|
||||||
void handleDebuggingHelperEditValue(const GdbResultRecord &record);
|
void handleDebuggingHelperEditValue(const GdbResultRecord &record);
|
||||||
void handleDebuggingHelperSetup(const GdbResultRecord &record);
|
void handleDebuggingHelperSetup(const GdbResultRecord &record, const QVariant &);
|
||||||
void handleStackListLocals(const GdbResultRecord &record);
|
void handleStackListLocals(const GdbResultRecord &record, const QVariant &);
|
||||||
void handleStackListArguments(const GdbResultRecord &record);
|
void handleStackListArguments(const GdbResultRecord &record, const QVariant &);
|
||||||
void handleVarListChildrenHelper(const GdbMi &child,
|
void handleVarListChildrenHelper(const GdbMi &child,
|
||||||
const WatchData &parent);
|
const WatchData &parent);
|
||||||
void setWatchDataType(WatchData &data, const GdbMi &mi);
|
void setWatchDataType(WatchData &data, const GdbMi &mi);
|
||||||
@@ -354,7 +374,7 @@ private:
|
|||||||
bool m_waitingForFirstBreakpointToBeHit;
|
bool m_waitingForFirstBreakpointToBeHit;
|
||||||
bool m_modulesListOutdated;
|
bool m_modulesListOutdated;
|
||||||
|
|
||||||
QList<GdbCookie> m_commandsToRunOnTemporaryBreak;
|
QList<GdbCommand> m_commandsToRunOnTemporaryBreak;
|
||||||
|
|
||||||
DebuggerManager *q;
|
DebuggerManager *q;
|
||||||
IDebuggerManagerAccessForEngines *qq;
|
IDebuggerManagerAccessForEngines *qq;
|
||||||
@@ -363,4 +383,6 @@ private:
|
|||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Debugger
|
} // namespace Debugger
|
||||||
|
|
||||||
|
Q_DECLARE_OPERATORS_FOR_FLAGS(Debugger::Internal::GdbEngine::GdbCommandFlags)
|
||||||
|
|
||||||
#endif // DEBUGGER_GDBENGINE_H
|
#endif // DEBUGGER_GDBENGINE_H
|
||||||
|
|||||||
Reference in New Issue
Block a user