14 Commits

Author SHA1 Message Date
John Harrison
46585a3082
[lldb-dap] Improve test performance by removing negative assertions. (#178041)
Investigating some of the biggest slow downs during tests, the biggest
offender is 'wait_for_stopped' requiring a negative assertion around the
'stopped' event.

It currently waits for a negative predicate to fail before continuing.
This means it must wait for the full DEFAULT_TIMEOUT (50s) before the
test is allowed to continue.

To mitigate this, I added a new `collect_events` helper that will wait
for the given event to occur with the DEFAULT_TIMEOUT, then wait for a
quiet period (0.25s) before returning.

This greatly reduces the amount of idle waiting during tests.

Additionally, looking a the performance of individual test files,
`TestDAP_launch` is the slowest overall test. No individual test is that
slow, but the fact it has so many tests in the same file results in the
test harness waiting for that one file to finish.

To mitigate that, I split `TestDAP_launch` into individual test files
that run in parallel, reducing the runtime locally from over 2mins to
~5s.
2026-01-28 09:53:17 -08:00
John Harrison
3f08fafbee
[lldb-dap] Adjusting the initialize/launch flow to better match the spec. (#171549)
In https://github.com/llvm/llvm-project/pull/170523 it was pointed out
that the spec does specifically specify that launch/attach should not
respond until configurationDone is handled.

This means we do need to support async request handlers. To better align
with the spec, I've added a new `lldb_dap::AsyncRequestHandler`. This is
an additional handler type that allows us to respond at a later point.
Additionally, I refactored `launch` and `attach` to only respond once
the `configurationDone` is complete, specifically during the `PostRun`
operation of the `configurationDone` handler.

I merged some of the common behavior between `RequestHandler` and
`AsyncRequestHandler` into their common `BaseRequestHandler`.

The flow should now be:

```
<-> initialize request / response
--> launch/attach request
<-- event initialized
... optionally ...
<-> setBreakpoints request / response
<-> setFunctionBreakpoints request / response
<-> setExceptionBreakpoints request / response
<-> setInstructionBreakpoints request / response
... finally ...
<-> configurationDone request / response
<-- launch/attach response
```

---------

Co-authored-by: Jonas Devlieghere <jonas@devlieghere.com>
2025-12-22 14:52:46 -08:00
Ebuka Ezike
b17f1fd676
[lldb-dap] Report any errors during attach request (#165270)
Attaching using `core`, `gdbremote` or `attachInfo` may have an error.
fail early if it does.
2025-10-29 18:53:00 +00:00
woruyu
0b9470b329
[lldb-dap] support moduleId in the stackTrace response (#149774)
This PR resolves https://github.com/llvm/llvm-project/issues/149316

---------

Co-authored-by: Ebuka Ezike <yerimyah1@gmail.com>
2025-08-01 13:43:13 +01:00
John Harrison
0e0b501bf5
[lldb-dap] Take two at refactoring the startup sequence. (#140331)
This is more straight forward refactor of the startup sequence that
reverts parts of ba29e60f9a2222bd5e883579bb78db13fc5a7588. Unlike my
previous attempt, I ended up removing the pending request queue and not
including an `AsyncReqeustHandler` because I don't think we actually
need that at the moment.

The key is that during the startup flow there are 2 parallel operations
happening in the DAP that have different triggers.

* The `initialize` request is sent and once the response is received the
`launch` or `attach` is sent.
* When the `initialized` event is recieved the `setBreakpionts` and
other config requests are made followed by the `configurationDone`
event.

I moved the `initialized` event back to happen in the `PostRun` of the
`launch` or `attach` request handlers. This ensures that we have a valid
target by the time the configuration calls are made. I added also added
a few extra validations that to the `configurationeDone` handler to
ensure we're in an expected state.

I've also fixed up the tests to match the new flow. With the other
additional test fixes in 087a5d2ec7897cd99d3787820711fec76a8e1792 I
think we've narrowed down the main source of test instability that
motivated the startup sequence change.
2025-05-16 19:28:34 -07:00
John Harrison
087a5d2ec7
[lldb-dap] Adding additional asserts to unit tests. (#140107)
Adding an assert that the 'continue' request succeeds caused a number of
tests to fail. This showed a number of tests that were not specifying if
they should be stopped or not at key points in the test. This is likely
contributing to these tests being flaky since the debugger is not in the
expected state.

Additionally, I spent a little time trying to improve the readability of
the dap_server.py and lldbdap_testcase.py.
2025-05-16 08:47:01 -07:00
Jonas Devlieghere
fb191efa70
[lldb-dap] Adaptor -> Adapter (NFC) (#129110)
Both spellings are considered correct and acceptable, with adapter being
more common in American English. Given that DAP stands for Debug Adapter
Protocol (with an e) let's go with that as the canonical spelling.
2025-02-27 19:56:56 -06:00
Da-Viper
d4c1789112
Make env and source map dictionaries #95137 (#106919)
Fixes #95137
2024-10-07 12:38:36 -04:00
David Spickett
f7d6dfa005 [lldb][lldb-dap] Enable more tests on Windows
These few worked without changes.
2024-08-29 13:33:30 +00:00
Pavel Labath
fa6377119c
[lldb-dap] Automatically skip lldb-dap tests for remote platforms (#93169)
The don't currently work (and they're also not particularly useful,
since all of the remote stuff happens inside lldb).

This saves us from annotating tests one by one.
2024-05-24 08:52:32 +02:00
Pranav Kant
aa89c1bd78
[lldb][DAP] Fix test failure from #73393 (#89692)
#73393 introduced a mandatory column field. Update test for that.
2024-04-22 17:47:17 -07:00
Jordan Rupprecht
9c2468821e
[lldb][test] Modernize asserts (#82503)
This uses [teyit](https://pypi.org/project/teyit/) to modernize asserts,
as recommended by the [unittest release
notes](https://docs.python.org/3.12/whatsnew/3.12.html#id3).

For example, `assertTrue(a == b)` is replaced with `assertEqual(a, b)`.
This produces better error messages, e.g. `error: unexpectedly found 1
and 2 to be different` instead of `error: False`.
2024-02-21 13:02:30 -06:00
Jonas Devlieghere
80fcecb13c
[lldb] Replace assertEquals with assertEqual (NFC) (#82073)
assertEquals is a deprecated alias for assertEqual and has been removed
in Python 3.12. This wasn't an issue previously because we used a
vendored version of the unittest module. Now that we use the built-in
version this gets updated together with the Python version used to run
the test suite.
2024-02-16 20:58:50 -08:00
Jonas Devlieghere
01263c6c6f
[lldb] Rename lldb-vscode to lldb-dap (#69264)
Rename lldb-vscode to lldb-dap. This change is largely mechanical. The
following substitutions cover the majority of the changes in this
commit:

  s/VSCODE/DAP/
  s/VSCode/DAP/
  s/vscode/dap/
  s/g_vsc/g_dap/

Discourse RFC:
https://discourse.llvm.org/t/rfc-rename-lldb-vscode-to-lldb-dap/74075/
2023-10-19 09:48:54 -07:00