https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/178466
Backport fa3b3a0be13c3921d983375b1d0ac03d3d2b725d Requested by: @da-viper >From 0e9676794030b74c69351370175058c0be97bd69 Mon Sep 17 00:00:00 2001 From: Ebuka Ezike <[email protected]> Date: Wed, 28 Jan 2026 16:51:12 +0000 Subject: [PATCH] [lldb-dap] Fix debugger initialisation order in DAP::InitializeDebugger (#178022) Validate the debugger before assigning it to the member debugger to avoid setting an invalid debugger on error. We usually have an existing session with that debugger ends up messing with that session. (cherry picked from commit fa3b3a0be13c3921d983375b1d0ac03d3d2b725d) --- lldb/tools/lldb-dap/DAP.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp index f09575ce8ba42..8bc4727378df6 100644 --- a/lldb/tools/lldb-dap/DAP.cpp +++ b/lldb/tools/lldb-dap/DAP.cpp @@ -1312,21 +1312,23 @@ void DAP::StartEventThreads() { llvm::Error DAP::InitializeDebugger(const DAPSession &session) { // Find the existing debugger by ID - debugger = lldb::SBDebugger::FindDebuggerWithID(session.debuggerId); - if (!debugger.IsValid()) { + lldb::SBDebugger found_debugger = + lldb::SBDebugger::FindDebuggerWithID(session.debuggerId); + if (!found_debugger.IsValid()) { return llvm::createStringError( "Unable to find existing debugger for debugger ID"); } // Find the target within the debugger by its globally unique ID lldb::SBTarget target = - debugger.FindTargetByGloballyUniqueID(session.targetId); + found_debugger.FindTargetByGloballyUniqueID(session.targetId); if (!target.IsValid()) { return llvm::createStringError( "Unable to find existing target for target ID"); } - // Set the target for this DAP session. + // Set the target and debugger for this DAP session. + debugger = found_debugger; SetTarget(target); StartEventThreads(); return llvm::Error::success(); _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
