Debugger: Make most views per-engine instead of singletons

This is a step towards properly supporting multiple debugger
sessions side-by-side.

The combined C++-and-QML engine has been removed, instead a
combined setup creates now two individual engines, under a single
DebuggerRunTool but mostly independent with no combined state
machine. This requires a few more clicks in some cases, but
makes it easier to direct e.g. interrupt requests to the
interesting engine.

Care has been taken to not change the UX of the single debugger
session use case if possible. The fat debug button operates
as-before in that case, i.e. switches to Interrupt if the
single active runconfiguration runs in the debugger etc.

Most views are made per-engine, running an engine creates
a new Perspective, which is destroyed when the run control dies.

The snapshot view remains global and becomes primary source
of information on a "current engine" that receives all menu
and otherwise global input.

There is a new global "Breakpoint Preset" view containing
all "static" breakpoint data. When an engine starts up it
"claims" breakpoint it believes it can handle, but operates
on a copy of the static data. The markers of the static
version are suppressed as long as an engine controls a
breakpoint (that inclusive all resolved locations), but are
re-instatet once the engine quits.

The old Breakpoint class that already contained this split
per-instance was split into a new Breakpoint and a
GlobalBreakpoint class, with a per-engine model for Breakpoints,
and a singleton model containing GlobalBreakpoints.

There is a new CppDebuggerEngine intermediate level serving as
base for C++ (or, rather, "compiled") binary debugging, i.e.
{Gdb,Lldb,Cdb}Engine, taking over bits of the current DebuggerEngine
base that are not applicable to non-binary debuggers.

Change-Id: I9994f4c188379b4aee0c4f379edd4759fbb0bd43
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
hjk
2018-07-31 12:30:48 +02:00
parent d6911fd10c
commit 3b5ecac238
58 changed files with 6543 additions and 6100 deletions

View File

@@ -65,12 +65,11 @@ namespace Internal {
PdbEngine::PdbEngine()
{
setObjectName("PdbEngine");
setDebuggerName("PDB");
}
void PdbEngine::executeDebuggerCommand(const QString &command, DebuggerLanguages languages)
void PdbEngine::executeDebuggerCommand(const QString &command)
{
if (!(languages & CppLanguage))
return;
QTC_ASSERT(state() == InferiorStopOk, qDebug() << state());
if (state() == DebuggerNotReady) {
showMessage("PDB PROCESS NOT RUNNING, PLAIN CMD IGNORED: " + command);
@@ -157,7 +156,7 @@ void PdbEngine::runEngine()
{
QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
showStatusMessage(tr("Running requested..."), 5000);
attemptBreakpointSynchronization();
BreakpointManager::claimBreakpointsForEngine(this);
notifyEngineRunAndInferiorStopOk();
updateAll();
}
@@ -246,35 +245,44 @@ void PdbEngine::selectThread(ThreadId threadId)
Q_UNUSED(threadId)
}
bool PdbEngine::acceptsBreakpoint(Breakpoint bp) const
bool PdbEngine::acceptsBreakpoint(const BreakpointParameters &bp) const
{
const QString fileName = bp.fileName();
const QString fileName = bp.fileName;
return fileName.endsWith(".py");
}
void PdbEngine::insertBreakpoint(Breakpoint bp)
void PdbEngine::insertBreakpoint(const Breakpoint &bp)
{
QTC_CHECK(bp.state() == BreakpointInsertRequested);
bp.notifyBreakpointInsertProceeding();
QTC_ASSERT(bp, return);
QTC_CHECK(bp->state() == BreakpointInsertionRequested);
notifyBreakpointInsertProceeding(bp);
QString loc;
if (bp.type() == BreakpointByFunction)
loc = bp.functionName();
const BreakpointParameters &params = bp->requestedParameters();
if (params.type == BreakpointByFunction)
loc = params.functionName;
else
loc = bp.fileName() + ':' + QString::number(bp.lineNumber());
loc = params.fileName + ':' + QString::number(params.lineNumber);
postDirectCommand("break " + loc);
}
void PdbEngine::removeBreakpoint(Breakpoint bp)
void PdbEngine::updateBreakpoint(const Breakpoint &bp)
{
QTC_CHECK(bp.state() == BreakpointRemoveRequested);
bp.notifyBreakpointRemoveProceeding();
BreakpointResponse br = bp.response();
showMessage(QString("DELETING BP %1 IN %2").arg(br.id.toString()).arg(bp.fileName()));
postDirectCommand("clear " + br.id.toString());
Q_UNUSED(bp);
QTC_CHECK(false);
}
void PdbEngine::removeBreakpoint(const Breakpoint &bp)
{
QTC_ASSERT(bp, return);
QTC_CHECK(bp->state() == BreakpointRemoveRequested);
notifyBreakpointRemoveProceeding(bp);
showMessage(QString("DELETING BP %1 IN %2")
.arg(bp->responseId()).arg(bp->fileName()));
postDirectCommand("clear " + bp->responseId());
// Pretend it succeeds without waiting for response.
bp.notifyBreakpointRemoveOk();
notifyBreakpointRemoveOk(bp);
}
void PdbEngine::loadSymbols(const QString &moduleName)
@@ -459,8 +467,8 @@ void PdbEngine::handleOutput(const QString &data)
void PdbEngine::handleOutput2(const QString &data)
{
foreach (QString line, data.split('\n')) {
const QStringList lines = data.split('\n');
for (const QString &line : lines) {
GdbMi item;
item.fromString(line);
@@ -479,21 +487,25 @@ void PdbEngine::handleOutput2(const QString &data)
} else if (line.startsWith("state=")) {
refreshState(item);
} else if (line.startsWith("Breakpoint")) {
int pos1 = line.indexOf(" at ");
const int pos1 = line.indexOf(" at ");
QTC_ASSERT(pos1 != -1, continue);
QString bpnr = line.mid(11, pos1 - 11);
int pos2 = line.lastIndexOf(':');
const QString bpnr = line.mid(11, pos1 - 11);
const int pos2 = line.lastIndexOf(':');
QTC_ASSERT(pos2 != -1, continue);
BreakpointResponse br;
br.id = BreakpointResponseId(bpnr);
br.fileName = line.mid(pos1 + 4, pos2 - pos1 - 4);
br.lineNumber = line.mid(pos2 + 1).toInt();
Breakpoint bp = breakHandler()->findBreakpointByFileAndLine(br.fileName, br.lineNumber, false);
if (bp.isValid()) {
bp.setResponse(br);
QTC_CHECK(!bp.needsChange());
bp.notifyBreakpointInsertOk();
}
const QString fileName = line.mid(pos1 + 4, pos2 - pos1 - 4);
const int lineNumber = line.mid(pos2 + 1).toInt();
const Breakpoint bp = Utils::findOrDefault(breakHandler()->breakpoints(), [&](const Breakpoint &bp) {
return bp->parameters().isLocatedAt(fileName, lineNumber, bp->markerFileName())
|| bp->requestedParameters().isLocatedAt(fileName, lineNumber, bp->markerFileName());
});
QTC_ASSERT(bp, continue);
bp->setResponseId(bpnr);
bp->setFileName(fileName);
bp->setLineNumber(lineNumber);
bp->adjustMarker();
bp->setPending(false);
QTC_CHECK(!bp->needsChange());
notifyBreakpointInsertOk(bp);
}
}
}