[Lldb-commits] [lldb] [llvm] [lldb-dap] Add multi-session support with shared debugger instances (PR #163653)
Janet Yang via lldb-commits
lldb-commits at lists.llvm.org
Wed Oct 22 18:04:54 PDT 2025
================
@@ -1289,13 +1293,92 @@ 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<uint32_t> target_id) {
+ // Initialize debugger instance (shared or individual).
+ if (target_id) {
+ std::optional<lldb::SBTarget> shared_target =
+ DAPSessionManager::GetInstance().TakeTargetById(*target_id);
+ // If the target ID is not valid, then we won't find a target.
+ if (!shared_target) {
+ return llvm::createStringError(
+ "Unable to find existing target for target ID");
+ }
+ // Get the debugger from the target and set it up.
+ debugger = shared_target->GetDebugger();
+ StartEventThreads();
----------------
qxy11 wrote:
Would we want some sort of callback mechanism here? Otherwise, it seems like using `initCommands/preRunCommands` from the attach config seems to also be able to provide the ability to serve as a hook for running commands when it's reused.
https://github.com/llvm/llvm-project/pull/163653
More information about the lldb-commits
mailing list