[lldb] [llvm] [lldb-dap] Add multi-session support with shared debugger instances (PR #163653)
Walter Erquinigo via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 22 20:05:49 PDT 2025
================
@@ -1289,13 +1293,108 @@ protocol::Capabilities DAP::GetCustomCapabilities() {
}
void DAP::StartEventThread() {
- event_thread = std::thread(&DAP::EventThread, this);
+ // Get event thread for this debugger (creates it if it doesn't exist).
+ event_thread_sp = DAPSessionManager::GetInstance().GetEventThreadForDebugger(
+ debugger, this);
}
void DAP::StartProgressEventThread() {
progress_event_thread = std::thread(&DAP::ProgressEventThread, this);
}
+void DAP::StartEventThreads() {
+ if (clientFeatures.contains(eClientFeatureProgressReporting))
+ StartProgressEventThread();
+
+ StartEventThread();
+}
+
+llvm::Error DAP::InitializeDebugger(std::optional<int> debugger_id,
+ std::optional<lldb::user_id_t> target_id) {
+ // Validate that both debugger_id and target_id are provided together.
+ if (debugger_id.has_value() != target_id.has_value()) {
+ return llvm::createStringError(
+ "Both debuggerId and targetId must be specified together for debugger "
+ "reuse, or both must be omitted to create a new debugger");
+ }
+
+ // Initialize debugger instance (shared or individual).
+ if (debugger_id && target_id) {
+ // Find the existing debugger by ID
+ debugger = lldb::SBDebugger::FindDebuggerWithID(*debugger_id);
+ if (!debugger.IsValid()) {
+ return llvm::createStringError(
+ "Unable to find existing debugger for debugger ID");
+ }
----------------
walter-erquinigo wrote:
this doesn't look very clean.
What about creating two `InitializeDebugger` functions? One doesn't take parameters and the other one takes forcefully those two ids?
https://github.com/llvm/llvm-project/pull/163653
More information about the llvm-commits
mailing list