diff options
Diffstat (limited to 'src/plugins/debugger/lldb/lldbengine.cpp')
-rw-r--r-- | src/plugins/debugger/lldb/lldbengine.cpp | 140 |
1 files changed, 69 insertions, 71 deletions
diff --git a/src/plugins/debugger/lldb/lldbengine.cpp b/src/plugins/debugger/lldb/lldbengine.cpp index 32f0a2cbf7..952505e51f 100644 --- a/src/plugins/debugger/lldb/lldbengine.cpp +++ b/src/plugins/debugger/lldb/lldbengine.cpp @@ -84,6 +84,7 @@ static int ¤tToken() LldbEngine::LldbEngine() { setObjectName("LldbEngine"); + setDebuggerName("LLDB"); connect(action(AutoDerefPointers), &SavedAction::valueChanged, this, &LldbEngine::updateLocals); @@ -114,7 +115,7 @@ LldbEngine::~LldbEngine() m_lldbProc.disconnect(); } -void LldbEngine::executeDebuggerCommand(const QString &command, DebuggerLanguages) +void LldbEngine::executeDebuggerCommand(const QString &command) { DebuggerCommand cmd("executeDebuggerCommand"); cmd.arg("command", command); @@ -175,13 +176,18 @@ void LldbEngine::shutdownInferior() void LldbEngine::shutdownEngine() { QTC_ASSERT(state() == EngineShutdownRequested, qDebug() << state()); - m_lldbProc.kill(); - notifyEngineShutdownFinished(); + if (m_lldbProc.state() == QProcess::Running) + m_lldbProc.terminate(); + else + notifyEngineShutdownFinished(); } void LldbEngine::abortDebuggerProcess() { - m_lldbProc.kill(); + if (m_lldbProc.state() == QProcess::Running) + m_lldbProc.kill(); + else + notifyEngineShutdownFinished(); } void LldbEngine::setupEngine() @@ -290,17 +296,9 @@ void LldbEngine::setupEngine() } cmd2.callback = [this](const DebuggerResponse &response) { - bool success = response.data["success"].toInt(); + const bool success = response.data["success"].toInt(); if (success) { - for (Breakpoint bp : breakHandler()->unclaimedBreakpoints()) { - if (acceptsBreakpoint(bp)) { - bp.setEngine(this); - insertBreakpoint(bp); - } else { - showMessage(QString("BREAKPOINT %1 IN STATE %2 IS NOT ACCEPTABLE") - .arg(bp.id().toString()).arg(bp.state())); - } - } + BreakpointManager::claimBreakpointsForEngine(this); } else { notifyEngineSetupFailed(); } @@ -442,7 +440,7 @@ void LldbEngine::activateFrame(int frameIndex) QTC_ASSERT(frameIndex < handler->stackSize(), return); handler->setCurrentIndex(frameIndex); - gotoLocation(handler->currentFrame()); + gotoCurrentLocation(); DebuggerCommand cmd("activateFrame"); cmd.arg("index", frameIndex); @@ -477,104 +475,103 @@ bool LldbEngine::stateAcceptsBreakpointChanges() const } } -bool LldbEngine::acceptsBreakpoint(Breakpoint bp) const +bool LldbEngine::acceptsBreakpoint(const BreakpointParameters &bp) const { if (runParameters().startMode == AttachCore) return false; - if (bp.parameters().isCppBreakpoint()) + if (bp.isCppBreakpoint()) return true; return isNativeMixedEnabled(); } -void LldbEngine::insertBreakpoint(Breakpoint bp) +void LldbEngine::insertBreakpoint(const Breakpoint &bp) { + QTC_ASSERT(bp, return); DebuggerCommand cmd("insertBreakpoint"); cmd.callback = [this, bp](const DebuggerResponse &response) { - QTC_CHECK(bp.state() == BreakpointInsertProceeding); + QTC_CHECK(bp && bp->state() == BreakpointInsertionProceeding); updateBreakpointData(bp, response.data, true); }; - bp.addToCommand(&cmd); - bp.notifyBreakpointInsertProceeding(); + bp->addToCommand(&cmd); + notifyBreakpointInsertProceeding(bp); runCommand(cmd); } -void LldbEngine::changeBreakpoint(Breakpoint bp) +void LldbEngine::updateBreakpoint(const Breakpoint &bp) { - const BreakpointResponse &response = bp.response(); + QTC_ASSERT(bp, return); DebuggerCommand cmd("changeBreakpoint"); - cmd.arg("lldbid", response.id.toString()); + cmd.arg("lldbid", bp->responseId()); cmd.callback = [this, bp](const DebuggerResponse &response) { - QTC_CHECK(!bp.isValid() || bp.state() == BreakpointChangeProceeding); + QTC_CHECK(bp && bp->state() == BreakpointUpdateProceeding); updateBreakpointData(bp, response.data, false); }; - bp.addToCommand(&cmd); - bp.notifyBreakpointChangeProceeding(); + bp->addToCommand(&cmd); + notifyBreakpointChangeProceeding(bp); runCommand(cmd); } -void LldbEngine::removeBreakpoint(Breakpoint bp) +void LldbEngine::removeBreakpoint(const Breakpoint &bp) { - const BreakpointResponse &response = bp.response(); - if (response.id.isValid()) { + QTC_ASSERT(bp, return); + if (!bp->responseId().isEmpty()) { DebuggerCommand cmd("removeBreakpoint"); - cmd.arg("lldbid", response.id.toString()); - cmd.callback = [bp](const DebuggerResponse &) { - QTC_CHECK(bp.state() == BreakpointRemoveProceeding); - Breakpoint bp0 = bp; - bp0.notifyBreakpointRemoveOk(); - }; - bp.notifyBreakpointRemoveProceeding(); + cmd.arg("lldbid", bp->responseId()); + notifyBreakpointRemoveProceeding(bp); runCommand(cmd); + + // Pretend it succeeds without waiting for response. Feels better. + // Otherwise, clicking in the gutter leaves the breakpoint visible + // for quite some time, so the user assumes a mis-click and clicks + // again, effectivly re-introducing the breakpoint. + notifyBreakpointRemoveOk(bp); } } -void LldbEngine::updateBreakpointData(Breakpoint bp, const GdbMi &bkpt, bool added) +void LldbEngine::updateBreakpointData(const Breakpoint &bp, const GdbMi &bkpt, bool added) { - BreakHandler *handler = breakHandler(); - BreakpointResponseId rid = BreakpointResponseId(bkpt["lldbid"].data()); - if (!bp.isValid()) - bp = handler->findBreakpointByResponseId(rid); - BreakpointResponse response = bp.response(); + QTC_ASSERT(bp, return); + QString rid = bkpt["lldbid"].data(); + QTC_ASSERT(bp, return); if (added) - response.id = rid; - QTC_CHECK(response.id == rid); - response.address = 0; - response.enabled = bkpt["enabled"].toInt(); - response.ignoreCount = bkpt["ignorecount"].toInt(); - response.condition = fromHex(bkpt["condition"].data()); - response.hitCount = bkpt["hitcount"].toInt(); - response.fileName = bkpt["file"].data(); - response.lineNumber = bkpt["line"].toInt(); + bp->setResponseId(rid); + QTC_CHECK(bp->responseId() == rid); + bp->setAddress(0); + bp->setEnabled(bkpt["enabled"].toInt()); + bp->setIgnoreCount(bkpt["ignorecount"].toInt()); + bp->setCondition(fromHex(bkpt["condition"].data())); + bp->setHitCount(bkpt["hitcount"].toInt()); + bp->setFileName(bkpt["file"].data()); + bp->setLineNumber(bkpt["line"].toInt()); GdbMi locations = bkpt["locations"]; const int numChild = int(locations.children().size()); if (numChild > 1) { for (const GdbMi &location : locations.children()) { - const int locid = location["locid"].toInt(); - BreakpointResponse sub; - sub.id = BreakpointResponseId(rid.majorPart(), locid); - sub.type = response.type; - sub.address = location["addr"].toAddress(); - sub.functionName = location["func"].data(); - sub.fileName = location["file"].data(); - sub.lineNumber = location["line"].toInt(); - bp.insertSubBreakpoint(sub); + const QString locid = QString("%1.%2").arg(rid).arg(location["locid"].data()); + SubBreakpoint loc = bp->findOrCreateSubBreakpoint(locid); + QTC_ASSERT(loc, continue); + loc->params.type = bp->type(); + loc->params.address = location["addr"].toAddress(); + loc->params.functionName = location["function"].data(); + loc->params.fileName = location["file"].data(); + loc->params.lineNumber = location["line"].toInt(); } - response.pending = false; + bp->setPending(false); } else if (numChild == 1) { const GdbMi location = locations.childAt(0); - response.address = location["addr"].toAddress(); - response.functionName = location["func"].data(); - response.pending = false; + bp->setAddress(location["addr"].toAddress()); + bp->setFunctionName(location["function"].data()); + bp->setPending(false); } else { // This can happen for pending breakpoints. - showMessage(QString("NO LOCATIONS (YET) FOR BP %1").arg(response.toString())); + showMessage(QString("NO LOCATIONS (YET) FOR BP %1").arg(bp->parameters().toString())); } - bp.setResponse(response); + bp->adjustMarker(); if (added) - bp.notifyBreakpointInsertOk(); + notifyBreakpointInsertOk(bp); else - bp.notifyBreakpointChangeOk(); + notifyBreakpointChangeOk(bp); } void LldbEngine::handleOutputNotification(const GdbMi &output) @@ -896,7 +893,7 @@ void LldbEngine::handleLocationNotification(const GdbMi &reportedLocation) void LldbEngine::reloadRegisters() { - if (!Internal::isRegistersWindowVisible()) + if (!isRegistersWindowVisible()) return; if (state() != InferiorStopOk && state() != InferiorUnrunnable) @@ -1012,7 +1009,8 @@ void LldbEngine::setRegisterValue(const QString &name, const QString &value) bool LldbEngine::hasCapability(unsigned cap) const { - if (cap & (ReverseSteppingCapability + if (cap & (0 + //| ReverseSteppingCapability | AutoDerefPointersCapability | DisassemblerCapability | RegisterCapability |