Commit 968ba7b7 authored by hjk's avatar hjk

Debugger: Replace the QVariant callback cookies by direct parameters

Lambda makes it possible.

Change-Id: I26a4df71dcd24b76a4f0d6d67545b2e1c6ba2412
Reviewed-by: default avatarhjk <hjk@theqtcompany.com>
parent d9e7a6e6
......@@ -191,7 +191,6 @@ public:
int token;
ResultClass resultClass;
GdbMi data;
QVariant cookie;
QByteArray logStreamOutput;
QByteArray consoleStreamOutput;
};
......
......@@ -39,8 +39,6 @@
namespace Debugger {
namespace Internal {
#define CB(callback) [this](const DebuggerResponse &r) { callback(r); }
///////////////////////////////////////////////////////////////////////
//
// AttachGdbAdapter
......@@ -69,7 +67,8 @@ void GdbAttachEngine::setupInferior()
{
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
const qint64 pid = startParameters().attachPID;
postCommand("attach " + QByteArray::number(pid), CB(handleAttach));
postCommand("attach " + QByteArray::number(pid), NoFlags,
[this](const DebuggerResponse &r) { handleAttach(r); });
// Task 254674 does not want to remove them
//qq->breakHandler()->removeAllBreakpoints();
}
......
......@@ -213,7 +213,7 @@ void GdbCoreEngine::setupInferior()
// Do that first, otherwise no symbols are loaded.
QFileInfo fi(m_executable);
QByteArray path = fi.absoluteFilePath().toLocal8Bit();
postCommand("-file-exec-and-symbols \"" + path + '"',
postCommand("-file-exec-and-symbols \"" + path + '"', NoFlags,
CB(handleFileExecAndSymbols));
}
......@@ -223,7 +223,7 @@ void GdbCoreEngine::handleFileExecAndSymbols(const DebuggerResponse &response)
QString core = coreFileName();
if (response.resultClass == ResultDone) {
showMessage(tr("Symbols found."), StatusBar);
postCommand("target core " + core.toLocal8Bit(),
postCommand("target core " + core.toLocal8Bit(), NoFlags,
CB(handleTargetCore));
return;
}
......@@ -246,9 +246,9 @@ void GdbCoreEngine::handleTargetCore(const DebuggerResponse &response)
handleInferiorPrepared();
// Due to the auto-solib-add off setting, we don't have any
// symbols yet. Load them in order of importance.
reloadStack(true);
reloadStack();
reloadModulesInternal();
postCommand("p 5", CB(handleRoundTrip));
postCommand("p 5", NoFlags, CB(handleRoundTrip));
return;
}
QString msg = tr("Attach to core \"%1\" failed:")
......
......@@ -59,6 +59,7 @@ public:
bool isCore;
};
static CoreInfo readExecutableNameFromCore(const QString &debuggerCmd, const QString &coreFile);
private:
void setupEngine();
void setupInferior();
......
This diff is collapsed.
......@@ -185,7 +185,6 @@ private: ////////// Gdb Command Management //////////
int flags;
GdbCommandCallback callback;
QByteArray command;
QVariant cookie;
QTime postTime;
};
......@@ -197,14 +196,9 @@ private: ////////// Gdb Command Management //////////
protected:
void runCommand(const DebuggerCommand &command);
void postCommand(const QByteArray &command,
GdbCommandFlags flags,
GdbCommandCallback callback = 0,
const QVariant &cookie = QVariant());
void postCommand(const QByteArray &command,
GdbCommandCallback callback = 0,
const QVariant &cookie = QVariant());
GdbCommandFlags flags = NoFlags,
GdbCommandCallback callback = GdbCommandCallback());
private:
void postCommandHelper(const GdbCommand &cmd);
void flushQueuedCommands();
Q_SLOT void commandTimeout();
void setTokenBarrier();
......@@ -238,9 +232,7 @@ protected:
Q_SLOT void handleResponse(const QByteArray &buff);
void handleStopResponse(const GdbMi &data);
void handleResultRecord(DebuggerResponse *response);
void handleStop1(const DebuggerResponse &response);
void handleStop1(const GdbMi &data);
void handleStop2(const DebuggerResponse &response);
void handleStop2(const GdbMi &data);
Q_SLOT void handleStop2();
StackFrame parseStackFrame(const GdbMi &mi, int level);
......@@ -304,18 +296,17 @@ private: ////////// View & Data Stuff //////////
// Breakpoint specific stuff
//
void handleBreakModifications(const GdbMi &bkpts);
void handleBreakIgnore(const DebuggerResponse &response);
void handleBreakDisable(const DebuggerResponse &response);
void handleBreakEnable(const DebuggerResponse &response);
void handleBreakInsert1(const DebuggerResponse &response);
void handleBreakInsert2(const DebuggerResponse &response);
void handleBreakDelete(const DebuggerResponse &response);
void handleTraceInsert2(const DebuggerResponse &response);
void handleBreakCondition(const DebuggerResponse &response);
void handleBreakThreadSpec(const DebuggerResponse &response);
void handleBreakLineNumber(const DebuggerResponse &response);
void handleWatchInsert(const DebuggerResponse &response);
void handleCatchInsert(const DebuggerResponse &response);
void handleBreakIgnore(const DebuggerResponse &response, Breakpoint bp);
void handleBreakDisable(const DebuggerResponse &response, Breakpoint bp);
void handleBreakEnable(const DebuggerResponse &response, Breakpoint bp);
void handleBreakInsert1(const DebuggerResponse &response, Breakpoint bp);
void handleBreakInsert2(const DebuggerResponse &response, Breakpoint bp);
void handleBreakDelete(const DebuggerResponse &response, Breakpoint bp);
void handleBreakCondition(const DebuggerResponse &response, Breakpoint bp);
void handleBreakThreadSpec(const DebuggerResponse &response, Breakpoint bp);
void handleBreakLineNumber(const DebuggerResponse &response, Breakpoint bp);
void handleWatchInsert(const DebuggerResponse &response, Breakpoint bp);
void handleCatchInsert(const DebuggerResponse &response, Breakpoint bp);
void handleBkpt(const GdbMi &bkpt, Breakpoint bp);
void updateResponse(BreakpointResponse &response, const GdbMi &bkpt);
QByteArray breakpointLocation(const BreakpointParameters &data); // For gdb/MI.
......@@ -336,14 +327,13 @@ private: ////////// View & Data Stuff //////////
void reloadModulesInternal();
void handleModulesList(const DebuggerResponse &response);
void handleShowModuleSymbols(const DebuggerResponse &response);
void handleShowModuleSections(const DebuggerResponse &response);
void handleShowModuleSections(const DebuggerResponse &response, const QString &moduleName);
//
// Snapshot specific stuff
//
virtual void createSnapshot();
void handleMakeSnapshot(const DebuggerResponse &response);
void handleMakeSnapshot(const DebuggerResponse &response, const QString &coreFile);
//
// Register specific stuff
......@@ -363,12 +353,9 @@ private: ////////// View & Data Stuff //////////
void fetchDisassemblerByCliPointMixed(const DisassemblerAgentCookie &ac);
void fetchDisassemblerByCliRangeMixed(const DisassemblerAgentCookie &ac);
void fetchDisassemblerByCliRangePlain(const DisassemblerAgentCookie &ac);
void handleFetchDisassemblerByCliPointMixed(const DebuggerResponse &response);
void handleFetchDisassemblerByCliRangeMixed(const DebuggerResponse &response);
void handleFetchDisassemblerByCliRangePlain(const DebuggerResponse &response);
bool handleCliDisassemblerResult(const QByteArray &response, DisassemblerAgent *agent);
void handleBreakOnQFatal(const DebuggerResponse &response);
void handleBreakOnQFatal(const DebuggerResponse &response, bool continueSetup);
//
// Source file specific stuff
......@@ -392,13 +379,13 @@ private: ////////// View & Data Stuff //////////
//
protected:
void updateAll();
void handleStackListFrames(const DebuggerResponse &response);
void handleStackListFrames(const DebuggerResponse &response, bool isFull);
void handleStackSelectThread(const DebuggerResponse &response);
void handleThreadListIds(const DebuggerResponse &response);
void handleThreadInfo(const DebuggerResponse &response);
void handleThreadNames(const DebuggerResponse &response);
QByteArray stackCommand(int depth);
Q_SLOT void reloadStack(bool forceGotoLocation);
Q_SLOT void reloadStack();
Q_SLOT virtual void reloadFullStack();
virtual void loadAdditionalQmlStack();
void handleQmlStackFrameArguments(const DebuggerResponse &response);
......@@ -421,7 +408,7 @@ protected:
void handleChangeMemory(const DebuggerResponse &response);
virtual void changeMemory(MemoryAgent *agent, QObject *token,
quint64 addr, const QByteArray &data);
void handleFetchMemory(const DebuggerResponse &response);
void handleFetchMemory(const DebuggerResponse &response, MemoryAgentCookie ac);
virtual void watchPoint(const QPoint &);
void handleWatchPoint(const DebuggerResponse &response);
......@@ -442,7 +429,7 @@ protected:
void updateLocals();
void updateLocalsPython(const UpdateParameters &parameters);
void handleStackFramePython(const DebuggerResponse &response);
void handleStackFramePython(const DebuggerResponse &response, bool partial);
void setLocals(const QList<GdbMi> &locals);
......
......@@ -45,7 +45,7 @@
namespace Debugger {
namespace Internal {
#define CB(callback) [this](const DebuggerResponse &r) { callback(r); }, STRINGIFY(callback)
#define CB(callback) [this](const DebuggerResponse &r) { callback(r); }
GdbPlainEngine::GdbPlainEngine(const DebuggerStartParameters &startParameters)
: GdbEngine(startParameters)
......@@ -63,7 +63,7 @@ void GdbPlainEngine::setupInferior()
postCommand("-exec-arguments " + toLocalEncoding(args));
}
postCommand("-file-exec-and-symbols \"" + execFilePath() + '"',
CB(handleFileExecAndSymbols));
NoFlags, CB(handleFileExecAndSymbols));
}
void GdbPlainEngine::handleFileExecAndSymbols(const DebuggerResponse &response)
......
......@@ -204,7 +204,7 @@ void GdbRemoteServerEngine::setupInferior()
// mi_execute_async_cli_command: Assertion `is_running (inferior_ptid)'
// failed.\nA problem internal to GDB has been detected,[...]
if (boolSetting(TargetAsync))
postCommand("set target-async on", CB(handleSetTargetAsync));
postCommand("set target-async on", NoFlags, CB(handleSetTargetAsync));
if (executableFileName.isEmpty()) {
showMessage(tr("No symbol file given."), StatusBar);
......@@ -214,7 +214,7 @@ void GdbRemoteServerEngine::setupInferior()
if (!executableFileName.isEmpty()) {
postCommand("-file-exec-and-symbols \"" + executableFileName.toLocal8Bit() + '"',
CB(handleFileExecAndSymbols));
NoFlags, CB(handleFileExecAndSymbols));
}
}
......@@ -264,11 +264,11 @@ void GdbRemoteServerEngine::callTargetRemote()
}
if (m_isQnxGdb)
postCommand("target qnx " + channel, CB(handleTargetQnx));
postCommand("target qnx " + channel, NoFlags, CB(handleTargetQnx));
else if (startParameters().multiProcess)
postCommand("target extended-remote " + channel, CB(handleTargetExtendedRemote));
postCommand("target extended-remote " + channel, NoFlags, CB(handleTargetExtendedRemote));
else
postCommand("target remote " + channel, CB(handleTargetRemote), 10);
postCommand("target remote " + channel, NoFlags, CB(handleTargetRemote));
}
void GdbRemoteServerEngine::handleTargetRemote(const DebuggerResponse &response)
......@@ -306,10 +306,10 @@ void GdbRemoteServerEngine::handleTargetExtendedRemote(const DebuggerResponse &r
if (startParameters().attachPID > 0) { // attach to pid if valid
// gdb server will stop the remote application itself.
postCommand("attach " + QByteArray::number(startParameters().attachPID),
CB(handleTargetExtendedAttach));
NoFlags, CB(handleTargetExtendedAttach));
} else {
postCommand("-gdb-set remote exec-file " + startParameters().remoteExecutable.toLatin1(),
CB(handleTargetExtendedAttach));
NoFlags, CB(handleTargetExtendedAttach));
}
} else {
QString msg = msgConnectRemoteServerFailed(
......@@ -343,9 +343,9 @@ void GdbRemoteServerEngine::handleTargetQnx(const DebuggerResponse &response)
const qint64 pid = isMasterEngine() ? startParameters().attachPID : masterEngine()->startParameters().attachPID;
const QString remoteExecutable = isMasterEngine() ? startParameters().remoteExecutable : masterEngine()->startParameters().remoteExecutable;
if (pid > -1)
postCommand("attach " + QByteArray::number(pid), CB(handleAttach));
postCommand("attach " + QByteArray::number(pid), NoFlags, CB(handleAttach));
else if (!remoteExecutable.isEmpty())
postCommand("set nto-executable " + remoteExecutable.toLatin1(), CB(handleSetNtoExecutable));
postCommand("set nto-executable " + remoteExecutable.toLatin1(), NoFlags, CB(handleSetNtoExecutable));
else
handleInferiorPrepared();
} else {
......
......@@ -46,8 +46,6 @@ using namespace Utils;
namespace Debugger {
namespace Internal {
#define CB(callback) [this](const DebuggerResponse &r) { callback(r); }
///////////////////////////////////////////////////////////////////////
//
// TermGdbAdapter
......@@ -136,8 +134,8 @@ void GdbTermEngine::runEngine()
{
QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
const qint64 attachedPID = m_stubProc.applicationPID();
postCommand("attach " + QByteArray::number(attachedPID),
CB(handleStubAttached));
postCommand("attach " + QByteArray::number(attachedPID), NoFlags,
[this](const DebuggerResponse &r) { handleStubAttached(r); });
}
void GdbTermEngine::handleStubAttached(const DebuggerResponse &response)
......
......@@ -48,21 +48,6 @@ enum StackColumns
StackColumnCount = StackAddressColumn,
};
////////////////////////////////////////////////////////////////////////
//
// StackCookie
//
////////////////////////////////////////////////////////////////////////
struct StackCookie
{
StackCookie() : isFull(true), gotoLocation(false) {}
StackCookie(bool full, bool jump) : isFull(full), gotoLocation(jump) {}
bool isFull;
bool gotoLocation;
};
////////////////////////////////////////////////////////////////////////
//
// StackModel
......@@ -120,7 +105,4 @@ private:
} // namespace Internal
} // namespace Debugger
Q_DECLARE_METATYPE(Debugger::Internal::StackCookie)
#endif // DEBUGGER_STACKHANDLER_H
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