From 2dfa539b9651d6d1d49c82836faa795d16326ccd Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 5 May 2020 10:46:05 +0200 Subject: [PATCH] Debugger: Avoid race condition on setting initial LLDB breakpoints Breakpoints inserting is async, so they did end up when the process was running already. This adds an extra roundtrip. Better, but more intrusive solution might be to set the initial breakpoints synchronously, but that would touch all engines. Change-Id: Ia728a9c5ae8f1d6d29d3cc02b9e2d04952091fe9 Reviewed-by: David Schulz Reviewed-by: Christian Stenger --- share/qtcreator/debugger/lldbbridge.py | 4 +++- src/plugins/debugger/lldb/lldbengine.cpp | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/share/qtcreator/debugger/lldbbridge.py b/share/qtcreator/debugger/lldbbridge.py index f0083be012d..8ce954ce1ce 100644 --- a/share/qtcreator/debugger/lldbbridge.py +++ b/share/qtcreator/debugger/lldbbridge.py @@ -124,7 +124,6 @@ class Dumper(DumperBase): self.interpreterBreakpointResolvers = [] self.report('lldbversion=\"%s\"' % lldb.SBDebugger.GetVersionString()) - self.reportState('enginesetupok') def fromNativeFrameValue(self, nativeValue): return self.fromNativeValue(nativeValue) @@ -1732,6 +1731,9 @@ class Dumper(DumperBase): error = str(result.GetError()) self.report('success="%d",output="%s",error="%s"' % (success, output, error)) + def executeRoundtrip(self, args): + self.reportResult('', args) + def fetchDisassembler(self, args): functionName = args.get('function', '') flavor = args.get('flavor', '') diff --git a/src/plugins/debugger/lldb/lldbengine.cpp b/src/plugins/debugger/lldb/lldbengine.cpp index 05a7d3b14f5..20badcf0a8e 100644 --- a/src/plugins/debugger/lldb/lldbengine.cpp +++ b/src/plugins/debugger/lldb/lldbengine.cpp @@ -314,6 +314,13 @@ void LldbEngine::setupEngine() const bool success = response.data["success"].toInt(); if (success) { BreakpointManager::claimBreakpointsForEngine(this); + // Some extra roundtrip to make sure we end up behind all commands triggered + // from claimBreakpointsForEngine(). + QTimer::singleShot(0, this, [this] { + DebuggerCommand cmd3("executeRoundtrip"); + cmd3.callback = [this](const DebuggerResponse &) { notifyEngineSetupOk(); }; + runCommand(cmd3); + }); } else { notifyEngineSetupFailed(); } @@ -903,8 +910,6 @@ void LldbEngine::handleStateNotification(const GdbMi &item) notifyInferiorStopFailed(); else if (newState == "inferiorill") notifyInferiorIll(); - else if (newState == "enginesetupok") - notifyEngineSetupOk(); else if (newState == "enginesetupfailed") { Core::AsynchronousMessageBox::critical(adapterStartFailed(), item["error"].data());