diff options
Diffstat (limited to 'src/plugins/debugger/cdb/cdbengine.cpp')
-rw-r--r-- | src/plugins/debugger/cdb/cdbengine.cpp | 298 |
1 files changed, 94 insertions, 204 deletions
diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index f64dd94d644..55dbc5c8fb2 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -75,11 +75,10 @@ #include <cctype> -enum { debug = 0 }; -enum { debugLocals = 0 }; -enum { debugSourceMapping = 0 }; -enum { debugWatches = 0 }; -enum { debugBreakpoints = 0 }; +constexpr bool debug = false; +constexpr bool debugLocals = false; +constexpr bool debugSourceMapping = false; +constexpr bool debugBreakpoints = false; #define CB(callback) [this](const DebuggerResponse &r) { callback(r); } @@ -152,40 +151,11 @@ namespace Internal { static const char localsPrefixC[] = "local."; -struct MemoryViewCookie -{ - explicit MemoryViewCookie(MemoryAgent *a = nullptr, quint64 addr = 0, quint64 l = 0) - : agent(a), address(addr), length(l) - {} - - MemoryAgent *agent; - quint64 address; - quint64 length; -}; - -struct MemoryChangeCookie -{ - explicit MemoryChangeCookie(quint64 addr = 0, const QByteArray &d = QByteArray()) : - address(addr), data(d) {} - - quint64 address; - QByteArray data; -}; - -} // namespace Internal -} // namespace Debugger - -Q_DECLARE_METATYPE(Debugger::Internal::MemoryViewCookie) -Q_DECLARE_METATYPE(Debugger::Internal::MemoryChangeCookie) - -namespace Debugger { -namespace Internal { - // Base data structure for command queue entries with callback class CdbCommand { public: - CdbCommand() {} + CdbCommand() = default; CdbCommand(CdbEngine::CommandHandler h) : handler(h) {} CdbEngine::CommandHandler handler; @@ -243,17 +213,19 @@ CdbEngine::CdbEngine() : this, &CdbEngine::readyReadStandardOut); connect(action(UseDebuggingHelpers), &SavedAction::valueChanged, this, &CdbEngine::updateLocals); + + if (action(UseCodeModel)->isChecked()) + m_codeModelSnapshot = CppTools::CppModelManager::instance()->snapshot(); } void CdbEngine::init() { m_effectiveStartMode = NoStartMode; m_accessible = false; - m_specialStopMode = NoSpecialStop; + m_stopMode = NoStopRequested; m_nextCommandToken = 0; m_currentBuiltinResponseToken = -1; - m_operateByInstructionPending = action(OperateByInstruction)->isChecked(); - m_operateByInstruction = true; // Default CDB setting + m_operateByInstruction = true; m_hasDebuggee = false; m_sourceStepInto = false; m_watchPointX = m_watchPointY = 0; @@ -268,7 +240,7 @@ void CdbEngine::init() m_pendingBreakpointMap.clear(); m_insertSubBreakpointMap.clear(); m_pendingSubBreakpointMap.clear(); - m_customSpecialStopData.clear(); + m_interrupCallbacks.clear(); m_symbolAddressCache.clear(); m_coreStopReason.reset(); @@ -295,25 +267,12 @@ void CdbEngine::init() QTC_ASSERT(m_process.state() != QProcess::Running, SynchronousProcess::stopProcess(m_process)); } -CdbEngine::~CdbEngine() -{ -} +CdbEngine::~CdbEngine() = default; void CdbEngine::operateByInstructionTriggered(bool operateByInstruction) { - // To be set next time session becomes accessible - m_operateByInstructionPending = operateByInstruction; - if (state() == InferiorStopOk) - syncOperateByInstruction(operateByInstruction); -} - -void CdbEngine::syncOperateByInstruction(bool operateByInstruction) -{ - if (debug) - qDebug("syncOperateByInstruction current: %d new %d", m_operateByInstruction, operateByInstruction); if (m_operateByInstruction == operateByInstruction) return; - QTC_ASSERT(m_accessible, return); m_operateByInstruction = operateByInstruction; runCommand({QLatin1String(m_operateByInstruction ? "l-t" : "l+t"), NoFlags}); runCommand({QLatin1String(m_operateByInstruction ? "l-s" : "l+s"), NoFlags}); @@ -410,7 +369,7 @@ void CdbEngine::setupEngine() sp.inferior.commandLineArguments.clear(); sp.attachPID = ProcessHandle(terminal()->applicationPid()); sp.startMode = AttachExternal; - sp.inferior.runMode = ApplicationLauncher::Gui; // Force no terminal. + sp.useTerminal = false; // Force no terminal. showMessage(QString("Attaching to %1...").arg(sp.attachPID.pid()), LogMisc); } else { m_effectiveStartMode = sp.startMode; @@ -459,7 +418,7 @@ void CdbEngine::setupEngine() // register idle (debuggee stop) notification << "-c" << ".idle_cmd " + m_extensionCommandPrefix + "idle"; - if (sp.inferior.runMode == ApplicationLauncher::Console) // Separate console + if (sp.useTerminal) // Separate console arguments << "-2"; if (boolSetting(IgnoreFirstChanceAccessViolation)) arguments << "-x"; @@ -527,8 +486,7 @@ void CdbEngine::setupEngine() // Make sure that QTestLib uses OutputDebugString for logging. const QString qtLoggingToConsoleKey = QStringLiteral("QT_LOGGING_TO_CONSOLE"); - if (sp.inferior.runMode != ApplicationLauncher::Console - && !inferiorEnvironment.hasKey(qtLoggingToConsoleKey)) + if (!sp.useTerminal && !inferiorEnvironment.hasKey(qtLoggingToConsoleKey)) inferiorEnvironment.set(qtLoggingToConsoleKey, QString(QLatin1Char('0'))); m_process.setEnvironment(mergeEnvironment(inferiorEnvironment.toStringList(), @@ -565,6 +523,7 @@ void CdbEngine::handleInitialSessionIdle() const DebuggerRunParameters &rp = runParameters(); if (!rp.commandsAfterConnect.isEmpty()) runCommand({rp.commandsAfterConnect, NoFlags}); + operateByInstructionTriggered(action(OperateByInstruction)->isChecked()); // QmlCppEngine expects the QML engine to be connected before any breakpoints are hit // (attemptBreakpointSynchronization() will be directly called then) attemptBreakpointSynchronization(); @@ -580,10 +539,12 @@ void CdbEngine::handleInitialSessionIdle() runCommand({"sxn 0x4000001f", NoFlags}); // Do not break on WowX86 exceptions. runCommand({"sxn ibp", NoFlags}); // Do not break on initial breakpoints. runCommand({".asm source_line", NoFlags}); // Source line in assembly - runCommand({m_extensionCommandPrefix + "setparameter maxStringLength=" - + action(MaximalStringLength)->value().toString() - + " maxStackDepth=" - + action(MaximalStackDepth)->value().toString(), NoFlags}); + runCommand({m_extensionCommandPrefix + + "setparameter maxStringLength=" + action(MaximalStringLength)->value().toString() + + " maxStackDepth=" + action(MaximalStackDepth)->value().toString() + + " firstChance=" + (action(FirstChanceExceptionTaskEntry)->value().toBool() ? "1" : "0") + + " secondChance=" + (action(SecondChanceExceptionTaskEntry)->value().toBool() ? "1" : "0") + , NoFlags}); if (boolSetting(CdbUsePythonDumper)) runCommand({"print(sys.version)", ScriptCommand, CB(setupScripting)}); @@ -643,7 +604,7 @@ void CdbEngine::runEngine() qDebug("runEngine"); const QStringList breakEvents = stringListSetting(CdbBreakEvents); - foreach (const QString &breakEvent, breakEvents) + for (const QString &breakEvent : breakEvents) runCommand({"sxe " + breakEvent, NoFlags}); // Break functions: each function must be fully qualified, // else the debugger will slow down considerably. @@ -863,14 +824,7 @@ void CdbEngine::interruptInferior() notifyInferiorRunOk(); return; } - doInterruptInferior(NoSpecialStop); -} - -void CdbEngine::doInterruptInferiorCustomSpecialStop(const QVariant &v) -{ - if (m_specialStopMode == NoSpecialStop) - doInterruptInferior(CustomSpecialStop); - m_customSpecialStopData.push_back(v); + doInterruptInferior(); } void CdbEngine::handleDoInterruptInferior(const QString &errorMessage) @@ -885,11 +839,20 @@ void CdbEngine::handleDoInterruptInferior(const QString &errorMessage) m_signalOperation.clear(); } -void CdbEngine::doInterruptInferior(SpecialStopMode sm) +void CdbEngine::doInterruptInferior(const InterruptCallback &callback) { - showMessage(QString("Interrupting process %1...").arg(inferiorPid()), LogMisc); + if (callback) { + m_interrupCallbacks.push_back(callback); + if (!m_initialSessionIdleHandled) + return; + if (m_stopMode == NoStopRequested) + m_stopMode = Callback; + } else { + m_stopMode = Interrupt; + } - QTC_ASSERT(!m_signalOperation, notifyInferiorStopFailed(); return;); + showMessage(QString("Interrupting process %1...").arg(inferiorPid()), LogMisc); + QTC_ASSERT(!m_signalOperation, notifyInferiorStopFailed(); return); if (DebuggerRunTool *rt = runTool()) { IDevice::ConstPtr device = rt->device(); if (!device) @@ -897,7 +860,6 @@ void CdbEngine::doInterruptInferior(SpecialStopMode sm) if (device) m_signalOperation = device->signalOperation(); } - m_specialStopMode = sm; QTC_ASSERT(m_signalOperation, notifyInferiorStopFailed(); return;); connect(m_signalOperation.data(), &DeviceProcessSignalOperation::finished, this, &CdbEngine::handleDoInterruptInferior); @@ -985,7 +947,7 @@ void CdbEngine::handleJumpToLineAddressResolution(const DebuggerResponse &respon if (apPos != -1) answer.remove(apPos, 1); bool ok; - const quint64 address = answer.toLongLong(&ok, 16); + const quint64 address = answer.toULongLong(&ok, 16); if (ok && address) { jumpToAddress(address); gotoLocation(Location(context.fileName, context.lineNumber)); @@ -994,7 +956,7 @@ void CdbEngine::handleJumpToLineAddressResolution(const DebuggerResponse &respon static inline bool isAsciiWord(const QString &s) { - foreach (const QChar &c, s) { + for (const QChar &c : s) { if (!c.isLetterOrNumber() || c.toLatin1() == 0) return false; } @@ -1063,9 +1025,12 @@ void CdbEngine::runCommand(const DebuggerCommand &dbgCmd) { QString cmd = dbgCmd.function + dbgCmd.argsToString(); if (!m_accessible) { - const QString msg = QString("Attempt to issue command \"%1\" to non-accessible session (%2)") + doInterruptInferior([this, dbgCmd](){ + runCommand(dbgCmd); + }); + const QString msg = QString("Attempt to issue command \"%1\" to non-accessible session (%2)... interrupting") .arg(cmd, stateName(state())); - showMessage(msg, LogError); + showMessage(msg, LogMisc); return; } @@ -1106,7 +1071,7 @@ void CdbEngine::runCommand(const DebuggerCommand &dbgCmd) elapsedLogTime(), qPrintable(dbgCmd.function), qPrintable(stateName(state())), m_commandForToken.size()); } - if (debug > 1) { + if (debug) { qDebug("CdbEngine::postCommand: resulting command '%s'\n", qPrintable(fullCmd)); } showMessage(cmd, LogInput); @@ -1165,10 +1130,9 @@ void CdbEngine::doUpdateLocals(const UpdateParameters &updateParameters) cmd.arg("displaystringlimit", action(DisplayStringLimit)->value().toString()); if (boolSetting(UseCodeModel)) { - QStringList uninitializedVariables; - getUninitializedVariables(Internal::cppCodeModelSnapshot(), - frame.function, frame.file, frame.line, &uninitializedVariables); - cmd.arg("uninitialized", uninitializedVariables); + QStringList variables = getUninitializedVariables(m_codeModelSnapshot, + frame.function, frame.file, frame.line); + cmd.arg("uninitialized", variables); } cmd.callback = [this](const DebuggerResponse &response) { @@ -1215,7 +1179,7 @@ void CdbEngine::doUpdateLocals(const UpdateParameters &updateParameters) if (!expanded.isEmpty()) { str << blankSeparator << "-e "; int i = 0; - foreach (const QString &e, expanded) { + for (const QString &e : expanded) { if (i++) str << ','; str << e; @@ -1236,13 +1200,12 @@ void CdbEngine::doUpdateLocals(const UpdateParameters &updateParameters) // Uninitialized variables if desired. Quote as safeguard against shadowed // variables in case of errors in uninitializedVariables(). if (boolSetting(UseCodeModel)) { - QStringList uninitializedVariables; - getUninitializedVariables(Internal::cppCodeModelSnapshot(), - frame.function, frame.file, frame.line, &uninitializedVariables); - if (!uninitializedVariables.isEmpty()) { + const QStringList variables = getUninitializedVariables(m_codeModelSnapshot, + frame.function, frame.file, frame.line); + if (!variables.isEmpty()) { str << blankSeparator << "-u \""; int i = 0; - foreach (const QString &u, uninitializedVariables) { + for (const QString &u : variables) { if (i++) str << ','; str << localsPrefixC << u; @@ -1493,34 +1456,26 @@ void CdbEngine::handleResolveSymbolHelper(const QList<quint64> &addresses, Disas } } -void CdbEngine::fetchMemory(MemoryAgent *agent, quint64 addr, quint64 length) +void CdbEngine::fetchMemory(MemoryAgent *agent, quint64 address, quint64 length) { if (debug) - qDebug("CdbEngine::fetchMemory %llu bytes from 0x%llx", length, addr); - const MemoryViewCookie cookie(agent, addr, length); - if (m_accessible) - postFetchMemory(cookie); - else - doInterruptInferiorCustomSpecialStop(qVariantFromValue(cookie)); -} - -void CdbEngine::postFetchMemory(const MemoryViewCookie &cookie) -{ + qDebug("CdbEngine::fetchMemory %llu bytes from 0x%llx", length, address); DebuggerCommand cmd("memory", ExtensionCommand); QString args; StringInputStream str(args); - str << cookie.address << ' ' << cookie.length; + str << address << ' ' << length; cmd.args = args; - cmd.callback = [this, cookie](const DebuggerResponse &response) { - if (!cookie.agent) + cmd.callback = [this, agent = QPointer<MemoryAgent>(agent), address, length] + (const DebuggerResponse &response) { + if (!agent) return; if (response.resultClass == ResultDone) { const QByteArray data = QByteArray::fromHex(response.data.data().toUtf8()); - if (unsigned(data.size()) == cookie.length) - cookie.agent->addData(cookie.address, data); + if (unsigned(data.size()) == length) + agent->addData(address, data); } else { showMessage(response.data["msg"].data(), LogWarning); - cookie.agent->addData(cookie.address, QByteArray(int(cookie.length), char())); + agent->addData(address, QByteArray(int(length), char())); } }; runCommand(cmd); @@ -1529,12 +1484,7 @@ void CdbEngine::postFetchMemory(const MemoryViewCookie &cookie) void CdbEngine::changeMemory(MemoryAgent *, quint64 addr, const QByteArray &data) { QTC_ASSERT(!data.isEmpty(), return); - if (!m_accessible) { - const MemoryChangeCookie cookie(addr, data); - doInterruptInferiorCustomSpecialStop(qVariantFromValue(cookie)); - } else { - runCommand({cdbWriteMemoryCommand(addr, data), NoFlags}); - } + runCommand({cdbWriteMemoryCommand(addr, data), NoFlags}); } void CdbEngine::reloadModules() @@ -1593,8 +1543,8 @@ void CdbEngine::handleModules(const DebuggerResponse &response) Module module; module.moduleName = gdbmiModule["name"].data(); module.modulePath = gdbmiModule["image"].data(); - module.startAddress = gdbmiModule["start"].data().toULongLong(0, 0); - module.endAddress = gdbmiModule["end"].data().toULongLong(0, 0); + module.startAddress = gdbmiModule["start"].data().toULongLong(nullptr, 0); + module.endAddress = gdbmiModule["end"].data().toULongLong(nullptr, 0); if (gdbmiModule["deferred"].type() == GdbMi::Invalid) module.symbolsRead = Module::ReadOk; handler->updateModule(module); @@ -1821,6 +1771,8 @@ unsigned CdbEngine::examineStopReason(const GdbMi &stopReason, return rc; } if (reason == "exception") { + if (m_stopMode == Callback) + rc |= StopIgnoreContinue; WinException exception; exception.fromGdbMI(stopReason); QString description = exception.toString(); @@ -1863,6 +1815,7 @@ void CdbEngine::processStop(const GdbMi &stopReason, bool conditionalBreakPointT ThreadId forcedThreadId; const unsigned stopFlags = examineStopReason(stopReason, &message, &exceptionBoxMessage, conditionalBreakPointTriggered); + m_stopMode = NoStopRequested; // Do the non-blocking log reporting if (stopFlags & StopReportLog) showMessage(message, LogMisc); @@ -1946,7 +1899,7 @@ void CdbEngine::handleBreakInsert(const DebuggerResponse &response, const Breakp const QStringList reply = response.data.data().split('\n'); if (reply.isEmpty()) return; - foreach (const QString &line, reply) + for (const QString &line : reply) showMessage(line); if (!reply.last().startsWith("Ambiguous symbol error") && (reply.length() < 2 || !reply.at(reply.length() - 2).startsWith("Ambiguous symbol error"))) { @@ -1967,7 +1920,7 @@ void CdbEngine::handleBreakInsert(const DebuggerResponse &response, const Breakp return; Breakpoint bp = breakHandler()->breakpointById(bpId); // add break point for every match - int subBreakPointID = 0; + quint16 subBreakPointID = 0; for (auto line = reply.constBegin(), end = reply.constEnd(); line != end; ++line) { if (!line->startsWith("Matched: ")) continue; @@ -2050,9 +2003,9 @@ void CdbEngine::handleSessionAccessible(unsigned long cdbExState) return; if (debug) - qDebug("CdbEngine::handleSessionAccessible %dms in state '%s'/'%s', special mode %d", + qDebug("CdbEngine::handleSessionAccessible %dms in state '%s'/'%s'", elapsedLogTime(), cdbStatusName(cdbExState), - qPrintable(stateName(state())), m_specialStopMode); + qPrintable(stateName(state()))); switch (s) { case EngineShutdownRequested: @@ -2075,9 +2028,9 @@ void CdbEngine::handleSessionInaccessible(unsigned long cdbExState) return; if (debug) - qDebug("CdbEngine::handleSessionInaccessible %dms in state '%s', '%s', special mode %d", + qDebug("CdbEngine::handleSessionInaccessible %dms in state '%s', '%s'", elapsedLogTime(), cdbStatusName(cdbExState), - qPrintable(stateName(state())), m_specialStopMode); + qPrintable(stateName(state()))); switch (state()) { case EngineSetupRequested: @@ -2114,37 +2067,13 @@ void CdbEngine::handleSessionIdle(const QString &message) return; if (debug) - qDebug("CdbEngine::handleSessionIdle %dms '%s' in state '%s', special mode %d", + qDebug("CdbEngine::handleSessionIdle %dms '%s' in state '%s'", elapsedLogTime(), qPrintable(message), - qPrintable(stateName(state())), m_specialStopMode); - - // Switch source level debugging - syncOperateByInstruction(m_operateByInstructionPending); - - // Engine-special stop reasons: Breakpoints and setup - const SpecialStopMode specialStopMode = m_specialStopMode; - - m_specialStopMode = NoSpecialStop; + qPrintable(stateName(state()))); - switch (specialStopMode) { - case SpecialStopSynchronizeBreakpoints: - if (debug) - qDebug("attemptBreakpointSynchronization in special stop"); - attemptBreakpointSynchronization(); - doContinueInferior(); - return; - case SpecialStopGetWidgetAt: - postWidgetAtCommand(); - return; - case CustomSpecialStop: - foreach (const QVariant &data, m_customSpecialStopData) - handleCustomSpecialStop(data); - m_customSpecialStopData.clear(); - doContinueInferior(); - return; - case NoSpecialStop: - break; - } + for (const InterruptCallback &callback : m_interrupCallbacks) + callback(); + m_interrupCallbacks.clear(); if (!m_initialSessionIdleHandled) { // Temporary stop at beginning handleInitialSessionIdle(); @@ -2163,11 +2092,11 @@ void CdbEngine::handleSessionIdle(const QString &message) void CdbEngine::handleExtensionMessage(char t, int token, const QString &what, const QString &message) { - if (debug > 1) { + if (debug) { QDebug nospace = qDebug().nospace(); nospace << "handleExtensionMessage " << t << ' ' << token << ' ' << what << ' ' << stateName(state()); - if (t == 'N' || debug > 1) + if (t == 'N' || debug) nospace << ' ' << message; else nospace << ' ' << message.size() << " bytes"; @@ -2268,12 +2197,11 @@ void CdbEngine::handleExtensionMessage(char t, int token, const QString &what, c if (!isDebuggerWinException(exception.exceptionCode)) { const Task::TaskType type = isFatalWinException(exception.exceptionCode) ? Task::Error : Task::Warning; - const FileName fileName = exception.file.isEmpty() - ? FileName() : FileName::fromUserInput(exception.file); + const FileName fileName = FileName::fromUserInput(exception.file); const QString taskEntry = tr("Debugger encountered an exception: %1").arg( exception.toString(false).trimmed()); TaskHub::addTask(type, taskEntry, - Debugger::Constants::TASK_CATEGORY_DEBUGGER_RUNTIME, + Constants::TASK_CATEGORY_DEBUGGER_RUNTIME, fileName, exception.lineNumber); } return; @@ -2331,7 +2259,7 @@ void CdbEngine::parseOutputLine(QString line) static const QString creatorExtPrefix = "<qtcreatorcdbext>|"; if (line.startsWith(creatorExtPrefix)) { // "<qtcreatorcdbext>|type_char|token|remainingChunks|serviceName|message" - const char type = line.at(creatorExtPrefix.size()).unicode(); + const char type = char(line.at(creatorExtPrefix.size()).unicode()); // integer token const int tokenPos = creatorExtPrefix.size() + 2; const int tokenEndPos = line.indexOf('|', tokenPos); @@ -2360,7 +2288,7 @@ void CdbEngine::parseOutputLine(QString line) int token = 0; bool isStartToken = false; const bool isCommandToken = checkCommandToken(m_tokenPrefix, line, &token, &isStartToken); - if (debug > 1) + if (debug) qDebug("Reading CDB stdout '%s',\n isCommand=%d, token=%d, isStart=%d", qPrintable(line), isCommandToken, token, isStartToken); @@ -2467,7 +2395,7 @@ static QByteArray multiBreakpointCommand(const char *cmdC, const Breakpoints &bp { QByteArray cmd(cmdC); ByteArrayInputStream str(cmd); - foreach (const BreakpointData *bp, bps) + for (const BreakpointData *bp : bps) str << ' ' << bp->bpNumber; return cmd; } @@ -2569,7 +2497,7 @@ void CdbEngine::attemptBreakpointSynchronization() // Check if there is anything to be done at all. BreakHandler *handler = breakHandler(); // Take ownership of the breakpoint. Requests insertion. TODO: Cpp only? - foreach (Breakpoint bp, handler->unclaimedBreakpoints()) + for (Breakpoint bp : handler->unclaimedBreakpoints()) if (acceptsBreakpoint(bp)) bp.setEngine(this); @@ -2577,7 +2505,7 @@ void CdbEngine::attemptBreakpointSynchronization() bool changed = !m_insertSubBreakpointMap.isEmpty(); const Breakpoints bps = handler->engineBreakpoints(this); if (!changed) { - foreach (Breakpoint bp, bps) { + for (Breakpoint bp : bps) { switch (bp.state()) { case BreakpointInsertRequested: case BreakpointRemoveRequested: @@ -2604,18 +2532,12 @@ void CdbEngine::attemptBreakpointSynchronization() if (!changed) return; - if (!m_accessible) { - // No nested calls. - if (m_specialStopMode != SpecialStopSynchronizeBreakpoints) - doInterruptInferior(SpecialStopSynchronizeBreakpoints); - return; - } // Add/Change breakpoints and store pending ones in map, since // Breakhandler::setResponse() on pending breakpoints clears the pending flag. // handleBreakPoints will the complete that information and set it on the break handler. bool addedChanged = false; QScopedPointer<BreakpointCorrectionContext> lineCorrection; - foreach (Breakpoint bp, bps) { + for (Breakpoint bp : bps) { BreakpointParameters parameters = bp.parameters(); BreakpointModelId id = bp.id(); const auto handleBreakInsertCB = [this, id](const DebuggerResponse &r) { handleBreakInsert(r, id); }; @@ -2634,9 +2556,10 @@ void CdbEngine::attemptBreakpointSynchronization() && parameters.type == BreakpointByFileAndLine && boolSetting(CdbBreakPointCorrection)) { if (lineCorrection.isNull()) - lineCorrection.reset(new BreakpointCorrectionContext(Internal::cppCodeModelSnapshot(), + lineCorrection.reset(new BreakpointCorrectionContext(m_codeModelSnapshot, CppTools::CppModelManager::instance()->workingCopy())); - response.lineNumber = lineCorrection->fixLineNumber(parameters.fileName, parameters.lineNumber); + response.lineNumber = int(lineCorrection->fixLineNumber( + parameters.fileName, unsigned(parameters.lineNumber))); QString cmd = cdbAddBreakpointCommand(response, m_sourcePathMappings, id, false); runCommand({cmd, BuiltinCommand, handleBreakInsertCB}); } else { @@ -2763,7 +2686,7 @@ static StackFrames parseFrames(const GdbMi &gdbmi, bool *incomplete = nullptr) frame.function = frameMi["function"].data(); frame.module = frameMi["from"].data(); frame.context = frameMi["context"].data(); - frame.address = frameMi["address"].data().toULongLong(0, 16); + frame.address = frameMi["address"].data().toULongLong(nullptr, 16); rc.push_back(frame); } return rc; @@ -2967,7 +2890,7 @@ void CdbEngine::handleWidgetAt(const DebuggerResponse &response) break; } // 0x000 -> nothing found - if (!watchExp.mid(sepPos + 1).toULongLong(0, 0)) { + if (!watchExp.mid(sepPos + 1).toULongLong(nullptr, 0)) { message = QString("No widget could be found at %1, %2.").arg(m_watchPointX).arg(m_watchPointY); break; } @@ -3076,44 +2999,11 @@ void CdbEngine::watchPoint(const QPoint &p) { m_watchPointX = p.x(); m_watchPointY = p.y(); - switch (state()) { - case InferiorStopOk: - postWidgetAtCommand(); - break; - case InferiorRunOk: - // "Select Widget to Watch" from a running application is currently not - // supported. It could be implemented via SpecialStopGetWidgetAt-mode, - // but requires some work as not to confuse the engine by state-change notifications - // emitted by the debuggee function call. - showMessage(tr("\"Select Widget to Watch\": Please stop the application first."), LogWarning); - break; - default: - showMessage(tr("\"Select Widget to Watch\": Not supported in state \"%1\"."). - arg(stateName(state())), LogWarning); - break; - } -} - -void CdbEngine::postWidgetAtCommand() -{ DebuggerCommand cmd("widgetat", ExtensionCommand); - cmd.args = QString("%1 %2").arg(m_watchPointX, m_watchPointY); + cmd.args = QString("%1 %2").arg(p.x(), p.y()); runCommand(cmd); } -void CdbEngine::handleCustomSpecialStop(const QVariant &v) -{ - if (v.canConvert<MemoryChangeCookie>()) { - const MemoryChangeCookie changeData = qvariant_cast<MemoryChangeCookie>(v); - runCommand({cdbWriteMemoryCommand(changeData.address, changeData.data), NoFlags}); - return; - } - if (v.canConvert<MemoryViewCookie>()) { - postFetchMemory(qvariant_cast<MemoryViewCookie>(v)); - return; - } -} - } // namespace Internal } // namespace Debugger |