Skip to content

Commit 09f30ef

Browse files
authored
[lldb-dap] Use SetTarget for launch and attach commands (llvm#200133)
Without this patch event listener registration was skipped, as a result `Modules` view in UI was not displayed in case of launching target via `launchCommands` or `attachCommands`.
1 parent 0068e3c commit 09f30ef

4 files changed

Lines changed: 14 additions & 3 deletions

File tree

lldb/test/API/tools/lldb-dap/attach-commands/TestDAP_attachCommands.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ def test_commands(self):
7777
output = self.collect_console(pattern=stopCommands[-1])
7878
self.verify_commands("stopCommands", output, stopCommands)
7979

80+
# Check that we got module events from target
81+
modules = self.dap_server.wait_for_module_events()
82+
self.assertGreater(len(modules), 0)
83+
8084
# Continue after launch and hit the "pause()" call and stop the target.
8185
# Get output from the console. This should contain both the
8286
# "stopCommands" that were run after we stop.

lldb/test/API/tools/lldb-dap/launch/TestDAP_launch_extra_launch_commands.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,15 @@ def test(self):
5757
# After execution, program should launch
5858
self.verify_commands("launchCommands", output, launchCommands)
5959
self.verify_commands("postRunCommands", output, postRunCommands)
60+
61+
# Finish configuration and continue target
62+
self.verify_configuration_done()
63+
64+
# Check that we got module events from target
65+
modules = self.dap_server.wait_for_module_events()
66+
self.assertGreater(len(modules), 0)
67+
6068
# Verify the "stopCommands" here
61-
self.continue_to_next_stop()
6269
output = self.get_console()
6370
self.verify_commands("stopCommands", output, stopCommands)
6471

lldb/tools/lldb-dap/Handler/AttachRequestHandler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ Error AttachRequestHandler::Run(const AttachRequestArguments &args) const {
103103
if (llvm::Error err = dap.RunAttachCommands(args.attachCommands))
104104
return err;
105105

106-
dap.target = dap.debugger.GetSelectedTarget();
106+
dap.SetTarget(dap.debugger.GetSelectedTarget());
107107

108108
// Validate the attachCommand results.
109109
if (!dap.target.GetProcess().IsValid())

lldb/tools/lldb-dap/Handler/RequestHandler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ llvm::Error BaseRequestHandler::LaunchProcess(
261261

262262
// The custom commands might have created a new target so we should use
263263
// the selected target after these commands are run.
264-
dap.target = dap.debugger.GetSelectedTarget();
264+
dap.SetTarget(dap.debugger.GetSelectedTarget());
265265
}
266266
}
267267

0 commit comments

Comments
 (0)