<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/140154>140154</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Infinite Loop in DAP when sending request before launch.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
lldb-dap
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
da-viper
</td>
</tr>
</table>
<pre>
I noticed this while implementing the [supportsDataBreakpointBytes](https://microsoft.github.io/debug-adapter-protocol//specification.html#Requests_DataBreakpointInfo)
This adds an option to the break-point panel in vscode, to set an address range. It is also persistent between debug sessions.
lldb-dap goes into an infinite loop because, The current implementation creates pending requests places request based on the below filter,
https://github.com/llvm/llvm-project/blob/efae492ad1ba80764ec4a85f5622a8713646f970/lldb/tools/lldb-dap/DAP.cpp#L927-L933
Since VSCode is waiting for a response for the `databreakpointInfo` request it will not send the `configurationdone` request.
Since lldb-dap is waiting for the `configurationDone` request it will not start the launch or attach request, and it is stuck in an infinite loop.
Normally adding the `databreakpointinfo` to the filter would suffice, but it will break existing binary when there is a new capability.
Example scenario.
- User debugs a program with `debugger A` and set's a `dataBreakpointInfo`
- User end `debugger A` session.
- User starts debugging with lldb-dap.
- lldb-dap enters an infinite loop because it cannot respond to the request.
Another way to mediate the issue is to handle it the way it is done in lldb
```
(lldb) b main
Breakpoint 1: no locations (pending).
Breakpoint set in dummy target, will get copied into future targets.
```
During the `launch request` and `attach request` we create the target and after the `configurationDone` request we then launch the debuggee. This is something similar to
```sh
# During launch request
(lldb) target create a.out
Current executable set to '/home/da-viper/Dev/projects/test_lldb/a.out' (x86_64).
(lldb) b main
Breakpoint 1: where = a.out`main + 18 at main.cc:21:7, address = 0x00000000004005f2
# After configuration done request
(lldb) run
Process 136009 launched: '/home/da-viper/Dev/projects/test_lldb/a.out' (x86_64)
```
This also deals with the issue of unverified breakpoints as breakpoints can be set with a valid target.
Relevant stuck lldb-dap with the logs on the side.

Pinging for feedback in case I am missing anything before implementing the fix.
@JDevlieghere @ashgti @ely @kazutakahirata
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVl1v47oR_TXMy8CGRH3YfvCDs66BFItice9tXxcjciSxS5EqSdlxf31BSkrW2RS4BRoEsGXNDIfnnPlA71VniI6sembV-Qmn0Ft3lLi5qpHcU2Pl_ciy0wsYG5QgCaFXHm690gRqGDUNZIIyHYSegFXPfhpH64I_Y8BnR_hjtMqE53sgz6oz4_s-hNGz4sT4hfHLoISz3rZh26nQT81WWcYvkpqp26DEMZDbjM4GK6yePfxIQrVKYFDWbPswaMaL3-hfE_ngvz8e-2Jay_iBZSeWnf6IiaOUHtCAHaM7BJvybqLHJrnAiIY0KANXL6wkxr9EK08huqGUjrwHh6ajLbwEiDG1tzCS88oHMgEaCjciA-kW4Ml7ZY3fwpyG1rLZSByhs-RBmWBjYGVaZVQg0NaO0JDAyaez_-gJxORcDPyGd7o7CEcYyMNIRkYG3AICjBoF-fUZGvQkId42XpW0vUGrdCDH-Jc5p0dOFiaEHRi_aH1dPyIR_yQRGL802jaMX6hFKg8cZd7gPtvVJYkS91Vb1ZzjfpcXdVm3h12WAsjoEazVfnmMKDB-OZ--bcU4Ml58PfDd5uuhKOasfldGEPzj9y9WUsT5hioprbUOEBz50RpP6TGJr84kBmwe2a-zNxxUgJvSOioZPBm5eglrWtVNLqEqraGfnFbW5lzeuPuQzWeBzo-BHk8P6ELy0jgZ0UO8UQgo-tU8Uo9GRi_lwYdJ_Iia_KiUNb2_WTeg1vco0Ldi_IiHWvBYRD9rAG520hL81LZKJMU103uyyRnoVfl010YZdHe49ZTE5BItCIZuIHDERmkV7mtOf3nFqFfwggw6ZdPvG_i7JzeXRnQdne0cDnBToU8ZxxcdOTjFTCMCngLju2i7XOj5F4Lf40ZWf4myVODP5ycC_JxGF2-Wzl_p3SbDN7LJBHL-v1ZpBEugibzOmpQrwh80xLLTydiIG9zwHo0GkgoDJWPl_ZTwDBZ6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