From 3e30c4b5712e2381dd35bf10cbb3fbca93fb1cde Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 6 Jan 2021 17:34:41 +0100 Subject: [PATCH] Debugger: Move initial breakpoint setting into individual branches This avoids pending breakpoints in local attach setups now. Change-Id: I6872a97020955180d4c3f915f6bb19c1f771f07f Reviewed-by: Christian Stenger --- src/plugins/debugger/gdb/gdbengine.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 9aa72fbebcf..fbb1e8fac0d 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -4191,12 +4191,11 @@ void GdbEngine::runEngine() { CHECK_STATE(EngineRunRequested); - claimInitialBreakpoints(); - const DebuggerRunParameters &rp = runParameters(); if (rp.startMode == AttachToRemoteProcess) { + claimInitialBreakpoints(); notifyEngineRunAndInferiorStopOk(); QString channel = rp.remoteChannel; @@ -4206,8 +4205,9 @@ void GdbEngine::runEngine() const qint64 pid = rp.attachPID.pid(); showStatusMessage(tr("Attaching to process %1.").arg(pid)); - runCommand({"attach " + QString::number(pid), - [this](const DebuggerResponse &r) { handleLocalAttach(r); }}); + runCommand({"attach " + QString::number(pid), [this](const DebuggerResponse &r) { + handleLocalAttach(r); + }}); // In some cases we get only output like // "Could not attach to process. If your uid matches the uid of the target\n" // "process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try\n" @@ -4218,6 +4218,7 @@ void GdbEngine::runEngine() } else if (isRemoteEngine()) { + claimInitialBreakpoints(); if (runParameters().useContinueInsteadOfRun) { notifyEngineRunAndInferiorStopOk(); continueInferiorInternal(); @@ -4227,6 +4228,7 @@ void GdbEngine::runEngine() } else if (isCoreEngine()) { + claimInitialBreakpoints(); runCommand({"target core " + runParameters().coreFile, CB(handleTargetCore)}); } else if (isTermEngine()) { @@ -4240,6 +4242,7 @@ void GdbEngine::runEngine() } else if (isPlainEngine()) { + claimInitialBreakpoints(); if (runParameters().useContinueInsteadOfRun) runCommand({"-exec-continue", DebuggerCommand::RunRequest, CB(handleExecuteContinue)}); else @@ -4260,11 +4263,13 @@ void GdbEngine::handleLocalAttach(const DebuggerResponse &response) // We will get a '*stopped' later that we'll interpret as 'spontaneous' // So acknowledge the current state and put a delayed 'continue' in the pipe. showMessage(tr("Attached to running application."), StatusBar); + claimInitialBreakpoints(); notifyEngineRunAndInferiorRunOk(); } else { // InferiorStopOk, e.g. for "Attach to running application". // The *stopped came in between sending the 'attach' and // receiving its '^done'. + claimInitialBreakpoints(); notifyEngineRunAndInferiorStopOk(); if (runParameters().continueAfterAttach) continueInferiorInternal(); @@ -4602,6 +4607,7 @@ void GdbEngine::handleStubAttached(const DebuggerResponse &response, qint64 main switch (response.resultClass) { case ResultDone: case ResultRunning: + claimInitialBreakpoints(); if (runParameters().toolChainAbi.os() == ProjectExplorer::Abi::WindowsOS) { QString errorMessage; // Resume thread that was suspended by console stub process (see stub code).