[Lldb-commits] [lldb] [lldb-dap] Use SetTarget for launch commands (PR #200133)
Sergei Druzhkov via lldb-commits
lldb-commits at lists.llvm.org
Thu May 28 06:03:56 PDT 2026
https://github.com/DrSergei updated https://github.com/llvm/llvm-project/pull/200133
>From 3f3bfbe4c83eda930207684d801409a34ccd310b Mon Sep 17 00:00:00 2001
From: Sergei Druzhkov <serzhdruzhok at gmail.com>
Date: Thu, 28 May 2026 11:30:07 +0300
Subject: [PATCH 1/2] [lldb-dap] Use SetTarget for launch commands
---
.../launch/TestDAP_launch_extra_launch_commands.py | 9 ++++++++-
lldb/tools/lldb-dap/Handler/RequestHandler.cpp | 2 +-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch_extra_launch_commands.py b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch_extra_launch_commands.py
index 46a1b0a6165c9..ad48af6364aba 100644
--- a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch_extra_launch_commands.py
+++ b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch_extra_launch_commands.py
@@ -57,8 +57,15 @@ def test(self):
# After execution, program should launch
self.verify_commands("launchCommands", output, launchCommands)
self.verify_commands("postRunCommands", output, postRunCommands)
+
+ # Finish configuration and continue target
+ self.verify_configuration_done()
+
+ # Check that we got module events from target
+ modules = self.dap_server.wait_for_module_events()
+ self.assertGreater(len(modules), 0)
+
# Verify the "stopCommands" here
- self.continue_to_next_stop()
output = self.get_console()
self.verify_commands("stopCommands", output, stopCommands)
diff --git a/lldb/tools/lldb-dap/Handler/RequestHandler.cpp b/lldb/tools/lldb-dap/Handler/RequestHandler.cpp
index e44e09e4741e4..f375a409d251a 100644
--- a/lldb/tools/lldb-dap/Handler/RequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/RequestHandler.cpp
@@ -261,7 +261,7 @@ llvm::Error BaseRequestHandler::LaunchProcess(
// The custom commands might have created a new target so we should use
// the selected target after these commands are run.
- dap.target = dap.debugger.GetSelectedTarget();
+ dap.SetTarget(dap.debugger.GetSelectedTarget());
}
}
>From 58489f11a460eeeb0d9f20c52015868a6046ff5e Mon Sep 17 00:00:00 2001
From: Sergei Druzhkov <serzhdruzhok at gmail.com>
Date: Thu, 28 May 2026 15:56:06 +0300
Subject: [PATCH 2/2] Add fix for attach commands
---
.../tools/lldb-dap/attach-commands/TestDAP_attachCommands.py | 4 ++++
lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/lldb/test/API/tools/lldb-dap/attach-commands/TestDAP_attachCommands.py b/lldb/test/API/tools/lldb-dap/attach-commands/TestDAP_attachCommands.py
index 056e213a6fc81..f24a32edbaa7b 100644
--- a/lldb/test/API/tools/lldb-dap/attach-commands/TestDAP_attachCommands.py
+++ b/lldb/test/API/tools/lldb-dap/attach-commands/TestDAP_attachCommands.py
@@ -77,6 +77,10 @@ def test_commands(self):
output = self.collect_console(pattern=stopCommands[-1])
self.verify_commands("stopCommands", output, stopCommands)
+ # Check that we got module events from target
+ modules = self.dap_server.wait_for_module_events()
+ self.assertGreater(len(modules), 0)
+
# Continue after launch and hit the "pause()" call and stop the target.
# Get output from the console. This should contain both the
# "stopCommands" that were run after we stop.
diff --git a/lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp b/lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp
index 03b26f63292f3..c4cfbcbd3d73c 100644
--- a/lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp
@@ -103,7 +103,7 @@ Error AttachRequestHandler::Run(const AttachRequestArguments &args) const {
if (llvm::Error err = dap.RunAttachCommands(args.attachCommands))
return err;
- dap.target = dap.debugger.GetSelectedTarget();
+ dap.SetTarget(dap.debugger.GetSelectedTarget());
// Validate the attachCommand results.
if (!dap.target.GetProcess().IsValid())
More information about the lldb-commits
mailing list