Jonas Devlieghere aeeb9a3c09
[lldb-dap] Change the launch sequence (#138219) (reland)
This PR changes how we treat the launch sequence in lldb-dap.

 - Send the initialized event after we finish handling the initialize
   request, rather than after we finish attaching or launching.
 - Delay handling the launch and attach request until we have handled
   the configurationDone request. The latter is now largely a NO-OP and
   only exists to signal lldb-dap that it can handle the launch and
   attach requests.
 - Delay handling the initial threads requests until we have handled
   the launch or attach request.
 - Make all attaching and launching synchronous, including when we have
   attach or launch commands. This removes the need to synchronize
   between the request and event thread.

Background:
https://discourse.llvm.org/t/reliability-of-the-lldb-dap-tests/86125
2025-05-07 16:20:47 -07:00

32 lines
1.1 KiB
Python

"""
Test stop hooks
"""
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
import lldbdap_testcase
class TestDAP_stop_hooks(lldbdap_testcase.DAPTestCaseBase):
def test_stop_hooks_before_run(self):
"""
Test that there is no race condition between lldb-dap and
stop hooks executor
"""
program = self.getBuildArtifact("a.out")
preRunCommands = ["target stop-hook add -o help"]
self.build_and_launch(program, stopOnEntry=True, preRunCommands=preRunCommands)
# The first stop is on entry.
self.dap_server.wait_for_stopped()
breakpoint_ids = self.set_function_breakpoints(["main"])
# This request hangs if the race happens, because, in that case, the
# command interpreter is in synchronous mode while lldb-dap expects
# it to be in asynchronous mode, so, the process doesn't send the stop
# event to "lldb.Debugger" listener (which is monitored by lldb-dap).
self.continue_to_breakpoints(breakpoint_ids)
self.continue_to_exit()